Compose – PSIM Integration Starter’s Guide 1: PsimSimulate


Altair PSIM is a simulation and design software for power electronics, motor drives, and power conversion systems. Altair Compose is an environment for doing math calculations, handling data, automating workflows and much more.

 

A new, powerful, library has been released on Compose from v2022.3 onwards, the PSIM Integration library. This library allows to seamlessly build workflows integrating both tools for running simulations in batch mode, extracting, handling, and writing results for further usage and, in general, for saving time and effort in design and simulation tasks on PSIM.

 

In this series of posts, I will be exploring the newly added capabilities briefly, so you can get a head start on how to leverage Compose if you are a PSIM user or vice versa. To follow along, you just need Compose and PSIM, both v2022.3, installed on your machine.

 

PSIM Schematic

 

The PSIM Schematic file (.psimsch) that we will be using is a simple buck converter: A DC – DC converter that is very common in power electronics. It lowers voltage applied to a load with respect to its input, while increasing current.

 

 

The simulation runs for 2 milliseconds and the results produced are I(L): Current passing through the inductor, I(R): Current passing through the resistor and Vout: Voltage at the voltage probe. The parameters that can be defined in the circuit are Vin: Input voltage, C: Capacitance, L: Inductance, R: Load resistance and Fsw: Switching frequency for the MOSFET. We will be working with this model throughout this guide.

 

PsimSimulate

 

Let’s start with the most basic function from this library: PsimSimulate. This command runs a single simulation with any given parameters and returns the results graph. It can be used as follows:

 

First, we define the file path to the PSIM schematic file (i.e., the circuit model) that we want to run. The way we define how the simulation is going to be run is to define a structure (in this case called input_var) which contains three fields: FilePath: The schematic file to use, GraphFilePath: Name and location of the results output and Parameters: The parameters which the simulation will be run with. The only thing that we will define at this point is the model we want to simulate.

 

Let’s also define some fixed parameters to include later, and a set of values (with linspace) that we will vary over several runs. Also note the command tic, which sets an internal clock for measuring time elapsed until execution reaches another command: toc (we’ll use it later). As we will be plotting several simulation results, let’s also create a figure and turn on options hold, grid, and legend and set up axis labels.

 

close all, clear, clc

 

% Start measuring time elapsed running script

tic;

 

% Define input .psimsch file

input_var.FilePath = '..\buck.psimsch';

 

% Fixed parameters

C = 50e-6;

Fsw = 200e3;

R = 2.5;

Vin = 120;

 

% Design parameter

Lspace = linspace(50e-6, 200e-6, 10);

 

% Create figure & format

figure; hold on, grid on, legend on

xlabel('Time [ms]');

ylabel('Output Voltage [V]');

 

A straightforward way to run several simulations of this model is to use a for loop, in which we can iterate over all the inductance values of L, keeping everything else the same. At this point, we can declare the output file GraphFilePath and the parameters to use, which are defined as a formatted string using sprintf.

 

% Run simulation with each value of L

for i = 1:numel(Lspace)

     

      L = Lspace(i);

     

      % Define output .smv graph file

      input_var.GraphFilePath = sprintf('.\\Results\\buck_L_%1.2g.smv', L);

     

      % Create parameters text for simulation

      parametersTxt = sprintf('L = %e\nC = %e\nFsw = %e\nR = %e\nVin = %e', L, C, Fsw, R, Vin);

      input_var.Parameters = parametersTxt;

 

Now we are ready to run the simulation with PsimSimulate, the only required input is the structure input_var that we set up before, and the output (simResults) is a structure with all signals written into the results (.smv) file. These results are contained under the field Graph and subfield Values which is a cell array in which each element has to be accessed using curly brackets { }.

 

      % Run PSIM simulation

      simResults = PsimSimulate(input_var);

     

      % Extract graph results

      t = simResults.Graph.Values{1};

      IL = simResults.Graph.Values{2};

      IR = simResults.Graph.Values{3};

      Vout = simResults.Graph.Values{4};

 

Finally, let’s overlay all the results in a single plot so we can visualize how parameter L affects the response. The call to toc, return the time elapsed setting up and running all these simulations. It will become relevant in the following post, for now just get an idea of how long all this took. For me, it took 0.966 seconds.

 

      % Plot & set legend with L value

      lineHandle = plot(t,Vout);

      leg = sprintf('L = %1.2e', L);

      set(lineHandle, 'displayname', leg);

     

end

 

toc

 

Let’s have a look at the results:

 

 

From this plot, we can see that a higher inductance results in less overshoot at the cost of a higher settling time. Go ahead and leverage this on your own schematics and continue to the next post so you learn how to run all these simulations concurrently!

 

Contents

Compose – PSIM Integration Starter’s Guide 1: PsimSimulate

Compose – PSIM Integration Starter’s Guide 2: PsimASimulate

Compose – PSIM Integration Starter’s Guide 3: PsimSimview, PsimWriteGraphFile, PsimReadGraphFile

Automate PSIM using Python in Altair Compose