soft4pes.sim.simulation#
Simulation environment for power electronic systems.
Classes#
A class used to print the progress of the simulation process. |
|
A class to handle switching-related logic, such as quantizing switching time instants and |
|
Simulation environment. |
Module Contents#
- class soft4pes.sim.simulation.ProgressPrinter(total_steps)[source]#
A class used to print the progress of the simulation process.
- Parameters:
total_steps (int) – The total number of steps in the process.
- class soft4pes.sim.simulation.SwitchingLogic(Ts_sim, Ts)[source]#
A class to handle switching-related logic, such as quantizing switching time instants and extracting the three-phase switch position or modulating signal.
- Parameters:
Ts_sim (float) – Simulation sampling interval [s].
Ts (float) – Control system sampling interval [s].
- quantize_switching_time_instants(t_switch)[source]#
Quantize the switching time instants.
- Parameters:
t_switch (ndarray) – Switching time instants.
- Returns:
Quantized switching time instants.
- Return type:
ndarray
- get_switch_positions(ctr_output, k_sim)[source]#
Get the three-phase switch position or modulating signal for the current discrete time instant. The switching time instants are quantized to the simulation sampling interval in the beginning of the control interval.
- Parameters:
ctr_output (SimpleNamespace) – Output from the controller including the switching time instants and the corresponding switch position or modulating signal.
k_sim (int) – The current simulation step within the control interval.
- Returns:
Three-phase switch positions or modulating signal for current simulation step.
- Return type:
ndarray
- class soft4pes.sim.simulation.Simulation(sys, ctr, Ts_sim, disc_method='forward_euler')[source]#
Simulation environment.
- Parameters:
sys (system object) – System model.
ctr (controller object) – Control system.
Ts_sim (float) – Simulation sampling interval [s].
- simulate(t_stop)[source]#
Simulate the system.
- Parameters:
t_stop (float) – Simulation length [s]. Simulation start time is always 0 s, i.e. kTs = 0.
- save_data(filename='sim_data.mat', path='')[source]#
Save the simulation data to a .mat file.
- Parameters:
filename (str, optional) – Name of the file to save the data to. The default filename is ‘sim_data.mat’.
path (str, optional) – Directory path to save the file to. The path can be absolute or relative to the current directory. The default saving directory is the current directory.
- process_simulation_data(data)[source]#
Recursively convert lists of arrays in a SimpleNamespace to NumPy arrays.
- Parameters:
data (SimpleNamespace or list of ndarray) – The data to be converted. Can be a SimpleNamespace or a list of arrays.
- Returns:
A SimpleNamespace with lists of arrays converted to NumPy arrays, or a NumPy array if the input is a list of arrays.
- Return type:
SimpleNamespace or ndarray