Model Constrained Systems as DAEs
Model Constrained Systems as DAEs
Model the motion of a single pendulum.
deqns = {m x''[t] == ((λ[t]/l)) x[t], m y''[t] == ((λ[t]/l)) y[t] - m g};aeqns = {x[t]^2 + y[t]^2 == l^2};ics = {x[0] == 1, y[0] == 0, x'[0] == 0, y'[0] == 1};params = {g -> 9.81, m -> 1, l -> 1};pendulumSol = First[NDSolve[{deqns, aeqns, ics} /. params, {x, y, λ}, {t, 0, 15}, Method -> {"IndexReduction" -> {"Pantelides", "ConstraintMethod" -> "Projection"}}]];Show[{ParametricPlot[Evaluate[{x[t], y[t]} /. pendulumSol], {t, 0, 15}, PlotStyle -> {DotDashed}],
Graphics[{{Red, Line[{{0, 0}, {0.5, -Sqrt[3] / 2}}]},
{Blue, Disk[{0.5, -Sqrt[3] / 2}, 0.1]}
}]}, ImageSize -> 400]