MacrosΒΆ

The great flexibility of the VSim input file languages allows VSim to be used to model a wide variety of systems, but at the same time can make the construction of input files rather daunting. Macros simplify input file construction, and are a mechanism to abstract complex input file sequences into (parameterized) tokens. In its simplest form, a macro provides a way to substitute a code snippet from an input file. A user can then put only the macro into the input file, and it will be expanded into the full input file at the time the .pre file is preprocessed.

An example of a macro has already been used in the Geometries section of this document, wherein we created a hollow cylinder:

<macro hollowCylinder>
  H(-INNER_RADIUS^2 + x^2 + y^2)*H(RADIUS^2 + x^2 + y^2)
</macro>

Macros can contain your own functions, built-in functions from VSim (like geoBoxP, for example), or a combination of the two types. Once your macro is defined, you can call it as many times as you wish in your simulation.

VSim also contains a number of pre-defined macros that are used throughout the example input files available through the VSimComposer interface. You may find the VSim macros to be helpful in your own simulations, especially in cases like addFarFieldBox where the macro automatically adds 18 different (and necessary) histories to your simulation.

The ability to use certain macros in VSim is tied to the particular VSim license in use.

For further information on macros, please visit either VSim Customization for more of the basics of macros, or refer to VSim Reference for a full list of macros included in VSim versions 7 and 8.