AmesimKnowledge

Using the Simulink to Simcenter Amesim Interface > Tutorials

One-level voltage source

Model presentation

The following diagram represents the one-level voltage source we intend to model with a Simulink block diagram and to export to Simcenter Amesim.

Figure 83: One-level voltage source

This model requires 3 input and 2 output ports. The currents [A] are input at ports 1 and 2. A dimensionless control signal [null] is input at port 3. V1 [V] and V2 [V] are computed by the model and output signals at ports 1 and 2.

The transistor model is represented using a variable resistor:

  • If control = 0, R is set to 1e8 Ohm

  • If control != 0, R is set to Rt

Two very small 'virtual' capacitors C1 and C2 have been added to the circuit for numerical reasons. This makes it possible to compute the derivative of the voltages at port 1 and 2.

The equations used are presented below:

The voltages V1 and V2 are state variables. They are computed from their derivative with respect to time as:

The corresponding Simulink model is presented in the following block diagram:

The Simcenter Amesim model is named voltage_source_and_DC.ame. The model parameters have been defined using global parameters from the MATLAB workspace:

Where:

  • [V] ' voltage source Vs

  • Rs [Ohm] ' source resistor

  • Rd [Ohm] ' extinction resistor

  • Rt [Ohm] ' transistor resistor

  • Vz [V] ' Zener diode extinction voltage

  • C1 [F] ' first virtual capacitor

  • C2 [F] ' second virtual capacitor

The model also requires two initial conditions for the voltage state variables (V10 and V20).

On the Simulink block diagram, the input blocks are green and the output blocks are blue.

The blocks using global parameters from the workspace are red. In order to load these global parameters into the MATLAB workspace an M-script is created (voltage_source_initialization.m).

This m-file should be run before SL2AMECosim.

Code export from Simulink to Simcenter Amesim

The following steps enable you to export the Simulink block diagram of the one-level voltage source to Simcenter Amesim.

Procedure

  1. Get the voltage_source_and_DC.ame model, available in through Help > Get demo in the Platform > MiLSiLRealTime > MiLSiL > SimulinkAmesim folder. This model is available from the VoltageSource.pck pack file:

    This gives access to the voltage_source.mdl model and the voltage_source_initialization.m files.

  2. Within MATLAB, run the voltage_source_initialization.m script in order to load the global parameters in the MATLAB workspace.

  3. Open the voltage_source.slx model, click on the Simulation menu and choose Configuration parameters.

  4. Select Optimization, tick the Inline parameters box and click on the Configure button.

    Figure 84: Configure button

  5. Add the workspace variables to the global parameters table.

  6. Save the Simulink model.

  7. In the MATLAB command window, type: Copysl2amecosim('voltage_source','c:\AMETest\libsl2ame','auto');where C:\AMETest\libsl2ame is the directory where you intend to save the SL2AMECosim category.

  8. The model export is now completed and a new submodel VOLTAGE_SOURCE should be available in the libsl2ame category. Add this new category to the Simcenter Amesim path list.

  9. Now you can use and test the voltage source model by connecting it to a DC motor built with the signal and mechanical libraries (voltage_source_and_DC.ame)

    The parameters and the variables of the exported submodel are presented below.

Results

The validation of the exported model can be done through direct comparison with an equivalent model built in Simulink or Simcenter Amesim. The following comparison has been made using the voltage_source_and_DC_vs_EMD.ame model, available in the Simcenter Amesim Infrastructure > Interfaces > SimulinkAmesim folder.

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Simulink/Onelevel_voltage_source · retrieved 2026-07-17