HyperWorks Solvers

The Subroutine Interface for MotionSolve

The Subroutine Interface for MotionSolve

Previous topic Next topic No expanding text in this topic  

The Subroutine Interface for MotionSolve

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Introduction

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 linked together to create a Demand Loaded Library (DLL). Once it is in this format, MotionSolve knows how to invoke the functions within a DLL and use these. There is no need to compile or link subroutines written in a scripting language. Table-1 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 very popular, object-oriented, concise language. 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 http://numpy.scipy.org/ and http://www.scipy.org/.

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. Subroutines written in MATLAB may be somewhat slower than those written in Fortran/C/C++.

Table-1: A summary of the options for writing user subroutines in MotionSolve

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 should work directly with MotionSolve without any need to recompile the source or recreate the DLL.