andes.core.block.Piecewise#
- class andes.core.block.Piecewise(u, points: List | Tuple, funs: List | Tuple, name=None, tex_name=None, info=None)[source]#
Piecewise block. Outputs an algebraic variable y.
This block takes a list of N points, [x0, x1, ...x_{n-1}] to define N+1 ranges, namely (-inf, x0), (x0, x1), ..., (x_{n-1}, +inf). and a list of N+1 function strings [fun0, ..., fun_n].
Inputs that fall within each range applies the corresponding function. The first range (-inf, x0) applies fun_0, and the last range (x_{n-1}, +inf) applies the last function fun_n.
The function returns zero if no condition is met.
Note
Piecewise.y must remain
Algeb(notObservable) because: (1) model authors may setv_iteron the output for coupled iterative initialization (e.g., EXAC1), and (2) zero-valued branches causeComplexInfinitywhen the expression is substituted into denominators during code generation.- Parameters:
- pointslist, tuple
A list of piecewise points. Need to be provided in the constructor function.
- funslist, tuple
A list of strings for the piecewise functions. Need to be provided in the overloaded define function.
Methods
define()Build the equation string for the piecewise equations.
enforce_tex_name(fields)Enforce tex_name is not None
export()Method for exporting instances defined in this class in a dictionary.
f_numeric(**kwargs)Function call to update differential equation values.
g_numeric(**kwargs)Function call to update algebraic equation values.
j_numeric(**kwargs)Per-iteration numerical Jacobian update.
j_reset()Helper function to clear the lists holding the numerical Jacobians.
j_setup()One-time Jacobian sparsity pattern and constant value setup.
Attributes
class_nameReturn the class name.