# 8.7. OpenCS Examples¶

 OpenCS Example DAE 1 The chemical kinetics problem with 6 non-linear differential equations. OpenCS Example DAE 2 A simple heat conduction problem (re-implementation of the model in Tutorial 1). OpenCS Example DAE 3 Auto-catalytic chemical reaction with oscillations (the Brusselator PDE). OpenCS Example ODE 1 The Roberts chemical kinetics problem with 3 rate equations. OpenCS Example ODE 2 A simple advection-diffusion in 2-D. OpenCS Example ODE 3 2-species diurnal kinetics advection-diffusion PDE system in 2D.

## 8.7.1. OpenCS Example DAE 1¶

Reimplementation of IDAS idasAkzoNob_dns example. The chemical kinetics problem with 6 non-linear diff. equations:

dy1_dt + 2*r1 - r2 + r3 + r4 = 0
dy2_dt + 0.5*r1 + r4 + 0.5*r5 - Fin = 0
dy3_dt - r1 + r2 - r3 = 0
dy4_dt + r2 - r3 + 2*r4 = 0
dy5_dt - r2 + r3 - r5 = 0
Ks*y1*y4 - y6 = 0


where:

r1  = k1 * pow(y1,4) * sqrt(y2)
r2  = k2 * y3 * y4
r3  = k2/K * y1 * y5
r4  = k3 * y1 * y4 * y4
r5  = k4 * y6 * y6 * sqrt(y2)
Fin = klA * (pCO2/H - y2)


The system is stiff. The original results are in tutorial_opencs_dae_1.csv file.

Files

 Source code tutorial_opencs_dae_1.py Auxiliary functions tutorial_opencs_aux.py DAE Tools model tutorial_opencs_daetools_1.py The original results tutorial_opencs_dae_1.csv

## 8.7.2. OpenCS Example DAE 2¶

Reimplementation of DAE Tools tutorial1.py example. A simple heat conduction problem: conduction through a very thin, rectangular copper plate:

rho * cp * dT(x,y)/dt = k * [d2T(x,y)/dx2 + d2T(x,y)/dy2];  x in (0, Lx), y in (0, Ly)


Two-dimensional Cartesian grid (x,y) of 20 x 20 elements. The original results are in tutorial_opencs_dae_2.csv file.

Files

 Source code tutorial_opencs_dae_2.py Auxiliary functions tutorial_opencs_aux.py The original results tutorial_opencs_dae_2.csv

## 8.7.3. OpenCS Example DAE 3¶

Reimplementation of IDAS idasBruss_kry_bbd_p example. The PDE system is a two-species time-dependent PDE known as Brusselator PDE and models a chemically reacting system:

du/dt = eps1(d2u/dx2  + d2u/dy2) + u^2 v - (B+1)u + A
dv/dt = eps2(d2v/dx2  + d2v/dy2) - u^2 v + Bu


Boundary conditions: Homogenous Neumann. Initial Conditions:

u(x,y,t0) = u0(x,y) =  1  - 0.5*cos(pi*y/L)
v(x,y,t0) = v0(x,y) = 3.5 - 2.5*cos(pi*x/L)


The PDEs are discretized by central differencing on a uniform (Nx, Ny) grid. The model is described in:

• R. Serban and A. C. Hindmarsh. CVODES, the sensitivity-enabled ODE solver in SUNDIALS. In Proceedings of the 5th International Conference on Multibody Systems, Nonlinear Dynamics and Control, Long Beach, CA, 2005. ASME.
• M. R. Wittman. Testing of PVODE, a Parallel ODE Solver. Technical Report UCRL-ID-125562, LLNL, August 1996.

The original results are in tutorial_opencs_dae_3.csv file.

Files

 Source code tutorial_opencs_dae_3.py Auxiliary functions tutorial_opencs_aux.py The original results tutorial_opencs_dae_3.csv

## 8.7.4. OpenCS Example ODE 1¶

Reimplementation of CVodes cvsRoberts_dns example. The Roberts chemical kinetics problem with 3 rate equations:

dy1/dt = -0.04*y1 + 1.e4*y2*y3
dy2/dt =  0.04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
dy3/dt =  3.e7*(y2)^2


The problem is simulated for 4000 s, with the initial conditions:

y1 = 1.0
y2 = y3 = 0


The problem is stiff. The original results are in tutorial_opencs_ode_1.csv file.

Files

 Source code tutorial_opencs_ode_1.py Auxiliary functions tutorial_opencs_aux.py The original results tutorial_opencs_ode_1.csv

## 8.7.5. OpenCS Example ODE 2¶

Reimplementation of CVodes cvsAdvDiff_bnd example. The problem is simple advection-diffusion in 2-D:

du/dt = d2u/dx2 + 0.5 du/dx + d2u/dy2


on the rectangle:

0 <= x <= 2
0 <= y <= 1


and simulated for 1 s. Homogeneous Dirichlet boundary conditions are imposed, with the initial conditions:

u(x,y,t=0) = x(2-x)y(1-y)exp(5xy)


The PDE is discretized on a uniform Nx+2 by Ny+2 grid with central differencing. The boundary points are eliminated leaving an ODE system of size Nx*Ny. The original results are in tutorial_opencs_ode_2.csv file.

Files

 Source code tutorial_opencs_ode_2.py Auxiliary functions tutorial_opencs_aux.py The original results tutorial_opencs_ode_2.csv

## 8.7.6. OpenCS Example ODE 3¶

Reimplementation of CVodes cvsDiurnal_kry example. 2-species diurnal kinetics advection-diffusion PDE system in 2D:

dc(i)/dt = Kh*(d/dx)^2 c(i) + V*dc(i)/dx + (d/dy)(Kv(y)*dc(i)/dy) + Ri(c1,c2,t), i = 1,2


where:

R1(c1,c2,t) = -q1*c1*c3 - q2*c1*c2 + 2*q3(t)*c3 + q4(t)*c2
R2(c1,c2,t) =  q1*c1*c3 - q2*c1*c2 - q4(t)*c2
Kv(y) = Kv0*exp(y/5)


Kh, V, Kv0, q1, q2, and c3 are constants, and q3(t) and q4(t) vary diurnally. The problem is posed on the square:

0 <= x <= 20 (km)
30 <= y <= 50 (km)


with homogeneous Neumann boundary conditions, and integrated for 86400 sec (1 day). The PDE system is discretised using the central differences on a uniform 10 x 10 mesh. The original results are in tutorial_opencs_ode_3.csv file.

Files

 Source code tutorial_opencs_ode_3.py Auxiliary functions tutorial_opencs_aux.py The original results tutorial_opencs_ode_3.csv