Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

 

Solving statically determinate trusses in Maple

This worksheet shows how to solve a statically determinate truss in Maple.
It is done through an example but the method is general and applies to both
2D and 3D trusses.  With a little extra work it should be possible to encapsulate
the process into a general module.  I will leave that as an exercise for the interested
reader.


The example truss is taken from

http://adaptivemap.ma.psu.edu/websites/5_structures/method_of_joints/methodofjoints.html
                               

 

Rouben Rostamian
2019-11-06

restart;

with(plots):

with(plottools):

Define the coordinates of the joints, taken from the picture above:

Joints := [
  <0,0>,                     # A
  <10,0>,                    # B
  <10, -10*tan(20/180*Pi)>,  # C
  <20, 0>,                   # D
  <20, -10*tan(20/180*Pi)>,  # E
  <30, 0>,                   # F
NULL];

[Vector(2, {(1) = 0, (2) = 0}), Vector(2, {(1) = 10, (2) = 0}), Vector(2, {(1) = 10, (2) = -10*tan((1/9)*Pi)}), Vector(2, {(1) = 20, (2) = 0}), Vector(2, {(1) = 20, (2) = -10*tan((1/9)*Pi)}), Vector(2, {(1) = 30, (2) = 0})]

nJoints := nops(Joints);

6

A member that connects joints i and j is represented as the pair [i, j]

Members := [[1,2], [2,4], [4,6], [1,3], [3,5], [5,6], [2,3], [4,5], [2,5]];

[[1, 2], [2, 4], [4, 6], [1, 3], [3, 5], [5, 6], [2, 3], [4, 5], [2, 5]]

nMembers := nops(Members);

9

We precompute the lengths of the members because these will be needed in several places later on.

MemberLength := (x->LinearAlgebra:-Norm(Joints[x[2]]-Joints[x[1]],2))~(Members);

[10, 10, 10, 10*(1+tan((1/9)*Pi)^2)^(1/2), 10, 10*(1+tan((1/9)*Pi)^2)^(1/2), 10*tan((1/9)*Pi), 10*tan((1/9)*Pi), 10*(1+tan((1/9)*Pi)^2)^(1/2)]

Force[i] is the force vector acting on the joint #i.  We do not distinguish between the given/applied
forces (in this case those acting on the joints #2 and #4) and the (unknown) reaction forces at the
supports.  Referring to the picture, we see that joint #1 is an anchor therefore its reaction has
both horizontal and vertical components ("`H__1`,`V__1`)" but joint #6 is a rolling support therefore its
reaction has only a vertical component "(0,`V__6`)."

Force := Array(1..nJoints, {1=<H[1],V[1]>, 2=<0,-60>, 4=<0,-80>, 6=<0,V[6]>});

Vector[row](6, {(1) = Vector(2, {(1) = H[1], (2) = V[1]}), (2) = Vector(2, {(1) = 0, (2) = -60}), (3) = 0, (4) = Vector(2, {(1) = 0, (2) = -80}), (5) = 0, (6) = Vector(2, {(1) = 0, (2) = V[6]})})

Here are the components of the reaction forces:

Reactions := {H[1], V[1], V[6]};

{H[1], V[1], V[6]}

We write T[i] for the (yet unknown)  axial force within the member #i.  A positive T[i]
corresponds to tension while a negative T[i]  corresponds to compression.  Here is
the problem's complete set of unknowns:

unknowns := {T[k] $k=1..nMembers} union Reactions;

{H[1], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9], V[1], V[6]}

We plot the truss to reassure ourselves that we have made no data entry errors

display([
  seq(pointplot([Joints[Members[k][1]], Joints[Members[k][2]]], connect), k=1..nMembers),
  seq(pointplot(Joints[k], symbol=solidcircle, symbolsize=20, color=red), k=1..nJoints),
NULL], scaling=constrained, axes=framed, thickness=5, color="Green", size=[700,200]);

At this point we are done with setting up the problem.  Now we proceed with the solution.

The matrix B defined below expresses the connectivity of the truss.  Specifically,
if B[i, j] is zero then the joints NULL and NULLare not connected.  Otherwise they are
connected through the member k = B[i, j].

B := Matrix(nJoints, shape=symmetric):
for k from 1 to nMembers do
  i := Members[k][1];
  j := Members[k][2];
  B[i,j] := k;
end do:
unassign('i', 'j', 'k');

This is what B  looks like:

print(B);

Matrix(6, 6, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 4, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 7, (2, 4) = 2, (2, 5) = 9, (2, 6) = 0, (3, 1) = 4, (3, 2) = 7, (3, 3) = 0, (3, 4) = 0, (3, 5) = 5, (3, 6) = 0, (4, 1) = 0, (4, 2) = 2, (4, 3) = 0, (4, 4) = 0, (4, 5) = 8, (4, 6) = 3, (5, 1) = 0, (5, 2) = 9, (5, 3) = 5, (5, 4) = 8, (5, 5) = 0, (5, 6) = 6, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 3, (6, 5) = 6, (6, 6) = 0})

