OOMMF Radial Applied Field With Polar Coordinates

By | April 22, 2017

It is often more useful to think of applied field in terms of polar coordinates – with an angle and a magnitude. By default the Zeeman term in OOMMF takes inputs in cartesian coordinates – i.e. x, y and z components. In many situations this is fine, but there are times when polar coordinates make more sense – perhaps you are investigating the angle of the applied field . In this post I show you how you can represent an applied field in OOMMF using polar coordinates.

Hopefully this simple example will help you get started with using polar coordinates with the applied field in OOMMF.

Download an example mif file of an applied field defined in terms of polar coordinates (based on OOMMF ellipsoid example).

Use The Script Zeeman Term

Rather than using the ‘standard’ Zeeman term, we can use the script Zeeman. This allows us to point to a function which will define our field. We’ll use a function to convert an angle and magnitude into a x, y and z components.

The specify block below tells the Zeeman term to look for a function called ‘Radial’ (we can call the function pretty much whatever we want):

Specify Oxs_ScriptUZeeman [ subst {
	multiplier [expr {0.001/$mu0}]
	script Radial

Read more about ScriptUZeeman.

Define The Radial Field Function

The script Zeeman term expects a script (called ‘Radial’ in this example) to define the applied field. We will use that function to convert an angle and magnitude into x,y and z components of the field.

proc Radial { x y z } {
	variable theta
	variable magnitude
	set PI [expr {4 * atan(1.)}]
	set Hx [expr $magnitude * cos(($PI/180.)*$theta)]
	set Hy [expr $magnitude * sin(($PI/180.)*$theta)]
    return [list $Hx $Hy 0  0 0 0 ]

This function will take a our angle ‘theta’ and magnitude and return a list x, y and z field components (Hx, Hy and Hz). In this simple example I have assumed that the z-component of the field is zero (you could change this by adding a phi angle and changing the corresponding coordinate tranformations).

Read more about user defined scripts in OOMMF.

This function refers uses ‘variable‘ to refer to variables defined outside of its scope. At the start of the mif file we can set the values of the variables ‘theta’ and ‘magnitude’.

set theta 270
set magnitude 500

Read more about using variables in OOMMF.

Examples of outputs for different angles are set out below.

OOMMF Radial Applied Field