Proper way to write ode45
Ältere Kommentare anzeigen
I am having some problems with my results using ode 45 and i dont know if i am using the right way to run the function.I send to you a few lines of the functions and the scripts so that you can get the general idea.I am using so many inputs to the function to avoid using global and if you know any other way to make it run faster i would be very interested in hearing it.
so the function is
- function [ dydt ] = adm1_no_w5 (t,y,Ssu_in,Saa_in,Sfa_in,Sva_in,Sbu_in,Spro_in,Sac_in,Sh2_in,Sch4_in,Sic_in,Sin_in,Si_in,Xc_in,Xch_in,Xpr_in,Xli_in,Xsu_in,Xaa_in,Xfa_in,Xc4_in,Xpro_in,Xac_in,Xh2_in,Xi_in,Scation_in,Sanion_in,kLa,T_base,T_op,Ka_va,Ka_bu,Ka_pro,Ka_ac,Ka_co2,Ka_in,Ka_Bva,Ka_Bbu,Ka_Bpro,Ka_Bac,Ka_Bco2,Ka_Bin,Patm,kp,KH_co2,KH_ch4,KH_h2,Kh_h20_base,Vgas,R,Kw,Vliq,qin,Kdis,Khyd_ch,Khyd_pr,Khyd_li,Kdec,pHul_aa,pHll_aa,Km_su,Ks_su,Ysu,Km_aa,Ks_aa,Yaa,Km_fa,Ks_fa,Yfa,Klh2_fa,Km_c4,Ks_c4,Yc4,Klh2_c4,Km_pro,Ks_pro,Ypro,Klh2_pro,Km_ac,Ks_ac,Yac,pHul_ac,pHll_ac,Klnh3,Km_h2,Ks_h2,Yh2,pHul_h2,pHll_h2,Ks_in,fsi_xc,fxi_xc,fch_xc,fpr_xc,fli_xc,Nxc,ffa_li,fh2_su,fbu_su,fpro_su,fac_su,fh2_aa,Naa,fva_aa,fbu_aa,fpro_aa,fac_aa,Ni,Nbac,C_xc,C_si,C_ch,C_pr,C_li,C_xi,C_su,C_aa,C_fa,C_bu,C_pro,C_ac,C_bac,C_va,C_ch4)
dydt(1)=(((qin/Vliq)*(Ssu_in-y(1))+r2+(1-ffa_li)*r4)-r5);
dydt(2)=((qin/Vliq)*(Saa_in-y(2)))+r3-r6;
end
the general type is
𝑑𝑆/dt= 𝑞𝑖𝑛/Vliq ∗(𝑆in −𝑆 )+Σr
And the way i am writting the ode solver is
- options = odeset('RelTol',1e-2,'AbsTol',1e-2);
tspan=0.000001:0.1:5;
[t,y]=ode45(@(t,y) adm1_no_w5 (t,y,Ssu_in,Saa_in,Sfa_in,Sva_in,Sbu_in,Spro_in,Sac_in,Sh2_in,Sch4_in,Sic_in,Sin_in,Si_in,Xc_in,Xch_in,Xpr_in,Xli_in,Xsu_in,Xaa_in,Xfa_in,Xc4_in,Xpro_in,Xac_in,Xh2_in,Xi_in,Scation_in,Sanion_in,kLa,T_base,T_op,Ka_va,Ka_bu,Ka_pro,Ka_ac,Ka_co2,Ka_in,Ka_Bva,Ka_Bbu,Ka_Bpro,Ka_Bac,Ka_Bco2,Ka_Bin,Patm,kp,KH_co2,KH_ch4,KH_h2,Kh_h20_base,Vgas,R,Kw,Vliq,qin,Kdis,Khyd_ch,Khyd_pr,Khyd_li,Kdec,pHul_aa,pHll_aa,Km_su,Ks_su,Ysu,Km_aa,Ks_aa,Yaa,Km_fa,Ks_fa,Yfa,Klh2_fa,Km_c4,Ks_c4,Yc4,Klh2_c4,Km_pro,Ks_pro,Ypro,Klh2_pro,Km_ac,Ks_ac,Yac,pHul_ac,pHll_ac,Klnh3,Km_h2,Ks_h2,Yh2,pHul_h2,pHll_h2,Ks_in,fsi_xc,fxi_xc,fch_xc,fpr_xc,fli_xc,Nxc,ffa_li,fh2_su,fbu_su,fpro_su,fac_su,fh2_aa,Naa,fva_aa,fbu_aa,fpro_aa,fac_aa,Ni,Nbac,C_xc,C_si,C_ch,C_pr,C_li,C_xi,C_su,C_aa,C_fa,C_bu,C_pro,C_ac,C_bac,C_va,C_ch4),tspan,y0,options);
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!