discontinuities module¶
-
class
simupy.discontinuities.
DiscontinuousSystem
(state_equation=None, state=None, input_=None, output_equation=None, constants_values={}, dt=0, initial_condition=None, code_generator=None, code_generator_args={})[source]¶ Bases:
simupy.systems.symbolic.DynamicalSystem
A continuous-time dynamical system with a discontinuity. Must provide the following attributes in addition to those of DynamicalSystem:
event_equation_function
- A function called at each integration time- step and stored in simulation results. Takes input and state, if stateful. A zero-crossing of this output triggers the discontinuity.event_equation_function
- A function that is called when the discontinuity occurs. This is generally used to change whatstate_equation_function
,output_equation_function
, andevent_equation_function
compute based on the occurance of the discontinuity. If stateful, returns the state immediately after the discontinuity.DynamicalSystem constructor, used to create systems from symbolic expressions.
Parameters: - state_equation (array_like of sympy Expressions, optional) – Vector valued expression for the derivative of the state.
- state (array_like of sympy symbols, optional) – Vector of symbols representing the components of the state, in the desired order, matching state_equation.
- input (array_like of sympy symbols, optional) – Vector of symbols representing the components of the input, in the desired order. state_equation may depend on the system input. If the system has no state, the output_equation may depend on the system input.
- output_equation (array_like of sympy Expressions) – Vector valued expression for the output of the system.
- constants_values (dict) – Dictionary of constants substitutions.
- dt (float) – Sampling rate of system. Use 0 for continuous time systems.
- initial_condition (array_like of numerical values, optional) – Array or Matrix used as the initial condition of the system. Defaults to zeros of the same dimension as the state.
- code_generator (callable, optional) – Function to be used as code generator.
- code_generator_args (dict, optional) – Dictionary of keyword args to pass to the code generator.
By default, the code generator uses a wrapper for
sympy.lambdify
. You can change it by passing the system initialization argumentscode_generator
(the function) and additional keyword arguments to the generator in a dictionarycode_generator_args
. You can change the defaults for future systems by changing the module values. See the readme or docs for an example.-
dt
¶
-
class
simupy.discontinuities.
MemorylessDiscontinuousSystem
(input_=None, output_equation=None, **kwargs)[source]¶ Bases:
simupy.discontinuities.DiscontinuousSystem
,simupy.systems.symbolic.MemorylessSystem
DynamicalSystem constructor
Parameters: - input (array_like of sympy symbols) – Vector of symbols representing the components of the input, in the desired order. The output may depend on the system input.
- output_equation (array_like of sympy Expressions) – Vector valued expression for the output of the system.
-
class
simupy.discontinuities.
SwitchedOutput
(event_variable_equation, event_bounds_expressions, state_equations=None, output_equations=None, state_update_equation=None, **kwargs)[source]¶ Bases:
simupy.discontinuities.SwitchedSystem
,simupy.discontinuities.MemorylessDiscontinuousSystem
A memoryless discontinuous system to conveninetly construct switched outputs.
SwitchedSystem constructor, used to create switched systems from symbolic expressions. The parameters below are in addition to parameters from the
systems.symbolic.DynamicalSystems
constructor.Parameters: - event_variable_equation (sympy Expression) – Expression representing the event_equation_function
- event_bounds_expressions (list-like of sympy Expressions or floats) – Ordered list-like values which define the boundaries of events (relative to event_variable_equation).
- state_equations (array_like of sympy Expressions, optional) – The state equations of the system. The first dimension indexes the event-state and should be one more than the number of event bounds. This should also be indexed to match the boundaries (i.e., the first expression is used when the event_variable_equation is below the first event_bounds value). The second dimension is dim_state of the system. If only 1-D, uses single equation for every condition.
- output_equations (array_like of sympy Expressions, optional) – The output equations of the system. The first dimension indexes the event-state and should be one more than the number of event bounds. This should also be indexed to match the boundaries (i.e., the first expression is used when the event_variable_equation is below the first event_bounds value). The second dimension is dim_output of the system. If only 1-D, uses single equation for every condition.
- state_update_equation (sympy Expression) – Expression representing the state_update_equation_function
-
class
simupy.discontinuities.
SwitchedSystem
(event_variable_equation, event_bounds_expressions, state_equations=None, output_equations=None, state_update_equation=None, **kwargs)[source]¶ Bases:
simupy.systems.SwitchedSystem
,simupy.discontinuities.DiscontinuousSystem
SwitchedSystem constructor, used to create switched systems from symbolic expressions. The parameters below are in addition to parameters from the
systems.symbolic.DynamicalSystems
constructor.Parameters: - event_variable_equation (sympy Expression) – Expression representing the event_equation_function
- event_bounds_expressions (list-like of sympy Expressions or floats) – Ordered list-like values which define the boundaries of events (relative to event_variable_equation).
- state_equations (array_like of sympy Expressions, optional) – The state equations of the system. The first dimension indexes the event-state and should be one more than the number of event bounds. This should also be indexed to match the boundaries (i.e., the first expression is used when the event_variable_equation is below the first event_bounds value). The second dimension is dim_state of the system. If only 1-D, uses single equation for every condition.
- output_equations (array_like of sympy Expressions, optional) – The output equations of the system. The first dimension indexes the event-state and should be one more than the number of event bounds. This should also be indexed to match the boundaries (i.e., the first expression is used when the event_variable_equation is below the first event_bounds value). The second dimension is dim_output of the system. If only 1-D, uses single equation for every condition.
- state_update_equation (sympy Expression) – Expression representing the state_update_equation_function
-
event_bounds_expressions
¶
-
event_variable_equation
¶
-
output_equations
¶
-
state_equations
¶
-
state_update_equation
¶