Setting parameter values
Alias Submodel Title Name Value
coefficient of coefv 0
viscous friction
[N/(m/s)]
coefficient of wind 0
windage
[N/(m/s)**2]
coulomb coul 0
friction force
[N]
stiction force stict 0
[N]
inclination angle 0
(+90 port 1
lowest, -90
port 1 highest)
[degree]
rload01 RL00-1 shaft speed omega 4000
[rev/min]
moment of J 10
inertia
[kgm**2]
coefficient of vis 1
viscous friction
[Nm/(rev/min)]
coulomb coul 0
friction torque
[Nm]
sticition torque stict 0
[Nm]
simple_crank CRANK0-1 angular theta ANG
position of
crank [degree]
Simcenter Amesim API 2-11
© 2020 Siemens
2. Tutorial
Alias Submodel Title Name Value
radius of crank rad R
[mm]
length of length L
connecting rod
[mm]
offset for offset 0
displacement
[mm]
simple_crank_2 CRANK0-2 angular theta ANG+OFF
position of
crank [degree]
radius of crank rad R
[mm]
length of length L
connecting rod
[mm]
offset for offset 0
displacement
[mm]
spring_damper01 SD0000A-1 spring force force0 0
with both
displacements
zero [N]
spring rate srate 100000
[N/m]
damper rating cdamp 1000
[N/(m/s)]
material shear G 8.57e+10
modulus [N/
m**2]
spring sdiam 20
diameter [mm]
2-12 Simcenter Amesim API
© 2020 Siemens
Obtaining parameter and variable names
Alias Submodel Title Name Value
wire diameter wdiam 2
[mm]
spring stiffness stiffmode numerical
mode value
number of na 10
active coils
spring_damper01_2 SD0000A-2 spring force force0 0
with both
displacements
zero [N]
spring rate srate 100000
[N/m]
damper rating cdamp 1000
[N/(m/s)]
material shear G 8.57e+10
modulus [N/
m**2]
spring sdiam 20
diameter [mm]
wire diameter wdiam 2
[mm]
spring stiffness stiffmode numerical
mode value
number of na 10
active coils
2.5.1 Obtaining parameter and variable names
To obtain the name of a parameter or variable from an existing Simcenter Amesim system, right-click
and select Copy parameter path or Copy variable path:
Simcenter Amesim API 2-13
© 2020 Siemens
2. Tutorial
Figure 2-7. Copying the parameter path
Once you have selected either of these functions, you can paste the path into any text editor to display
the result:
Figure 2-8. The parameter path
Here we can see the parameter path for the parameter named stiffmode on the springdamper01. In
the code this will be used as follows when setting the parameters:
AMESetParameterValue('stiffmode@springdamper01', '1')
Note that in the case of a supercomponent, the path is as follows:
2-14 Simcenter Amesim API
© 2020 Siemens
Editing the code
x@comp1.comp2
2.5.2 Editing the code
The code which sets these parameters is quite long, but simple:
# Set parameter values
# Set 'mass_friction1port' parameters
AMESetParameterValue('v1@mass_friction1port', '0')
AMESetParameterValue('x1@mass_friction1port', '0')
AMESetParameterValue('mass@mass_friction1port', 'MASS')
AMESetParameterValue('coefv@mass_friction1port', '0')
AMESetParameterValue('wind@mass_friction1port', '0')
AMESetParameterValue('coul@mass_friction1port', '0')
AMESetParameterValue('stict@mass_friction1port', '0')
AMESetParameterValue('angle@mass_friction1port', '0')
# Set 'springdamper01' parameters
AMESetParameterValue('force0@springdamper01', '0')
AMESetParameterValue('srate@springdamper01', '1e5')
AMESetParameterValue('cdamp@springdamper01', '1e3')
AMESetParameterValue('G@springdamper01', '8.57e10')
AMESetParameterValue('sdiam@springdamper01', '20')
AMESetParameterValue('wdiam@springdamper01', '2')
AMESetParameterValue('stiffmode@springdamper01', '1')
AMESetParameterValue('na@springdamper01', '10')
# Set 'simple_crank' parameters
AMESetParameterValue('theta@simple_crank', 'ANG')
Simcenter Amesim API 2-15
© 2020 Siemens
2. Tutorial
AMESetParameterValue('rad@simple_crank', 'R')
AMESetParameterValue('length@simple_crank', 'L')
AMESetParameterValue('offset@simple_crank', '0')
# Set 'rconnector' parameters
# No parameter
# Set 'simple_crank_2' parameters
AMESetParameterValue('theta@simple_crank_2', 'ANG+OFF')
AMESetParameterValue('rad@simple_crank_2', 'R')
AMESetParameterValue('length@simple_crank_2', 'L')
AMESetParameterValue('offset@simple_crank_2', '0')
# Set 'springdamper01_2' parameters
AMESetParameterValue('force0@springdamper01_2', '0')
AMESetParameterValue('srate@springdamper01_2', '1e5')
AMESetParameterValue('cdamp@springdamper01_2', '1e3')
AMESetParameterValue('G@springdamper01_2', '8.57e10')
AMESetParameterValue('sdiam@springdamper01_2', '20')
AMESetParameterValue('wdiam@springdamper01_2', '2')
AMESetParameterValue('stiffmode@springdamper01_2', '1')
AMESetParameterValue('na@springdamper01_2', '10')
# Set 'rload01' parameters
AMESetParameterValue('omega@rload01', '4000')
AMESetParameterValue('J@rload01', '10')
AMESetParameterValue('vis@rload01', '1')
AMESetParameterValue('coul@rload01', '0')
AMESetParameterValue('stict@rload01', '0')
# Set 'mass_friction1port_2' parameters
AMESetParameterValue('v1@mass_friction1port_2', '0')
AMESetParameterValue('x1@mass_friction1port_2', '0')
AMESetParameterValue('mass@mass_friction1port_2', 'MASS')
AMESetParameterValue('coefv@mass_friction1port_2', '0')
AMESetParameterValue('wind@mass_friction1port_2', '0')
AMESetParameterValue('coul@mass_friction1port_2', '0')
AMESetParameterValue('stict@mass_friction1port_2', '0')
AMESetParameterValue('angle@mass_friction1port_2', '0')
Copy and paste this code into your tutorial_step_2.py file and run the script. If you open your model in
Simcenter Amesim you will see that the parameter values have been assigned to the submodels:
2-16 Simcenter Amesim API
© 2020 Siemens
Creating global parameters
Figure 2-9. Parameter values assigned
You will have noticed that some of the parameter values are not numerical values, but text: MASS, ANG,
OFF, R, L. These are Global parameters. Global parameters are commonly used in Simcenter Amesim
when several parameters need the same value. Moreover, MASS is highlighted in red, as the MASS
Global Parameter does not yet exist.
The next step is to create these Global parameters.
2.6 Creating global parameters
Global parameters are created using the function AMEAddGlobalParameter. You should consult the
documentation for this function by typing help (‘AMEAddGlobalParameter’).
We will create the following Global parameters:
Simcenter Amesim API 2-17
© 2020 Siemens
2. Tutorial
Name Title Value Unit
MASS mass of piston 0.5 kg
BORE bore of piston 60 mm
R radius of crank 30 mm
ANG initial angular position of crank 30 degree
OFF difference in piston angles 180 degree
L length of connecting rod 40 mm
We suggest you set meaningful default, minimum and maximum values for your Global parameters,
according to usage type.
Add the code to your script:
# Set Global parameter values
AMEAddGlobalParameter('MASS', 'mass of piston', 'ame_real_parameter', '0.5',
'0.1', '0.5', '2', 'kg')
AMEAddGlobalParameter('BORE', 'bore of piston', 'ame_real_parameter', '60',
'20', '60', '100', 'mm')
AMEAddGlobalParameter('R', 'radius of crank', 'ame_real_parameter', '30',
'10', '30', '50', 'mm')
AMEAddGlobalParameter('ANG', 'initial angular position of piston 1',
'ame_real_parameter', '0', '0', '0', '360', 'degree')
AMEAddGlobalParameter('OFF', 'difference in piston angles',
'ame_real_parameter', '180', '0', '0', '360', 'degree')
AMEAddGlobalParameter('L', 'length of connecting rod', 'ame_real_parameter',
'40', '25', '40', '110', 'mm')
Launch your script and then open the circuit in Simcenter Amesim. Switch to Parameter mode and
check the parameter values and Global parameter values you created:
2-18 Simcenter Amesim API
© 2020 Siemens
Creating global parameters
Figure 2-10. Global Parameters set for a component
You will observe that MASS now appears in black as the global parameter now exists.
Figure 2-11. Global Parameters
Simcenter Amesim API 2-19
© 2020 Siemens
2. Tutorial
2.7 Creating supercomponents
In this section we demonstrate how to create supercomponents with the Circuit API. To do this, we will
use the circuit built in the previous sections, and show how to create supercomponents within that
circuit.
The following Python script produces the supercomponents shown in the figure below.
AMECreateSupercomponent(('mass_friction1port', 'springdamper01'),
'left_piston', 'left_piston_alias', 'LEFT_PISTON', 'duplicate')
AMECreateSupercomponent(('mass_friction1port_2', 'springdamper01_2'),
'right_piston', 'right_piston_alias', 'RIGHT_PISTON', 'keep')
AMECreateSupercomponent(('simple_crank', 'simple_crank_2', 'rconnector'),
'rot_to_linear', 'rot_to_linear_alias', 'ROT_TO_LINEAR', 'replace')
AMECreateSupercomponent(('rload01',), 'rotational_src',
'rotational_src_alias', 'ROTATION_SRC')
Add the code to your script.
2-20 Simcenter Amesim API
© 2020 Siemens