pheromone_dispersion.advection_operator module

class pheromone_dispersion.advection_operator.Advection(*args: Any, **kwargs: Any)[source]

Bases: LinearOperator

Class containing the advection term linear operator \(A:c\mapsto \nabla\cdot(\vec{u}c)~\forall (x,y)\in\Omega~\forall t\in]0;T]\) with the related boundary condition \(\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]\).

The implementation of this linear operator is a subclass of the LinearOperator class.

U

The wind field \(\vec{u}(x,y,t)\).

Type:

Velocity

msh

The geometry of the domain.

Type:

MeshRect2D

minus_U

The opposite sign wind field \(-\vec{u}(x,y,t)\).

Type:

Velocity

shape

Shape of the matrix of the linear operator. The shape is (msh.y.size * msh.x.size, msh.y.size * msh.x.size)

Type:

tuple of int

dtype

Data type of the elements of the matrix of the linear operator. The type is float64

Type:

dtype

__init__(U, msh)[source]

Constructor method

Parameters:
  • U (Velocity) – The wind field \(\vec{u}(x,y,t)\).

  • msh (MeshRect2D) – The geometry of the domain.

_matvec(x_out)[source]

Compute the image (matrix-vector product) of \(A:c\mapsto \nabla\cdot(\vec{u}c)\) with the related boundary condition for a given concentration map \(c\) at the current time.

Parameters:

x_out (ndarray) – The map of concentration of pheromones \(c(x,y)\) at a given time \(t\) raveled into a vector.

Returns:

Array containing the image \(\nabla\cdot(\vec{u}c)\).

Return type:

ndarray

Notes

The input \(c\) has to be raveled into a (msh.y.size * msh.x.size,)-shape array to match the format of the LinearOperator class. The same way, the ouput can be reshape into a (msh.y.size, msh.x.size)-shape array to get the map \(Ac(x,y)\) at the current time \(t\)

_rmatvec(x_out)[source]

Compute the image (matrix-vector product) of \(A^*:c^*\mapsto - \nabla\cdot(\vec{u}c^*)+(\nabla.\vec{u})c^*\) with the related boundary condition for the map of a given element of the adjoint state space at the current time.

Parameters:

x_out (ndarray) – The map of an element of the adjoint state space \(c^*(x,y)\) at a given time \(t\) raveled into a vector.

Returns:

Array containing the image \(- \nabla\cdot(\vec{u}c^*)+(\nabla.\vec{u})c^*\).

Return type:

ndarray

Notes

The input \(c^*\) has to be raveled into a (msh.y.size * msh.x.size,)-shape array to match the format of the LinearOperator class. The same way, the ouput can be reshape into a (msh.y.size, msh.x.size)-shape array to get the map \(A^*c^*(x,y)\) at the current time \(t\).

at_current_time(tc)[source]

Update the attributes U and minus_U at a given time.

Parameters:

tc (float or integer) – The current time.

Notes

Updates the wind fields U and minus_U and their own attributes using the method at_current_time() of the class Velocity.

pheromone_dispersion.advection_operator.sum_advection_flux_given_U(U, x, msh)[source]

Compute at each cells the sum of the flux of an advection term \(A:c\mapsto \nabla\cdot(\vec{u}c)~\forall (x,y)\in\Omega~\forall t\in]0;T]\) with the related boundary condition \(\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]\) for a given velocity field \(\vec{u}\) at the current time.

Parameters:
  • U (Velocity) – The wind field \(\vec{u}(x,y,t)\).

  • x (ndarray) – The concentration of pheromones map \(c(x,y)\) at the current time \(t\) raveled into a vector.

  • msh (MeshRect2D) – The geometry of the domain.

Returns:

the sum of the flux at each cells at the current time.

Return type:

ndarray