Hello Erik, Apologies for the delayed response. Many thanks for explaining all the concepts clearly and providing suggestions. The simulation done above is a great help in understanding dynamics and how Mathematica works. Thanks, Varun
|
|
This is a better version with some loose ends fixed. One can experiment and see that the most critical parameter to obtain a long shooting range is the moment the projectile is released from the poach. In this Manipulate, this is set by the angle between the vertical and the sling {rlsAngle) at the moment of release. This was the most critical job of the trebuchet operator: pull a string to open the poach at the right moment to obtain the desired range. Good luck!
Attachments:
|
|
The demo is beautiful, Erik. Thank you. I love Lagrangian mechanics, and here we have additional interest in knowing these things brought the age of castles to an end!
|
|
This is exactly what I suggested David. here is an attempt to "glue" the two together using the trebuchet NDSolve output as the initial conditions of the projectile equations.
I attach a preliminary notebook based on my previous demonstration. Still needs some refining!
Attachments:
|
|
Hello David, I tried using separate projectile equations and the impact equations for the trebuchet, but I get errors like: Limiting value is not a machine sized integer. I cannot quite understand, how to use the projectile equations of motion and impact equations for the trebuchet. I can solve impact equations separately for a 3 pendulum system which has a similar analogy to the trebuchet, so that the pendulum hits a wall at x=0.I have attached the file for reference. But when it comes to the trebuchet, I cannot seem to set up the equations properly. Any suggestions. Again apologies for the trivial questions and the inconvenience. Thanks
Varun
Attachments:
|
|
Hi Varun. I took a look at the notebook. I don't follow the physical logic. I only see NDSolve in use to solve the trebuchet equations. To elaborate on my response of 1 day ago, the solution for ballistic flight of the projectile would go like this: 1) Solve the trebuchet just as done by Erik Mahieu in the demonstration. This solution terminates at a final time tMax, which is when the projectile leaves the pouch to begin ballistic flight. At that time tMax we have numerical values for the 3 generalized coordinates and their derivatives. These are the arm angles defining the configuration of the trebuchet as it goes through its motion. 2) Erik also gives the equations for the x, y location x[t], y[t] and the velocity components of the projectile in the pouch as derived from the general coordinate angles. So at the point where the projectile leaves the pouch it is at x[tMax], y[tMax] and has velocity components x'[tMax] and y'[tMax]. 3) The ballistic flight of the projectile after leaving the pouch is a completely separate problem from the trebuchet problem. The trebuchet equations have nothing to do with it. The equations for ballistic flight without drag are the usual: xx''[t]==0, yy''[t]==-g. These are solved using NDSolve, and the connection to the trebuchet problem is in the initial conditions xx[tMax]==x[tMax], xx'[tMax]==x'[tmax], yy[tmax]==y[tmax], yy'[tmax]==y'[tMax]. (Notice that x and y refer to the values derived from the trebuchet solution while xx and yy are the coordinates for the ballistic flight.) The ballistic flight is solved with NDSolve with a "StopIntegration" when yy[t]==0, which is when the projectile hits the ground. So the ballistic flight is solved for {t, tMax, Infinity} with Event Location or WhenEvent used to stop the simulation on impact. 4) So you see there are two separate solves for two different differential equation systems. First for the trebuchet, and then for the ballistic flight with initial conditions provided by the end point of the trebuchet solution. These will provide separate interpolating functions for the solutions: the first set for coordinates of the trebuchet, and the derived values for the location of the projectile in the pouch; and the second set for the coordinates of the projectile in ballistic flight after leaving the pouch. Both are required for plotting the full path of the projectile. If you don't mind, I would like to make a few suggestions about using Mathematica. First, your notebook puts all the calculations in a single cell. It is easier to find your way through a problem if you put each calculation in its own cell, and you evaluate and look at the result as you go along. Second, if you are going to put something in Manipulate, first solve it without. For example, in the method I outline above, do each of these things in separate cells, one at a time, and look at the result by plotting the NDSolve solutions using Plot and ParametricPlot, so you can see that you are getting what you expect. Do the same for the following graphics. Once you have everything going as you expect, then you can delete the output cells, merge the separate cells into one with semicolons as separators, and then encapsulate in animations or Manipulations. Best regards, David
|
|
Hello David, Apologies for the delayed response. Thank you for explaining all the concepts in detail and providing a well defined approach for problem solving and modelling. It really helped in the understanding of different aspects and the way equations are used and solved in Mathematica. Thanks, Varun
|
|
Anonymous User
Posted 8 years ago
David said > It is easier to find your way through a problem if you put each calculation in its own cell, and you evaluate and look at the result as you go along.
I had thought Mathematica 11.0 has a feature that debugs functions step by step, it has breakpoints i cannot get it to work yet. Documentation is very thin - despite setting breakpoints it never stops :) I made the below for an earlier Mathematica (4.0). I'm unsure if it works "for complicated functions" in Mathematica 11.0 or not. It is in jutilspkg part of fNBookForm2 (orig. part of PeriodicTable` pkg). It is supposed to do what you said without all the ; editing. This allows being able to freeform work a cell at a time, then have a function made auto. It works but needs tender care, and has a help page.
Attachments:
|
|
POSTED BY: Anonymous User
Hi Varun, I agree with Erik on this. The trebuchet part of the problem determines the coordinates and velocity at the point where the projectile leaves the pouch. These are the initial conditions for a second set of differential equations which describe ballistic flight. There are two ways to string these together: You can do so manually by executing them in sequence, either in separate cells or in the same cell; or they can be placed in a module, with local variables connecting them, and both solutions used for building the plot. To animate them together, they would need to be all encapsulated in the animation. Using the impact point as an input is another matter. It is really part of the solution. The likely method here is to build the full simulation into a function which can return the impact point. A solver like FindRoot can then be used to solve for some selected input parameter being used to adjust the impact. In a simple projectile problem that might be the launch angle. This gets you to a way to specify the impact point as an input, and retrieve the parameter setting needed, as well as the full trajectory. Before version 10, this would require that NDSolve be enclosed in the FindRoot process, which means solving the set of diffeqs many times. However, with V10 we have ParametricNDSolve, which allows us to specify an input parameter and returns a function for a solution to the diffeqs, given a value of the input parameter. This output from ParametricNDSolve can be used as an alternative to wrapping the solution process in the solve. Best regards,
David
|
|
I would not combine the equations but use the output (speed and direction) as the input of the projectile equations. Two separate computations.
|
|
Hello, I tried solving both equations separately, but I face an error everytime saying that the limiting value is not a machine sized number and a certain replacement rule is invalid. I cannot quite figure it where that error exists. I used the below mentioned Projectile equations as suggested for the Trebuchet, but, cannot get the projectile to leave the Trebuchet.
Manipulate[
ParametricPlot[{{V Cos[\[Theta]] t,
V Sin[\[Theta]] t -
9.8 t^2/2}, {V vt Cos[\[Theta]]/9.8 (1 - Exp[-9.8 t/vt]),
vt/9.8 (V Sin[\[Theta]] + vt) (1 - Exp[-9.8 t/vt]) - vt t}}, {t,
0, tf}, PlotStyle -> {{Thick, Blue}, {Thick, Red}},
AxesOrigin -> {0, 0}, AxesLabel -> {x, z},
PlotRange -> {{0, 400}, {0, 300}}, ImageSize -> 500,
Epilog -> {Green, PointSize[.02],
Point[{{V Cos[\[Theta]] tf,
V Sin[\[Theta]] tf -
9.8 tf^2/2}, {V vt Cos[\[Theta]]/9.8 (1 - Exp[-9.8 tf/vt]),
vt/9.8 (V Sin[\[Theta]] + vt) (1 - Exp[-9.8 tf/vt]) -
vt tf}}]}], {{V, 48.8, "initial velocity"}, 1, 100,
Appearance -> "Labeled"}, {{\[Theta], 1.09, "angle"}, .1, \[Pi]/2,
Appearance -> "Labeled"}, {{vt, 100, "terminal velocity"}, .01, 300,
Appearance -> "Labeled"}, {{tf, 8.75, "time"}, .1, 17,
Appearance -> "Labeled"}]
How do I separately solve for the Trebuchet and the Projectile, so that I can get an animation where the projectile actually leaves the trebuchet? Thanks.
|
|
Hi,
Thanks I was able to generate the equations of motions for the Trebuchet and calculate the Lagrangian. I tried using the equations of Projectile motion as well. But I am not quite sure as to how to combine the equations from Projectile with Air Drag into the Trebuchet equations to animate the projectile to actually leave the Trebuchet and make an impact against something like a wall at a distance say x='constant'. Is there any specific way to do that? The equations I got were:
cn = {L1, L2, L3, L4, m1, m2, mb, rg, rc};
(*Coordinates of the short end of the beam*) (*Defined 'a'*)
x1[?_] := L1 *Sin[?];
y1[?_] := -L1 *Cos[?];
(*Coordinates of the long end of the beam:*) (*Defined 'b'*)
x2[?_] := -L2* Sin[?];
y2[?_] := L2 *Cos[?];
(*Coordinates of the center of mass of the Counterweight*) \
(*Defined 'c'*)
x4[?_, ?_] :=
L1* Sin[?] - L4 *Sin[? + ?];
y4[?_, ?_] := -L1 *Cos[?] +
L4* Cos[? + ?];
(*Coordinates of the Projectile end of the Sling *) (*Defined 'd'*)
x3[?_, ?_] := -(L3 *Sin[? - ?] +
L2* Sin[?]);
y3[?_, ?_] := -(L3 *Cos[? - ?] -
L2* Cos[?]);
(* potential energy of the three parts:*)
PE[?_, ?_, ?_] :=
m1 *g* y4[?, ?] + m2 *g* y3[?, ?] -
mb* g* rc *Cos[?];
(* kinetic energy of the three parts:*)
KE[?_, ?_, ?_] :=
0.5*m1*((Dt[x4[?, ?], t, Constants -> cn])^2 + (Dt[
y4[?, ?], t, Constants -> cn])^2
) + 0.5*
m2 *((Dt[x3[?, ?], t, Constants -> cn])^2 + (Dt[
y3[?, ?, Constants -> cn], t])^2) +
(mb/2) *(rg^2)* Dt[?, t, Constants -> cn]^2;
(* the lagrangian*)
Lag = KE - PE;
L[?_, ?_, ?_] :=
KE[?, ?, ?] - PE[?, ?, ?];
(* define what is constant, and the derivatives of the angles, \
denoted by the "d" suffix:*)
EL = L[?, ?, ?] /. {Dt[?, t,
Constants -> {L1, L2, L3, L4, m1, m2, mb, rg, rc}] -> ?d,
Dt[?, t,
Constants -> {L1, L2, L3, L4, m1, m2, mb, rg, rc}] -> ?d,
Dt[?, t,
Constants -> {L1, L2, L3, L4, m1, m2, mb, rg, rc}] -> ?d,
Dt[?, t] -> ?d, Dt[?, t] -> ?d,
Dt[?, t] -> ?d};
eq? =
Simplify[
Dt[D[EL, ?d], t] - D[EL, ?] == 0 /. {Dt[L1, t] -> 0,
Dt[L2, t] -> 0, Dt[L3, t] -> 0, Dt[L4, t] -> 0, Dt[mb, t] -> 0,
Dt[m1, t] -> 0, Dt[m2, t] -> 0, Dt[g, t] -> 0, Dt[rg, t] -> 0,
Dt[rc, t] -> 0,
Dt[?, t] -> ?d, Dt[?, t] -> ?d,
Dt[?, t] -> ?d, Dt[?d, t] -> ?dd,
Dt[?d, t] -> ?dd, Dt[?d, t] -> ?dd}];
eq? =
Simplify[Dt[D[EL, ?d], t] - D[EL, ?] ==
0 /. {Dt[L1, t] -> 0, Dt[L2, t] -> 0, Dt[L3, t] -> 0,
Dt[L4, t] -> 0, Dt[mb, t] -> 0, Dt[m1, t] -> 0, Dt[m2, t] -> 0,
Dt[g, t] -> 0, Dt[rg, t] -> 0, Dt[rc, t] -> 0,
Dt[?, t] -> ?d, Dt[?, t] -> ?d,
Dt[?, t] -> ?d, Dt[?d, t] -> ?dd,
Dt[?d, t] -> ?dd, Dt[?d, t] -> ?dd}];
eq? =
Simplify[Dt[D[EL, ?d], t] - D[EL, ?] ==
0 /. {Dt[L1, t] -> 0, Dt[L2, t] -> 0, Dt[L3, t] -> 0,
Dt[L4, t] -> 0, Dt[mb, t] -> 0, Dt[m1, t] -> 0, Dt[m2, t] -> 0,
Dt[g, t] -> 0, Dt[rg, t] -> 0, Dt[rc, t] -> 0,
Dt[?, t] -> ?d, Dt[?, t] -> ?d,
Dt[?, t] -> ?d, Dt[?d, t] -> ?dd,
Dt[?d, t] -> ?dd, Dt[?, t] -> ?dd}];
sol = Solve[{eq?, eq?, eq?}, {?dd, ?dd, ?dd}];
Thanks
|
|
Once the projectile leaves the pouch, the trebuchet is no longer in the game. We then have a gravity (and air friction damping) only situation that can be solved by another differential equation.
Have a look at another demonstration that handles this problem very well: Projectile with Air Drag
It is possible to combine these two demonstrations and use the trebuchet output (speed, angular position,...) as input to the ballistic motion of the second demonstration.
If you are interested, a very good article is: Trebuchet mechanics by D B Siano
|
|
Reply to this discussion
in reply to
Group Abstract
|