Nonlinear damper parameter sweep problem

1 view (last 30 days)
I’m simulating a multibody vehicle model. Within this model I’m using nonlinear dampers – damper subsystem reads the damper velocity vector and damper force vector from base workspace. Force and velocity vectors are defined via live script which uses base workspace variables for “low speed” compression damping, “high speed” compression damping, blow off velocity (damper velocity at which it “switches” to “high speed” damping curve etc.
%Variables that I want to change/sweep in an automated design stady
fdlb; % Bump/Compression Low speed damping rate
fdhb; % Bump/Compression High speed damping rate
fdlr; % Rebound Low speed damping rate
fdhr; % Rebound High speed damping rate
fkb; % Bump/Compression High/Low speed cutoff coefficient (number of velocity vector component)
fkr; % Rebound High/Low speed cutoff coefficient
fvb=0:0.025:0.3; % Bump/Compression velocity (positive) vector
fvr=-0.3:0.025:0; % Rebound velocity (negative) vector
fvhb=fvb(fkb:end); % Bump/Compression High Speed velocity vector
fvlr=fvr(fkr:end); % Rebound Low Speed velocity vector
fvhr=fvr(1:fkr); % Rebound High Speed velocity vector
fDbl=fvlb*fdlb; % Bump/Compression Low Speed damping forces
fDbhi=fvhb*fdhb; % Bump/Compression High Speed damping forces (starting from zero)
fDeltab=fDbl(end)-fDbhi(1); % Delta at kb (cutoff velocity)
fDbh=fvhb*fdhb+fDeltab; % Bump/Compression High Speed damping forces
fDrl=fvlr*fdlr; % Rebound Low Speed damping forces
fDrhi=fvhr*fdhr; % Rebound High Speed damping forces (starting from zero)
fDeltar=fDrl(1)-fDrhi(end); % Delta at kr (cutoff velocity)
fDrh=fvhr*fdhr+fDeltar; % Rebound High Speed damping forces
% Front Damper force and velocity vectors
F_vDamper=[fvr,fvb(2:end)]
F_fDamper=[fDrh,fDrl(2:end),fDbl(2:end),fDbh(2:end)]
% assigning vectors to workspace variables that simulink non linear
% damper will use for velocity and force vectors
Damper.NonLinear.Faxle.vDamper.Value=F_vDamper;
Damper.NonLinear.Faxle.fDamper.Value=F_fDamper;
In the Model Callbacks (InitFcn) I call this above-mentioned Live script to update damping force and velocity vectors according to current values (base workspace) of above-mentioned variables.
My problem is that I can’t figure out how I can do damping parameter sweeps… i.e. how can I set up the model so that it runs multiple simulations and changes damping related variables (base workspace) according to some predefined list. It works fine if I would be changing/sweeping any of model block parameters or variables that are mentioned within block. In this particular case it’s an array with values calculated via script. If I setup design study from multiple simulations panel – it doesn’t effect variables in base workspace that would effect the script that calculates required vectors.
I’ve tried to use matlab function that would use this script to create required vectors and assign it to base (or model) workspace but it doesn’t work or better say I don’t know how to do it properly.
Any suggestions would be very highly appreciated.
Thank you.
Ted

Accepted Answer

Steve Miller
Steve Miller on 22 Nov 2022
Hi Tudor,
Two things to try:
  1. Make sure the fields where you have defined the parameter are configured to be run-time parameters. The setting is shown below.
  2. To reduce the complexity a bit, try storing the values you are sweeping in a separate MATLAB variable, just to see if that works. Enter F_vDamper and F_fDamper directly in the fields. This is not required, but it eliminates some complexity to figure out what is not working.
--Steve
  5 Comments
Tudor Miron
Tudor Miron on 24 Nov 2022
Edited: Tudor Miron on 24 Nov 2022
Let me once again say: Thank you for your help!
Here's a code that seem to be working (it does plot expected damper curves).
fdlb=18000; % Bump/Compression Low speed damping coefficient
fdhb=8000; % Bump/Compression High speed damping coefficient
fdlr=12000; % Rebound Low speed damping coefficient
fdhr=5000; % Rebound High speed damping coefficient
fvb=0:0.025:0.3; % Bump/Compression velocity (positive) vector
fvr=-0.3:0.025:0; % Rebound velocity (negative) vector
fkb=4; % Bump/Compression High/Low speed cutoff coefficient (number of velocity vector component)
fkr=10; % Rebound High/Low speed cutoff coefficient
fkb_sweep=[4 5 6];
for i = 1:length(fkb_sweep)
fvlb=fvb(1:fkb_sweep(i)); % Bump/Compression Low Speed velocity vector
fvhb=fvb(fkb_sweep(i):end); % Bump/Compression High Speed velocity vector
fvlr=fvr(fkr:end); % Rebound Low Speed velocity vector
fvhr=fvr(1:fkr); % Rebound High Speed velocity vector
fDbl=fvlb*fdlb; % Bump/Compression Low Speed damping forces
fDbhi=fvhb*fdhb; % Bump/Compression High Speed damping forces (starting from zero)
fDeltab=fDbl(end)-fDbhi(1); % Delta at kb (cutoff velocity)
fDbh=fvhb*fdhb+fDeltab; % Bump/Compression High Speed damping forces
fDrl=fvlr*fdlr; % Rebound Low Speed damping forces
fDrhi=fvhr*fdhr; % Rebound High Speed damping forces (starting from zero)
fDeltar=fDrl(1)-fDrhi(end); % Delta at kr (cutoff velocity)
fDrh=fvhr*fdhr+fDeltar; % Rebound High Speed damping forces
F_vDamper=[fvr,fvb(2:end)];
F_fDamper=[fDrh,fDrl(2:end),fDbl(2:end),fDbh(2:end)];
plot(F_vDamper,F_fDamper)
hold on
grid on
xlim([-0.3 0.3])
ylim([-4000 4000])
xlabel('Velocity [m/s]')
ylabel('Force [N]')
title('Front Force vs Velocity')
end
hold off
Below is the code where I want to alter 2 variables (fkb and fkr for example).
fdlb=18000; % Bump/Compression Low speed damping coefficient
fdhb=8000; % Bump/Compression High speed damping coefficient
fdlr=12000; % Rebound Low speed damping coefficient
fdhr=5000; % Rebound High speed damping coefficient
fvb=0:0.025:0.3; % Bump/Compression velocity (positive) vector
fvr=-0.3:0.025:0; % Rebound velocity (negative) vector
fkb=4; % Bump/Compression High/Low speed cutoff coefficient (number of velocity vector component)
fkr=10; % Rebound High/Low speed cutoff coefficient
fkb_sweep=[4 5 6];
fkr_sweep=[8 9 10];
% Store simulation inputs
for i = 1:length(fkb_sweep)
for idx=1:length(fkr_sweep)
fvlb=fvb(1:fkb_sweep(i)); % Bump/Compression Low Speed velocity vector
fvhb=fvb(fkb_sweep(i):end); % Bump/Compression High Speed velocity vector
fvlr=fvr(fkr_sweep(idx):end); % Rebound Low Speed velocity vector
fvhr=fvr(1:fkr_sweep(idx)); % Rebound High Speed velocity vector
fDbl=fvlb*fdlb; % Bump/Compression Low Speed damping forces
fDbhi=fvhb*fdhb; % Bump/Compression High Speed damping forces (starting from zero)
fDeltab=fDbl(end)-fDbhi(1); % Delta at kb (cutoff velocity)
fDbh=fvhb*fdhb+fDeltab; % Bump/Compression High Speed damping forces
fDrl=fvlr*fdlr; % Rebound Low Speed damping forces
fDrhi=fvhr*fdhr; % Rebound High Speed damping forces (starting from zero)
fDeltar=fDrl(1)-fDrhi(end); % Delta at kr (cutoff velocity)
fDrh=fvhr*fdhr+fDeltar; % Rebound High Speed damping forces
F_vDamper=[fvr,fvb(2:end)];
F_fDamper=[fDrh,fDrl(2:end),fDbl(2:end),fDbh(2:end)]
plot(F_vDamper,F_fDamper)
end
hold on
grid on
xlim([-0.3 0.3])
ylim([-4000 4000])
xlabel('Velocity [m/s]')
ylabel('Force [N]')
title('Front Force vs Velocity')
end
F_fDamper = 1×25
1.0e+03 * -2.3750 -2.2500 -2.1250 -2.0000 -1.8750 -1.7500 -1.6250 -1.5000 -1.2000 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.5500 1.7500 1.9500 2.1500 2.3500 2.5500 2.7500 2.9500 3.1500
F_fDamper = 1×25
1.0e+03 * -2.2000 -2.0750 -1.9500 -1.8250 -1.7000 -1.5750 -1.4500 -1.3250 -1.2000 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.5500 1.7500 1.9500 2.1500 2.3500 2.5500 2.7500 2.9500 3.1500
F_fDamper = 1×25
1.0e+03 * -2.0250 -1.9000 -1.7750 -1.6500 -1.5250 -1.4000 -1.2750 -1.1500 -1.0250 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.5500 1.7500 1.9500 2.1500 2.3500 2.5500 2.7500 2.9500 3.1500
F_fDamper = 1×25
1.0e+03 * -2.3750 -2.2500 -2.1250 -2.0000 -1.8750 -1.7500 -1.6250 -1.5000 -1.2000 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000 3.2000 3.4000
F_fDamper = 1×25
1.0e+03 * -2.2000 -2.0750 -1.9500 -1.8250 -1.7000 -1.5750 -1.4500 -1.3250 -1.2000 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000 3.2000 3.4000
F_fDamper = 1×25
1.0e+03 * -2.0250 -1.9000 -1.7750 -1.6500 -1.5250 -1.4000 -1.2750 -1.1500 -1.0250 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000 3.2000 3.4000
F_fDamper = 1×25
1.0e+03 * -2.3750 -2.2500 -2.1250 -2.0000 -1.8750 -1.7500 -1.6250 -1.5000 -1.2000 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.8000 2.2500 2.4500 2.6500 2.8500 3.0500 3.2500 3.4500 3.6500
F_fDamper = 1×25
1.0e+03 * -2.2000 -2.0750 -1.9500 -1.8250 -1.7000 -1.5750 -1.4500 -1.3250 -1.2000 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.8000 2.2500 2.4500 2.6500 2.8500 3.0500 3.2500 3.4500 3.6500
F_fDamper = 1×25
1.0e+03 * -2.0250 -1.9000 -1.7750 -1.6500 -1.5250 -1.4000 -1.2750 -1.1500 -1.0250 -0.9000 -0.6000 -0.3000 0 0.4500 0.9000 1.3500 1.8000 2.2500 2.4500 2.6500 2.8500 3.0500 3.2500 3.4500 3.6500
hold off
It would be extremely helpful if you could help me setup the sweep properly.
Thank you,
Ted

Sign in to comment.

More Answers (1)

Tudor Miron
Tudor Miron on 26 Nov 2022
I have no problem creating Simulation Input object if I want to sweep 1 variable (code from the 1st half of the above post/comment):
fdlb=18000; % Bump/Compression Low speed damping coefficient
fdhb=8000; % Bump/Compression High speed damping coefficient
fdlr=12000; % Rebound Low speed damping coefficient
fdhr=5000; % Rebound High speed damping coefficient
fvb=0:0.025:0.3; % Bump/Compression velocity (positive) vector
fvr=-0.3:0.025:0; % Rebound velocity (negative) vector
fkb=4; % Bump/Compression High/Low speed cutoff coefficient (number of velocity vector component)
fkr=10; % Rebound High/Low speed cutoff coefficient
fkb_sweep=[4 5 6];
mdl = 'FullVehicleAssembly_v3_6_1';
clear simIn
for i = 1:length(fkb_sweep)
simIn(i) = Simulink.SimulationInput(mdl);
fvlb=fvb(1:fkb_sweep(i)); % Bump/Compression Low Speed velocity vector
fvhb=fvb(fkb_sweep(i):end); % Bump/Compression High Speed velocity vector
fvlr=fvr(fkr:end); % Rebound Low Speed velocity vector
fvhr=fvr(1:fkr); % Rebound High Speed velocity vector
fDbl=fvlb*fdlb; % Bump/Compression Low Speed damping forces
fDbhi=fvhb*fdhb; % Bump/Compression High Speed damping forces (starting from zero)
fDeltab=fDbl(end)-fDbhi(1); % Delta at kb (cutoff velocity)
fDbh=fvhb*fdhb+fDeltab; % Bump/Compression High Speed damping forces
fDrl=fvlr*fdlr; % Rebound Low Speed damping forces
fDrhi=fvhr*fdhr; % Rebound High Speed damping forces (starting from zero)
fDeltar=fDrl(1)-fDrhi(end); % Delta at kr (cutoff velocity)
fDrh=fvhr*fdhr+fDeltar; % Rebound High Speed damping forces
F_vDamper=[fvr,fvb(2:end)];
F_fDamper=[fDrh,fDrl(2:end),fDbl(2:end),fDbh(2:end)];
simIn(i) = simIn(i).setVariable('F_vDamper',F_vDamper);
simIn(i) = simIn(i).setVariable('F_fDamper',F_fDamper);
plot(F_vDamper,F_fDamper)
hold on
grid on
xlim([-0.3 0.3])
ylim([-4000 4000])
xlabel('Velocity [m/s]')
ylabel('Force [N]')
title('Front Force vs Velocity')
end
hold off
simOut = [];
simOut = sim(simIn,'ShowProgress','off','UseFastRestart','on');
It does output 1X3 SimulationInput object. When I check it out - each (1,1;1,2 etc) simIn has proper F_fDamper value. Model runs fine. BUT when I check the results - damper forces are unchanged. I run the model over 50mm bump to make sure that high damper velocities are produced. It does use Simin(1,1) variable thought as can be seen from scatter plot (force vs velocity). Both velocity and force vector of nonlinear damper are set as "Run-time". I'm really lost what may go wrong... May I ask if can suggest what may be wrong?
And I can't figure out how can I create 1X9 SimulationInput object - code from 2nd half of the above post/comment.
Thank you,
Ted
  1 Comment
Tudor Miron
Tudor Miron on 27 Nov 2022
Interestingly enough removing 'UseFastRestart' solved the problem and now it does iterate through damping settings variants that are created in SimulationInput object.
Now if I could figure out how do I properly setup nested for loop when I want to alter more than one variable...

Sign in to comment.

Categories

Find more on Manual Performance Optimization in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!