# -*- coding: utf-8 -*-
"""
Created on Sat Sep  9 10:31:55 2023

@author: maxim
"""
import numpy as np
import scipy.integrate as sp
import matplotlib.pyplot as plt

'ex 6'



't pour tracé temporelle'
t=np.linspace(0,5,2000)

y01=[np.pi/4,0]
y02=[np.pi/20,0]


def Fnl(y, t):
    return [y[1], -(9.81/0.3)*np.sin(y[0])]

def Fl(y,t):
    return [y[1], -(9.81/0.3)*y[0]]


ysol1nl=sp.odeint(Fnl,y01,t)
ysol2nl=sp.odeint(Fnl,y02,t)

ysol1l=sp.odeint(Fl,y01,t)
ysol2l=sp.odeint(Fl,y02,t)

theta1l=ysol1l[:,0]
thetapr1l=ysol1l[:,1]

theta2l=ysol2l[:,0]
thetapr2l=ysol2l[:,1]



theta1=ysol1nl[:,0]
thetapr1=ysol1nl[:,1]

theta2=ysol2nl[:,0]
thetapr2=ysol2nl[:,1]

"tracé thetaprim=f(theta) portrait de phase"
#plt.plot(theta1*180/np.pi,thetapr1*180/np.pi)
#plt.plot(theta1l*180/np.pi,thetapr1l*180/np.pi)

plt.xlabel("theta °")
plt.ylabel("thetapr rad/sec")

"tracé theta=f(t)"
plt.plot(t,theta1*180/np.pi)
plt.plot(t,theta1l*180/np.pi)
plt.plot(t,theta2*180/np.pi)
plt.plot(t,theta2l*180/np.pi)




plt.xlabel("temps s")
plt.ylabel("theta °")



plt.show()

