CADETProcess.dynamicEvents.Event#

class CADETProcess.dynamicEvents.Event(name: str, event_handler: EventHandler, parameter_path: str, state: float, time: float = 0.0, indices: int | list[int] | None = None)[source]#

Bases: object

Defines dynamic changes of model parameters based on events.

An Event is a time-based modification to an attribute of a performer. Its execution time can depend on other Events or Durations. To handle cyclic behavior, times are computed modulo the cycle time of the EventHandler.

Attributes:
namestr

The event’s name.

event_handlerEventHandler

Object managing the performers and cycle time.

parameter_pathstr

str: Dot notation path to the target parameter within the evaluation_object.

statefloat

Return the state of the parameter event.

timefloat, default=0.0

float: Time when the event is executed.

indicesint or list, default=None

list: Indices for events that modifies only specific entries of a parameter.

add_dependency(dependency: Event, factor: float = 1, transform: Callable | None = None) None[source]#

Add a time dependency on another event.

When an event is dependent, the time of the event is based on a linear combination of its dependencies.

Parameters:
dependencyEvent

Event that this event depends on.

factorfloat, default=1

Weighting factor for the dependency.

transformcallable, optional

A function to transform the dependent event’s time.

Raises:
CADETProcessError

If the dependency is already listed.

property current_value: Any#

any: Current state of the associated event parameter.

property degree: int#

int: The degree of the polynomial event state.

property dependencies: list[Event]#

list: Events on which the Event depends.

property factors: list[int]#

list: Linear coefficients for dependent events.

property full_indices: list[int]#

list: Full indices.

property full_state: float | list#

Construct the full state based on indices and current value.

This method reconstructs the state from the stored state value,.

Returns:
float or list

The computed full state, either as a scalar or an array.

Raises:
ValueError

If the length of the state does not match the length of the indices.

property index_states: dict[tuple, float]#

dict[tuple, float]: State values mapped to their respective indices.

property indices: list[tuple[int]] | None#

list: Indices for events that modifies only specific entries of a parameter.

List of tuples for each entry. If parameter is scalar, None

property is_independent: bool#

bool: True, if event is independent, False otherwise.

property is_index_specific: bool#

bool: True if event modifies entry of a parameter array, False otherwise.

property is_polynomial: bool#

bool: True if descriptor is instance of NdPolynomial. False otherwise.

property is_sized: bool#

bool: True if descriptor is instance of Sized. False otherwise.

property n_entries: int#

int: The number of entries in the event state.

property n_indices: int#

int: Number of (full) indices.

property parameter_descriptor: ParameterBase | None#

Return parameter descriptor.

property parameter_path: str#

str: Dot notation path to the target parameter within the evaluation_object.

property parameter_sequence: tuple[str, ...]#

tuple: Tuple of parameters path elements.

property parameter_shape: tuple[int, ...]#

tuple: Shape of the parameter array.

property parameter_type: Type[Any]#

type: Type of the parameter.

property parameters: dict#

dict: list with all parameters.

property performer: str#

str: The name of the performer of the event.

property performer_obj: Any#

any: Performer object from the event handler.

remove_dependency(dependency: Event) None[source]#

Remove dependencies of events.

Parameters:
dependencyEvent

Event object to remove from dependencies.

Raises:
CADETProcessError

If the dependency doesn’t exists in list dependencies.

set_value(state: float | ndarray) None[source]#

Set the specified state to the associated event parameter.

property state: float | ndarray#

Return the state of the parameter event.

When retrieving, it returns the current state of the event. When setting, the internal state is updated.

Returns:
float | np.ndarray

The state of the parameter event.

property time: float#

float: Time when the event is executed.

If the value is larger than the cycle time, the time modulo cycle time is returned. If the Event is not independent, the time is calculated from its dependencies.

Raises:
CADETProcessError

If the event is not independent.

property transforms: list[Callable]#

list: Transform functions for dependent events.