I'm looking to model the precipitation of a mineral through time at rate, r. As this mineral precipitates, it draws down the concentration of Fe(II) in solution, and this reduces the saturation state of the solution with respect to the mineral, slowing the rate of mineral precipitation.
cla;
clf;
%%
%variables and rate calculation
Fe(1)=0.01*0.26/1000; %mM, * activity coefficient, convert to M
Si=1.8/1000; %mM, convert to M
pH=8;
H=10^(-pH);
k=1.11*10^(-9);
b=1.81;
Ksp=4.68*10^(22);
IAP=(Fe^(3)*Si^(2))/H^(6);
logIAP=log10(IAP);
logKsp=log10(Ksp);
rate=k*exp(b*(logIAP-logKsp)); %mm Fe Kg-1 hour-1
%%
%Fe vs time
dt=0.01;
t=0:dt:10;
for ind=2:length(t)
Fe=Fe(1)-(k*exp(b*(logIAP-logKsp))/1000*t);
end
I eventually want a plot of Fe vs time. The above code doesn't work because Fe depends on logIAP, which depends on Fe from the previous timestep... I need Matlab to iteratively calculate the two for each time step.
Any help appreciated, thanks!