16 Command Line Utilities

16.7 Field from Magnetization (3D): computefield

Inspired by the 2D-solver based mag2hfield, the computefield application uses the 3D Oxs solver engine to compute demagnetization and other fields from a magnetization snapshot. Various options allow fields to be computed outside the original simulation volume (say the stray field above a thin film sample) or to isolate the field arising from one portion of the sample (for example from one layer in a multilayer structure).

Launching
The computefield launch command is:

tclsh oommf.tcl computefield [standard options] \
   [-cwd directory] [-Msfile Msinputfile] [-Msspec spec] \
   [-Msmask maskexpr] [-simulationbox xmin ymin zmin xmax ymax zmax] \
   [-outdemagenergy demagenergyfile] [-outmif miffile] \
   [-outM magfile] [-pbc axes] [-userscriptfile energyscriptfile] \
   [-useroutputs "name1 file1 ..."] \
   [-runboxsi <0|1>] [-runopts boxsiopts] <m0_infile> [outdemagfile]
where

-cwd directory

Make directory the active working directory.

-Msfile Msinputfile

Set pointwise saturation magnetization values from Msinputfile, overriding Ms values from m0_infile. Any points outside the span of Msinputfile have Ms set to 0.

-Msspec spec

Override the Ms values from m0_infile with the (quoted) spec string in the form of an inline Specify block. Note: If spec is a single numeric value representing a uniform saturation magnetization (in A/m), then that value is applied but restricted to the simulation volume described by the m0_infile, with Ms is set to 0 A/m in any extended volume requested by the -simulationbox option.

At most one of -Msfile and -Msspec may be used.

-Msmask maskexpr

At each point in the simulation volume, the Tcl expr-expression maskexpr is evaluated to rescale (multiply) the otherwise set saturation magnetization Ms. The expr-expression may include the special variables $x, $y, $z, $rx, $ry, $rz, $Ms, $mx, $my, and $mz. The first three are the raw pointwise location in meters, the second three are the relative location (each in the range [0,1]), $Ms is the saturation magnetization at the point, and ($mx,$my,$,mz) is the reduced (unit normalized) magnetization. Analogous to the -wgtfunc option of avf2odt, maskexpr is typically a 0/1 valued function used to mask off a portion of the simulation part. See the first example below.

-simulationbox xmin ymin zmin xmax ymax zmax

Use the specified values for the simulation volume, overriding the extents in the input m0_infile magnetization file. The x/y/z/min/max values can be listed as either six individual values or quoted as a single element to computefield. Any entry specified as a single hyphen (‘-’) will inherit the corresponding value from the m0_infile. (The -info option to the command line utility avf2ovf can be used to view the m0_infile extents.)

The simulationbox option is typically used to compute stray fielda outside the original simulation volume. If the original volume extends outside the requested volume, then magnetization outside the requested volume is ignored and a warning is printed.

-outdemagenergy demagenergyfile

Write the demagnetization energy density scalar field (.oef) to demagenergyfile.

-outmif miffile

The computefield application creates a temporary MIF used as input for running boxsi. This MIF file is deleted after boxsi exits, but the -outmif option will save a copy in miffile.

-outM magfile

Saves a copy of the magnetization as used in the computation, incorporating m0_infile and Ms/file/spec/mask options. This can be helpful for checking that input parameters, in particular -Msmask, are behaving as expected.

-pbc axes

Creates a periodic mesh for the simulation. The axes should be a string of one or more of the letters “x”, “y”, and “z”, denoting the periodic direction(s), as used by the periodic option to the Oxs_PeriodicRectangularMesh Specify block (Sec. 7.3.2).

-userscriptfile energyscriptfile

The only outputs directly supported on the computefield command line are demagnetization field, demagnetization energy density, and magnetization. However, the user can create a separate Tcl script file (energyscriptfile) with additional Oxs_Energy objects to include in the run. (See second example below.) The name of each desired output and the associated filename should be appended to the Tcl list “user_outputs”, either directly inside the script file, or via the -useroutputs command line option.

-useroutputs "name1 file1 …"

A list, quoted as a single element on the command line, of alternating outputs and filenames, referring to Oxs_Energy objects specified in the separate -userscriptfile. This command line option augments and amends any user_outputs setting in the script file.

-runboxsi <0|1>

By default, computefield runs boxsi on its constructed MIF file to compute the requested output fields. This behavior is short circuited with -runboxsi 0, which can be used in conjunction with -outmif to allow additional user edits to the MIF file preceding a manual boxsi run.

-runopts boxsiopts

Command line options passed to the automatic boxsi run. The boxsiopts string must be quoted as a single argument to computefield.

m0_infile

Input magnetization (.omf) file. Required. This file sets the magnetization direction at each point, i.e., the MIF m0 value in the Oxs_TimeDriver and Oxs_MinDriver Specify blocks. The pointwise saturation magnetization (MIF Ms option) and simulation volume extents (MIF atlas object) are also derived from this file unless overridden by other options.

outdemagfile

Demagnetization output file name. Optional. If not specified then the demagnetization field is not output.

Examples
Consider a multilayer thin film having total thickness 30 nm, with the top layer 10 nm thick. A simulation is run and the magnetization at some interesting point is saved to the file foo.omf. For efficiency, the simulation volume was set to contain only the film itself, but for analysis we want to know the stray field out to 150 nm above the top of the film. Moreover, we would like to know the portion of the stray field coming from just the top 10 nm layer. The command

tclsh oommf.tcl computefield -simulationbox - - - - - 180e-9 \
  -Msmask ’20e-9<$z && $z<30e-9 ? 1 : 0’ foo.omf foo-toplayer.ohf

will compute this and save the results in foo-toplayer.ohf. (On the Windows command line, remove or replace the backslash line continuation character with a caret, ^, and replace the single quotes with double quotes.)

As another example, suppose bar.omf holds Oxs_MinDriver::Spin normalized magnetization output for a sample with uniform saturation magnetization of 1400 kA/m. If we want to know the magnetocrystalline anisotropy field at that magnetization state, we can construct a separate file, say barK.tcl, that contains the anisotropy block from the original simulation:

Specify Oxs_UniaxialAnisotropy:K {
   K1 520e3
   axis {0 0 1}
}
lappend user_outputs Oxs_UniaxialAnisotropy:K:Field barK.ohf

The last line requests the field output be written to the file barK.ohf. We will feed this file to computefield using the -userscriptfile option. After closing barK.tcl we decide we would also like to have the anisotropy energy density, so we’ll use the -useroutput option to request that, and for good measure request the demagnetization energy density with -outdemagenergy as well. The accompanying computefield command is

tclsh oommf.tcl computefield -Msspec 1.4e6 -userscriptfile barK.tcl \
   -useroutputs "Oxs_UniaxialAnisotropy:K:Energy\ density barK.oef" \
   -outdemagenergy bar-demag.oef bar.omf

Note that the demagnetization field is not requested and so won’t be saved. (If that field is wanted, just add the filename after bar.omf.)