I am quite new to Mathematica, please help me struggling out of this question.
I want to know how the HNO3 and HNO2 change in the system.
first, I put the kinetics of some reactions:
knitricprod = 6*10^8;
knitricconsumed = 1.46*10^10;
NO3radicalproduction = 2.271*10^-6;
HNO2production = 2.072*10^-5;
then,I wrote the equations:
NO3eqns = {NO3'[t] == (-knitricprod*proton[t]*NO3[t]) +
knitricconsumed*HNO3[t] - NO3radicalproduction, NO3[0] == 0};
HNO3eqns = {HNO3'[t] ==
knitricprod*proton[t]*NO3[t] + (-knitricconsumed*HNO3[t]) -
HNO2production, HNO3[0] == 0.2};
protoneqns = {proton'[t] == (-knitricprod*proton[t]*NO3[t]) +
knitricconsumed*HNO3[t], proton[0] == 0};
HNO2eqns = {HNO2'[t] == HNO2production, HNO2[0] == 0};
NO3radicaleqns = {NO3radical'[t] == NO3radicalproduction,
NO3radical[0] == 0};
Next,join them together:
eqns = Join[NO3eqns, HNO3eqns, protoneqns, HNO2eqns, NO3radicaleqns];
soln = NDSolve[
eqns, {NO3, HNO3, proton, HNO2, NO3radical}, {t, 0, 20000}];
BUT, a error came out. NDSolve::nderr: Error test failure at t == 5082.429032772312`; unable to continue.
The fowllowing is my remaining code:
NO3pfunc[t_] = NO3[t] //. soln;
HNO3pfunc[t_] = HNO3[t] //. soln;
protonpfunc[t_] = proton[t] //. soln;
HNO2pfunc[t_] = HNO2[t] //. soln;
NO3radicalpfunc[t_] = NO3radical[t] //. soln;
Plot[NO3pfunc[xs] // Evaluate, {xs, 0, 20000}, PlotRange -> All,
AxesLabel -> {"Time/s", "NO3 anion concentration/M"}]
Plot[HNO3pfunc[xs] // Evaluate, {xs, 0, 20000}, PlotRange -> All,
AxesLabel -> {"Time/s", "Nitric acid concentration/M"}]
Plot[protonpfunc[xs] // Evaluate, {xs, 0, 20000}, PlotRange -> All,
AxesLabel -> {"Time/s", "proton concentration/M"}]
Plot[HNO2pfunc[xs] // Evaluate, {xs, 0, 20000}, PlotRange -> All,
AxesLabel -> {"Time/s", "Nitrous acid concentration/M"}]
Plot[NO3radicalpfunc[xs] // Evaluate, {xs, 0, 20000},
PlotRange -> All,
AxesLabel -> {"Time/s", "NO3radical concentration/M"}]
knitricprod = 6*10^8;knitricconsumed = 146/100*10^10;NO3radicalproduction = 2271/1000*10^-6;HNO2production = 2072/1000*10^-5;and changed 0.2 to 2/10 in one of your equations so every decimal constant became an exact rational constant and thensoln = NDSolve[eqns, {NO3, HNO3, proton, HNO2, NO3radical}, {t, 0, 20000},WorkingPrecision->64,MaxSteps->10^6]and it completes without warnings or errors. Check that result VERY carefully to determine if it might be correct. – Bill Jul 23 '21 at 01:55MaxStepSize -> 400and see if it looks right. (Hint came from here and the step-size data produced byNO3["Grid"] /. First[soln] // Differences // Take[#, -10] &.) – Michael E2 Jul 23 '21 at 04:00