At equilibrium the resultant of forces applied to every joint
is zero.  This gives us a system of (2*nJoints) equations.

sys := NULL:
for i from 1 to nJoints do
  eq := 0;
  for j from 1 to nJoints do
    if (k := B[i,j]) = 0 then next end if;
    eq += (Joints[j] - Joints[i])/MemberLength[k]*T[k];
  end do;
  eq + Force[i];
  sys := sys, convert(%, set);
end do:
unassign('i', 'j', 'k');
sys := `union`(sys);

{-T[2]+T[3], -T[3]-T[6]/(1+tan((1/9)*Pi)^2)^(1/2), -T[8]-80, -T[4]/(1+tan((1/9)*Pi)^2)^(1/2)+T[5], -T[4]*tan((1/9)*Pi)/(1+tan((1/9)*Pi)^2)^(1/2)+V[1], T[4]*tan((1/9)*Pi)/(1+tan((1/9)*Pi)^2)^(1/2)+T[7], -T[6]*tan((1/9)*Pi)/(1+tan((1/9)*Pi)^2)^(1/2)+V[6], -T[1]+T[2]+T[9]/(1+tan((1/9)*Pi)^2)^(1/2), T[1]+T[4]/(1+tan((1/9)*Pi)^2)^(1/2)+H[1], -T[7]-T[9]*tan((1/9)*Pi)/(1+tan((1/9)*Pi)^2)^(1/2)-60, -T[9]/(1+tan((1/9)*Pi)^2)^(1/2)-T[5]+T[6]/(1+tan((1/9)*Pi)^2)^(1/2), T[9]*tan((1/9)*Pi)/(1+tan((1/9)*Pi)^2)^(1/2)+T[8]+T[6]*tan((1/9)*Pi)/(1+tan((1/9)*Pi)^2)^(1/2)}

Here is the solution of truss

sol := solve(sys, unknowns);

{H[1] = 0, T[1] = -(200/3)/tan((1/9)*Pi), T[2] = -(220/3)/tan((1/9)*Pi), T[3] = -(220/3)/tan((1/9)*Pi), T[4] = (200/3)*(1+tan((1/9)*Pi)^2)^(1/2)/tan((1/9)*Pi), T[5] = (200/3)/tan((1/9)*Pi), T[6] = (220/3)*(1+tan((1/9)*Pi)^2)^(1/2)/tan((1/9)*Pi), T[7] = -200/3, T[8] = -80, T[9] = (20/3)*(1+tan((1/9)*Pi)^2)^(1/2)/tan((1/9)*Pi), V[1] = 200/3, V[6] = 220/3}

and here is the floating point representation of the solution:

evalf(sol);

{H[1] = 0., T[1] = -183.1651613, T[2] = -201.4816774, T[3] = -201.4816774, T[4] = 194.9202934, T[5] = 183.1651613, T[6] = 214.4123227, T[7] = -66.66666667, T[8] = -80., T[9] = 19.49202934, V[1] = 66.66666667, V[6] = 73.33333333}

 

 

 

Download truss.mw

 

restart;

Your system consists of four differential equations:

de1 := 2.412138000*diff(varphi(t), t)^2 = -0.28*Yb;

2.412138000*(diff(varphi(t), t))^2 = -.28*Yb

