soft4pes.sim.simulation#

Simulation environment for power electronic systems.

Classes#

ProgressPrinter

A class used to print the progress of the simulation process.

Simulation

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.

total_steps[source]#

The total number of steps in the process.

Type:

int

last_printed_percent[source]#

The last printed percentage of progress.

Type:

int

__call__(current_step)[source]#

Prints the current progress with steps of 5 percent.

Parameters:

current_step (int) – The number of the current step in the process.

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].

sys[source]#

System model.

Type:

system object

ctr[source]#

Control system.

Type:

controller object.

Ts_sim[source]#

Simulation sampling interval [s].

Type:

float

t_stop[source]#

Simulation stop time [s].

Type:

float

matrices[source]#

Discrete state-space matrices of the simulated system.

Type:

SimpleNamespace

simulation_data[source]#

Data from the simulation.

Type:

dict

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