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: object

Class 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:

MeshRect2D

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:

Advection

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:

Diffusion

R

The reaction linear operator \(R:c\mapsto \tau_{loss}c~\forall (x,y)\in\Omega~\forall t\in]0;T]\).

Type:

Reaction

ID

The identity operator \(Id:c\mapsto c~\forall (x,y)\in\Omega~\forall t\in]0;T]\).

Type:

Id

S

The source term \(s(x,y,t)\).

Type:

Source

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:

list of str

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:

ndarray or None

__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_discretization is not in implemented_solver_type

at_current_time(tc)[source]

Update the attributes S, D and A at a given time.

Parameters:

tc (float or integer) – The current time.

Notes

Updates the attributes S, D and A and their own attributes using the method at_current_time() of resp. the class Source, the class Diffusion and the class Advection.

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_discretization is 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 attribute inv_matrix_implicit_part is not used.

set_source(value, t=None)[source]

Update the attribute S with the provided new values.

Parameters:
  • value (ndarray) – The new values of S.

  • t (ndarray, optional, default: None) – The associated time array. None if the source is stationary.

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:

  • t_save (ndarray) – The array containing the times \(t\) at which the concentration maps are stored.

  • c_save (ndarray) – The concentration maps \(c(x,y)\) at several times \(t\).

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_est of the given object of the class Obs.

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.