2.7. drrc.spatially_extended_systems module
Solver for spatially extended systems.
Code author: Luk Fleddermann
- class LocalModel(Pardict)[source]
Bases:
object
Local Model of Exitation.
The init function creates the environment for the different models of the electric excitation, i.e. it sets parameters for differential equation and a propper Grid-size (Physical and numerical) for the animation.
- Parameters:
Pardict – Parameterfile
- fitzhugh_nagumo_local(vars)[source]
The local FitzHugh-Nagumo model follows
\[\begin{split}\partial_t u(x,y,t) &= au(u-b)(1-u)-w\,,\\ \partial_t w(x,y,t) &= -\varepsilon(u-w)\,,\end{split}\]which is extended to the spatially extended FitzHugh-Nagumo model by adding a diffusion term to the u variable.
- Parameters:
vars (np.ndarray) – excitation of variables
[u,w] = [vars[0], vars[1]]
- Returns:
change in excitation of u and w following the fitz_nagumo model. If
LocalModel
is of wrong type, returns -1.- Return type:
np.ndarray
Notes
The class needs to be initialized, with
model='fitzhugh_nagumo
, for the function to work.
- aliev_panfilov_local(vars)[source]
The local Aliev-Panfilov model follows
\[\begin{split}\partial_t u(x,y,t) &= ku(u-a)(1-u)-uw\,,\\ \partial_t w(x,y,t) &= \left(\varepsilon+\frac{\mu_1 w}{\mu_2 +u}\right)\cdot(-w-ku(u-b-1))\,,\end{split}\]which is extended to the spatially extended Aliev-Panfilov model by adding a diffusion term to the u variable.
- Parameters:
vars (np.ndarray) – excitation of variables
- Returns:
change in excitation of u and w following the fitz_nagumo model. If class.model is of wrong type, returns -1.
- Return type:
np.ndarray
Notes
The class needs to be initialized, with
model='aliev_panfilov
, for the function to work.
- class Diffusion(Pardict)[source]
Bases:
object
Diffusion model, different accuracy (5 point/ 9 point stencil). May be extended to other methods of implementing diffusion.
- Parameters:
- apply_5stencil(u)[source]
- Parameters:
u – excitation of grid.
- Returns:
Two dimensional array of discrete Laplacian of the excitation of u, using the five-point stencil.
- Return type:
laplacian
Notes
The outer layer of u needs to be a ghost layer s.t. no flux boundary conditions are inforced. Without ghost layer periodic boundary conditions are used.
- apply_9stencil(u)[source]
- Parameters:
u – excitation of grid.
- Returns:
Two dimensional array of discrete Laplacian of the excitation of u, using the five-point stencil.
- Return type:
laplacian
Notes
The outer layer of u needs to be a ghost layer s.t. no flux boundary conditions are inforced. Without ghost layer periodic boundary conditions are used.
- class BoundaryCondition(Pardict)[source]
Bases:
object
Different Typs of Boundary conditions. So far only ‘no_flux’ has a proper meaning.
The init function creates the environment for the different models of the electric excitation, i.e. it sets parameters for differential equation and a proper Grid-size (Physical and numerical) for the animation.
- Parameters:
- no_flux(vars, itterator=None)[source]
- Parameters:
u – excitation of grid.
- Returns:
excitation of grid with no flux boundary condition enforced for 5-point stencil.
- Return type:
u
Notes
The outer layer is turned in a ghost layer with no physical meaning. The corners of the grid (i.e. u[0,0]) are unimportant for the calculations of the five point stencil, hence orientation of the four executed steps does not matter.
- class IntegrationMethods[source]
Bases:
object
Methods of temporal integraion of class ‘LocalModel’ coupled by class ‘Diffusion’.
- static exp_euler_itt(dif: Diffusion, lm: LocalModel, bc: BoundaryCondition, Pardict: dict, seed: int | None = None)[source]
Iterative application of explicit Euler method.
- Parameters:
dif – Diffusion Model
lm – Local Model
bc – Boundary Conditions
Pardict – Parameter File
seed – seed of random initial condition
- Returns:
Last time step of integration
- Return type:
vars
- static exp_euler_itt_with_save(dif: Diffusion, lm: LocalModel, bc: BoundaryCondition, Pardict: dict, vars0: ndarray | None = None, seed: int | None = None, prog_feetback: bool = True)[source]
Iterative application of explicit euler method.
- Parameters:
dif – Diffusion Model
lm – Local Model
bc – Boundary Conditions
Pardict – Parameter File
vars0 – Initial Condition
seed – seed of random initial condition
- Returns:
Last time step of integration
- Return type:
vars
- static _get_initial(Pardict: dict, vars0: ndarray | None = None, seed: int | None = None) ndarray [source]
Creates initial condition (array) from string in dictionary.
- Parameters:
- Returns:
initial condition
- Return type:
np.ndarray
Notes
Pardict needs to have keys ‘LocalModel’, ‘SpatialParameter’ and ‘initial_condition’