User Subroutine Guidelines

User subroutines are created for various reasons. Some include:
  • To describe a physical phenomenon that is determined by non-trivial logical conditions.
  • When it is impractical to formulate a complicated expression in an explicit form.
  • To take full advantage of a programming language like C/C++, Fortran, or a scripting language like Python, Compose, or MATLAB.
    Note: Using user subroutines adds a level of complexity to your multibody model. We recommend using the built-in functions to model your system before using subroutines unless it is necessary or more convenient to use subroutines.

To use your own subroutines in MotionSolve, follow these steps:

  1. Create a Python, Compose, MATLAB, C/C++, or Fortran source file that contains the user-defined modeling entity.
  2. Obtain a Dynamic-Link Library (DLL) or Shared Object (SO) by compiling and linking your user subroutine(s), only for C/C++ or Fortran source code. No compiling is required for Python, Compose, or MATLAB source code. Python routines are automatically compiled, and you can use compiled Python files with MotionSolve and without the source files. All Altair Simulation products come with a Python interpreter. For Compose and MATLAB, you must install the interpreter separately.
  3. Modify the corresponding entity in your multibody model to be "user defined" and to point to your DLL/SO or script file.
  4. Run MotionSolve, verifying that it finds the appropriate DLL/SO or script file during simulation.
The above steps are described in detail in the subsequent sections.

See Also

Compiler and System Requirements

Solver-Neutral Routines