toc issueshttps://gitlab.irit.fr/groups/toc/-/issues2022-05-12T07:15:10Zhttps://gitlab.irit.fr/toc/ens-n7/controle-optimal/etudiants/-/issues/1TP EDO2022-05-12T07:15:10ZOlivier CotsTP EDO* $`x_0`$ en ligne. Est-ce normal ? On ne peut pas faire $`\dot{x} = Ax+b`$.
* Pendule : préciser $`m=1`$.
* Il est écrit pour l'exemple 1 :
```julia
# t : time, variable not use here
```
alors que l'on a $`\sin(t)`$.
* Soucis dans la d...* $`x_0`$ en ligne. Est-ce normal ? On ne peut pas faire $`\dot{x} = Ax+b`$.
* Pendule : préciser $`m=1`$.
* Il est écrit pour l'exemple 1 :
```julia
# t : time, variable not use here
```
alors que l'on a $`\sin(t)`$.
* Soucis dans la dynamique du pendule. Manque la division par $`l^2`$ :
```julia
xpoint[2] = -(g/l)*sin(x[1]) - k*x[2]/l^2
```
Mon code pour l'affichage :
```julia
# Main
#
g = 9.81; l = 1.5; k = 0.15;
p = [g l k]
plot()
for theta0 in 0:(2*pi)/2:2*pi
theta0_princ = theta0
tf = 3*pi*sqrt(l/g)*(1 + theta0_princ^2/16 + theta0_princ^4/3072) # 2*approximation of the period
tspan = (0.0,tf)
x0 = [theta0 0]
prob = ODEProblem(pendule,x0,tspan,p)
sol = solve(prob)
plot!(sol,vars=(1,2), xlabel = "x1", ylabel = "x2", legend = false, lw = 0.5) # lw = linewidth
end
theta0 = pi-10*eps()
x0 = [theta0 0]
tf = 50 # problem for tf=50 1/4 of the period!
tspan = (0.0,tf)
prob = ODEProblem(pendule,x0,tspan,p)
sol = solve(prob)
plot!(sol,vars=(1,2), xlims = (-2*pi,4*pi), xlabel = "x1", ylabel = "x2", legend = false, lw = 0.5) # lw = linewidth
theta0 = pi+10*eps()
x0 = [theta0 0]
tf = 50
tspan = (0.0,tf)
prob = ODEProblem(pendule,x0,tspan,p)
sol = solve(prob)
plot!(sol,vars=(1,2), xlims = (-2*pi,4*pi), xlabel = "x1", ylabel = "x2", legend = false, lw = 0.5) # lw = linewidth
# circulation case
for thetapoint0 in 0:0.5:2
tf = 10
tspan = (0.,tf)
x0 = [-pi thetapoint0] # thetapoint0 > 0 so theta increases from -pi to ...
prob = ODEProblem(pendule,x0,tspan,p)
sol = solve(prob)
plot!(sol,vars=(1,2), xlabel = "x1", ylabel = "x2", legend = false, lw = 0.5) # lw = linewidth
end
for thetapoint0 in -2:0.5:0
tf = 10
tspan = (0.,tf)
x0 = [3*pi thetapoint0] # thetapoint0 < 0 so theta decreases from 3pi to ...
prob = ODEProblem(pendule,x0,tspan,p)
sol = solve(prob)
plot!(sol,vars=(1,2), xlabel = "x1", ylabel = "x2", legend = false, lw = 0.5) # lw = linewidth
end
plot!([-pi 0 pi 2*pi 3*pi], [0 0 0 0 0], seriestype=:scatter)
plot!(xlims = (-pi,3*pi), size=(900, 600))
```