Group Abstract Group Abstract

Message Boards Message Boards

Numerical solution to Euler Lagrange equation

Posted 1 year ago
POSTED BY: Ee Kin Chan
6 Replies
Posted 1 year ago

Thank you so much. Your contributions have been pivotal to my project :)

POSTED BY: Ee Kin Chan
POSTED BY: Gianluca Gorni
Posted 1 year ago

Hello. thank you very much for the help. may i know how i could manually enter the initial conditions (1. Angular displacement 2. angular velocity), instead of setting them equal to 1 like you did? thank you very much.

POSTED BY: Ee Kin Chan
POSTED BY: Gianluca Gorni
Posted 1 year ago

Oh wow. thank you very much. may i know how i might increase nn to greater than 2. would i need to manually type the NDSolveValue equation to include all the thetas? Or is there a more general way to do it. Thank you.

POSTED BY: Ee Kin Chan

This is a difficult task for a beginner. Here is an attempt:

r[n_, t_] = \[Zeta][t] {0, 0, 1} + 
   Sum[{1, 0, 0} l[i] Sin[\[Theta][i, t]] -
     {0, 0, 1} l[i] Cos[\[Theta][i, t]], {i, n}];
rdot[n_, t_] = D[r[n, t], t]
tt = 1/2 Sum[m[n] Total[rdot[n, t]^2], {n, nn}];
vv = -g*Sum[
    m[n] Sqrt[Total[r[n, t]^2]] Cos[\[Theta][n, t]], {n, nn}];
ll = tt - vv;
rr = 1/2 cd*Sum[Total[rdot[n, t]^2], {n, nn}];
eqLag[k_] = D[D[ll, D[\[Theta][k, t], t]], t] -
    D[ll, \[Theta][k, t]] == -D[rr, D[\[Theta][k, t], t]];
eqs = Block[{nn = 2, m = Function[1],
    l = Function[1], cd = 1, \[Zeta] = Function[1], g = 1},
   Table[eqLag[n], {n, nn}]] // Simplify
sols = NDSolveValue[{eqs,
   \[Theta][1, 0] == 1, \[Theta][2, 0] == 1,
   Derivative[0, 1][\[Theta]][1, 0] == 1,
   Derivative[0, 1][\[Theta]][2, 0] == 1},
  {\[Theta][1, t], \[Theta][2, t]}, {t, 0, 4}]
ParametricPlot[sols, {t, 0, 4}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard