I want to be able to add a second pendulum with independent initial conditions, but at the same time I want it to run on the same frame so I can compare the two systems. Everything that I have tried so far hasn't worked for me. Here is my code, I will attach the file as well. Needs["VariationalMethods`"]
Clear[s1, s2, [Phi]1, [Phi]2, t, g, m1, m2]; variables = {[Phi]1[t], [Phi]2[t]}; r1 = s1 {Sin[[Phi]1[t]], -Cos[[Phi]1[t]]}; r2 = r1 + s2 {Sin[[Phi]2[t]], -Cos[[Phi]2[t]]};
lagrangian = m1/2 D[r1, t].D[r1, t] + m2/2 D[r2, t].D[r2, t] - g {0, 1}.(m1 r1 + m2 r2); eqs = EulerEquations[lagrangian, variables, t];
s1 = 1; s2 = 1; m1 = 1; m2 = 1; g = 9.81; tMax = 30; initial = {[Phi]1[0] == Pi/2, [Phi]2[0] == Pi/2, [Phi]1'[0] == Pi/2, [Phi]2'[0] == 0}; sol = First[NDSolve[Join[eqs, initial], variables, {t, 0, tMax}]]; nFrames = 1000; frames = Table[ Graphics[{Gray, Thick, Line[{{0, 0}, r1, r2}], Darker[Black], Disk[{0, 0}, .1], Darker[Black], Disk[r1, m1/10], Disk[r2, m2/10]} /. sol, PlotRange -> {{-2.5, 2.5}, {-2.5, 2.5}}, Background -> Lighter[White]], {t, tMax/nFrames, tMax, tMax/nFrames}]; ListAnimate[frames]
Attachments: