Faire un code python identique : syms theta1(t) theta2(t) syms m l k g d e1 e2 e3 e4 w…
- User
Faire un code python identique : syms theta1(t) theta2(t)
syms m l k g d e1 e2 e3 e4 w realDtheta1 = diff(theta1,t); Dtheta2 = diff(theta2,t);
cond = [theta1(0)==e1, Dtheta1(0)==e2,theta2(0)==e3, Dtheta2(0)==e4];
fprintf("Cas ") Y = [theta1; theta2]; Matrice_Masse = [mll, 0 ; 0, mll];
Matrice_Ressort = [(kdd+mgl), -kdd ; -kdd,(kdd+mgl)];
Matrice_Amortisseur = [0, 0 ; 0 ,0]; Excitation =[0; 0]; odes11 = Matrice_Massediff(Y,t,2)+Matrice_Amortisseurdiff(Y,t,1)+ Matrice_Ressort*Y-Excitation ==0 [theta11_Sol(t), theta22_Sol(t)] = dsolve(odes11,cond); x11Sol(t) = simplify(theta11_Sol(t))
x22Sol(t) = simplify(theta22_Sol(t)) Matrice_Dynamique = (Matrice_Masse)\Matrice_Ressort;
[Vecteurs_propres,Valeur_propres] = eig(Matrice_Dynamique)
- Assistant
from sympy import symbols, Function, diff, dsolve, Eq, S, simplify, eig
t = symbols('t') theta1 = Function('theta1')(t) theta2 = Function('theta2')(t) m, l, k, g, d, e1, e2, e3, e4, w = symbols('m l k g d e1 e2 e3 e4 w', real=True)
Dtheta1 = theta1.diff(t) Dtheta2 = theta2.diff(t)
cond = [theta1.subs(t,0)-e1, Dtheta1.subs(t,0)-e2, theta2.subs(t,0)-e3, Dtheta2.subs(t,0)-e4]
print("Cas ") Y = [theta1, theta2] Matrice_Masse = [[mll, 0], [0, mll]]
Matrice_Ressort = [[kdd+mgl, -kdd], [-kdd, kdd+mgl]]
Matrice_Amortisseur = [[0, 0], [0, 0]] Excitation =[0, 0] odes11 = Matrice_Masse[0][0]*Y[0].diff(t, 2) + Matrice_Amortisseur[0][0]*Y[0].diff(t, 1) + Matrice_Ressort[0][0]*Y[0] - Excitation[0] odes12 = Matrice_Masse[0][1]*Y[1].diff(t, 2) + Matrice_Amortisseur[0][1]*Y[1].diff(t, 1) + Matrice_Ressort[0][1]*Y[1] - Excitation[1] odes21 = Matrice_Masse[1][0]*Y[0].diff(t, 2) + Matrice_Amortisseur[1][0]*Y[0].diff(t, 1) + Matrice_Ressort[1][0]*Y[0] odes22 = Matrice_Masse[1][1]*Y[1].diff(t, 2) + Matrice_Amortisseur[1][1]*Y[1].diff(t, 1) + Matrice_Ressort[1][1]*Y[1]