Subject: Not sure if Maxima is the best choice for this
From: Robert Dodier
Date: Sat, 8 Sep 2012 20:06:01 +0000 (UTC)
On 2012-09-07, Ardillas del Monte <ardillasdelmonte at gmail.com> wrote:
> One common operation all these problems will have is a
> system of three linear equations, with three unknowns. There will be three
> unknowns, different in each problem, which can be either components or
> positions of the forces, while the equations will come from the 2D statics
> conditions (ie: zero sum of X forces components, zero sum of Y forces
> components, zero sum of momentum at some point).
> forces will be defined as a point of application (a 2D point, with
> length units in its coordinates) and as a pair of X-Y force components
> (with force units).
Well, here is one approach, I'm sure there are others.
Represent the position & force combination as a structure (so that the
components have names, which makes it easier to remember what they are).
Represent vectors as lists of two elements since that's what the vect
package expects. Attach units to vectors instead of making vectors of
unit-ful quantities; this is just a convenience, I think it works both
ways. Define a convenience function to solve unit-ful equations.
load (ezunits);
load (vect);
defstruct (pf (p, f));
matchdeclare ([uu, vv], unitp);
tellsimp (uu ~ vv, (qty(uu) ~ qty(vv)) ` (units(uu) * units(vv)));
sumfx ([L]) := lsum (e at f[1], e, L);
sumfy ([L]) := lsum (e at f[2], e, L);
summ ([L]) := lsum (e at p ~ e at f, e, L);
usolve (L1, L2) := solve (map (lambda ([e], qty (lhs (e)) = rhs (e)), L1), L2);
Here's a random example I nicked from the Interwebs.
(Example #3 at http://www.eng.iastate.edu/efmd/statics.htm)
A : new (pf ([-8, 0]`m, [300*sin(30`degree), -300*cos(30`degree)]`N));
B : new (pf ([-6, 0] ` m, [0, By] ` N));
C : new (pf ([-4, 0] ` m, [0, -150] ` N));
D : new (pf ([0, 0] ` m, [Dx, Dy] ` N));
foo : sumfx (A, B, C, D);
bar : sumfy (A, B, C, D);
summ (A, B, C, D);
baz : express (%);
usolve ([foo = 0, bar = 0, baz = 0], [Dx, Dy, By]);
=> [[Dx = -150,Dy = 50-50*sqrt(3),By = 200*sqrt(3)+100]]
float (%);
=> [[Dx = - 150.0, Dy = - 36.60254037844386, By = 446.4101615137754]]
I get a result with one of the signs reversed; I guess I must have
looked backwards at something. Oh well.
It is kind of messy to use lists to represent vectors, since vectors
have their own algebraic properties, but it's simple-minded, and what
the vect package expects, so I won't fight it.
Note that it's necessary to apply the function 'express' on cross
product expressions (e.g. [a, b] ~ [c, d]) to actually carry out the
operation.
Hope this helps,
Robert Dodier