problem with Euler's explicit methode
Afficher commentaires plus anciens
clc
clear all
%%%%%%%%%%%%%Entering the variable%%%%%%%%%%%%%%%%%
Vn=1.52*(10^-5) ; %Volumen start punkt
Vch4=53/100 ;
Vco2=47/100 ;
%PV=nRT...... V/n=RT/P aber R,T und P are constant:
%V=n; n=C.Vn....C=V/Vn
%k3= 0.008;
%k4= 0.001;
%k6=0.5;
%k8 = 0.048;
%Cco2=X Cch4=Y Ch2=Z Cco= M Ch2o= L Cc=N
%dY/dt= -0.5*Y*L;
%dL/dt= 0.016*X*Z -0.001*M*L -0.5*Y *L;
%dX/dt= -0.008*X*Z -0.048*N*X +0.001*M*L;
%dM/dt= -0.001*M*L +0.5*Y*L + 0.096*N*X;
%dZ/dt= -0.016*X*Z +0.001*M*L +1.5*Y*L;
%dN/dt= 0.008*X*Z -0.048*N*X;
y0= Vch4/Vn; %34.868,421052631578947368421052632 %m0 consentration in Startpunkt für Methan
X0= Vco2/Vn; %30.921,052631578947368421052631579 %k0 consentration in Startpunkt für CO2
t0=0;
tend=100;
h=0.1;
L0=0;M0=0;Z0=0;N0=0;
X(1)=X0;Y(1)=y0;L(1)=L0;M(1)=M0;Z(1)=Z0;N(1)=N0;
k=(tend-t0)/h;
%%% solution
t(1)=t0;
func1=@(Y,L) -0.5*Y*L; %dY/dt
func2=@(X,Z,M,Y,L) 0.016*X*Z -0.001*M*L -0.5*Y *L; %dL/dt
func3=@(X,Z,M,L,N) -0.008*X*Z -0.048*N*X +0.001*M*L; %dX/dt
func4=@(M,L,Y,N,X) -0.001*M*L +0.5*Y*L + 0.096*N*X; %dM/dt
func5=@(X,Z,M,L,Y) -0.016*X*Z +0.001*M*L +1.5*Y*L; %dZ/dt
func6=@(X,Z,N)0.008*X*Z -0.048*N*X; %dN/dt
%% Euler
for i=1:k-1
t(i+1)=i*h;
Y(i+1)=Y(i)+ h*func1(Y(i),L(i));
L(i+1)=L(i)+h*func2(X(i),Z(i),M(i),L(i),Y(i));
X(i+1)=X(i)+h*func3(X(i),Z(i),N(i),M(i),L(i));
M(i+1)=M(i)+h*func4(M(i),L(i),Y(i),N(i),X(i));
Z(i+1)=Z(i)+h*func5(X(i),Z(i),M(i),L(i),Y(i));
N(i+1)=N(i)+h*func6(X(i),Z(i),N(i)) ;
end
figure(1)
plot (t,Y)
xlabel('Zeit in S');
ylabel('konzentration in mol/l')
title('CH4');
figure(2)
plot(t,X)
xlabel('Zeit in S');
ylabel('konzentration in mol/l')
title('CO2');
figure(3)
plot(t,L)
xlabel('Zeit in S');
ylabel('konzentration in mol/l')
title('H2O');
figure(4)
plot(t,Z)
xlabel('Zeit in S');
ylabel('konzentration in mol/l')
title('H2');
figure(5)
plot(t,M);
xlabel('Zeit in S');
ylabel('konzentration in mol/l')
title('Co');
figure(6)
plot(t,N);
xlabel('Zeit in S');
ylabel('konzentration in mol/l')
title('C');
I would like to write a program for solving 6 equations with 6 variables throw Euler's explicit methode ,but all the Variable take just 0 value.
it is somthing for my University Homwork
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structural Mechanics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!