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
vat t=0, saved bysnapshot_init(). Used byrestore_init()to resetvto 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.vand set the array to zero.get_names()Return name in a list
restore_init()Restore
vfrom_v_t0saved bysnapshot_init().snapshot_init()Save the current
vinto_v_t0forrestore_init().Attributes
class_nameReturn the class name
nReturn the count of values in
self.v.