How to define an advanced multi-simulation (with user-defined input and output)?

The multi-simulation workflow of MANATEE allows the user to select several Output variables to be tracked, and study the effect of the Input variables on these response variables. To achieve this, MANATEE creates a configuration matrix named Xconf that contains the selected Input and Output values at every simulation step.

In this case, the tracked Input and Output variables must be in the default Input and Output structures, which forbids the use of user-defined variables. To get around this, one need to define a pre-processing script for Input (resp. a post-processing script) to be run at the begining (resp. at the end) of every simulation step.

Pre-processing for user-defined Input

To activate this option, you only need to add the name of the .m file script to your project:

Input.Simu.pre_filename = 'my_script';

When running a multi-simulation, MANATEE creates for each simulation a new machine structure with modified Input variables. After this step, if a pre-processing file is defined, it is run before running MANATEE multiphysic models.

For instance, let’s say that you want to study the impact of the stator slot dimension on the acoustic noise (by scaling the complete slot shape). Slot dimensions are usually defined by several parameters that should evolve together, so here you can use the pre-processing script feature to automatically scale your slot:

Input.Simu.type_sensitivity = 1;
Input.Simu.names_var={'W0s'}; % slot opening default Input variable
Input.Simu.pre_filename = 'scale_slot'; %pre-processing script name
Input.Simu.bds_contvar={[10e-3, 15e-3]};

The scale_slot mfile contains the following:

%Scaling factor (12 mm is the current value of slot opening W0s)
alpha = Input.Geometry.W0s / 12e-3;

Input.Geometry.H0s = 1e-3*alpha;            %scaling heights
Input.Geometry.H1s = 1.5e-3*alpha;         %scaling heights  
Input.Geometry.H2s = 30e-3*alpha;          %scaling heights

Input.Geometry.W1s = 14e-3*alpha;         %scaling widths
Input.Geometry.W2s = 12e-3*alpha;          %scaling widths

To check the scaling, we add an Input.Simu.SS_post_filename to call the plot_machine post processing:

20. Slot scalling (simulation n°1 vs simulation n°10)
Slot scalling (simulation n°1 vs simulation n°10)

Post-processing for user-defined Output

The Input.Simu.SS_post_filename script is run before assigning the configuration matrix, so any new variable defined in this script is then accessible in the multi-simulation outputs.

There are two rules to follow when adding a user-defined variable in the Output structure :

  1. The variable must be set in Output.Post (to separate the user define variable from the MANATEE one)
  2. The variable name must be unique inside the whole Output structure to avoid conflict with the existing MANATEE variables.

This template of post processing script (in PostProcessing folder) exacts the magnitude of the 2-th harmonic (2 times the electrical frequency), 2-th wavenumber (elliptical waveform) of the radial magnetic force:

%% loading useful inputs from Input and Output structures
XPradwr=Output.Mechanics.XPradwr;           % FFT of radial magnetic forces, already calculated in MANATEE
orders_circ=Output.Mechanics.orders_circ;   % corresponding space frequencies (circumferential wavenumbers of the force waves)
freqs=Output.Mechanics.freqs;               % corresponding time frequencies (electrical frequencies of the force waves) [Hz]
freq0=Output.Electrical.freq0;              % fundamental electrical frequency [Hz]

%% making calculations
[~,I2n]=find(orders_circ==-2);  %finding wavenumber 2 index
[~,J2]=min(abs(freqs-2*freq0)); %finding 2f index

Frad22=abs(XPradwr(J2,I2n));    %taking magnitude

%% saving post processings the Output structure

You now can select Frad22 as an output of the multi-simulation with

Previous Next