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:
Print["Start time is " "Start time is ", ds = DateString[], "."];
prec = 100000;
(**Number of required decimals.*.*)ClearSystemCache[];
T0 = SessionTime[];
expM[pre_] :=
Module[{lg, a, d, s, k, bb, c, end, iprec, xvals, x, pc, cores = 16(*=
4*number of physical cores*), tsize = 2^7, chunksize, start = 1,
ll, ctab, pr = Floor[1.0002 pre]}, chunksize = cores*tsize;
n = Floor[1.32 pr];
end = Ceiling[n/chunksize];
Print["Iterations required: ", n];
Print["Will give ", end,
" time estimates, each more accurate than the previous."];
Print["Will stop at ", end*chunksize,
" iterations to ensure precsion of around ", pr,
" decimal places."]; d = ChebyshevT[n, 3];
{b, c, s} = {SetPrecision[-1, 1.1*n], -d, 0};
iprec = pr/2^6;
Do[xvals = Flatten[ParallelTable[Table[ll = start + j*tsize + l;
lg = Log[ll]/(ll); x = N[E^(lg), iprec];
pc = iprec;
While[pc < pr, pc = Min[4 pc, pr];
x = SetPrecision[x, pc];
xll = x^ll; z = (ll - xll)/xll;
t = 2 ll - 1; t2 = t^2;
x =
x*(1 + SetPrecision[4.5, pc] (ll - 1)/
t2 + (ll + 1) z/(2 ll t) -
SetPrecision[13.5, 2 pc] ll (ll - 1)/(3 ll t2 + t^3 z))];
x - lg, {l, 0, tsize - 1}], {j, 0, cores - 1},
Method -> "EvaluationsPerKernel" -> 16]];
ctab = ParallelTable[Table[c = b - c;
ll = start + l - 2;
b *= 2 (ll + n) (ll - n)/((ll + 1) (2 ll + 1));
c, {l, chunksize}], Method -> "EvaluationsPerKernel" -> 16];
s += ctab.(xvals - 1);
start += chunksize;
st = SessionTime[] - T0; kc = k*chunksize;
ti = (st)/(kc + 10^-10)*(n)/(3600)/(24);
If[kc > 1,
Print[kc, " iterations done in ", N[st - stt, 4], " seconds.",
" ] :=
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