Batch Mode

From BurnSim Wiki
Jump to navigation Jump to search

BurnSim 4 can run a simulation with no window at all: give it a motor file and somewhere to put the results, and it loads the motor, simulates it, writes the burn data as CSV and exits with a status code a script can test. This is how you sweep a parameter, re-run a set of designs after changing a propellant, or check motors from a build script.

It requires an activated personal or commercial license. It is not available on an educational license, or in trial/unlicensed mode.

Usage

BurnSim -infile <motor.bsx> -outfile <results.csv> [-units metric|imperial]
Option What it does
-infile The .bsx motor file to simulate. Required.
-outfile Where to write the CSV. Required. This is the same time-step table File → Export CSV writes, minus the imported-test-data columns - a batch run has no way to supply a measured trace.
-units metric or imperial. Optional; without it the run uses your saved display-units setting.
-help (or -?) Print the usage text and exit.

Both -infile and -outfile must be given. Supplying only one is an error rather than a silent fall-back to opening the window - a typo in one flag would otherwise leave a windowless BurnSim running on a build machine having written nothing.

A bare file path on its own does not trigger batch mode: that is how a double-clicked .bsx arrives, and it still opens normally in the GUI.

Exit codes

Code Meaning
0 Success - the CSV was written.
1 The simulation or file access failed. The input file was missing, or the design has a problem serious enough to stop the run. No CSV is written.
2 A usage error - a missing or unrecognized option, or a -units value that is neither metric nor imperial.
3 The license does not cover batch mode (educational, trial, or unlicensed).

Any design messages BurnSim would have shown in the Results panel are written to standard error, prefixed burnsim:. Warnings do not stop the run; a critical message does, and is the usual reason for exit code 1.

Waiting for the run to finish

This is the one thing that catches people out. BurnSim is a GUI program, and a shell does not wait for one of those - it returns to the prompt immediately, before the CSV exists and before the exit code is set. Read a result straight after the command and you will read a half-written file, or none.

Redirecting the output is what makes the shell wait:

BurnSim -infile motor.bsx -outfile results.csv | Out-Null     # PowerShell
BurnSim -infile motor.bsx -outfile results.csv > log.txt      # cmd

Start-Process -Wait works too. On success the path of the CSV it wrote is printed to standard output.

See also