emulsim.actors.autonomous.fields module
Provides actors that influence scalar fields.
Actor simulating a local chemical reactions in a field. |
|
Actor evolving a field according to a PDE. |
|
Actor evolving a field according to a simple diffusion equation. |
|
Actor evolving a field according to a reaction-diffusion equation. |
|
Actor evolving a field collection according to a PDE. |
- class CollectionPDEActor(pde: PDEBase, parameters: dict[str, Any] | None = None)[source]
Bases:
ActorBaseActor evolving a field collection according to a PDE.
Initialize the actor and its PDE.
- Parameters:
- copy() CollectionPDEActor[source]
Returns a copy the actor.
- element_classes: tuple[type[_ElementBase] | tuple[type[_ElementBase], ...], ...] | EllipsisType = (<class 'emulsim.elements.fields.FieldCollectionElement'>,)
defines the elements this actor handles and in what order they need to be supplied. An ellipsis (…) indicates that all elements and lists of elements are accepted. Setting this attribute allows internal consistency checks.
- Type:
- evolve(elements: tuple[FieldCollectionElement], t: float, dt: float)[source]
Evolve the field from time t to t + dt
- Parameters:
elements (tuple of
ScalarFieldElement) – The element affected by the actort (float) – The current time point
dt (float) – The time step used to evolve the element
- make_evolver_numba(elements: tuple[FieldCollectionElement]) Callable[[tuple[ndarray], float, float], None][source]
Return a function evolving the field from time t to t + dt
- Parameters:
elements (tuple of
ScalarFieldElement) – The element affected by the actor- Returns:
- A function with signature (field_data, t: float,
dt: float), which evolves the field_data.
- Return type:
callable
- class DiffusionActor(parameters: dict[str, Any] | None = None)[source]
Bases:
ScalarPDEActorActor evolving a field according to a simple diffusion equation.
- Parameters Dictionary:
boundary_conditions: Defines the boundary conditions on the field.Boundary conditions are generally given as a dictionary with one condition for
- each axis side (default=’auto_periodic_neumann’)
diffusivity: Diffusivity in the field (default=1.0)
- Parameters:
parameters (dict) – Parameters affecting the actor. Call
show_parameters()for details.
Parameters of DiffusionActor:
- diffusivity
Diffusivity in the field. This actor only supports constant diffusivities. Diffusivities depending on local concentration are supported by ReactionDiffusionActor. (Default value:
1.0)- boundary_conditions
Defines the boundary conditions on the field.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. (Default value:
'auto_periodic_neumann')
- estimate_dt(elements: tuple[ScalarFieldElement]) float[source]
Get the optimal time step for the simulation of the actor.
- Parameters:
elements (tuple of
ScalarFieldElement) – The element affected by the actor- Returns:
the time step
- Return type:
- class LocalReactionsActor(parameters: dict[str, Any] | None = None)[source]
Bases:
ActorBaseActor simulating a local chemical reactions in a field.
- Parameters Dictionary:
reaction_flux: An expression for the reaction flux in the mean field (default=’0’)
- Parameters:
parameters (dict) – Parameters affecting the actor. Call
show_parameters()for details.
Parameters of LocalReactionsActor:
- reaction_flux
An expression for the reaction flux in the mean field. The expression may depend on the concentration and time, which are denoted by the variables c and t respectively. (Default value:
'0')
- element_classes: tuple[type[_ElementBase] | tuple[type[_ElementBase], ...], ...] | EllipsisType = (<class 'emulsim.elements.fields.FieldElementBase'>,)
defines the elements this actor handles and in what order they need to be supplied. An ellipsis (…) indicates that all elements and lists of elements are accepted. Setting this attribute allows internal consistency checks.
- Type:
- estimate_dt(elements: tuple[FieldElementBase]) float[source]
Get the optimal time step for the simulation of the actor.
- Parameters:
elements (tuple of
MeanfieldElement) – The element affected by the actor
- evolve(elements: tuple[FieldElementBase], t: float, dt: float)[source]
Evolve the field from time t to t + dt
- Parameters:
elements (tuple of
MeanfieldElement) – The element affected by the actort (float) – The current time point
dt (float) – The time step used to evolve the element
- make_evolver_numba(elements: tuple[FieldElementBase]) Callable[[tuple[ndarray], float, float], None][source]
Return a function evolve the field from time t to t + dt
- Parameters:
elements (tuple of
MeanfieldElement) – The element affected by the actor- Returns:
- A function with signature (field_data, t: float,
dt: float), which evolves the field_data.
- Return type:
callable
- class MeanfieldActor(parameters: dict[str, Any] | None = None)[source]
Bases:
LocalReactionsActorParameters Dictionary: * reaction_flux: An expression for the reaction flux in the mean field (default=’0’)
- Parameters:
parameters (dict) – Parameters affecting the actor. Call
show_parameters()for details.
Parameters of MeanfieldActor:
- reaction_flux
An expression for the reaction flux in the mean field. The expression may depend on the concentration and time, which are denoted by the variables c and t respectively. (Default value:
'0')
- class ReactionDiffusionActor(parameters: dict[str, Any] | None = None)[source]
Bases:
ScalarPDEActorActor evolving a field according to a reaction-diffusion equation.
This class relies on the optional phasesep package, which needs to be installed separately.
- Parameters Dictionary:
boundary_conditions: Defines the boundary conditions on the field.Boundary conditions are generally given as a dictionary with one condition for
- each axis side (default=’auto_periodic_neumann’)
diffusivity: Diffusivity in the field (default=’1’)
expression_constants: A dictionary defining values of constants that can be used in expressions, e.g., the parameter reaction_flux. (default={})
reaction_flux: An expression for the reaction flux in the field, which can depend on the concentration (denoted by c or phi), spatial coordinates (denoted by x[i], where i is the dimension), and time t. (default=’0’)
- Parameters:
parameters (dict) – Parameters affecting the actor. Call
show_parameters()for details
Parameters of ReactionDiffusionActor:
- diffusivity
Diffusivity in the field. This can be an expression depending on the local concentration that is parsed by sympy. Alternatively, simple numbers are also supported. (Default value:
'1')- reaction_flux
An expression for the reaction flux in the field, which can depend on the concentration (denoted by c or phi), spatial coordinates (denoted by x[i], where i is the dimension), and time t. (Default value:
'0')- boundary_conditions
Defines the boundary conditions on the field.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. (Default value:
'auto_periodic_neumann')- expression_constants
A dictionary defining values of constants that can be used in expressions, e.g., the parameter reaction_flux. (Default value:
{})
- estimate_dt(elements: tuple[ScalarFieldElement]) float[source]
Get the optimal time step for the simulation of the actor.
- Parameters:
elements (tuple of
ScalarFieldElement) – The element affected by the actor- Returns:
the time step
- Return type:
- class ScalarPDEActor(pde: PDEBase, parameters: dict[str, Any] | None = None)[source]
Bases:
ActorBaseActor evolving a field according to a PDE.
Initialize the actor and its PDE.
- Parameters:
- copy() ScalarPDEActor[source]
Returns a copy the actor.
- element_classes: tuple[type[_ElementBase] | tuple[type[_ElementBase], ...], ...] | EllipsisType = (<class 'emulsim.elements.fields.ScalarFieldElement'>,)
defines the elements this actor handles and in what order they need to be supplied. An ellipsis (…) indicates that all elements and lists of elements are accepted. Setting this attribute allows internal consistency checks.
- Type:
- evolve(elements: tuple[ScalarFieldElement], t: float, dt: float)[source]
Evolve the field from time t to t + dt
- Parameters:
elements (tuple of
ScalarFieldElement) – The element affected by the actort (float) – The current time point
dt (float) – The time step used to evolve the element
- make_evolver_numba(elements: tuple[ScalarFieldElement]) Callable[[tuple[ndarray], float, float], None][source]
Return a function evolving the field from time t to t + dt
- Parameters:
elements (tuple of
ScalarFieldElement) – The element affected by the actor- Returns:
- A function with signature (field_data, t: float,
dt: float), which evolves the field_data.
- Return type:
callable