Using Adams External Interface (AEI)
Use the following instructions to create a prototype application for driving Adams simulations. A license to run Adams Solver, Adams View and Adams Controls is required.
The following files are included in this package;
AEI_proto.c <--- A prototype driver for driving Adams simulations.
pendulum_1.cmd <--- Simple pendulum test model for Adams.
These files may be found in <adams_install_dir>/controls/examples/AEI
mdi_aei.h <--- Header file for AEI_proto.c with main AEI functions.
ac_def.h <--- Header file for AEI_proto.c with AEI-specific type definitions.
The header files may be found in <adams_install_dir>/controls/aei_inc
Note: | Please copy all the files listed above to the working directory before proceeding further. |
Instructions for creating an external driver executable
1. Locate the Adams distribution on your computer. Copy the file “plant.lib” for Windows or “libplant.a” for Linux to your working directory from one of the following location.
(install_dir)/controls/$ARCH
Note: | $ARCH is the platform specific directory, e.g. “win64” |
2. Compile the AEI_proto.c driver using the following command on the OS command shell. This would create an object file name “AEI_proto.obj”.
a. On Windows
cl -c AEI_proto.c -Dport2pcnt
Note: | The above command is to be executed from “x64 Native Tools Command Prompt for VS 2019”. This can be found in the Windows Start Menu under the Visual Studio 2019 program folder. For a list of compilers supported by Adams on Windows, refer to the installation guide |
b. On Linux
/opt/intel/bin/icc -c -w -DUNIX -Dport2linux -I ./ -O2 -mtune=pentium4 -prec_div -mieee-fp -cxxlib -fPIC -pthread -fexceptions -m64 AEI_proto.c
Note: | For a list of compilers supported by Adams on Linux, refer to the installation guide. |
3. Create a test executable, “AEI_proto.exe”.
a. On Windows
Use the following link command on a single line,
link /machine:x64 /incremental:no /nodefaultlib:libcmt.lib /subsystem:console /out:AEI_proto.exe AEI_proto.obj plant.lib user32.lib shell32.lib wsock32.lib
b. On Linux
Add /opt/intel/lib/intel64 to the LD_LIBRARY_PATH using the following command setenv /opt/intel/lib/intel64:$LD_LIBRARY_PATH
Then build the executable using the following command in a single line.
/opt/intel/bin/icc -cxxlib -fPIC -pthread -fexceptions -m64 -o AEI_proto.exe AEI_proto.o -L./ -lplant -L/opt/intel/lib/intel64 -lifcoremt –lifport
Instructions for creating a model and running the model
1. To create a plant model of the Adams model start Adams View.
2. From the welcome screen, select Existing Model and import ‘pendulum_1.cmd’.
3. From the Tools menu, select Plugin Manager and Load Adams Controls plugin.
4. Perform an Adams Controls Plant Export (Controls → Plant Export) for Easy5 (target software) to generate an .adm, .cmd, and .inf by following instructions from the online Adams Controls documentation.
5. This export step will write the following files to your local directory.
pendulum_1.adm
pendulum_1.cmd
pendulum_1.inf
6. Exit Adams View.
Instructions to run the model
1. Issue the following command at the command prompt in OS shell.
AEI_proto.exe pendulum_1.inf
2. This process runs four Adams simulations with different combinations of Co-simulation parameters, and Adams output files are written for each of the simulations.