andes.core.param.TimerParam#
- class andes.core.param.TimerParam(callback: Callable | None = None, default: float | str | Callable | None = None, name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = 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: Callable | None = None, default: float | str | Callable | None = None, name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = None, non_zero: bool = False, mandatory: bool = False, export: bool = True)[source]#
Methods
add([value])Add a value to the parameter value list.
get_names()Return
self.namein 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.vintoself.v.restore_init()Restore
vfrom_v_t0saved bysnapshot_init().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.
snapshot_init()Save the current post-pu
vinto_v_t0forrestore_init().to_array()Converts field
vto the NumPy array type.Attributes
class_nameReturn the class name.
nReturn the count of elements in the value array.