ClearAll["Global`*"]
L0 = 2;
\[Omega] = 4;
L[t_] = L0 + \[Delta] *Sin[\[Omega]*t + Pi];
x[t_] = L[t]*Cos[\[Alpha][t]];
y[t_] = L[t]*Sin[\[Alpha][t]];
T = m/2 * ((x'[t])^2 + (y'[t])^2);
U = -m*g*x[t];
Lagr = T - U;
Lgr = Simplify[Expand[Lagr]];
Eq1 = D[#1, #2] - D[D[#1, #3], t] & [Lgr, \[Alpha][t], \[Alpha]'[t]];
Eq2 = Solve[Eq1 == 0, \[Alpha]''[t]];
Equ = Eq1 /. g -> L0*\[CapitalOmega]^2 /. \[Delta] -> (\[CurlyEpsilon] * L0)/(\[CapitalOmega]^2);
\[Alpha]max = 1;
Lu[t_] = L[t] /. g -> L0*\[CapitalOmega]^2 /. \[Delta] -> (\[CurlyEpsilon] * L0)/(\[CapitalOmega]^2);
Equa = Equ /. \[CapitalOmega] -> 1 /.\[CurlyEpsilon] -> 0.05 /. m->1;
Lua[t_] = Lu[t] /. \[CapitalOmega] -> 1 /. \[CurlyEpsilon] -> 0.05 /. m->1;
sol = NDSolve[{Equa ==
0, \[Alpha][0] == 1, \[Alpha]'[0] == 0}, \[Alpha][
t], {t, -10, 10}, MaxSteps -> 100000];
a[t_] = \[Alpha][t]/.sol;
x1[t_] = Lua[t]*Cos[a[t]];
Show[Graphics[{Black, AbsolutePointSize[10],
Point[{x1[1],0}]}, Axes -> True],PlotRange->{{-10,10},{-10,10}}]
It must be a problem with the Point function here I guess.
Because if I instead want to plot the graph x1[t], i.e.
Plot[x1[t], {t, -10, 10}]
then it works.
Also, if I do
Show[Graphics[{Black, AbsolutePointSize[10],
Point[{0,0}]}, Axes -> True],PlotRange->{{-10,10},{-10,10}}]
It works and it shows me a black point at (0,0) (also, the Lua function works too without any problems, I can plot points which depend on the Lua function).
The problem only arises if I include x1[t] into it, then for some reasons the Graphics function (or Points function, I don't know which one here is the culprit) doesn't show me anything, it only shows me this:
EDIT
Even if I do
x1[1][[1]]
Then it still doesn't work if I try to animate it using Manipulate:
ClearAll["Global`*"]
L0 = 2;
\[Omega] = 4;
L[t_] = L0 + \[Delta] *Sin[\[Omega]*t + Pi];
x[t_] = L[t]*Cos[\[Alpha][t]];
y[t_] = L[t]*Sin[\[Alpha][t]];
T = m/2 * ((x'[t])^2 + (y'[t])^2);
U = -m*g*x[t];
Lagr = T - U;
Lgr = Simplify[Expand[Lagr]];
Eq1 = D[#1, #2] - D[D[#1, #3], t] & [Lgr, \[Alpha][t], \[Alpha]'[t]];
Eq2 = Solve[Eq1 == 0, \[Alpha]''[t]];
Equ = Eq1 /. g -> L0*\[CapitalOmega]^2 /. \[Delta] -> (\[CurlyEpsilon] * L0)/(\[CapitalOmega]^2);
\[Alpha]max = 1;
Lu[t_] = L[t] /. g -> L0*\[CapitalOmega]^2 /. \[Delta] -> (\[CurlyEpsilon] * L0)/(\[CapitalOmega]^2);
Equa = Equ /. \[CapitalOmega] -> 1 /.\[CurlyEpsilon] -> 0.05 /. m->1;
Lua[t_] = Lu[t] /. \[CapitalOmega] -> 1 /. \[CurlyEpsilon] -> 0.05 /. m->1;
f[p_] := Module[{sol},sol = NDSolve[{Equa ==
0, \[Alpha][0] == 1, \[Alpha]'[0] == 0}, \[Alpha][
t], {t,p,p-1}, MaxSteps -> 100000];
a[t_] = \[Alpha][t]/.sol;
x1[t_] = Lua[t]*Cos[a[t]];
y1[t_] = Lua[t]*Sin[a[t]];
Show[Graphics[{Black, AbsolutePointSize[10],
Point[{x1[p][[1]],y1[p][[1]]}]}, Axes -> True],PlotRange->{{-10,10},{-10,10}}]];
Manipulate[f[p], {{p,0,"animate"},0,Infinity,ControlType->Trigger}]
Even if I do
x1[1][[1]], y1[1][[1]]
it still just shows an empty coordinate system. Whereas if I do
0, 0
Then it again shows me a black point at (0,0)
SECOND EDIT
Ok, it seems that I need to do a[t] := instead of =. But if I try to manipulate the parameters [CapitalOmega] and such in my animation, it still fails to work (it does show the black ball, but just as I start my animation, the ball vanishes and I still have a coordinate system with nothing in it)
Code:
ClearAll["Global`*"]
L0 = 2;
\[Omega] = 4;
L[t_] = L0 + \[Delta] *Sin[\[Omega]*t + Pi];
x[t_] = L[t]*Cos[\[Alpha][t]];
y[t_] = L[t]*Sin[\[Alpha][t]];
T = m/2 * ((x'[t])^2 + (y'[t])^2);
U = -m*g*x[t];
Lagr = T - U;
Lgr = Simplify[Expand[Lagr]];
Eq1 = D[#1, #2] - D[D[#1, #3], t] & [Lgr, \[Alpha][t], \[Alpha]'[t]];
Eq2 = Solve[Eq1 == 0, \[Alpha]''[t]];
Equ = Eq1 /. g -> L0*\[CapitalOmega]^2 /. \[Delta] -> (\[CurlyEpsilon] * L0)/(\[CapitalOmega]^2);
Lu[t_] = L[t] /. g -> L0*\[CapitalOmega]^2 /. \[Delta] -> (\[CurlyEpsilon] * L0)/(\[CapitalOmega]^2);
Equa = Equ /. \[CapitalOmega] -> 1 /.\[CurlyEpsilon] -> 0.05 /. m->1;
Lua[t_] = Lu[t] /. \[CapitalOmega] -> 1 /. \[CurlyEpsilon] -> 0.05 /. m->1;
sol = NDSolve[{Equa == 0, \[Alpha][0] == 1, \[Alpha]'[0] == 0}, \[Alpha][ t], {t, -10, 10}, MaxSteps -> 100000];
a[t_] = \[Alpha][t]/.sol;
x1[t_] = Lua[t]*Cos[a[t]];
y1[t_] = Lua[t]*Sin[a[t]];
g[p_, \[Alpha]max_, \[CapitalOmega]_, \[CurlyEpsilon]_,m_] := Module[{sol1},sol1 =NDSolve[{Equ == 0, \[Alpha][0] == \[Alpha]max, \[Alpha]'[0] == 0}, \[Alpha][
t], {t, p, p - 1}, MaxSteps -> 100000];Show[Graphics[{Black, AbsolutePointSize[10],
Point[{Lu[p]*Sin[sol1[p][[1]]],-Lu[p]*Cos[sol1[p][[1]]] }]}, Axes -> True],PlotRange->{{-10,10},{-10,10}}]];
Show[Graphics[{Black, AbsolutePointSize[10],
Point[{x1[1][[1]],y1[1][[1]]}]}, Axes -> True],PlotRange->{{-10,10},{-10,10}}];
Manipulate[Show[Graphics[{Black, AbsolutePointSize[10],
Point[{y1[p][[1]],-x1[p][[1]]}]}, Axes -> True],PlotRange->{{-10,10},{-10,10}}], {{p, 0, "animation"}, 0, Infinity, ControlType -> Trigger}];
Manipulate[ g[p, \[Alpha]max, \[CapitalOmega], \[CurlyEpsilon], m], {{\[Alpha]max, 1}, 1, 10}, {{\[CapitalOmega], 1}, 1, 6.5}, {{\[CurlyEpsilon], 0.05}, 0.05, 0.5},{{m,1},1,10}, {{p, 0, "animation"}, 0, Infinity, ControlType -> Trigger}]
The problem I have with is the last manipulate where the g is plotted
Module
toBlock
or ( ) $\endgroup$