ODE45 Chemical kinetics
Show older comments
I'm using an ode45 to simulate production of H+ into an environment with time, but H+ just shows up as a horizontal line with time instead of increasing. If I plug in 0 for initial H (Hi) then I don't get a plot at all. Does anyone have any insight as to why H, or y(3) isn't changing over time? I posted my code below
clear all
global p00
tic
k1 = 8e13; % oxidation of Fe in min^-1*atm^-1*mol^-2*liter^2, Millero 1985 ph>5
k2 = 7% Fly ash MA As describe the experimental leaching kinetics data pseudo second order
%oxidation of Fe2+
Fei = 7; % initial [Fe]
O2i = 7; % intial [O2]
Hi = 1e-5 % initial [H] going to be generated
FAi = 1; % initial [FA]
Asi = 1
p00 = [k1;k2];
y0(1) = Fei;
y0(2) = O2i;
y0(3) = Hi;
y0(4) = FAi;
y0(5) = Asi
dt = 1;
t = (0:dt:1500);
tspan = [0 max(t)];
[T,y] = ode45('RK4odes',tspan,y0);
toc
plot(T,y)
legend('Fe','O2','H','FA','As')
xlabel('time-min')
ylabel('Concentration-M')
function RK4odes1= RK4odes(~,y)
global p00
k1 = p00(1);
k2 = p00(2);
a = 1 %stoichiometric coefficient defining # of moles As reacting with 1 mole of fly ash
kw = 1e-14
RK4odes1(1,1) = -k1.*y(1).*y(2).*(kw./y(3)).^2 %dFe/dt= -k1*Fe*O2*(kw/H)^2
RK4odes1(2,1) = -0.25.*k1.*y(1).*y(2).*(kw./y(3)).^2 %dO/dt = -1/4*k1*(Fe)*(O2)*(kw/H)^2
RK4odes1(3,1) = 2.*k1.*y(1).*y(2).*(kw./y(3)).^2- k2.*(y(4).^0).*y(3)%dH+/dt = 8/4*k1*(Fe)*(O2)*(kw/H)^2-k2*(Flyash-FA)^0*(H)
RK4odes1(4,1) = -k2.*(y(4).^0).*y(3)%dFA/dt = -k(FA)^0*(H+)
RK4odes1(5,1) = (1./a).*k2.*(y(4).^0).*y(3) %dAs/dt=1/a*k2*(FA)*(H+)
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!