andes.core.param.TimerParam#
- class andes.core.param.TimerParam(callback: Optional[Callable] = None, default: Optional[Union[float, str, Callable]] = None, name: Optional[str] = None, tex_name: Optional[str] = None, info: Optional[str] = None, unit: Optional[str] = None, non_zero: bool = False, mandatory: bool = False, export: bool = True)[source]#
A parameter whose values are event occurrence times during the simulation.
The constructor takes an additional Callable self.callback for the action of the event. TimerParam has a default value of -1, meaning deactivated.
Examples
A connectivity status toggle class Toggle takes a parameter t for the toggle time. Inside
Toggle.__init__
, one would haveself.t = TimerParam()
The Toggle class also needs to define a method for togging the connectivity status
def _u_switch(self, is_time: np.ndarray): action = False for i in range(self.n): if is_time[i] and (self.u.v[i] == 1): instance = self.system.__dict__[self.model.v[i]] # get the original status and flip the value u0 = instance.get(src='u', attr='v', idx=self.dev.v[i]) instance.set(src='u', attr='v', idx=self.dev.v[i], value=1-u0) action = True return action
Finally, in
Toggle.__init__
, assign the function as the callback for self.tself.t.callback = self._u_switch
- __init__(callback: Optional[Callable] = None, default: Optional[Union[float, str, Callable]] = None, name: Optional[str] = None, tex_name: Optional[str] = None, info: Optional[str] = None, unit: Optional[str] = None, non_zero: bool = False, mandatory: bool = False, export: bool = True)[source]#
Methods
add
([value])Add a value to the parameter value list.
Return
self.name
in a list.get_property
(property_name)Check the boolean value of the given property.
is_time
(dae_t)Element-wise check if the DAE time is the same as the parameter value.
restore
()Restore parameter to the original input by copying
self.vin
toself.v
.set
(pos, attr, value)Set attributes of the BaseParam class to new values at the given positions.
set_all
(attr, value)Set attributes of the BaseParam class to new values for all positions.
set_pu_coeff
(coeff)Store p.u.
to_array
()Converts field
v
to the NumPy array type.Attributes
Return the class name.
Return the count of elements in the value array.