O. Pannekoucke$^{1,2,3}$

$^1$ INPT-ENM, Toulouse, France

$^2$ CNRM, Université de Toulouse, Météo-France, CNRS, Toulouse, France

$^3$ CERFACS, Toulouse, France

(olivier.pannekoucke@meteo.fr)

**Abstract**

This notebook illustrates the use of sympkf to build and handle the PKF dynamics associated with the transport of two chemical species over a 1D domain, and in the case of a periodic chemical reaction. Hence, the dynamics reads as 
$$\left\{\begin{array}{c}
\partial_t A +u\partial_x A =B\\
\partial_t B +u\partial_x B =-A
\end{array}\right.$$
where $A$ and $B$ are functions of $t,x$, and $u(x)$ is a stationnary wind.

Thanks to the splitting strategy, the PKF is first applied in 0D on the periodic reaction, than on the full dynamics.

# Definition of the 1D multivariate dynamics


```python
import sympy
sympy.init_printing() 
```

**Definition of the dynamics from sympy tools**


```python
from sympy import Function, Derivative, Eq, symbols
from sympkf import SymbolicPKF, t
```


```python
x = symbols('x')
u = Function('u')(x)
A = Function('A')(t,x)
B = Function('B')(t,x)
```

# 0D periodic chemical reaction


```python
# definition of the dynamics
dynamics = [Eq(Derivative(A,t), B), Eq(Derivative(B,t),-A)]
dynamics
```


```python
pkf_dynamics = SymbolicPKF(dynamics)
```


```python
for equation in pkf_dynamics.in_metric:    
    #display(equation.subs(pkf_dynamics.internal_closure)) 
    display(equation)
```

# 1D transport of a periodic chemical reaction


```python
# Definition of the dynamics
dynamics = [Eq(Derivative(A,t),-u*Derivative(A,x)+ B), Eq(Derivative(B,t), -u*Derivative(B,x)-A)]
dynamics
```


```python
pkf_dynamics = SymbolicPKF(dynamics)
```


```python
for equation in pkf_dynamics.in_metric:    
    #display(equation.subs(pkf_dynamics.internal_closure)) 
    display(equation)
```


```python
for equation in pkf_dynamics.in_metric:    
    display(equation.subs(pkf_dynamics.internal_closure))     
```


```python
for equation in pkf_dynamics.in_aspect:    display(equation)
```

7efd3865b660af339d8d1d4f2a3d22bb1d275495
ipynb
Jupyter Notebook
example/PKF on 1D chemical transport model.ipynb
opannekoucke/sympkf
914dbc8127f16d28b1fe2f5afe2bc0864d53d644
CECILL-B
example/PKF on 1D chemical transport model.ipynb
opannekoucke/sympkf
914dbc8127f16d28b1fe2f5afe2bc0864d53d644
CECILL-B
example/PKF on 1D chemical transport model.ipynb
opannekoucke/sympkf
914dbc8127f16d28b1fe2f5afe2bc0864d53d644
CECILL-B
Qwen/Qwen-72B
1. YES
2. YES