When creating Simulation models, it is often required to validate the performance of the model in transient. This requires imposing boundary conditions to the model and comparing the results with the available test data.
Setting up a model to perform these tests can be time consuming and introduce errors which can have a detrimental effect on the evaluation of the model suitability but can also cause problems with both traceability and reusability.
Luckily LMS Imagine.Lab Amesim has a high level of scripting capability to help support some of the more tedious tasks.
LMS Amesim has scripting interfaces with Python, MATLAB, Scilab and VBA. More detail on these interfaces can be found in the help documentation. For this piece I would like to use the Amesim Python API to demonstrate how time based test data can be easily imported from Excel and integrated into an LMS Amesim model.
We will use a simple model for the example. The model itself is unimportant, it's just to show use-case.
Figure 1: Test LMS Amesim model, msd.ame
We have an Excel sheet containing the required input step pattern and output displacement and velocity profile to be compared to
Figure 2: Input Excel sheet data and structure
The basic process is as follows
Import the Excel file into Python
Identify the variable names to be imported
Create a list representing the time vector
Create a list of lists representing the input data
Use the LMS Amesim scripting API (amesim) to create a XY table data file that can be used with SIGFXA01
Use the LMS Amesim circuit API (ame_apy) to build an LMS Amesim model a containing a BUS structure with all signals accessible from their variable name
Finally we will integrate the model created in 3, with the model to be tested and connect the variables to be compared using the BUS get (SIGBUSGET01) components
Figure 3: Process flow
The resulting model will look like this. The required variables can be accessed on the BUS for comparison with the Simulation model results
Figure 4: Validation LMS Amesim model msd_final.ame
Running the demo
Open msd.ame in LMS Amesim 15.0.1
Start the Python interpreter from LMS Amesim – this ensures working from the correct directory
Execute the Python script - >> execfile(‘py5_msd.py’)
Figure 5: Python output
Open the generated test.ame model in data folder
Copy the model to msd.ame
In parameter mode, update the location of the created data file in the dynamic table