faire un code python : syms theta(t) syms m M l k c a b d real k=2000; c=10; a=0.4;…
- User
faire un code python : syms theta(t)
syms m M l k c a b d real k=2000; c=10; a=0.4; b=0.4; d=0.4; l=1.2; M=20; m=10; Dtheta = diff(theta,t); cond = [theta(0)==b, Dtheta(0)==d];%Serie de fourier syms Mo_1(t) Mo_2(t) ao an bn syms T w A ao=A; %latex(ao1) %latex(expand(an1)) bn =0;
Mo_1 = ao/2 -4A/(11pipi)cos((2pi/T)t)-4A/(33pipi)cos(3(2pi/T)t)-4A/(55pipi)cos(5(2pi/T)t);% n est impair 1 3 et 5 eqn_1 = (mll/3+Mll)diff(theta,t,2)+clldiff(theta,t,1)+ (ka*a)*theta == Mo_1
Mo_2 = A/pi + (A/2)sin(t2pi/T)+ cos(2(2pi/T)t)/(22-1) +cos(4(2pi/T)t)/(44-1)+cos(6(2pi/T)t)/(66-1) eqn_2 = (mll/3+Mll)diff(theta,t,2)+clldiff(theta,t,1)+ (ka*a)*theta == Mo_2
theta_Sol_1 = dsolve(eqn_1,cond)
theta_Sol_2 = dsolve(eqn_2,cond) %fplot(theta_Sol_1,'--or') %fplot(theta_Sol_2,'--g')
- Assistant
from sympy import symbols, diff, cos, pi, dsolve, fplot
t = symbols('t') theta = symbols('theta', function=True)(t) m, M, l, k, c, a, b, d = symbols('m M l k c a b d', real=True) k = 2000 c = 10 a = 0.4 b = 0.4 d = 0.4 l = 1.2 M = 20 m = 10
Dtheta = diff(theta, t) cond = [theta.subs(t, 0) - b, Dtheta.subs(t, 0) - d]
Fourier series
Mo_1 = ao/2 - 4A/(11pipi)cos((2pi/T)t) - 4A/(33pipi)cos(3(2pi/T)t) - 4A/(55pipi)cos(5(2pi/T)t) eqn_1 = (mll/3 + Mll)diff(theta, t, 2) + clldiff(theta, t) + (ka*a)*theta - Mo_1
Mo_2 = A/pi + (A/2)sin(t2pi/T) + cos(2(2pi/T)t)/(22-1) + cos(4(2pi/T)t)/(44-1) + cos(6(2pi/T)t)/(66-1) eqn_2 = (mll/3 + Mll)diff(theta, t, 2) + clldiff(theta, t) + (ka*a)*theta - Mo_2
theta_Sol_1 = dsolve(eqn_1, cond) theta_Sol_2 = dsolve(eqn_2, cond)
Uncomment to plot the solutions
fplot(theta_Sol_1, '--or')
fplot(theta_Sol_2, '--g')