Download NMAG User Manual (Incomplete DRAFT)
Transcript
sim.advance_time(dt*i)
#compute time development
if i % 10 == 0:
#every 10 loop iterations,
sim.save_data(fields=’all’)
#save averages and all
#fields spatially resolved
else:
sim.save_data()
#otherwise just save averages
As in Example demag field in uniformly magnetised sphere, we import nmag and create the the material object.
import nmag
from nmag import SI
mat_Py = nmag.MagMaterial(name="Py",
Ms=SI(0.86e6,"A/m"),
exchange_coupling=SI(13.0e-12, "J/m"),
llg_damping=SI(0.5,""))
We set the llg_damping parameter to 0.5. To be consistent with the other input parameters for the material, this
needs to be an SI object without units - this is why we write SI(0.5,"").
The next line creates the simulation object.
sim = nmag.Simulation("bar")
Here, we provide a name for the simulation object, i.e. bar. This will be used as the root of the name of any data
files that are being written. If this name is not specified (as in Example demag field in uniformly magnetised sphere),
it defaults to the name of the file that contains the script (but without the .py extension).
Next, we load the mesh file, and set the initial (normalised) magnetisation to point in the [1,0,1] direction, i.e. to
have equal magnitude in the x- and z-direction and 0 in the y-direction.
sim.load_mesh("bar30_30_100.nmesh.h5",
[("Py", mat_Py)],
unit_length=SI(1e-9,"m"))
sim.set_m([1,0,1])
This vector will automatically be normalised within nmag, so that [1,0,1] is equivalent to the normalised vector
[0.70710678,0,0.70710678].
In this example, we would like to study a dynamic process and will ask nmag to compute the time development over
a certain amount of time dt. The line:
dt = SI(5e-12, "s")
simply creates an SI object which represents this amount of time (i.e. 5 pico seconds) over which to carry out that
integration.
We then have a Python for-loop in which i will take integer values ranging from 0 to 60 for subsequent iterations. All
indented lines are the body of the for-loop.
for i in range(0, 61):
sim.advance_time(dt*i)
if i % 10 == 0:
sim.save_data(fields=’all’)
else:
sim.save_data()
13