Probing the magnetization, along a curve, as a function of space and time

This wiki page describes how to probe the magnetization, from the h5 file, along a circular arc. The arc may be replaced with any geometric curve.

Once the magnetization has been obtained, it may be Fourier transformed in order to obtain the dispersion of spin waves.

This script should be saved as a python script (say probe.py) and then run with the following command:

nsim probe.py <path to the .h5 file> <file in which the probed magnetization is to be saved>

This has been implemented with Nmag version 0.2.1


#Import some libraries
import math
import sys

import ocaml
from nmag.h5probe import Fields
from nmag import float_set

from numpy import pi, linspace, cos, sin, subtract, savetxt, size

# First we obtain the handler for the fields
handler = Fields(sys.argv[1])

#probing along a 90 degree (45 degrees on both sides from the centre) arc along a circle of radius 550 nm and at z=0
angle = float_set([3*pi/4.0, [100], pi/4.0])
R=550
xs=R*cos(angle)
ys=R*sin(angle)

#idlist to give different instances of time
idlist=range(0,10241,1)    

#Declare some lists for saving purposes
vs = []
minit=[];mlist=[]

#loading the 0th time step field; The '0' corresponds to the id and not a time value
field = handler.set_field_data("m", "Py", 0)

#Calculating the field along the arc for the 0th time step; it has to be subtracted from every other time step

for i in range(size(xs)):
    minit.append(ocaml.probe_field(field, "m_Py", [xs[i], ys[i], 0.0])[0][1][1])

#For each time (id) step, the field along the arc is calculated and
#the field at the 0th time step is deducted. This field is then appended to a file
for t in idlist:
    field = handler.set_field_data("m", "Py", t)
      vs=[]
    for i in range(size(xs)):
        vs.append(ocaml.probe_field(field, "m_Py", [xs[i], ys[i], 0.0])[0][1][1]);
    for num in range(size(xs)):
        mlist.append(subtract(vs, minit)[num])

savetxt(sys.argv[2], mlist)

Also available in: HTML TXT