4.4.10 pde.pdes.reaction_diffusion module
Defines a PDE class implementing a reaction-diffusion system.
- class ReactionDiffusionPDE(variables, diffusivity, sources, *, bc=None, bc_ops=None, post_step_hook=None, user_funcs=None, consts=None, noise=0, rng=None)[source]
Bases:
PDEReaction-diffusion equation
The equation being solved reads
\[\partial_t c_i = D_i \partial_\alpha^2 c_i + s_i(\{c_j\}, t)\]where c_i are the concentration fields, \(D_i\) are the diffusivities, and \(s_i\) are sink/source terms that account for chemical reactions.
- Parameters:
variables (list of strings) – The names and order of the variables \(c_i\) in the system
diffusivity (
ndarray) – Diffusivities \(D_i\) of all species. A scalar sets the same diffusivity for all species.sources (list of str or dict of str) – Specifies the source terms \(s_i\) of each species. Must be a list with an entry for each variable. Alternatively, a dictionary may be used to only specify the source term of a few variables, while all others are assumed to not have any sources.
bc (BoundariesData | None) – General boundary conditions for all operators that do not have a specialized condition given in bc_ops. Boundary conditions are generally given as a dictionary with one condition for each axis side. For periodic axes, only periodic boundary conditions are allowed (indicated by ‘periodic’ and ‘anti-periodic’). For non-periodic axes, different boundary conditions can be specified for the lower and upper end (using specific identifiers, like x- and y+). For instance, Dirichlet conditions enforcing a value NUM (specified by {‘value’: NUM}) and Neumann conditions enforcing the value DERIV for the derivative in the normal direction (specified by {‘derivative’: DERIV}) are supported. Note that the special value ‘auto_periodic_neumann’ imposes periodic boundary conditions for periodic axis and a vanishing derivative otherwise. More information can be found in the boundaries documentation.
bc_ops (dict) – Special boundary conditions for specific operators. The keys in this dictionary specify where the boundary condition will be applied. The keys follow the format “VARIABLE:OPERATOR”, where VARIABLE specifies the expression in rhs where the boundary condition is applied to the operator specified by OPERATOR. For both identifiers, the wildcard symbol “*” denotes that all fields and operators are affected, respectively. For instance, the identifier “c:*” allows specifying a condition for all operators of the field named c.
post_step_hook (callable) – A function with signature (state_data, t) that will be called after every time step. The function must return state_data, which can be modified in place. The hook can also abort the simulation immediately by raising StopIteration (might not work with all backends).
user_funcs (dict, optional) – A dictionary with user defined functions that can be used in the expressions in rhs.
consts (dict, optional) – A dictionary with user defined constants that can be used in the expression. These can be either scalar numbers or fields defined on the same grid as the actual simulation.
noise (float,
ndarray, or dict) – Variance of additive Gaussian white noise. The default value of zero implies deterministic partial differential equations will be solved. Different noise magnitudes can be supplied for each field in coupled PDEs by either specifying a sequence of numbers or a dictionary with values for each field.rng (
Generator) – Random number generator (default:default_rng()) used for stochastic simulations. Note that this random number generator is only used for numpy functions, while compiled numba code uses the random number generator of numba. Moreover, in simulations using multiprocessing, setting the same generator in all processes might yield unintended correlations in the simulation results.