pheromone_dispersion.geom module

class pheromone_dispersion.geom.MeshRect2D(L_x, L_y, dx, dy, T_final, X_0=None)[source]

Bases: object

Class containing the geometry of a 2D rectangular domain \(\Omega = [x_0;x_0+L_x]\times [y_0;y_0+L_y]\) with a cartesian mesh with constant space steps \(\Delta x\) and \(\Delta y\), and a time window \([0;T]\) discretized with constant time step \(\Delta t\).

L_x

Length of the domain along the \(x\)-axis \(L_x\).

Type:

float

L_y

Length of the domain along the \(y\)-axis \(L_y\).

Type:

float

dx

Space step of the mesh along the \(x\)-axis \(\Delta x\).

Type:

float

dy

Space step of the mesh along the \(y\)-axis \(\Delta y\).

Type:

float

x

Array of the \(x\)-coordinates of the center of the cells of the mesh.

Type:

ndarray

y

Array of the \(y\)-coordinates of the center of the cells of the mesh.

Type:

ndarray

x_vertical_interface

Array of the \(x\)-coordinates of the vertical interfaces between the cells of the mesh.

Type:

ndarray

y_horizontal_interface

Array of the \(y\)-coordinates of the horizontal interfaces between the cells of the mesh.

Type:

ndarray

mass_cell

The volume of mesh cells \(\Delta x\times \Delta y\).

Type:

float

t

The current time \(t\) of the modelling, initialized to \(t=0s\).

Type:

float

T_final

The final time \(T\) of the modeling time window.

Type:

float

dt

The time step \(\Delta t\). Initialized to None and to be computed using the methods calc_dt_explicit_solver() or calc_dt_implicit_solver().

Type:

float

t_array

The time array. Initialized to None and to be computed from the attribute dt using the methods calc_dt_explicit_solver() or calc_dt_implicit_solver().

Type:

ndarray

X_0

Coordinates of the origin of the mesh \((x_0, y_0)\). By default set to \((x_0, y_0)=(0, 0)\).

Type:

tuple of float

__init__(L_x, L_y, dx, dy, T_final, X_0=None)[source]

Constructor method.

Parameters:
  • L_x (float) – Length of the domain along the \(x\)-axis \(L_x\).

  • L_y (float) – Length of the domain along the \(y\)-axis \(L_y\).

  • dx (float) – Space step of the mesh along the \(x\)-axis \(\Delta x\).

  • dy (float) – Space step of the mesh along the \(y\)-axis \(\Delta y\).

  • T_final (float) – The final time \(T\) of the modeling time window.

  • X_0 (tuple of float, default: None) – Coordinates of the origin of the mesh \((x_0, y_0)\). If None, set to \((x_0, y_0)=(0, 0)\).

calc_dt_explicit_solver(U, dt_max=0.1)[source]

Compute the time step \(\Delta t\) such as it satisfies the CFL condition \(\Delta t<\left(\frac{max(u)}{\Delta x}+\frac{max(v)}{\Delta y}\right)^{-1}\) for a given wind field \(\vec{u}=(u,v)\). To be used with an explicit or semi-implicit numerical scheme.

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

  • dt_max (float, optional, default: 0.1) – The maximal time step \(\Delta t_{max}\) imposing that \(\Delta t<\Delta t_{max}\) to ensure a certain accuracy

Notes

Compute a time step \(\Delta t\), store it in the attribute dt and compute the attribute t_array accordingly.

calc_dt_implicit_solver(dt)[source]

Store the provided time step \(\Delta t\) in the attribute dt and compute the attribute t_array accordingly. To be used with an implicit numerical scheme.

Parameters:

dt (float) – The provided time step \(\Delta t\).