Manage Model Fidelity Using Variants
This example shows how to compare and contrast modeling different fidelity levels by using variants. The controller model uses a Variant Source block configured in Expression mode. The plant model uses a Variant Subsystem.
To permit easy interaction, this example demonstrates the commands you must type to configure the model from the command line.
Create variant controls for the converter controller. The controller has three different levels of fidelity: Averaged, AveragedPulse, and Pulse.
Averaged = Simulink.Variant; Averaged.Condition = 'fidelity==ee_fidelity_variants_enum.Low';
AveragedPulse = Simulink.Variant; AveragedPulse.Condition = 'fidelity==ee_fidelity_variants_enum.Medium';
Pulse = Simulink.Variant; Pulse.Condition = 'fidelity==ee_fidelity_variants_enum.High';
Create variant controls for the converter plant. The plant has two different levels of fidelity.
AveragedSwitch = Simulink.Variant; AveragedSwitch.Condition = 'fidelity==ee_fidelity_variants_enum.Low || fidelity==ee_fidelity_variants_enum.Medium';
IdealSwitch = Simulink.Variant; IdealSwitch.Condition = 'fidelity==ee_fidelity_variants_enum.High';
Averaged Control Output, Averaged Switch Converter
Configure the model to run in low fidelity with a timestep of 100us.
fidelity = ee_fidelity_variants_enum.Low; Ts = 1e-4;
Averaged Pulse Control Output, Averaged Switch Converter
Configure the model to run in medium fidelity with a timestep of 50us.
fidelity = ee_fidelity_variants_enum.Medium; Ts = 5e-5;
Pulse Control Output, Ideal Switch Converter
Configure the model to run in high fidelity with a timestep of 10us.
fidelity = ee_fidelity_variants_enum.High; Ts = 1e-5;
Results from Real-Time Simulation
This example, with level of fidelity set to Low and Medium, has been tested on a Speedgoat Performance real-time target machine with an Intel® 3.5 GHz i7 multi-core CPU. This model can run in real time with a step size of 50 microseconds.