de2 := 15.00000000*diff(varphi(t), t)^2 = Ya + Yb;

15.00000000*(diff(varphi(t), t))^2 = Ya+Yb

de3 := -2.412138000*diff(varphi(t), t, t) = -0.28*Xb;

-2.412138000*(diff(diff(varphi(t), t), t)) = -.28*Xb

de4 := 15.00000000*diff(varphi(t), t, t) = Xa + Xb;

15.00000000*(diff(diff(varphi(t), t), t)) = Xa+Xb

Differentiating de1 with respect to t we get

dde1 := diff(de1,t);

4.824276000*(diff(varphi(t), t))*(diff(diff(varphi(t), t), t)) = 0

This says that either the first derivative or the second derivative of `&varphi;` is zero.

Let's look at the case where the first derivative of `&varphi;` is zero.

Then `&varphi;` is a constant.  But you want `&varphi;`(0) = 0, therefore `&varphi;` is identically zero.
Then

from de1 we get Yb = 0
from de3 we get Xb = 0;
from de2 we get Ya = 0
from de4 we get Xa = 0.

Now, let's look at the case where the second derivative `&varphi;` is zero"."
Then `&varphi;`(t) = a*t because you want `&varphi;`(0) = 0.  The coefficient a
is arbitrary.  Then

from de3 we get Xb = 0
from de4 we get Xa = 0;
from de1 we get Yb = -8.614778571*a^2;
from de2 we get Ya = 23.61477857*a^2.

 

``

 

Download mw.mw

 

 

Your eq41 is:

eq41_orig:=R__max(theta,0)=piecewise(theta<=rhs(eq02),(B/2+L__1)/cos(theta),theta<=rhs(eq03),(H/2)/sin(theta),rhs(eq03)<theta,(B/2-L__1)/cos(Pi-theta));

eq41 := R__max(theta, 0) = piecewise(theta <= arctan(H/(2*((1/2)*B+L__1))), ((1/2)*B+L__1)/cos(theta), theta <= Pi-arctan(H/(2*((1/2)*B-L__1))), H/(2*sin(theta)), Pi-arctan(H/(2*((1/2)*B-L__1))) < theta, -((1/2)*B-L__1)/cos(theta))

We see that the right-hand side is a function of theta, everything else being
constants. To simplify the computation, replace that messy expression with
a generic phi(theta), as in

eq41:=R__max(theta,0)=phi(theta);

R__max(theta, 0) = phi(theta)

Then execute your worksheet to arrive at this simple representation of the solution:

sol3:=simplify(dsolve([eq37a,bc], v__r(r, theta,beta)));

v__r(r, theta, beta) = -8*Pi^2*H*B*(B+2*L__1)^2*(((B+2*L__1)*Pi+4*beta*C)*phi(theta)-r*Pi*(B+2*L__1))*r*C*(((B+2*L__1)*Pi+4*beta*C)*phi(theta)+r*Pi*(B+2*L__1))/(phi(theta)^2*(r*cos(theta)-R__f)*(Int(phi(theta)^2, theta = 0 .. Pi))*((B+2*L__1)*Pi+4*beta*C)^5)

To complete the calculation, you need to evaluate the integral in the denominator.
Since phi(theta) is defined piecewise, there are too many cases if the parameters "B, H,"
and L__1 are unspecified.  What do you know about how those parameters are related?
Perhaps with some a priori information on the relative values of the paramters a
general answer can be obtained.

In the absence of that information, specifying the parameters is the way to go.
For instance, with your choice of numerical values the integral evaluates to 100:

eval(rhs(eq41_orig), {B=10, H=10, L__1=4}):
int(%^2, theta=0..Pi);

100


 

Download mw.mw

 

Is your code attempting to guess what the last few notes of the melody are?  If that is so, then you should explain how that is supposed to work since the code that you have presented does not succeed.

In the meantime, I have edited your code by removing the guessing parts and adding the missing parts of the melody.  Since the final phrase of the melody calls for a B-flat note, I have added that to your set of notes.

Working code:   Download mw.mw

 

div := (a,b) -> a/b:                                                         
div(a,b);                                                                    
                                      a/b

