Error in ode45

1 view (last 30 days)
Imene Yed
Imene Yed on 29 May 2021
Commented: Imene Yed on 29 May 2021
Hi
clear all,clc
%constantes::
%temperature
T=17000
%constante k: recombinaison radiative
k1=2.36 *(1e-12)*(T/300)^(-0.29)*exp(17.60/T)
k2 =3.24 *(1e-12) *(T/300)^(-0.66)
k3=3.50 *(1e-12)*(T/300)^(-0.53)* exp(3.20/T)
%constante k::Reconmbinaison
k5=4.54*10^(-10)
k6=9.10*10^(-10)
k10=6*10^(-11)*(T/300)^(-0.16)
k13=2.94*10^(-11)*(T/300)^(0.5)*exp(-58025/T)
k14=1*10^(-9)
k15=4.80*10^(-10)
k16=1.00*10^(-9)*(T/300)^(-0.5)
k17=8.30*10^(-10)
k18=2.42*10^(-12)*(T/300)^(-0.21)*exp(44/T)
k21=1.66*10^(-10)*exp(-14100/T)
k22=1.15*10^(-10)*exp(-13400/T)
k23=2.51*10^(-10)*exp(-38602/T)
k30=1.30*10^(-10)
k31=5.00*10^(-10)
k33=3.10*10^(-10)
k34=3.66*10^(-11)
k35=2.26*10^(-12)*(T/300)^(0.86)*exp(-3134.0/T)
k36=1.80*10^(-10)
k40=6.10*10^(-10)
k42=5*10^(-11)
k45=4*10^(-11)
k49=4.10*10^(-10)
k50=8*10^(-10)
k52=2.8*10^(-12)*exp(23400/T)
k53=1*10^(-10)*exp(-55200/T)
k54=8.60*10^(-11)
%constante k::Association radiative
k61=4.01*10^(-18)*(T/300)^(0.17)*exp(-101.50/T)
k68=4.36*10^(-18)*(T/300)^(0.35)*exp(-161.30/T)
%constante k::Transfert de charge
k72=7.05*10^(-10)*(T/300)^(-0.03)*exp(16.70/T)
k73=1*10^(-10)
k74=1.10*10^(-10)
k75=1.10*10^(-10)
k76=1.10*10^(-10)
k77=5.20*10^(-11)
k78=4.80*10^(-10)
k80=6.30*10^(-10)
k81=1.90*10^(-11)
k82=1.00*10^(-11)
k83=1.40*10^(-10)
k85=1.00*10^(-9)
k86=3.11*10^(-10)
k87=1.00*10^(-9)
k88=8.25*10^(-10)
k89=1.10*10^(-9)*(T/300)^(-0.50)
k90=4.51*10^(-10)
k91=1* 10^(-11)
k92=8.40*10^(-10)
k93=8.50^(-10)
k94=3.40*10^(-10)
k95=5*10^(-11)
k96=1.20*10^(-10)
k97=6.60*10^(-10)
k98=4.60*10^(-10)
k99=1.00*10^(-10)*(T/300)^(-0.5)
k100=7.40*10^(-11)
k101=6.30*10^(-10)
k102=3.30*10^(-10)
k103=5.70*10^(-10)
%constante k::Neutralisation
k104=7.51*10^(-8)*(T/300)^(-0.5)
k105=7.51*10^(-8)*(T/300)^(-0.5)
k106=7.51*10^(-8)*(T/300)^(-0.5)
k107=7.51*10^(-8)*(T/300)^(-0.5)
k108=7.51*10^(-8)*(T/300)^(-0.5)
k109=7.51*10^(-8)*(T/300)^(-0.5)
k110=7.51*10^(-8)*(T/300)^(-0.50)
k111=7.51*10^(-8)*(T/300)^(-0.50)
k112=7.51*10^(-8)*(T/300)^(-0.50)
k113=7.51*10^(-8)*(T/300)^(-0.50)
k114=7.51*10^(-8)*(T/300)^(-0.5)
k115=7.51*10^(-8)*(T/300)^(-0.5)
k116=7.51*10^(-8)*(T/300)^(-0.5)
k117=7.51*10^(-8)*(T/300)^(-0.5)
%constante k::Photoionisation
k118=3.10*10^(-10)*exp(-3.3/T)
k119=4.90*10^(-8)*exp(-0.50/T)
k120=1.09*10^(-8)*exp(-0.5/T)
k121=4.10*10^(-10)*exp(-3.80/T)
k122=1*10^(-11)*exp(-1.70/T)
k123=2.96*10^(-9)*exp(-2/T)
k124=5*10^(-9)*exp(-2.1/T)
k125=6.88*10^(-9)*exp(-1.5/T)
k126=7.90*10^(-10)*exp(-2.1/T)
k127=6.10*10^(-9)*exp(-0.5/T)
k128=3.50*10^(-11)*exp(-2/T)
k129=2.30*10^(-10)*exp(-3.90/T)
k130=2.10*10^(-10)*exp(-3.50/T)
k131=4.70*10^(-10)*exp(-2.10/T)
%constante k::Attachement radiatif
k133=1.50*10^(-15)
%constante k::Détachement associatif
k136=5*10^(-10)
k139=5*10^(-10)
k140=5*10^(-10)
k141=5*10^(-11)
k142=5*10^(-10)
k143=1.90*10^(-10)
k146=6.50*10^(-10)
k147=2.20*10^(-10)
%constante k::Excitation/ Désexcitation
k150=2.0425*10^(-7)*T^(-0.3)*exp(-29489.55/T)
k153=6.0278*10^(-7)*T^(-0.4)*exp(-19880.36/T)
k154=1.6306*10^(-17)
k155=3.6532*10^(-11)
%initial
IC=10^19*ones(1,33)
[t,n]=ode45(@ODE,[0 1e-3],IC)
plot(t,n)
function dndt=ODE(t,n,k1,k2,k3,k5,k6,k10,k13,k14,k15,k16,k17,k18,k21,k22,k23,k30,k31,k33,k34,k35,k36,k40,k42,k45,k49,k50,k52,k53,k54,k61,k68,k72,k73,k74,k75,k76,k77,k78,k80,k81,k82,k83,k85,k86,k87,k88,k89,k90,k91,k92,k93,k94,k95,k96,k97,k98,k99,k100,k101,k102,k103,k104,k105,k106,k107,k108,k109,k110,k111,k112,k113,k114,k115,k116,k117,k118,k119,k120,k121,k122,k123,k124,k125,k126,k128,k129,k130,k131,k133,k136,k139,k140,k141,k142,k143,k146,k147,k150,k153,k154,k155)
dndt=zeros(33,1)
%Chemin C
dndt(1)= k1*n(2)*n(32)+k15*n(5)*n(9)+k16*n(5)*n(24)...
+k33*n(4)*n(11)+k40*n(7)*n(25)...
+k72*n(2)*n(22)+k104*n(3)*n(5)+k105*n(3)*n(8)+k106*n(3)*n(23)...
+k117*n(16)*n(2)+k119*n(3)*n(33)+k122*n(11)*n(33)+k124*n(13)*n(33)...
+k130*n(20)*n(33)...
-k10*n(1)*n(22)-k13*n(1)*n(20)...
-k61*n(2)*n(1)...
-k68*n(1)*n(1)-k73*n(1)*n(25)...
-k74*n(1)*n(11)-k75*n(1)*n(21)-k76*n(1)*n(19)-k77*n(1)*n(17)...
-k118*n(1)*n(33)-k136*n(1)*n(3)...
-k139*n(1)*n(6);
%Chemin C+
dndt(2)= -k1*n(2)*n(32)-k5*n(2)*n(15)-k6*n(2)*n(27)...
-k61*n(2)*n(1)-k72*n(2)*n(22)...
-k117*n(16)*n(2)+k45*n(7)*n(11)+k73*n(1)*n(25)...
+k74*n(1)*n(11)+k75*n(1)*n(21)+k76*n(1)*n(19)...
+k77*n(1)*n(17)+k118*n(1)*n(33)+k122*n(11)*n(33);
%Chemin C-
dndt(3)= -k14*n(3)*n(22)-k104*n(3)*n(5)...
-k105*n(3)*n(8)-k106*n(3)*n(23)-k119*n(3)*n(33)...
-k136*n(1)*n(3)-k140*n(3)*n(4)-k141*n(3)*n(15)-k142*n(3)*n(7);
%Chemin O:
dndt(4)= k2*n(5)*n(32)+k10*n(1)*n(22)+k13*n(1)*n(20)...
+k14*n(3)*n(22)+k35*n(7)*n(15)+k36*n(7)*n(17)...
+k52*n(15)*n(22)...
+k53*n(15)*n(18)...
+k78*n(5)*n(9)+k80*n(5)*n(27)...
+k81*n(5)*n(15)+k85*n(6)*n(24)...
+k104*n(3)*n(5)+2*k107*n(5)*n(6)+k108*n(5)*n(16)...
+k109*n(6)*n(8)+k120*n(6)*n(33)+2*k126*n(15)*n(33)...
+k128*n(17)*n(33)+k130*n(20)*n(33)+k131*n(22)*n(33)...
-k21*n(4)*n(27)-k22*n(4)*n(27)-k23*n(4)*n(18)...
-k30*n(4)*n(19)-k31*n(4)*n(14)...
-k33*n(4)*n(11)...
-k82*n(4)*n(19)-k83*n(4)*n(21)...
-k133*n(4)*n(32)-k140*n(3)*n(4)-k143*n(4)*n(6);
%Chemin O+:
dndt(5)= k5*n(2)*n(15)+k34*n(8)*n(15)+k82*n(4)*n(19)...
+k83*n(4)*n(21)+k128*n(17)*n(33)...
-k21*n(4)*n(27)-k22*n(4)*n(27)...
-k23*n(4)*n(18)...
-k30*n(4)*n(19)-k31*n(4)*n(14)...
-k33*n(4)*n(11)...
-k82*n(4)*n(19)...
-k83*n(4)*n(21)-k133*n(4)*n(32)-k140*n(3)*n(4)...
-k143*n(4)*n(6);
%Chemin O-:
dndt(6)= k133*n(4)*n(32)...
-k85*n(6)*n(24)-k107*n(5)*n(6)-k109*n(6)*n(8)-k120*n(6)*n(33)...
-k139*n(1)*n(6)-k143*n(4)*n(6)...
-k146*n(6)*n(20)-k147*n(6)*n(7);
%Chemin N:
dndt(7)= k3*n(8)*n(32)...
+k18*n(5)*n(18)+k23*n(4)*n(18)...
+k30*n(4)*n(19)...
+k86*n(8)*n(15)+k87*n(8)*n(9)+k88*n(8)*n(20)...
+k89*n(8)*n(24)+k90*n(8)*n(22)+k105*n(3)*n(8)...
+k109*n(6)*n(8)+k110*n(8)*n(16)+k111*n(8)*n(12)...
+k112*n(8)*n(26)+k113*n(8)*n(14)+2*k129*n(18)*n(33)...
+k131*n(22)*n(33)-k35*n(7)*n(15)...
-k36*n(7)*n(17)-k40*n(7)*n(25)...
-k42*n(7)*n(14)-k45*n(7)*n(11)...
-k91*n(7)*n(19)-k142*n(3)*n(7)-k147*n(6)*n(7);
%Chemin N+:
dndt(8)= k91*n(7)*n(19)-k3*n(8)*n(32)-k34*n(8)*n(15)...
-k86*n(8)*n(15)-k87*n(8)*n(9)...
-k88*n(8)*n(20)-k89*n(8)*n(24)-k90*n(8)*n(22)...
-k105*n(3)*n(8)-k109*n(6)*n(8)-k110*n(8)*n(16)...
-k111*n(8)*n(12)-k112*n(8)*n(26)-k113*n(8)*n(14);
%Chemin C2:
dndt(9)= k13*n(1)*n(20)+k68*n(1)*n(1)...
+k74*n(1)*n(11)+k94*n(11)*n(22)+k111*n(8)*n(12)...
+k115*n(12)*n(23)+k121*n(9)*n(33)+k123*n(12)*n(33)...
+k124*n(13)*n(33)+k136*n(1)*n(3)+k153*n(10)*n(32)...
+k154*n(10)^(2)+k155*n(10)*n(1)-k15*n(5)*n(9)...
-k49*n(9)*n(17)-k78*n(5)*n(9)-k87*n(8)*n(9)-k92*n(9)*n(21)...
-k93*n(9)*n(25)-k121*n(9)*n(33)-k150*n(9)*n(32);
%Chemin C2(d):
dndt(10)= k150*n(9)*n(32)-k153*n(10)*n(32)-k154*n(10)^(2)-k155*n(10)*n(1);
%Chemin C2+:
dndt(11)= k61*n(2)*n(1)+k78*n(5)*n(9)+k87*n(8)*n(9)...
+k92*n(9)*n(21)+k93*n(9)*n(25)-k33*n(4)*n(11)...
-k45*n(7)*n(11)-k50*n(11)*n(15)...
-k74*n(1)*n(11)-k94*n(11)*n(22)-k122*n(11)*n(33);
%Chemin C2-:
dndt(12)= -k111*n(8)*n(12)...
-k115*n(12)*n(23)-k123*n(12)*n(33)...
+k31*n(4)*n(14)+k42*n(7)*n(14);
%Chemin C3:
dndt(13)= k113*n(8)*n(14)...
+k114*n(14)*n(23)+k125*n(14)*n(33)...
-k124*n(13)*n(33);
%Chemin C3-:
dndt(14)= -k31*n(4)*n(14)...
-k42*n(7)*n(14)-k113*n(8)*n(14)...
-k114*n(14)*n(23)-k125*n(14)*n(33);
%Chemin O2:
dndt(15)= k17*n(5)*n(29)...
+k21*n(4)*n(27)...
+k77*n(1)*n(17)+k97*n(17)*n(29)+k98*n(17)*n(22)...
+k108*n(5)*n(16)+k110*n(8)*n(16)+k116*n(16)*n(23)...
+k117*n(16)*n(2)+k127*n(16)*n(33)+k143*n(4)*n(6)...
-k5*n(2)*n(15)-k34*n(8)*n(15)...
-k35*n(7)*n(15)-k50*n(11)*n(15)...
-k52*n(15)*n(22)-k53*n(15)*n(18)...
-k54*n(15)*n(25)-k81*n(5)*n(15)-k86*n(8)*n(15)...
-k95*n(15)*n(19)-k96*n(15)*n(21)-k126*n(15)*n(33)...
-k141*n(3)*n(15);
%Chemin O2-:
dndt(16)= -k108*n(5)*n(16)-k110*n(8)*n(16)...
-k116*n(16)*n(23)-k117*n(16)*n(2)-k127*n(16)*n(33);
%Chemin O2+
dndt(17)= k81*n(5)*n(15)+k86*n(8)*n(15)+k95*n(15)*n(19)...
+k96*n(15)*n(21)-k36*n(7)*n(17)-k49*n(9)*n(17)-k77*n(1)*n(17)...
-k97*n(17)*n(29)-k98*n(17)*n(22)-k128*n(17)*n(33);
%Chemin N2:
dndt(18)= k21*n(4)*n(27)...
+k76*n(1)*n(19)+k82*n(4)*n(19)...
+k91*n(7)*n(19)+k95*n(15)*n(19)+k99*n(19)*n(24)...
+k100*n(19)*n(20)-k18*n(5)*n(18)...
-k23*n(4)*n(18)-k53*n(15)*n(18)...
-k129*n(18)*n(33);
%Chemin N2+:
dndt(19)= k40*n(7)*n(25)-k30*n(4)*n(19)-k76*n(1)*n(19)...
-k82*n(4)*n(19)-k91*n(7)*n(19)...
-k95*n(15)*n(19)-k99*n(19)*n(24)-k100*n(19)*n(20);
%Chemin CO:
dndt(20)= +k5*n(2)*n(15)+k31*n(4)*n(14)...
+k49*n(9)*n(17)+k50*n(11)*n(15)+k54*n(15)*n(25)...
+k75*n(1)*n(21)+k83*n(4)*n(21)...
+k92*n(9)*n(21)+k96*n(15)*n(21)+k102*n(22)*n(21)...
+k139*n(1)*n(6)+k140*n(3)*n(4)-k13*n(1)*n(20)...
-k88*n(8)*n(20)-k100*n(19)*n(20)-k101*n(20)*n(25)...
-k130*n(20)*n(33)-k146*n(6)*n(20);
%Chemin CO+:
dndt(21)= k15*n(5)*n(9)+k33*n(4)*n(11)...
+k49*n(9)*n(17)+k50*n(11)*n(15)+k88*n(8)*n(20)...
+k100*n(19)*n(20)+k101*n(20)*n(25)-k75*n(1)*n(21)...
-k83*n(4)*n(21)-k92*n(9)*n(21)...
-k96*n(15)*n(21)-k102*n(22)*n(21);
%Chemin NO:
dndt(22)= k22*2*n(4)*n(27)+k23*n(4)*n(18)...
+k34*n(8)*n(15)+k35*n(7)*n(15)+k106*n(3)*n(23)...
+k114*n(14)*n(23)+k115*n(12)*n(23)+k116*n(16)*n(23)...
+k147*n(6)*n(7)-k10*n(1)*n(22)-k14*n(3)*n(22)...
-k52*n(15)*n(22)-k72*n(2)*n(22)-k90*n(8)*n(22)...
-k94*n(11)*n(22)-k98*n(17)*n(22)-k102*n(22)*n(21)...
-k103*n(22)*n(25)-k131*n(22)*n(33);
%Chemin NO+:
dndt(23)= k6*n(2)*n(27)+k16*n(5)*n(24)+k17*n(5)*n(29)...
+k18*n(5)*n(18)+k30*n(4)*n(19)+k36*n(7)*n(17)...
+k54*n(15)*n(25)+k72*n(2)*n(22)+k90*n(8)*n(22)...
+k94*n(11)*n(22)+k98*n(17)*n(22)+k102*n(22)*n(21)...
+k103*n(22)*n(25)-k106*n(3)*n(23)-k114*n(14)*n(23)...
-k115*n(12)*n(23)-k116*n(16)*n(23);
%Chemin CN:
dndt(24)= +k6*n(2)*n(27)+k10*n(1)*n(22)...
+k42*n(7)*n(14)+k45*n(7)*n(11)...
+k73*n(1)*n(25)+k93*n(9)*n(25)...
+k101*n(20)*n(25)+k103*n(22)*n(25)...
+k112*n(8)*n(26)+k142*n(3)*n(7)-k16*n(5)*n(24)...
-k85*n(6)*n(24)-k89*n(8)*n(24)-k99*n(19)*n(24);
%Chemin CN+
dndt(25)= +k89*n(8)*n(24)+k99*n(19)*n(24)...
-k40*n(7)*n(25)-k54*n(15)*n(25)...
-k73*n(1)*n(25)-k93*n(9)*n(25)...
-k101*n(20)*n(25)-k103*n(22)*n(25);
%Chemin CN-
dndt(26)= k14*n(3)*n(22)+k85*n(6)*n(24)-k112*n(8)*n(26);
%Chemin N2O:
dndt(27)= +k53*n(15)*n(18)...
-k6*n(2)*n(27)-k21*n(4)*n(27)...
-k22*n(4)*n(27)-k80*n(5)*n(27);
%Chemin N2O+:
dndt(28)= k80*n(5)*n(27);
%Chemin NO2:
dndt(29)= k52*n(15)*n(22)-k17*n(5)*n(29)...
-k97*n(17)*n(29);
%Chemin NO2+
dndt(30)= k97*n(17)*n(29);
%Chemin CO2:
dndt(31)= k141*n(3)*n(15)+k146*n(6)*n(20);
%Chemin e:
dndt(32)= k118*n(1)*n(33)+k119*n(3)*n(33)+k120*n(6)*n(33)...
+k121*n(12)*n(33)+k123*n(12)*n(33)+k125*n(14)*n(33)...
+k127*n(16)*n(33)+k136*n(1)*n(3)...
+k139*n(1)*n(6)+k140*n(3)*n(4)...
+k141*n(3)*n(15)+k142*n(3)*n(7)+k143*n(4)*n(6)...
+k146*n(6)*n(20)+k147*n(6)*n(7)...
+k150*n(9)*n(32)+k153*n(10)*n(32)...
-k1*n(2)*n(32)-k2*n(5)*n(32)-k3*n(8)*n(32)...
-k133*n(4)*n(32)-k150*n(9)*n(32)...
-k153*n(10)*n(32);
%Chemin hv:
dndt(33)= -k118*n(1)*n(33)-k119*n(3)*n(33)-k120*n(6)*n(33)...
-k121*n(9)*n(33)-k122*n(11)*n(33)-k123*n(12)*n(33)...
-k124*n(13)*n(33)-k125*n(14)*n(33)-k126*n(15)*n(33)...
-k127*n(16)*n(33)-k128*n(17)*n(33)-k129*n(18)*n(33)...
-k130*n(20)*n(33)-k131*n(22)*n(33)+k1*n(2)*n(32)...
+k2*n(5)*n(32)+k3*n(8)*n(32)+k61*n(2)*n(1)...
+k68*n(1)*n(1)+k133*n(4)*n(32);
end
Not enough input arguments.
Error in imene2022>ODE (line 129)
dndt(1)= k1*n(2)*n(32)+k15*n(5)*n(9)+k16*n(5)*n(24)...
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in imene2022 (line 124)
[t,n]=ode45(@ODE,[0 1e-3],IC)

Accepted Answer

Torsten
Torsten on 29 May 2021
Edited: Torsten on 29 May 2021
[t,n] = ode45(@(t,n)ODE(t,n,k1,k2,...),[0 1e-3],IC);
Better to write an array for k with 155 entries (k(1),k(2),...) than to define 155 constants named k1,k2,...
  1 Comment
Imene Yed
Imene Yed on 29 May 2021
thank you so much sir!!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by