pheromone_dispersion.convection_diffusion_2D module
- class pheromone_dispersion.convection_diffusion_2D.DiffusionConvectionReaction2DEquation(U, K, coeff_depot, S, msh, time_discretization='semi-implicit', tol_inversion=1e-14)[source]
Bases:
objectClass containing the pheromone propagation model given by the 2D diffusion-convection-reaction PDE:
\[\frac{\partial c}{\partial t}-\nabla\cdot(\mathbf{K}\nabla c)+\nabla\cdot(\vec{u}c)+\tau_{loss}c=s ~\forall (x,y)\in\Omega~\forall t\in]0;T]\]with the initial and boundary conditions:
a null initial condition \(c(x,y,t=0)=0~\forall (x,y)\in\Omega\),
a null diffusive flux \(\mathbf{K}\nabla c\cdot\vec{n}=0~\forall (x,y)\in\partial\Omega\),
null convective influx \(\vec{u}c\cdot\vec{n}=0~\forall (x,y)\in\partial\Omega\cap \{(x,y)|\vec{u}(x,y,t)\cdot\vec{n}<0\}~\forall t\in]0;T]\) with \(\vec{n}\) the outgoing normal vector,
and its solvers.
- msh
The geometry of the domain.
- Type:
- A
The advection linear operator \(A:c\mapsto \nabla\cdot(\vec{u}c)~\forall (x,y)\in\Omega~\forall t\in]0;T]\) with \(\vec{u}c\cdot\vec{n}=0~\forall (x,y)\in\partial\Omega\cap \{(x,y)|\vec{u}(x,y,t)\cdot\vec{n}<0\}~\forall t\in]0;T]\).
- Type:
- D
The diffusion linear operator \(D:c\mapsto -\nabla\cdot(\mathbf{K}\nabla c)~\forall (x,y)\in\Omega~\forall t\in]0;T]\) with \(\mathbf{K}\nabla c\cdot\vec{n}=0~\forall (x,y)\in\partial\Omega\).
- Type:
- R
The reaction linear operator \(R:c\mapsto \tau_{loss}c~\forall (x,y)\in\Omega~\forall t\in]0;T]\).
- Type:
- implemented_solver_type
The list of keywords of the implemented types of time discretization. The implemented types of time discretization are: [‘implicit’, ‘semi-implicit’, ‘semi-implicit with matrix inversion’, ‘implicit with stationnary matrix inversion’]
- Type:
listofstr
- time_discretization
The keyword identifying the type of time discretization.
- Type:
str
- tol_inversion
Tolerance for the inversion estimation algorithm called at each time step.
- Type:
float
- inv_matrix_implicit_part
Inverse matrix of the implicit part matrix of the time discretization. Initialized to None.
- Type:
ndarrayorNone
- __init__(U, K, coeff_depot, S, msh, time_discretization='semi-implicit', tol_inversion=1e-14)[source]
Constructor method
- Parameters:
U (
Velocity) – The wind field \(\vec{u}(x,y,t)\).K (
DiffusionTensor) – The diffusion tensor \(\mathbf{K}(x,y,t)\).coeff_depot (
ndarray) – The deposition coefficient \(\tau_{loss}(x,y)\).S (
Source) – The source term \(s(x,y,t)\).msh (
MeshRect2D) – The geometry of the domain.time_discretization (
str, default:'semi-implicit') – The keyword identifying the type of time discretization.tol_inversion (
float, optional, default:1e-14) – Tolerance for the inversion estimation algorithm called at each time step.
- Raises:
ValueError – if the type of discretization is not implemented, i.e. if
time_discretizationis not inimplemented_solver_type
- at_current_time(tc)[source]
Update the attributes
S,DandAat a given time.- Parameters:
tc (
floatorinteger) – The current time.
Notes
Updates the attributes
S,DandAand their own attributes using the methodat_current_time()of resp. the classSource, the classDiffusionand the classAdvection.
- init_inverse_matrix(path_to_matrix=None, matrix_file_name=None)[source]
Initialize the attribute
inv_matrix_implicit_part. If the inverse matrix of the implicit part matrix of the time discretization has never been computed, it is computed and stored. Otherwise, it loads the previously computed inverse matrix.- Parameters:
path_to_matrix (
str, optional, default:None) – Path where to save or load the inverse matrix. If not provided, set to ‘./data’.matrix_file_name (
str, optional, default:None) – Name of the file where the matrix stored or will be saved. If not provided, set to ‘inv_matrix_**_scheme’ with ** either ‘implicit’ or ‘semi_implicit’ depending on the time discretization.
Notes
This method is usefull only if
time_discretizationis either ‘semi-implicit with matrix inversion’ or ‘implicit with stationnary matrix inversion’. Otherwise, the linear system to solve at each time steps is solved using conjugate gradient or GMRES algorithm, and the attributeinv_matrix_implicit_partis not used.
- solver(save_flag=False, path_save='./save/', display_flag=True, store_rate=1)[source]
Compute the concentration \(c(x,y,t)\) by solving the pheromone propagation model on the whole time window.
- Parameters:
save_flag (
bool, optional, default:False) – If True, the resulting matrix of the concentration is saved.path_save (
str, optional, default:'./save/') – Path of the directory in which the outputs are saved.display_flag (
bool, default:True) – If True, print the evolution of the solver through the time iterations.store_rate (
int, optional, default:1) – Time frequency to which the concentration map is stored.
- Returns:
- solver_est_at_obs_times(obs, display_flag=True)[source]
Compute the concentration \(c(x,y,t)\) by solving the pheromone propagation model on the whole time window and store the results at the times and positions required to estimate the observed variable in the attribute
c_estof the given object of the classObs.- Parameters:
obs (
Obs) – Object containing all the features related to the observations and estimation of the observed variables and in which \(c(x,y,t)\) is stored at the times and positions required to estimate the observed variable.display_flag (
bool, default:True) – If True, print the evolution of the solver through the time iterations.