Macros

The great flexibility of the XSim input file languages allows XSim 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 XSim (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.

XSim also contains a number of pre-defined macros that are used throughout the example input files available through the XSimComposer interface. You may find the XSim 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 XSim is tied to the particular XSim license in use.

For further information on macros, please visit either the Customizatin manual for more of the basics of macros, or refer to XSim Reference for a full list of macros included in XSim-1.0.