andes.core.service.ConstService#

class andes.core.service.ConstService(v_str: str | None = None, v_numeric: Callable | None = None, vtype: type | None = None, name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = None)[source]#

A type of Service that stays constant once initialized.

ConstService are usually constants calculated from parameters. They are only evaluated once in the initialization phase before variables are initialized. Therefore, uninitialized variables must not be used in v_str`.

ConstService are evaluated in sequence after getting external variables and parameters and before initializing internal variables.

Parameters:
namestr

Name of the ConstService

v_strstr

An equation string to calculate the variable value.

v_numericCallable, optional

A callable which returns the value of the ConstService

v_type: type, optional, default to float

Type of element in the value array in float or complex

Attributes:
varray-like or a scalar

ConstService value

_v_t0np.ndarray or None

v at t=0, saved by snapshot_init(). Used by restore_init() to reset v to the post-init baseline.

__init__(v_str: str | None = None, v_numeric: Callable | None = None, vtype: type | None = None, name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = None)[source]#

Methods

assign_memory(n)

Assign memory for self.v and set the array to zero.

get_names()

Return name in a list

restore_init()

Restore v from _v_t0 saved by snapshot_init().

snapshot_init()

Save the current v into _v_t0 for restore_init().

Attributes

class_name

Return the class name

n

Return the count of values in self.v.