div_list := x -> x[1]/x[2]:                                                  
div_list([a,b]);                                                             
                                      a/b

 

restart;
de1 := diff(x1(t),t) = 3*x1(t) + 2*x2(t):
de2 := diff(x2(t),t) = 5*x1(t) + 1*x2(t):
ic := seq([x1(0)=s, x2(0)=0], s=-1..1, 0.1),
      seq([x1(0)=0, x2(0)=s], s=-1..1, 0.1):
DEtools:-DEplot({de1, de2}, [x1(t),x2(t)], t=-1..1, [ic],
    x1(t)=-1..1, x2(t)=-1..1, linecolor=black,
    thickness=1, arrows=none);

I will use subscripts to indicate partial derivatives, as in u__x for `&PartialD;`(u)/`&PartialD;`(x).
You are looking for the formula
u__x(x, y) = `u__&xi;`(xi, eta)*`&xi;__x`(x, y)+`u__&eta;`(xi, eta)*`&eta;__x`(x, y).
That is not quite wrong but it has at least a couple of difficulties.

First, you use the symbol u with two different meanings since your
u(xi, eta) really means u(xi(x, y), eta(x, y)).  A human can interpret
that by allowing for some sloppiness, but we shouldn't expect
Maple to get sloppy.

Second, your formula as a change of variables is incomplete.  In a
proper change of variables we expect to see the old variables on one
side and the new variables on the other side.  In your formula the
variables x and y occur on both sides.

OK, let's do it the right way.

Let the variables x, y and xi, eta be related through
"x = A(xi,eta),"
"y=B(xi,eta)."
Differentiating these with respect to x we get
"1=`A__xi`(xi,eta) `xi__x`+`A__eta`(xi,eta) `eta__x `,"
"0 =`B__xi`(xi,eta) `xi__x`+`B__eta`(xi,eta) `eta__x `."
We solve this as a linear system for `&xi;__x` and `&eta;__x` and obtain
`&xi;__x` = `B__&eta;`/Delta, `&eta;__x` = -`B__&xi;`/Delta,   where  Delta = `A__&xi;`*`B__&eta;`-`B__&xi;`*`A__&eta;`.

Now let "u(x,y)=u(A(xi,eta),B(xi,eta)) = U(xi,eta)."  Differentiating
this with respect to x we get

u__x(x, y) = `U__&xi;`(xi, eta)*`&xi;__x`+`U__&eta;`(xi, eta)*`&eta;__x` and `U__&xi;`(xi, eta)*`&xi;__x`+`U__&eta;`(xi, eta)*`&eta;__x` = `U__&xi;`(xi, eta)*`B__&eta;`(xi, eta)/Delta-`U__&eta;`(xi, eta)*`B__&xi;`(xi, eta)/Delta
.
That's the correct form of the change of variables formula.
Note that x and y occur on the left, while xi and eta occur
on the right.  Also observe the introduction of the symbols
U, A, B  to avoid notational ambiguity.

Now that we know how to do this by hand, let's see what
we get with Maple's dchange.

restart;

PDEtools:-dchange({x=A(xi,eta), y=B(xi,eta), u(x,y)=U(xi,eta)},
                      diff(u(x,y),x), {xi,eta,U});

(diff(U(xi, eta), eta))*(diff(B(xi, eta), xi))/((diff(A(xi, eta), eta))*(diff(B(xi, eta), xi))-(diff(A(xi, eta), xi))*(diff(B(xi, eta), eta)))-(diff(U(xi, eta), xi))*(diff(B(xi, eta), eta))/((diff(A(xi, eta), eta))*(diff(B(xi, eta), xi))-(diff(A(xi, eta), xi))*(diff(B(xi, eta), eta)))

We see that Maple's result agrees with our manual solution.

 


 

What you have observed is a shortcoming (a polite way of saying a bug) of pdsolve() and needs to be corrected.  A temporary workaround is to replace the four occurrences of Pi in the boundary conditions and the two occurrences of Pi in the range specification with 1.0*Pi.

Aside: The range specification is redundant since pdsolve() picks up the range from the boundary conditions.

