*************
ECOLE POLYTECHNIQUE D’ABOMEY-CALAVI
*************
SECTEUR INDUSTRUEL DEUXIEME ANNEE (SI2)
************
1
Exercice 1
1.1. Construire un solveur [𝑡, 𝑦] = 𝑅𝐿𝐶 (𝐸, 𝑅, 𝐿, 𝐶, 𝑡0, 𝑡1, 𝑞0, 𝑖0, 𝑛) du circuit RLC
de l’exercice 1 de la planche
2
for i=1:n
t(i+1) = t(i)+h;
k1 = f(t(i),y(i),dy(i));
k2 = f(t(i)+h/2,y(i)+h/2*dy(i),dy(i)
+h/2*k1);
k3 = f(t(i)+h/2,y(i)+h/2*dy(i)
+h^2/4*k1,dy(i)+h/2*k2);
k4 = f(t(i)+h,y(i)+h*dy(i)+h^2/2*k2,dy(i)
+h*k3);
y(i+1) = y(i)+h*dy(i)+h^2/6*(k1+k2+k3);
dy(i+1) = dy(i)+h/6*(k1+2*k2+2*k3+k4);
end
end
[t, y, dy] = RK4_ordre2(f,t0,tfin,y0, dy0,n);
End
6.36−2.7∙𝑐𝑜𝑠(15𝜋𝑡) 𝑠𝑖 0.1≤𝑡<0.15
function [ dy ] = rigid( t, y )
R =1.0; L =2; C =0.45;
E = @(t) (t>=0)*(t<0.05)*(9*sin(15*pi*t))+
(t>=0.05)*(t<0.1)*6.36+(t>=0.1)*(t<=0.15)*(6.36-
2.7*cos(15*pi*t));
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = (E(t)-R*y(2)-y(1)/C)/L;
end
3
Suite de la question 1.2 de l’exercice 1
% Résolution du problème suivant: L(di/dt)+Ri+q/C = E(t),
dq/dt = i
% Contions initiales: q(0)=0; i(0)=0;
% En posant: y1 = q et y2 = i,
% le probleme equivaut au système suivant:
%
% y'1 = y2, y1(0)=0;
% y'2 = (E(t)-Ry2-y1/C)/L, y2(0)=0.
4
EXERCICE 2
%Date:19/12/2020
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::
%Initialisation
x1=xo;
conv0=0;
Nit0=0;
%Itérations
while(1>0)
Rapport=fdf(x1);
x2=x1-Rapport(1)/Rapport(2);
Nit0=Nit0+1;
test=abs((x2-x1)/x2);
if(test<epsi)
conv0=1;
break;
end
if(Nit0>=Nmax)
break;
end
x1=x2;
end
conv=conv0;Nit=Nit0;y=x2;
end
suite de l’exercice 2
%=============================================================
%programme permettant d'évaluer le rendement d'un moteur pour
un gaz
%monoatomique
%Arguments d'entrés
% gamma: scalaire
% epsi: scalaire
% nu: le rendement du moteur
%Date: 20 / 01 /2020
% Auteurs: AKOUEHOU Noé, BONOU Habib, DANSOU Giovanni, ZINSOU
Karl
6
%Utilisons l'algorithme de NewRaph pour déterminer le rapport
T2/T1 tel que:
% nu = [T1/T2-1-ln(T1/T2)/[ln(T2/T1)+(1-T1/T2)(gamma-1)]
% n et gamma sont donne
%=============================================================
z = 5/3; nu = 0.3;
f = @(x) ((1/x-1)-log(1/x))*(z-1)-nu*(log(x)*(z-1)+(1-1/x));
df = @(x) (-1/x^2+1/x)*(z-1)-nu*((z-1)/x+1/x^2);
%================ NewRaph=====================================
fdf = @(x) [ f(x) df(x)]; x0 = 5; Nmax = 100; epsi=1e-6;
[ conv,Nit,y ] = NewRaph( fdf,x0,Nmax,epsi );
fplot(f,[0 10]); grid on;
7
EXERCICE 3
Où
8
• 𝑅𝑒=6378.14𝑘𝑚=𝑟𝑎𝑦𝑜𝑛 𝑑𝑒 𝑙𝑎 𝑡𝑒𝑟𝑟𝑒 𝑎𝑢 𝑛𝑖𝑣𝑒𝑎𝑢 𝑑𝑒𝑠 𝑚𝑒𝑟𝑠.
end
Suite de l’exercice 3
9
Exercice 4
10
D(i,i)=u(i,i);
for j=i+1:n
Ts(i,j)=u(i,j);
Ti(j,i)=u(j,i);
end
end
M=-1*inv(D)*(Ts+Ti);
end
function [ D ] = dF(K,n,X )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
%Auteurs: AKOUEHOU Noé, BONOU Habib, DANSOU Giovanni, ZINSOU
Karl
[line,col]=size(X);
A=tridiag(n);
B=Diag(X);
for i=1:line
for j=1:col
D(i,j)=A(i,j)+2*K*B(i,j);
end
end
end
function [ D ] = Diag( u )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
%Auteurs: AKOUEHOU Noé, BONOU Habib, DANSOU Giovanni, ZINSOU
Karl
[line,col]=size(u);
D=zeros(line,line);
for i=1:line-1
D(i,i)=cosh(u(i,1));
end
D(line,line)=cosh(u(line,1));
end
11
function [ D ] = Fa( n,landa,h,K,X,C)
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
%Auteurs: AKOUEHOU Noé, BONOU Habib, DANSOU Giovanni, ZINSOU
Karl
A=tridiag(n);
[line,col]=size(C);
[line,col]=size(X);
B=A*X;
for i=1:line
for j=1:col
D(i,j)=B(i,j)*(landa/h)^2+2*K*sinh(X(i,j))-C(i,j);
end
end
end
function [ U ] = SolvesSC(Uo,K,landa,C,epsi,n,Nmax)
%Syntaxe:[ U ] = SolvesSC(Uo,K,landa,epsi,n,Nmax)
%Argument:
%Nmax le nombre maximal d'itération
%epsi: le critère de convergence
% landa,K et n des constantes
% Uo: une matrice colonne
%Valeur retournée:
%U:
%Auteurs: AKOUEHOU Noé, BONOU Habib, DANSOU Giovanni, ZINSOU
Karl
%:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
h=1/(n+1);
compteur=0;conv=1;
N=size(Uo,1);
X1=Uo;
%=======================Boucle d'itérations==========================
while 1>0
compteur=compteur+1;
M=dF(K,n,X1);
B=-Fa(n,landa,h,K,X1,C);
dX=M\B;
X2=X1+dX;
Norme1=norm(dX)/norm(X2);
Norme2=norm(Fa(n,landa,h,K,X2,C));
%-----------------------test de convergence--------------------------
if (Norme1<epsi) && (Norme2<epsi)
Nbit=compteur;
break;
end
%------------------Test sur le nombre d'itérations-------------------
if compteur>=Nmax
conv=0;
Nbit=Nmax;
break;
end
%-------------Copie et retour à la prochaine itération----------------
X1=X2;
end
%=====================Fin de boucle d'itération=======================
U=X2;
12
end
function [ D] = tridiag(n )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
%Auteurs: AKOUEHOU Noé, BONOU Habib, DANSOU Giovanni, ZINSOU
Karl
D=zeros(n,n);
for i=1:n-1
D(i,i)=2;
D(i+1,i)=-1;
D(i,i+1)=-1;
end
D(n,n)=2;
end
2𝑢1−𝑢2+2𝑠𝑖𝑛ℎ(𝑢1)−0.5=0
−𝑢1+2𝑢2+2𝑠𝑖𝑛ℎ(𝑢2)−0.4=0 (2)
13
4.2.1. en partant de 𝑈0=[−0.21−0.1]𝑇, déterminer u avec le critère de convergence 𝜀=10−3 la
solution de (2).
%Resolution du système d'équation avec n=2
%et pour epsi=1e-3
% en utilisant le solver solvesSC
%Auteurs: AKOUEHOU Noé, BONOU Habib, DANSOU Giovanni, ZINSOU
Karl
%Date:19/01/2021
%::::::::::::::::::::::::::::::::::::::::::::::
global k lambda
U0 = [-0.21-0.1]' ; k = 1; lambda = 1/3; epsi = 1e-3; n = 2; Nmax = 100;
b = [0.5 0.4]';
[ U ] = SolvesSC( U0,k,lambda,epsi,n,Nmax );
fprintf('\n la solution du système est :[% %]',U(1),U(2));
14