block_diagram module¶
-
class
simupy.block_diagram.
BlockDiagram
(*systems)[source]¶ A block diagram of dynamical systems with their connections which can be numerically simulated.
Initialize a BlockDiagram, with an optional list of systems to start the diagram.
-
add_system
(system)[source]¶ Add a system to the block diagram
Parameters: system (dynamical system) – System to add to BlockDiagram
-
connect
(from_system_output, to_system_input, outputs=[], inputs=[])[source]¶ Connect systems in the block diagram.
Parameters: - from_system_output (dynamical system) – The system (already added to BlockDiagram) from which outputs will be connected. Note that the outputs of a system can be connected to multiple inputs.
- to_system_input (dynamical system) – The system (already added to BlockDiagram) to which inputs will be connected. Note that any previous input connections will be over-written.
- outputs (list-like, optional) – Selector index of the outputs to connect. If not specified or of length 0, will connect all of the outputs.
- inputs (list-like, optional) – Selector index of the inputs to connect. If not specified or of length 0, will connect all of the inputs.
-
simulate
(tspan, integrator_class=<class 'scipy.integrate._ode.ode'>, integrator_options={'nsteps': 500, 'max_step': 0.0, 'rtol': 1e-06, 'name': 'dopri5', 'atol': 1e-12}, event_finder=<function brentq>, event_find_options={'maxiter': 100, 'rtol': 8.881784197001252e-16, 'xtol': 2e-12})[source]¶ Simulate the block diagram
Parameters: - tspan (list-like or float) –
Argument to specify integration time-steps.
If a single time is specified, it is treated as the final time. If two times are specified, they are treated as initial and final times. In either of these conditions, it is assumed that that every time step from a variable time-step integrator will be stored in the result.
If more than two times are specified, these are the only times where the trajectories will be stored.
- integrator_class (class, optional) –
Class of integrator to use. Defaults to
scipy.integrate.ode
. Must provide the following subset of thescipy.integrate.ode
API:__init__(derivative_callable(time, state))
set_integrator(**kwargs)
set_initial_value(state, time)
set_solout(successful_step_callable(time, state))
integrate(time)
successful()
y
,t
properties
- integrator_options (dict, optional) – Dictionary of keyword arguments to pass to
integrator_class.set_integrator
. - event_finder (callable, optional) – Interval root-finder function. Defaults to
scipy.optimize.brentq
, and must take the equivalent positional arguments,f
,a
, andb
, and returnx0
, wherea <= x0 <= b
andf(x0)
is the zero. - event_find_options (dict, optional) – Dictionary of keyword arguments to pass to
event_finder
. It must provide a key'xtol'
, and it is expected that the exact zero lies withinx0 +/- xtol/2
, asbrentq
provides.
- tspan (list-like or float) –
-