pathsim.subsystem
- class pathsim.subsystem.Interface[source]
Bases:
BlockBare-bone block that serves as a data interface for the ‘Subsystem’ class.
It works like this:
Internal blocks of the subsystem are connected to the inputs and outputs of this Interface block via the internal connections.
It behaves like a normal block (inherits the main ‘Block’ class methods).
It implements some special methods to get and set the inputs and outputs of the blocks, that are used to translate between the internal blocks of the subsystem and the inputs and outputs of the subsystem.
Handles data transfer to and from the internal subsystem blocks to and from the inputs and outputs of the subsystem.
- class pathsim.subsystem.Subsystem(blocks=None, connections=None)[source]
Bases:
BlockSubsystem class that holds its own blocks and connecions and can natively interface with the main simulation loop.
IO interface is realized by a special ‘Interface’ block, that has extra methods for setting and getting inputs and outputs and serves as the interface of the internal blocks to the outside.
The subsystem doesnt use its ‘inputs’ and ‘outputs’ dicts directly. It exclusively handles data transfer via the ‘Interface’ block.
This class can be used just like any other block during the simulation, since it implements the required methods ‘update’ for the fixed-point iteration (resolving algebraic loops with instant time blocks), the ‘step’ method that performs timestepping (especially for dynamic blocks with internal states) and the ‘solve’ method for solving the implicit update equation for implicit solvers.
- Parameters:
connections (list[Connection]) – internal connections of the subsystem
- on()[source]
Activate the subsystem and all internal blocks, sets the boolean evaluation flag to ‘True’.
- off()[source]
Deactivate the subsystem and all internal blocks, sets the boolean evaluation flag to ‘False’. Also resets the subsystem.
- get_events()[source]
Recursively collect and return events spawned by the internal blocks of the subsystem, for discrete time blocks such as triggers / comparators, clocks, etc.
- set(port, value)[source]
The ‘set’ method of the ‘Subsystem’ sets the output values of the ‘Interface’ block.
- Parameters:
port (int) – input port to set value to
value (numeric) – value to set at input port (of subsystem)
- get(port)[source]
The ‘get’ method of the ‘Subsystem’ retrieves the input values of the ‘Interface’ block.
- Parameters:
port (int) – output port (of subsystem) to retrieve value from
- sample(t)[source]
Update the internal connections again and sample data from the internal blocks that implement the ‘sample’ method.
- Parameters:
t (float) – evaluation time
- update(t)[source]
Update the instant time components of the internal blocks to evaluate the (distributed) system equation.
- step(t, dt)[source]
Explicit component of timestep for internal blocks including error propagation.
Notes
This is pretty much an exact copy of the ‘_step’ method from the ‘Simulation’ class.