10.2 OOMMF 2D Micromagnetic Solver Batch System

10.2.1 2D Micromagnetic Solver Batch Interface: batchsolve

Overview
The application batchsolve provides a simple command line interface to the OOMMF 2D micromagnetic solver engine.

Launching
The application batchsolve is launched by the command line:

tclsh oommf.tcl batchsolve [standard options]
   [-end_exit <0|1>] [-end_paused] [-interface <0|1>] \
   [-restart <0|1>] [-start_paused] [file]

where

-end_exit <0|1>

Whether or not to explicitly call exit at bottom of batchsolve.tcl. When launched from the command line, the default is to exit after solving the problem in file. When sourced into another script, like batchslave.tcl, the default is to wait for the caller script to provide further instructions.

-interface <0|1>

Whether to register with the account service directory application, so that mmLaunch, can provide an interactive interface. Default = 1 (do register), which will automatically start account service directory and host service directory applications as necessary.

-start_paused

Pause solver after loading problem.

-end_paused

Pause solver and enter event loop at bottom of batchsolve.tcl rather than just falling off the end (the effect of which will depend on whether or not Tk is loaded).

-restart <0|1>

Determines solver behavior when a new problem is loaded. If 1, then the solver will look for basename.log and basename*.omf files to restart a previous run from the last saved state (where basename is the “Base Output Filename” specified in the input problem specification). If these files cannot be found, then a warning is issued and the solver falls back to the default behavior (equivalent to -restart 0) of starting the problem from scratch. The specified -restart setting holds for all problems fed to the solver, not just the first.

file

Immediately load and run the specified MIF 1.x file.

The input file file should contain a Micromagnetic Input Format 1.x problem description, such as produced by mmProbEd. The batch solver searches several directories for this file, including the current working directory, the data and scripts subdirectories, and parallel directories relative to the directories app/mmsolve and app/mmpe in the OOMMF distribution. Refer to the mif_path variable in batchsolve.tcl for the complete list.

If -interface is set to 1 (enabled), batchsolve registers with the account service directory application, and mmLaunch will be able to provide an interactive interface. Using this interface, batchsolve may be controlled in a manner similar to mmSolve2D. The interface allows you to pause, un-pause, and terminate the current simulation, as well as to attach data display applications to monitor the solver’s progress. If more interactive control is needed, mmSolve2D should be used.

If -interface is 0 (disabled), batchsolve does not register, leaving it without an interface, unless it is sourced into another script (e.g., batchslave.tcl) that arranges for an interface on the behalf of batchsolve.

Use the -start_paused switch to monitor the progress of batchsolve from the very start of a simulation. With this switch the solver will be paused immediately after loading the specified MIF file, so you can bring up the interactive interface and connect display applications before the simulation begins. Start the simulation by selecting the Run command from the interactive interface. This option cannot be used if -interface is disabled.

The -end_paused switch insures that the solver does not automatically terminate after completing the specified simulation. This is not generally useful, but may find application when batchsolve is called from inside a Tcl-only wrapper script.

Note on Tk dependence: If a problem is loaded that uses a bitmap mask file, and if that mask file is not in the PPM P3 (text) format, then batchsolve will launch any2ppm to convert it into the PPM P3 format. Since any2ppm requires Tk, at the time the mask file is read a valid display must be available. See the any2ppm documentation for details.

Output
The output may be changed by a Tcl wrapper script, but the default output behavior of batchsolve is to write tabular text data and the magnetization state at the control point for each applied field step. The tabular data are appended to the file basename.odt, where basename is the “Base Output Filename” specified in the input MIF 1.x file. See the routine GetTextData in batchsolve.tcl for details, but at present the output consists of the solver iteration count, nominal applied field B, reduced average magnetization m, and total energy. This output is in the ODT file format.

The magnetization data are written to a series of OVF (OOMMF Vector Field) files, basename.fieldnnnn.omf, where nnnn starts at 0000 and is incremented at each applied field step. (The ASCII text header inside each file records the nominal applied field at that step.) These files are viewable using mmDisp.

The solver also automatically appends the input problem specification and miscellaneous runtime information to the log file basename.log.

Programmer’s interface
In addition to directly launching batchsolve from the command line, batchsolve.tcl may also be sourced into another Tcl script that provides additional control structures. Within the scheduling system of OBS, batchsolve.tcl is sourced into batchslave, which provides additional control structures that support scheduling control by batchmaster. There are several variables and routines inside batchsolve.tcl that may be accessed and redefined from such a wrapper script to provide enhanced functionality.

Global variables

mif

A Tcl handle to a global mms_mif object holding the problem description defined by the input MIF 1.x file.

solver

A Tcl handle to the mms_solver object.

search_path

Directory search path used by the FindFile proc.

Refer to the source code and sample scripts for details on manipulation of these variables.

Batchsolve procs
The following Tcl procedures are designed for external use and/or redefinition:

SolverTaskInit

Called at the start of each task.

BatchTaskIterationCallback

Called after each iteration in the simulation.

BatchTaskRelaxCallback

Called at each control point reached in the simulation.

SolverTaskCleanup

Called at the conclusion of each task.

FindFile

Searches the directories specified by the global variable search_path for a specified file. The default SolverTaskInit proc uses this routine to locate the requested input MIF file.

SolverTaskInit and SolverTaskCleanup accept an arbitrary argument list (args), which is copied over from the args argument to the BatchTaskRun and BatchTaskLaunch procs in batchsolve.tcl. Typically one copies the default procs (as needed) into a task script, and makes appropriate modifications. You may (re-)define these procs either before or after sourcing batchsolve.tcl. See Sec. 10.2.2.4 for example scripts.