Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. l = 0.6 (1 + 0.00 I); g = 9.8;
  2. x0 = 0.01;
  3. coord[n_] := Table[Subscript[x, i][t], {i, n}];
  4. vel[n_] := D[coord[n], t];
  5. mass[1] = {x0 Cos[[Omega] t], 0};
  6. mass[i_] :=
  7. mass[i - 1] + {l Sin[Subscript[x, i - 1][t]], -l Cos[
  8. Subscript[x, i - 1][t]]};
  9. ke[i_] := With[{v = D[mass[i + 1], t]}, v.v/2];
  10. pe[i_] := g mass[i + 1][[2]];
  11. L[n_] := Sum[ke[i] - pe[i], {i, n}];
  12. eq[n_] :=
  13. Table[D[D[L[n], vel[n][[m]]], t] - D[L[n], coord[n][[m]]] == 0, {m,
  14. n}];
  15. ic[n_] :=
  16. Table[{Subscript[x, i][0] == 0, Subscript[x, i]'[0] == 0}, {i, n}] //
  17. Flatten;
  18.  
  19. SOL[n_] :=
  20. NDSolve[{FullSimplify[eq[n]] /. [Omega] -> 1, ic[n]} // Flatten,
  21. Table[Subscript[x, i][t], {i, n}], {t, 0, 100},
  22. Method -> {"EquationSimplification" -> "Residual"}]
  23.  
  24. NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions. >>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement