Components

Core component classes and signals.

Public components

class Clock(dt: float, sampling_rate: int = -1, name: str = 'default_clock')[source]

Bases: Component

Represents the clock class.

This class manages the time counter and all operations on it.

Parameters:
  • dt (float) – Time step variable for the simulation

  • sampling_rate (int = 1) – Integral postive multiple of dt, simulation data are stored on these time steps

  • name (str = “default_clock”) – Name of the component

Variables:
  • dt (float) – Time step variable for the simulation

  • _sampling_rate (float) – Integral postive multiple of dt, simulation data are stored on these time steps

  • t (float = 0.0) – Time counter variable for simulation

  • _t_sample (float = 0.0) – Helper for sampling rate

  • running (bool = True) – Clock status for time updates

  • _t_final (float = 0.0) – Time at which to stop simulation and set running to False

dt

Clock Delta time data

t

Clock time data

running

Clock running state data

set(t_final: float, t: float | None = None)[source]

Clock set method

Sets t_final and t. Also sets running to True.

Parameters:
  • t_final (float)

  • t (float = None)

update()[source]

Clock update method

Checks if t exceeded _t_final, then sets running to False and returns. Else it updates both t and _t_sample by one time step, ie dt. If _t_sample exceeds _sampling_rate then sets _t_sample to 0.0

output_port(kwargs: dict = {})[source]

Clock output port method

Parameters:

kwargs (dict = {})

Returns:

kwargs – Returns dict with ‘clock’:self data

Return type:

dict

class TimeComponent(name: str = 'default_time_component')[source]

Bases: Component

Represents the base timecomponent class.

This class is the base class for all components which are time dependent on clock data.

It provides methods for simulate() and input_port() based on clock data.

Parameters:

name (str = “default_time_component”) – Name of the component

Variables:

_data (any = 0) – A container for specific data according to child classes

simulate(clock: Clock)[source]

TimeComponent simulate method (to override)

Parameters:
  • clock (Clock)

  • method (Empty)

  • ------------

input_port()[source]

TimeComponent input port method (to override)

Returns:

kwargs – Returns dict with ‘clock’:None data as requirements for simulate()

Return type:

dict

class DataComponent(name: str = 'default_data_component')[source]

Bases: Component

Represents the base datacomponent class.

This class manages simulation data, and their corresponding data units.

It provides methods for data handling like get, display, store.

Parameters:

name (str = “default_data_component”) – Name of the component

Variables:
  • _simulation_data (dict = {}) – A dict storing keys and it stores values for those keys, at each sampling time step

  • _simulation_data_units (dict = {}) – A dict storing units corresponding to the keys

store_data()[source]

DataComponent store_data method

Stores data for each key based on matching name of variable and key.

reset_data()[source]

DataComponent reset_data method

Clears all key data.

display_data(time_data: ndarray, simulation_keys: tuple[str, ...] | None = None)[source]

DataComponent display_data method

Plots stored data of the component based on time_data and simulation_keys.

Parameters:
  • time_data (ndarray) – A numpy array containing sequential time data

  • simulation_keys (tuple[str, …] = None) – An optional tuple of strings containing keys for which to plot data, Default all defined keys

get_data()[source]

DataComponent get_data method

get_data_units()[source]

DataComponent get_data_units method

Returns:

A new dict copy of all the keys:units

Return type:

dict

reset(save_simulation: bool = False)[source]

DataComponent reset method to override

output_port(kwargs: dict = {})[source]

DataComponent output port method to override

class PhysicalComponent(name: str = 'default_physical_component')[source]

Bases: DataComponent, TimeComponent

PhysicalComponent class

simulate(clock: Clock, _data: float | None = None)[source]

PhysicalComponent simulate method to override

input_port()[source]

PhysicalComponent input port method to override

Noise and waveforms

class LangevinNoise(Mu: int, Std_dev: int, name: str = 'default_langevin_noise')[source]

Bases: NoNoise

LangevinNoise class

class ArbitaryWave(name: str, t_unit: float = -1, total_spread: float = 1.0)[source]

ArbitaryWave class

WaveSignal(t: float)[source]

ArbitaryWave WaveSignal method to override

class StaticWave(name: str, static_val: float)[source]

StaticWave class

WaveSignal(t: float)[source]

StaticWave WaveSignal method

class PulseWave(name: str, pulse_low: float, pulse_high: float, t_unit: float, total_spread: float = 1)[source]

PulseWave class

WaveSignal(t: float)[source]

PulseWave WaveSignal method

class AlternatingPulseWave(name: str, static_val: float, pulse_val: float, t_unit: float, total_spread: float = 1)[source]

AlternatingPulseWave class

WaveSignal(t: float)[source]

AlternatingPulseWave WaveSignal method

class ArbitaryWaveGenerator(*arg, **kwargs)[source]

ArbitaryWaveGenerator Singleton class

signals: dict[str, ArbitaryWave]

Signals dictionary for ArbitaryWaves

set(arbitarywaves: ArbitaryWave | tuple[ArbitaryWave, ...])[source]

ArbitaryWaveGenerator set method

simulate(clock: Clock, signal_keys: str | tuple[str, ...]) float[source]

ArbitaryWaveGenerator simulate method

Simulation wiring

class Connection(input_components: Component | tuple[Component, ...] | None, output_components: Component | tuple[Component, ...], name: str = 'default_connection')[source]

Bases: TimeComponent

Connection class

reset_data()[source]

Connection reset_data method

reset(save_simulation: bool)[source]

Connection reset method

simulate(clock: Clock)[source]

Connection simulate method

class Simulator(simulation_clock: Clock, name: str = 'default_simulator')[source]

Bases: DataComponent

Simulator class

store_data()[source]

Simulator store_data method

reset_data()[source]

Simulator reset_data method

display_data()[source]

Simulator display_data method

get_data()[source]

Simulator get_data method

reset(save_simulation: bool = False)[source]

Simulator reset method

set(connections: Connection | tuple[Connection, ...])[source]

Simulator set method

simulate()[source]

Simulator simulate method