emulsim.actors.base module
Supplies the base class for actors.
Base class of a single actor that affects one or more elements. |
|
Finds actors compatible with the given elements. |
- class ActorBase(parameters: dict[str, Any] | None = None)[source]
Bases:
ParameterizedBase class of a single actor that affects one or more elements.
- Parameters:
parameters (dict) – Parameters defining the behavior of the actor. Call
show_parameters()for details.
- element_classes: tuple[type[_ElementBase] | tuple[type[_ElementBase], ...], ...] | EllipsisType = ()
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[_ElementBase, ...]) float[source]
Estimate the maximal time step for simulating this actor.
- Parameters:
elements (tuple of
_ElementBase) – The elements that this actor affects- Returns:
the maximal time step
- Return type:
- abstractmethod evolve(elements: tuple[_ElementBase, ...], t: float, dt: float)[source]
Evolve the state from time t to t + dt
- Parameters:
elements (tuple of
_ElementBase) – The elements that this actor affectst (float) – The current time point
dt (float) – The time step
- make_evolver_numba(elements: tuple[_ElementBase, ...]) Callable[[tuple[ndarray, ...], float, float], None][source]
Return a function evolve the state from time t to t + dt
- Parameters:
elements (tuple of
_ElementBase) – The elements that this actor affects- Returns:
- A function with signature
(state_data:
ndarray, t: float, dt: float), evolving state_data
- Return type:
callable
- property num_elements: int | EllipsisType
the number of elements this actor affects. This value is determined from the element_classes attribute
- Type:
- classmethod supports_elements(*elements: _ElementBase | type[_ElementBase], silent: bool = False) bool[source]
Determines whether this actor supports the given elements.
- Parameters:
elements (
_ElementBase) – Various elements or element classes.silent (bool) – Determines whether the function returns silently or whether an exception is raised when an element is not supported.
- Returns:
Whether the current actor supports the elements in the given order
- Return type:
- find_actors(*elements: _ElementBase | type[_ElementBase], unordered: bool = False) list[type[ActorBase]][source]
Finds actors compatible with the given elements.
- Parameters:
elements (
_ElementBase) – Element classes or instances that shall serve as input for the actorsunordered (bool) – Determines whether also actors are returned that only accept a reordered arrangement of the elements.
- Returns:
A list of all compatible actor classes
- Return type:
list of
ActorBase