Intermediate Java Macros: Run Multiple Simulations

This tutorial simulates a train in a cross-wind, to calculate the drag coefficient on the train for different angles of attack.

One way in which Java macros can be used effectively is to run a number of simulations in which a single variable or a set of variables is altered in each one.

The train is modeled under field test conditions. The resultant velocity of the wind as seen from the train, is calculated based on a 22 m/s head wind and a 6 m/s cross-wind at angle of attack. In addition, you set a constant velocity on the track that is equivalent to the velocity of the train. The following diagram shows how the resultant velocity is calculated:

A Java macro runs a set of simulations consecutively, each with a different set of boundary conditions. The macro performs the following:

Read the boundary condition values from an external text file;

Set the new boundary conditions in each simulation;

Run the simulation;

Export data, scenes, and plots for post-processing.

The tutorial introduces the use of multiple classes to organize your macro and includes a fully commented Java file for reference purposes.