Carl has shown how to find the path of the steepest descent on a surface.  I want to point out that a particle that slides down a surface (without friction) does not necessarily follow the path of steepest descent—the particle's inertia pulls it away.

In the attached worksheet I calculate and plot on a paraboloid (a) the path of steepest descent in red (as Carl has done), and (b) the path followed by a point mass in blue.  The figure below, extracted from the worksheet, shows that the two paths are not the same.

 

Worksheet: paticle-sliding-on-a-paraboloid.mw

 

This was asked here about a year ago and I posted this answer.

  
Reference: https://www.mapleprimes.com/questions/225760-Spinning-T-Handle-In-Space#answer253863

Note added later:

Oops, I just noticed that you are asking for a solution in MapleSim.  I don't have MapleSim so I cannot help you there.  Sorry.  Perhaps someone else can.

 

As Carl said, there are very many ways of doing this.  Here is an alternative.

restart;

Replace this with your function of current versus torque and speed

F := proc(torque, speed)
  return torque*speed;
end proc:

Tabulate:

torque_max := 100:
speed_max := 4000:
printf("%15s%15s%15s\n", "torque", "speed", "current");
for i from 0 to 10 do
  torque := i/10*torque_max;
  for j from 0 to 10 do
    speed := j/10*speed_max;
    printf("%15g%15g%15g\n", torque, speed, F(torque, speed));
  end do:
end do:

         torque          speed        current
              0              0              0
              0            400              0
              0            800              0
             ... (snipped)
             90           3600         324000
             90           4000         360000
            100              0              0
            100            400          40000
            100            800          80000
            100           1200         120000
            100           1600         160000
            100           2000         200000
            100           2400         240000
            100           2800         280000
            100           3200         320000
            100           3600         360000
            100           4000         400000

 

 

Download mw.mw

It would be difficult to produce a truly periodic solution.  The cage has its own natural frequency (which depends on the amplitude) and the hamster has its own independent frequency.  The overall effect is the combination of two frequencies which is not necessarily periodic.  If you add some damping in the cage's motion, and if the hamster's motion is periodic, then the cage's motion will converge to a periodic solution in the long run.

In the attached worksheet I derive the equation of motion (without damping) assuming that the hamster movies sinusoidally on the cage's floor, solve the equation, and produce an animation.  The motion is not quite periodic but it comes close.  That's why the animation (which is played in an infinite loop) gives the appearance of a periodic motion.

Worksheet:  hamster_cage.mw

 

Let f(t) be int(c(h),h=0..t).  Then we have D(f)=c, and f(0)=0, D(f)(0)=c(0).  Then you may express your differential equation in terms of f, as follows.

Nota bene: I have inserted a missing multiplication sign (marked in red) in your equation.  Be sure to verify that's what is intended.

ode := diff(c(t),t) = (ln(c(t)) + w - p*c(t)) *
           (c(t) * (t + 1/int(c(h), h =0..t)) + int(c(h), h=0..t)) /
           (p - 1/c(t));

diff(c(t), t) = (ln(c(t))+w-p*c(t))*(c(t)*(t+1/(int(c(h), h = 0 .. t)))+int(c(h), h = 0 .. t))/(p-1/c(t))

diff(f(t),t,t) = (ln(diff(f(t),t)) + w - p*diff(f(t),t)) *
         ( diff(f(t),t) * (diff(f(t),t)*(t+1/f(t)) + f(t))) /
         (p - 1/diff(f(t),t));

diff(diff(f(t), t), t) = (ln(diff(f(t), t))+w-p*(diff(f(t), t)))*(diff(f(t), t))*((diff(f(t), t))*(t+1/f(t))+f(t))/(p-1/(diff(f(t), t)))


 

Download mw.mw

plots:-gradplot3d(r^2+1, r=0..1, phi=0..2*Pi, theta=0..Pi/2, coords=spherical,
  view=[-1.5..1.5, -1.5..1.5, 0..1.5], scaling=constrained, axes=normal,
  grid=[3,10,5], arrows=THIN);

vars := [x,y,z];
seq([seq(cat(v,i), i=1..nops(vars))], v in vars);

 

First 24 25 26 27 28 29 30 Last Page 26 of 58