0% found this document useful (0 votes)
34 views10 pages

Build Simcenter Amesim Circuit Tutorial

This tutorial guides users through building a Simcenter Amesim circuit from scratch using Python scripting. It covers creating a new circuit, adding components with specific positions and rotations, setting submodels, connecting components, and assigning parameter values. The tutorial emphasizes the use of various API functions to manipulate the circuit effectively.

Uploaded by

472063269
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views10 pages

Build Simcenter Amesim Circuit Tutorial

This tutorial guides users through building a Simcenter Amesim circuit from scratch using Python scripting. It covers creating a new circuit, adding components with specific positions and rotations, setting submodels, connecting components, and assigning parameter values. The tutorial emphasizes the use of various API functions to manipulate the circuit effectively.

Uploaded by

472063269
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

2.

Tutorial
In this tutorial, we will build an Simcenter Amesim circuit from scratch.

We will start by creating a new file named tutorial_step_2.py, containing the following lines:

AMEInitAPI(False)
AMECreateCircuit('FlatTwin')
AMECloseCircuit(True)
AMECloseAPI()

Note:
Adding (True) to the AMECloseCircuit line enables the circuit to be saved before it is closed. It
would also be possible to insert AMESaveCircuit before AMECloseCircuit to achieve the same
result in two steps.

2.1 Creating the system


The file shown previously will create a new system by calling the AMECreateCircuit function. It then
saves and closes it by calling the AMECloseCircuit function. You can check the details of these two
functions using the help command in a Python Command Interpreter.

Execute the script. It creates an empty Simcenter Amesim file named [Link]. You can open it in
Simcenter Amesim:

Simcenter Amesim API 2-1


© 2020 Siemens
2. Tutorial

Figure 2-1. The empty system in Simcenter Amesim

Note:
You can change the working directory for your model using in the Python Command Interpreter as
follows:

>>> import os
>> [Link]('D:/AMETest')

The above example would change the working directory to ‘AMETest’ on the ‘D’ drive.
You can check your current working directory as follows:

>>> [Link]()

2.2 Adding components to the system


We will now add components to the sketch using the AMEAddComponent function. We could add the
components to the sketch without giving them any geometrical details, but since we will open the

2-2 Simcenter Amesim API


© 2020 Siemens
Adding components to the system

created sketch in Simcenter Amesim, we do not want to create an ugly sketch so we will provide the
component positions and rotation details.

• Components are rotated using AMERotateComponent

• Components are moved using AMEMoveComponent.

Insert the following lines after the command that creates the circuit and before the command that
closes the circuit:

# Add components

# Add "mass_friction1port" component


AMEAddComponent('mass_friction1port', 'mass_friction1port',
(40, 99))

# Add "springdamper01" component


AMEAddComponent('springdamper01', 'springdamper01')

# Rotate and flip the component


AMERotateComponent('springdamper01')
AMEMoveComponent('springdamper01', (89, 99))

# Add "simple_crank" component


AMEAddComponent('simple_crank', 'simple_crank')

# Rotate and flip the component


AMERotateComponent('simple_crank')
AMEFlipComponent('simple_crank')
AMEMoveComponent('simple_crank', (138, 103))

# Add "rconnector" component


AMEAddComponent('rconnector', 'rconnector')

# Rotate and flip the component


AMERotateComponent('rconnector', 2)
AMEMoveComponent('rconnector', (176, 149))

# Add "simple_crank_2" component


AMEAddComponent('simple_crank', 'simple_crank_2')

# Rotate and flip the component


AMERotateComponent('simple_crank_2')
AMEMoveComponent('simple_crank_2', (229, 103))

# Add "springdamper01_2" component


AMEAddComponent('springdamper01',
'springdamper01_2')

Simcenter Amesim API 2-3


© 2020 Siemens
2. Tutorial

# Rotate and flip the component


AMERotateComponent('springdamper01_2')
AMEMoveComponent('springdamper01_2', (287, 99))

# Add "rload01" component


AMEAddComponent('rload01', 'rload01')

# Rotate and flip the component


AMERotateComponent('rload01')
AMEMoveComponent('rload01', (187, 174))

# Add "mass_friction1port_2" component


AMEAddComponent('mass_friction1port',
'mass_friction1port_2')

# Rotate and flip the component


AMERotateComponent('mass_friction1port_2', 2)
AMEMoveComponent('mass_friction1port_2', (336,
99))

Here, the first argument of AMEAddComponent is the component icon name.

# Add "mass_friction1port" component


AMEAddComponent('mass_friction1port','mass_friction1port', (40, 99))

You can obtain component names as follows:

1. Locate the component you require.

2. Right-click the component and select Help.

Figure 2-2. Obtaining a component name

