- Make sure the fields where you have defined the parameter are configured to be run-time parameters. The setting is shown below.
- 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.
Nonlinear damper parameter sweep problem
조회 수: 4 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Steve Miller
2022년 11월 22일
Hi Tudor,
Two things to try:
--Steve
댓글 수: 5
Steve Miller
2022년 11월 24일
There certainly is. I would have used your code but it doesn't run because many of the values at the start are unassigned. The code you provided should from line fvhb=fvb(fkb:end); should appear in the for-loop that creates the simInput object. As long as the for-loop indexes through the variables you wish to modify and the calculated force and velocity vectors are assigned to the simInput object using setVariable, it will work.
If you are going to vary multiple parameters, you will need nested for loops.
I recommend you set up the code that generates the force-velocity relationships for nonlinear damping all set up first, and plot the damper curves on top of another to make sure your parameterization is set up correctly before trying to run the sweep. If you get that code set up so that it plots all the damper curves, I can help you set up the sweep.
--Steve
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!