The Subroutine Interface for MotionSolve


MotionSolve provides an extensive subroutine interface that allows you to extend the solver so it can represent the physics of a large set of phenomena. Many modeling elements in MotionSolve can be extended with user-written subroutines. During simulation, MotionSolve will invoke these subroutines as needed to evaluate the phenomena modeled by you.

User-Written Subroutines

You can write user subroutines in a compiled language or in a scripted language. The key difference between the two is that a when subroutines are written in a compiled language, they need to be compiled using a compiler. This converts the source code to a binary format. The binary files then need to be linked together to create a Dynamic-Linked Library (DLL) or Shared Object (SO). Once the source code is compiled, MotionSolve knows how to invoke the functions within a DLL/SO and use these. There is no need to compile or link subroutines written in a scripting language. The table below shows the different languages that are supported by MotionSolve. Any user subroutine may be written in one of these languages.

Language Comments
Fortran This is the traditional way to write user-written subroutines. Subroutines written in Fortran, because they are compiled, are extremely efficient. However, you are required to have a Fortran compiler in order to use user-subroutines written in Fortran.
C / C++ The user-written and access subroutines also support a C/C++ interface. Subroutines written in C/C++, because they are compiled, are extremely efficient. However, you are required to have a C/C++ compiler in order to use user subroutines written in C/C++.
Python User-written subroutines may also be written in the Python scripting language. Python is a popular, object-oriented, and concise language. It is also open-source. It is very easy to write user subroutines in Python. If you are not an experienced programmer, you should write user subroutines in Python. Subroutines written in Python may be somewhat slower than those written in Fortran/C/C++. However, Python supports a large set of libraries. Most notable among these are the NumPy and SciPy packages. These are extremely comprehensive and efficient libraries of built-in functions for scientific or engineering calculations that are freely available with Python. For more information about these, please visit and All HyperWorks products come with a Python interpreter installed.
Compose Altair Compose is an integrated development environment and interpreter for the open-source computational programming language OpenMatrix Language (OML). Just as in Python, it is very easy to write user subroutines in Compose, or more specifically, in OML. This language is particularly powerful for matrix-based computations. Subroutines written in Compose may be somewhat slower than those written in Python/Fortran/C/C++. You have to install Compose separately.
MATLAB The MATLAB scripting language is yet another option for writing MotionSolve user-written subroutines. MATLAB is a proprietary language developed by the MathWorks, Inc. It is highly concise language that is tailor made for manipulating matrices, just as OML. Subroutines written in MATLAB may be somewhat slower than those written in Python/Fortran/C/C++.

User subroutines may be written in any combination of these supported languages. User subroutines are an advanced feature of MotionSolve. You should use it only if they are absolutely necessary, since they add complexity to the model and may require debugging if written incorrectly.

The subroutine facility in MotionSolve is compatible with the documented standard defined in Adams. Thus, when the documented standard is adhered to, Adams user subroutine DLLs/SOs should work directly with MotionSolve without any need to recompile the source or recreate the DLL/SO.