README for mifmaker.py
Mifmaker is a tool that accepts some command line options, and produces a mif-file as appropriate to drive the OOMMF micromagnetic framework.
The tool has been developed by Richard Boardman while working on his PhD thesis (pdf available from http://eprints.soton.ac.uk/45942/), under the supervision of Hans Fangohr, at the university of Southampton (UK).
It was used to systematically (and script driven) create a range of 3d geometries as were studied in publications such as
- R.P. Boardman et al, "Micromagnetic modelling of ferromagnetic cones", Journal of Magnetism and Magnetic Materials 312, 234-238 (2007) (journal, preprint)
- R.P. Boardman et al. "Micromagnetic simulation studies of ferromagnetic part-spheres", Journal of Applied Physics 97, 10E305 (2005) (journal , preprint)
- R.P. Boardman et al. "Micromagnetic simulation of ferromagnetic part-spherical particles" Journal of Applied Physics 95, 7037-7039 (2004) (journal, preprint)
The code was never meant to be released, and is more than 10 years old. Accordingly, it could be structured nicer, is not Python 3 compatible, has no tests, doesn't use the latest option parsing, etc. (Any contributions are welcome.)
Historical note 1: this was written when numpy didn't exist (as can be seen from the import statement import numpy as Numeric)
Historical note 2: There are references to CVS in the code, which is a versioning control tool predating SVN. We provide only the latest version here (without history), now as a mercurial repository.
The tool was discussed on the mumag mailing list (2015), and thus made available here.
Richard Boardman, Hans Fangohr, 8 April 2015
As this code was never really intended for "production" release, there are a number of options which will make little or no sense! Generally, if you stick to the primitive set, then it should be relatively straightforward.
The primitive set in this case refers to the options:
--cuboid --cylinder --ellipsoid --sphere --cone --ring --torus
Some of the other options (e.g. --halfsphere) may be useful. If you wish to use --ring, then specify --rif (which is the fraction of the radius that is the "hole" of the ring), and similarly for --torus, use --torrad.
Hopefully the physical simulation space parameters and the material parameters are straightforward to understand, along with the simulation parameters. The micromagnetic solver options are less useful; the theta evolver can only be used with an extension which Michael Donahue hosts at the OOMMF site --- it is not part of the standard distribution of OOMMF.
You probably won't be able to use the PNG support unless you have some extra Python libraries (but the generated code is horrible in this instance anyway).
The default values for parameters should be fairly sane, but it will be worth verifying the output initially to check that they are within sensible limits.
When run, the program outputs the problem to the standard output, so to create the MIF file, redirect it.
As an example:
./mifmaker.py --sphere \ -m 8e5 -h 500 -l -500 -s 100 \ -a 0.25 -c 5e-9 -x 160e-9 -y 160e-9 -z 160e-9 \ -e 1.3e-11 --name=mysphere > mysphere.mif
This will generate a spherical problem with a saturation magnetisation of 8x10^5 A/m, an exchange parameter of 1.3x10^-11 J/m, a cell size of 5 nm (cubic) and a problem dimension of 160nm (i.e. 160nm in x, y and z, such that the radius of the sphere is 80nm). In this case, the simulation shall have an initial applied field of 500mT, reducing to -500 across 100 steps (10mT per step). The damping parameter (alpha) here will be 0.25.
Instead of specifying -m and -e, you can use -b (--material=) to select appropriate parameters for a limited set of hard-coded materials (nickel-iron, cobalt, supermalloy &c.).
Magnetocrystalline anisotropy is turned _off_ by default and you should force it to be on with the --use-anisotropy flag.
Prerequisites / platforms
The code itself requires Python 2.x to be installed on the machine. Although it has only ever been used on Linux and Apple machines, I have briefly tested it with Windows and it is OK if you install the ActiveState Python package from http://www.activestate.com/Products/ActivePython/ . (As of 2003.)
Once you have Python 2.x installed, the most basic way to execute this script is to type:
python mifmaker.py [OPTIONS]
With a little bit of effort, this could be converted into a python script that can be installed using the PYthon Package Index (PYPI).
The code is hosted in a bitbucket repository at https://bitbucket.org/fangohr/mifmaker
The actual source files are visible at https://bitbucket.org/fangohr/mifmaker/src
The one Python script that contains (as on early April 2015) all the functionality is also available from https://bitbucket.org/fangohr/mifmaker/raw/tip/mifmaker.py
Bitbucket provides a download service at https://bitbucket.org/fangohr/mifmaker/downloads
There is no suport for this code - it is given to the community just in case it might be useful to somebody. Time permitting, we will try to deal with queries on a best effort basis. Extensions, bugfixes and re-writes are of course welcome :)
If coloured output makes your day better, try changing line 28 in mifmaker.py from:
It looks pretty (if your terminal supports it).
Copyright (c) 2002, Richard Boardman, Hans Fangohr, University of Southampton, UK All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.