Skip to content

Commit 70ca3d0

Browse files
Update nonlinchem.jl
1 parent 9c47b27 commit 70ca3d0

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/ode/nonlinchem.jl

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,35 @@ function nonLinChem(dy,y,p,t)
44
dy[3] = (y[2])^2
55
end
66
y0 = [1.0;0.0;0.0]
7-
tspan = (0.0,20)
7+
tspan = (0.0,20.0)
88
nlc_analytic(u0,p,t) = [exp(-t);
99
(2sqrt(exp(-t))besselk(1,2sqrt(exp(-t)))-2besselk(1,2)/besseli(1,2)*sqrt(exp(-t))besseli(1,2sqrt(exp(-t))))/(2besselk(0,2sqrt(exp(-t)))+(2besselk(1,2)/besseli(1,2))besseli(0,2sqrt(exp(-t))));
1010
-exp(-t)+1+(-2sqrt(exp(-t))*besselk(1,2sqrt(exp(-t)))+sqrt(exp(-t))*besseli(1,2sqrt(exp(-t)))*2besselk(1,2)/besseli(1,2))/(2besselk(0,2sqrt(exp(-t)))+2besselk(1,2)/besseli(1,2)*besseli(0,2sqrt(exp(-t))))]
1111
nonLinChem_f = ODEFunction(nonLinChem,analytic = nlc_analytic)
1212

1313
"""
14-
TODO: Insert Problem Description here.
14+
Nonlinear system of reactions with an analytical solution
15+
16+
```math
17+
\frac{dy_1}{dt} = -y_1
18+
```
19+
20+
```math
21+
\frac{dy_2}{dt} = y_1 - y_2^2
22+
```
23+
24+
```math
25+
\frac{dy_3}{dt} = y_2^2
26+
```
27+
28+
with initial condition ``y=[1;0;0]`` on a time span of ``t \in (0,20)``
29+
30+
From
31+
32+
Liu, L. C., Tian, B., Xue, Y. S., Wang, M., & Liu, W. J. (2012). Analytic solution
33+
for a nonlinear chemistry system of ordinary differential equations. Nonlinear
34+
Dynamics, 68(1-2), 17-21.
35+
36+
The analytical solution is implemented, allowing easy testing of ODE solvers.
1537
"""
1638
prob_ode_nonlinchem = ODEProblem(nonLinChem,y0,tspan)

0 commit comments

Comments
 (0)