andes.core.var.State#

class andes.core.var.State(name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = None, v_str: str | float | None = None, v_iter: str | None = None, e_str: str | None = None, discrete: Discrete | None = None, t_const: BaseParam | DummyValue | BaseService | None = None, check_init: bool | None = True, v_setter: bool | None = False, e_setter: bool | None = False, addressable: bool | None = True, export: bool | None = True, diag_eps: float | None = 0.0, deps: List | None = None)[source]#

Differential variable class, an alias of the BaseVar.

Parameters:
t_constBaseParam, DummyValue

Left-hand time constant for the differential equation. They will be collected to array dae.Tf. Time constants will not be used when evaluating the right-hand side specified in e_str but will be applied to the left-hand side.

check_initbool

True to check if the equation right-hand-side is zero initially. Disabling the checking can be used for integrators when the initial input may not be zero.

Examples

To implement the swing equation

\[M \dot {\omega} = \tau_m - \tau_e - D(\omega - 1)\]

Do the following in the __init__() of a model class:

self.omega = State(e_str = 'tm - te - D * (omega - 1)',
                   t_const = self.M,
                   ...
                   )

Note that self.M, the inertia parameter is given through t_const and is not part of e_str.

Attributes:
e_codestr

Equation code string, equals string literal f

v_codestr

Variable code string, equals string literal x

__init__(name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = None, v_str: str | float | None = None, v_iter: str | None = None, e_str: str | None = None, discrete: Discrete | None = None, t_const: BaseParam | DummyValue | BaseService | None = None, check_init: bool | None = True, v_setter: bool | None = False, e_setter: bool | None = False, addressable: bool | None = True, export: bool | None = True, diag_eps: float | None = 0.0, deps: List | None = None)[source]#

Methods

get_names()

reset()

Reset the internal numpy arrays and flags.

set_address(addr[, contiguous])

Set the address of internal variables.

set_arrays(dae[, inplace, alloc])

Set the equation and values arrays.

Attributes

class_name

e_code

v_code