A common question when running models in SPS Software is whether it is possible to tune parameters on the fly without stopping the simulation.
Here is how SPS Software handles parameter changes and how you can automate multiple scenarios using MATLAB® scripts.
General Rule: Re-initialization
Each time you change a parameter of an SPS Software library block (like a resistance, inductance, or machine inertia), you generally have to restart the simulation. This is because the software needs to re-evaluate the state-space model and update the matrices for the linear and nonlinear parts of your circuit during the initialization phase.
The Exception: Source Parameters
You can change the parameters of electrical sources during the simulation!
If you modify the Magnitude, Frequency, or Phase of an AC or DC source block, the modification takes place immediately as soon as you click Apply or close the block menu. This is great for manually testing voltage dips or frequency variations on the fly.
Pro-Tip: Automating Parametric Studies
If you need to test multiple values for a passive component (like finding the worst-case scenario for an inductor), you don’t need to change it manually and click “Run” every single time.
You can enter a MATLAB variable (e.g., L1) in the block’s parameter dialog instead of a fixed number, and use a script to loop through the simulation.
Example: Finding the worst-case overvoltage
Suppose you have a model named my_circuit and you want to test an inductance (L1) from 10mH to 100mH to see which value causes the highest overvoltage (V1).
Here is a clean MATLAB script you can use to automate this parametric study:
% 1. Define the range of values to test (10 mH to 100 mH in 10 steps)
L1_vec = (10:10:100) * 1e-3;
% 2. Initialize the maximum voltage tracker
V1_max = 0;
% 3. Loop through each value
for i = 1:10
% Assign the current value to the workspace variable used in the block
L1 = L1_vec(i);
fprintf('Test No %d: L1 = %g H\n', i, L1);
% Run the simulation
sim('my_circuit');
% Memorize the worst case (assuming V1 is saved to the workspace via ToWorkspace block)
if max(abs(V1)) > V1_max
imax = i;
V1_max = max(abs(V1));
end
end
% 4. Display the final result
fprintf('Maximum overvoltage %g V occurred for L1 = %g H\n', V1_max, L1_vec(imax));
This approach saves you hours of manual work and ensures you never miss a critical operational point in your design!