andes.core.var.State#
- class andes.core.var.State(name: Optional[str] = None, tex_name: Optional[str] = None, info: Optional[str] = None, unit: Optional[str] = None, v_str: Optional[Union[str, float]] = None, v_iter: Optional[str] = None, e_str: Optional[str] = None, discrete: Optional[andes.core.discrete.Discrete] = None, t_const: Optional[Union[andes.core.param.BaseParam, andes.core.common.DummyValue, andes.core.service.BaseService]] = None, check_init: Optional[bool] = True, v_setter: Optional[bool] = False, e_setter: Optional[bool] = False, addressable: Optional[bool] = True, export: Optional[bool] = True, diag_eps: Optional[float] = 0.0, deps: Optional[List] = 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 ine_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 throught_const
and is not part ofe_str
.- Attributes
- e_codestr
Equation code string, equals string literal
f
- v_codestr
Variable code string, equals string literal
x
- __init__(name: Optional[str] = None, tex_name: Optional[str] = None, info: Optional[str] = None, unit: Optional[str] = None, v_str: Optional[Union[str, float]] = None, v_iter: Optional[str] = None, e_str: Optional[str] = None, discrete: Optional[andes.core.discrete.Discrete] = None, t_const: Optional[Union[andes.core.param.BaseParam, andes.core.common.DummyValue, andes.core.service.BaseService]] = None, check_init: Optional[bool] = True, v_setter: Optional[bool] = False, e_setter: Optional[bool] = False, addressable: Optional[bool] = True, export: Optional[bool] = True, diag_eps: Optional[float] = 0.0, deps: Optional[List] = None)[source]#
Methods
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