The icon is named mass_friction1port. The submodel it is compatible with is MAS003.

2-4 Simcenter Amesim API


© 2020 Siemens
Setting submodels

Note also that when adding a component to a circuit, we must give it a name (the second argument in
the function) that is unique in the entire circuit. If you try to use the same name twice, you will get an
error. This name identifies the component.

Launch your script. It produces the [Link] system, now containing the components specified.

Open the system in Simcenter Amesim again:

Figure 2-3. The updated system in Simcenter Amesim

All the components are in reverse video as their submodels have not been set, and they therefore
cannot be connected.

2.3 Setting submodels


You use the AMEChangeSubmodel command to set component submodels. Add the following lines to
your script to set the submodels:

Simcenter Amesim API 2-5


© 2020 Siemens
2. Tutorial

# Set submodels

# Set "MAS003" submodel to "mass_friction1port" component


AMEChangeSubmodel('mass_friction1port', 'MAS003', '$AME/libmec/
submodels')

# Set "SD0000A" submodel to "springdamper01" component


AMEChangeSubmodel('springdamper01', 'SD0000A', '$AME/libmec/submodels')

# Set "CRANK0" submodel to "simple_crank" component


AMEChangeSubmodel('simple_crank', 'CRANK0', '$AME/libmec/submodels')

# Set "RCON00" submodel to "rconnector" component


AMEChangeSubmodel('rconnector', 'RCON00', '$AME/libmec/submodels')

# Set "CRANK0" submodel to "simple_crank_2" component


AMEChangeSubmodel('simple_crank_2', 'CRANK0', '$AME/libmec/submodels')

# Set "SD0000A" submodel to "springdamper01_2" component


AMEChangeSubmodel('springdamper01_2', 'SD0000A', '$AME/libmec/submodels')

# Set "RL00" submodel to "rload01" component


AMEChangeSubmodel('rload01', 'RL00', '$AME/libmec/submodels')

# Set "MAS003" submodel to "mass_friction1port_2" component


AMEChangeSubmodel('mass_friction1port_2', 'MAS003', '$AME/libmec/
submodels')

Launch your script and then open the circuit produced in Simcenter Amesim. Right-click and select
Labels > Show component labels:

2-6 Simcenter Amesim API


© 2020 Siemens
Connecting components

Figure 2-4. The circuit with submodels set

Again, all the components are in reverse video, this time because the components are not yet
connected.

2.4 Connecting components


In order to connect two components, you require the port numbers. To obtain the port numbers, right-
click a component and select External variables:

Simcenter Amesim API 2-7


© 2020 Siemens
2. Tutorial

Figure 2-5. External Variables

Here we can see the component port numbers. However, when you connect the ports using the script,
you require the port indexes. The conversion to obtain the indexes is port index = port number -1.

Modify your script to perform the connection by adding the following lines:

# Do connections

# Connect "mass_friction1port" and "springdamper01"


AMEConnectTwoPorts('mass_friction1port', 0, 'springdamper01', 0)

# Connect "springdamper01" and "simple_crank"


AMEConnectTwoPorts('springdamper01', 1, 'simple_crank', 1)

# Connect "simple_crank" and "rconnector"


AMEConnectTwoPorts('simple_crank', 0, 'rconnector', 1)

# Connect "rconnector" and "simple_crank_2"

2-8 Simcenter Amesim API


© 2020 Siemens
Connecting components

AMEConnectTwoPorts('rconnector', 0, 'simple_crank_2', 0)

# Connect "rconnector" and "rload01"


AMEConnectTwoPorts('rconnector', 2, 'rload01', 0)

# Connect "simple_crank_2" and "springdamper01_2"


AMEConnectTwoPorts('simple_crank_2', 1, 'springdamper01_2', 0)

# Connect "springdamper01_2" and "mass_friction1port_2"


AMEConnectTwoPorts('springdamper01_2', 1, 'mass_friction1port_2', 0)

Launch your script again, and then open the system in Simcenter Amesim:

Figure 2-6. Ports connected

The components are no longer in reverse video, they are connected.

Simcenter Amesim API 2-9


© 2020 Siemens
2. Tutorial

2.5 Setting parameter values


Next we will assign parameters values to component submodels using the AMESetParameterValue
function.

We will set the following values:

Alias Submodel Title Name Value

mass_friction1port MAS003-1 velocity at port v1 0


1[m/s]

displacement x1 0
at port 1 [m]

mass [kg] mass MASS

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]

mass_friction1port MAS003-2 velocity at port v1 0


1[m/s]

displacement x1 0
at port 1 [m]

mass [kg] mass MASS

2-10 Simcenter Amesim API


© 2020 Siemens

You might also like