Beispiel #1
0
def simulation(
    sim_name=None, initial_m=None, Hs=[None], save=[], do=[], have_j=False, damping_Py=0.01, damping_FePt=0.1
):
    if have_j:
        have_j = 1.0
    else:
        have_j = 0.0

    # FeNi, Permalloy
    mat_Py = nmag.MagMaterial(
        name="Py",
        Ms=SI(0.86e6, "A/m"),
        exchange_coupling=SI(13.0e-12, "J/m"),
        llg_damping=damping_Py,
        llg_polarisation=have_j * SI(1.0),
        llg_xi=SI(0.01),
    )

    anis_FePt = nmag.uniaxial_anisotropy(axis=[1, 0, 0], K1=SI(2.5e6, "J/m^3"))

    mat_FePt = nmag.MagMaterial(
        name="FePt",
        Ms=SI(1e6, "A/m"),
        exchange_coupling=SI(10.0e-12, "J/m"),
        anisotropy=anis_FePt,
        llg_damping=damping_FePt,
        llg_polarisation=have_j * SI(1.0),
        llg_xi=SI(0.01),
    )

    s = nmag.Simulation(sim_name)

    s.set_local_magnetic_coupling(mat_Py, mat_FePt, SI(2.0e-4, "N/A^2"))

    s.load_mesh(
        mesh_filename,
        [
            ("HARD-LEFT", mat_FePt),
            ("SOFT-LEFT", mat_Py),
            ("HARD-CENTER", mat_FePt),
            ("SOFT-RIGHT", mat_Py),
            ("HARD-RIGHT", mat_FePt),
        ],
        unit_length=SI(1e-9, "m"),
    )

    if type(initial_m) == str:  # Set the initial magnetisation
        s.load_m_from_h5file(initial_m)  # a) from file if a string is provided

    else:
        s.set_m(initial_m[0], "m_Py")
        s.set_m(initial_m[1], "m_FePt")

    s.hysteresis(Hs, save=save, do=do, convergence_check=every(5, "step"))
    return s
Beispiel #2
0
  def setup(self):
    nf = self.norm_factor

    # Create the material for Fe2 in DyFe2 and YFe2
    # A unique material can be used because the iron moment per unit volume
    # in DyFe2 and YFe2 are the same.
    # NOTE: The demagnetising field acts as a shape anisotropy in the 1D model:
    # H_demag = -M_x which can be expressed as an uniaxial anisotropy
    #   H_demag = (2 K_1 m*u) / (mu0*M_sat)
    # where the axis u = (1, 0, 0) and K_1 = -mu0*M_sat^2/2
    # NOTE: Strictly this is wrong
    demag_Fe2 = \
      nmag.uniaxial_anisotropy(axis=[1, 0, 0],
                               K1=-self.enable_demag*0.5*mu0*self.Ms_Fe2**2)
    mat_Fe2 = \
      nmag.MagMaterial(name="Fe2",
                       Ms=self.Ms_Fe2,
                       exchange_coupling=self.A_Fe2,
                       anisotropy=demag_Fe2,
                       llg_normalisationfactor=SI(nf, "1/s"),
                       llg_damping=SI(self.damping),
                       llg_polarisation=SI(self.P),
		       llg_xi=SI(self.xi))

    # Create the material
    # the sum comes from taking the data from Jurgen's simulations
    # where the total moment in DyFe2 is given Ms_DyFe2 = Ms_Dy - Ms_Fe2
    cubic_Dy = \
      nmag.cubic_anisotropy(axis1=[1, -1, 0],
                            axis2=[1,  1, 0],
                            K1=SI(33.853774961e6, "J/m^3"),
                            K2=SI(-16.1710504363e6, "J/m^3"),
                            K3=SI(16.3584237059e6, "J/m^3"))

    demag_Dy = \
      nmag.uniaxial_anisotropy(axis=[1, 0, 0],
                               K1=-self.enable_demag*0.5*mu0*self.Ms_Dy**2)
    mat_Dy = \
      nmag.MagMaterial(name="Dy",
                       Ms=self.Ms_Dy,
                       exchange_coupling=SI(0.0e-12, "J/m"),
                       anisotropy=demag_Dy + cubic_Dy,
                       llg_normalisationfactor=SI(nf, "1/s"),
                       llg_damping=SI(self.damping),
		       llg_polarisation=0.0)

    #--------------------------------------------
    ## Here we set up the simulation

    # Create the simulation object
    sim = nmag.Simulation(self.sim_name, do_demag=False,
                          adjust_tolerances=False)

    # Set the coupling between the two magnetisations
    #sim.set_local_magnetic_coupling(mat_Fe2, mat_Dy, SI(-2.2337e-4, "N/A^2"))
    sim.set_local_magnetic_coupling(mat_Fe2, mat_Dy, self.A_lc)

    x0 = self.width_soft*0.5
    x1 = x0 + self.width_hard
    layers = [(-x1, -x0), (-x0, x0), (x0, x1)]
    mat_allocation = [("DyFe2_up", [mat_Dy, mat_Fe2]),
                      ("YFe2", mat_Fe2),
                      ("DyFe2_down", [mat_Dy, mat_Fe2])]

    # Creates the mesh from the layer structure
    if not os.path.exists(self.mesh_file_name) or self.new_mesh:
        print "Creating the mesh"
        mesh_lists = unidmesher.mesh_1d(layers, self.discretization)
        unidmesher.write_mesh(mesh_lists, out=self.mesh_file_name)
    sim.load_mesh(self.mesh_file_name, mat_allocation, unit_length=SI(1e-9, "m"))

    self.sim = sim
    return sim
Beispiel #3
0
H_unit = SI(1e6, "A/m") # The unit for these values

# From the norms and the direction (which is constant) we derive
# all the values that the applied field will take during the simulation
Hs = vector_set(direction=H_direction, norm_list=H_norms, units=H_unit)

#--------------------------------------------
## Here we set up the simulation

# Create the material
mat_Py = nmag.MagMaterial(
           name="Py",
           Ms=m_sat,
           exchange_coupling=exchange_coupling,
           anisotropy=nmag.uniaxial_anisotropy(
                        axis=[1,0,0],
                        K1=SI(5e6, "J/m^3")),
           llg_gamma_G=SI(0.2211e6, "m/A s"),
           llg_damping=SI(0.5),
           llg_normalisationfactor=SI(0.001e12, "1/s"))

# Create the simulation object
sim = nmag.Simulation(do_demag=False)

# Creates the mesh from the layer structure
mesh_file_name = '%s.nmesh' % mesh_name
if not os.path.exists(mesh_file_name) or new_mesh:
  print "Creating the mesh"
  mesh_lists = unidmesher.mesh_1d(layers, discretization)
  unidmesher.write_mesh(mesh_lists, out=mesh_file_name)
Beispiel #4
0
# Initial magnetization
xfactor = float(SI("m") / (length * mesh_unit))


def m0(r):
    x = max(0.0, min(1.0, r[0] * xfactor))
    mx = x
    mz = 0.1
    my = (1.0 - (mx * mx * 0.99 + mz * mz)) ** 0.5
    return [mx, my, mz]

# Create the material
mat_Py = nmag.MagMaterial(name="Py",
                          Ms=SI(0.86e6, "A/m"),
                          exchange_coupling=SI(0, "J/m"),  # disables exchange?
                          anisotropy=nmag.uniaxial_anisotropy(
                              axis=[0, 0, 1], K1=SI(520e3, "J/m^3")),
                          llg_gamma_G=SI(0.2211e6, "m/A s"),
                          llg_damping=SI(0.2),
                          llg_normalisationfactor=SI(0.001e12, "1/s"))

# Create the simulation object
sim = nmag.Simulation("1d", do_demag=False)

# Creates the mesh from the layer structure
mesh_file_name = '1d.nmesh'
mesh_lists = unidmesher.mesh_1d(layers, discretization)
unidmesher.write_mesh(mesh_lists, out=mesh_file_name)

# Load the mesh
sim.load_mesh(mesh_file_name, [("Py", mat_Py)], unit_length=mesh_unit)
Beispiel #5
0
# One dimensional magnetic system studied using nsim
import os, sys, math
import nmag
from nmag import SI, vector_set, every, at
from nsim.si_units.si import degrees_per_ns

ps = SI(1e-12, "s"); nm = SI(1e-9, "m")

mat_A = nmag.MagMaterial(name="A",
                         Ms=SI(0.5e6, "A/m"),
                         exchange_coupling=SI(13.0e-12, "J/m"),
                         llg_damping=0.5)

anis_B = nmag.uniaxial_anisotropy(axis=[1, 0, 0], K1=SI(0.1e6, "J/m^3"))
mat_B =  nmag.MagMaterial(name="B",
                          Ms=SI(0.5e6, "A/m"),
                          exchange_coupling=SI(10.0e-12, "J/m"),
                          anisotropy=anis_B,
                          llg_damping=0.1)

# Create the simulation object
sim = nmag.Simulation()

# Set the coupling between the two magnetisations
sim.set_local_magnetic_coupling(mat_A, mat_B, SI(-1.0e-5, "N/A^2"))

# Load the mesh
sim.load_mesh("thinfilm.nmesh.h5", [("mesh", [mat_A, mat_B])], unit_length=1*nm)

# Set additional parameters for the time-integration
sim.set_params(stopping_dm_dt=1*degrees_per_ns,
Beispiel #6
0
# Anisotropy -- K
Stability_constant = 55 * 1.38e-23 * 350  # Stability Constant
Area_constant = 25e-27  # Area Constant = area * 1e-9
ku_soft = 100.0
ku_hard = (Stability_constant / Area_constant - ku_soft * soft_h) / hard_h
print('ku_hard %f' % ku_hard)
K_hard = SI(ku_hard, "J/m^3")
K_soft = SI(ku_soft, "J/m^3")
# Max Apply Field
H_max = 2 * ku_hard * 1e4 / ms_hard
H_max = H_max * 1e3 / (4 * math.pi)  # koe to A/m
print('H_max %f' % H_max)
Mat_Hard = nmag.MagMaterial(name='Mat_Hard',
                            Ms=M_hard,
                            exchange_coupling=A_hard,
                            anisotropy=nmag.uniaxial_anisotropy(
                                axis=[0, -0.05, -1.0], K1=K_hard),
                            llg_damping=1.0)

Mat_Soft = nmag.MagMaterial(name='Mat_Soft',
                            Ms=M_soft,
                            exchange_coupling=A_soft,
                            anisotropy=nmag.uniaxial_anisotropy(
                                axis=[0, 0, -1.0], K1=K_soft),
                            llg_damping=1.0)

# load mesh
sim.load_mesh('%s' % mesh_file, [('Mat_Hard', Mat_Hard),
                                 ('Mat_Soft', Mat_Soft)],
              unit_length=SI(1e-9, 'm'))

sim.set_m([0, 0, 1])
Beispiel #7
0
import nmag
from nmag import SI, every, at
from numpy import array
import math

# Create simulation object (no demag field!)
sim = nmag.Simulation(do_demag=False)

# Define magnetic material (data from OOMMF materials file)
Co = nmag.MagMaterial(name="Co",
                      Ms=SI(1400e3, "A/m"),
                      exchange_coupling=SI(30e-12, "J/m"),
                      anisotropy=nmag.uniaxial_anisotropy(axis=[0, 0, 1], K1=SI(520e3, "J/m^3")))

# Load the mesh
sim.load_mesh("bar.nmesh.h5", [("bar", Co)], unit_length=SI(1e-9,"m") )

# Our bar is subdivided into 3 regions:
# - region A: for x < offset;
# - region B: for x between offset and offset+length
# - region C: for x > offset+length;
# The magnetisation is defined over all the three regions,
# but is pinned in region A and C.
offset = 2e-9   # m (meters)
length = 500e-9 # m

# Set initial magnetisation
def sample_m0((x, y, z)):
  # relative_position goes linearly from -1 to +1 in region B
  relative_position = -2*(x - offset)/length + 1
  mz = min(1.0, max(-1.0, relative_position))
Beispiel #8
0
Area_constant = 25e-27  # Area Constant = area * 1e-9
ku_soft = 2.5e5
ku_hard = (Stability_constant/Area_constant-ku_soft*soft_h)/hard_h
print('ku_hard %f' % ku_hard)
K_hard = SI(ku_hard, "J/m^3")
K_soft = SI(ku_soft, "J/m^3")
# LLG damping
LLG_damping = 1.0

# create a simulation
sim = nmag.Simulation()
# --------------------------------------------------------------------------- #
H_1 = nmag.MagMaterial(name='H_1',
    Ms=M_hard,
    exchange_coupling=A_hard,
    anisotropy=nmag.uniaxial_anisotropy(axis=KA_hard, K1=K_hard),
    llg_damping=LLG_damping)
S_2 = nmag.MagMaterial(name='S_2',
    Ms=M_soft,
    exchange_coupling=A_soft,
    anisotropy=nmag.uniaxial_anisotropy(axis=KA_soft, K1=K_soft),
    llg_damping=LLG_damping)
H_3 = nmag.MagMaterial(name='H_3',
    Ms=M_hard,
    exchange_coupling=A_hard,
    anisotropy=nmag.uniaxial_anisotropy(axis=KA_hard, K1=K_hard),
    llg_damping=LLG_damping)
S_4 = nmag.MagMaterial(name='S_4',
    Ms=M_soft,
    exchange_coupling=A_soft,
    anisotropy=nmag.uniaxial_anisotropy(axis=KA_soft, K1=K_soft),
Beispiel #9
0
import nmag
from nmag import SI, si, at

# create simulation object
ps = SI(1e-12, "s")

sim = nmag.Simulation()

# define magnetic material (data from Kronmueller's book)
NdFeB = nmag.MagMaterial(name="NdFeB",
                         Ms=1.6 * si.Tesla / si.mu0,
                         exchange_coupling=SI(7.3e-12, "J/m"),
                         anisotropy=nmag.uniaxial_anisotropy(
                             axis=[0.01, 0.01, 1],
                             K1=SI(4.3e6, "J/m^3"),
                             K2=SI(0 * 0.65e6, "J/m^3")))

sim.load_mesh("cube.nmesh.h5", [("cube", NdFeB)], unit_length=SI(1.0e-9, "m"))

sim.set_m([-0.01, -0.01, 1])

Hs = nmag.vector_set(
    direction=[0., 0., 1.],
    norm_list=[-1, -2, [], -4, -4.2, [], -4.9, -4.91, [], -4.94],
    units=1e6 * SI('A/m'))

sim.hysteresis(Hs, save=[('fields', 'restart', at('convergence'))])
Beispiel #10
0
import nmag
from nmag import SI, si, at

# create simulation object
ps = SI(1e-12, "s")

sim = nmag.Simulation()

# define magnetic material (data from Kronmueller's book)
NdFeB = nmag.MagMaterial(
    name="NdFeB",
    Ms=1.6 * si.Tesla / si.mu0,
    exchange_coupling=SI(7.3e-12, "J/m"),
    anisotropy=nmag.uniaxial_anisotropy(axis=[0.01, 0.01, 1], K1=SI(4.3e6, "J/m^3"), K2=SI(0 * 0.65e6, "J/m^3")),
)

sim.load_mesh("cube.nmesh.h5", [("cube", NdFeB)], unit_length=SI(1.0e-9, "m"))

sim.set_m([-0.01, -0.01, 1])

Hs = nmag.vector_set(
    direction=[0.0, 0.0, 1.0], norm_list=[-1, -2, [], -4, -4.2, [], -4.9, -4.91, [], -4.94], units=1e6 * SI("A/m")
)

sim.hysteresis(Hs, save=[("fields", "restart", at("convergence"))])
Beispiel #11
0
    # Create the simulation object
    sim = nmag.Simulation(name, do_demag=False)

    # Load the mesh
    sim.load_mesh("bar.nmesh.h5", [("Py", mat_Py)], unit_length=SI(1e-9, "m"))

    # Set the initial magnetisation
    sim.set_m(lambda r: m_gen(np.array(r) * 1e9))
    #sim.advance_time(SI(1e-12, 's') )

    # Save the exchange field and the magnetisation once at the beginning
    # of the simulation for comparison with finmag
    np.savetxt("H_%s_nmag.txt" % name, sim.get_subfield("H_anis_Py"))
    np.savetxt("m0_nmag.txt", sim.get_subfield("m_Py"))


if __name__ == "__main__":
    # define uniaxial_anisotropy
    anis = nmag.uniaxial_anisotropy(axis=[1, 0, 0],
                                    K1=SI(520e3, "J/m^3"),
                                    K2=SI(230e3, "J/m^3"))
    generate_anisotropy_data(anis)

    cubic = nmag.cubic_anisotropy(axis1=[1, 0, 0],
                                  axis2=[0, 1, 0],
                                  K1=SI(520e3, "J/m^3"),
                                  K2=SI(230e3, "J/m^3"),
                                  K3=SI(123e3, "J/m^3"))
    generate_anisotropy_data(cubic, name='cubic_anis')
Beispiel #12
0
import os, sys, math
import nmag, nfem
from nmag import SI, mesh
from nsim import sets
from nsim.si_units.si import mu0, Tesla, degrees_per_ns
import nmeshlib.unidmesher as unidmesher

# --------------------------------------------
# --- Details about the layers and the mesh and the material

# Choose Co as a material
mat_Co = nmag.MagMaterial(
    name="Co",
    Ms=SI(1.42444e6, "A/m"),
    exchange_coupling=SI(3.02e-11, "J/m"),
    anisotropy=nmag.uniaxial_anisotropy(axis=[1, 1, 1], K1=SI(0.7e6, "J/m^3"), K2=SI(0.18e6, "J/m^3")),
    llg_gamma_G=SI(0.2211e6, "m/ A s"),
    llg_normalisationfactor=SI(0.001e12, "1/s"),
)

mesh_name = "uniaxial_1d"
mesh_unit = SI(1e-9, "m")
layers = [(-10.0, 10.0)]
discretization = 1.0
new_mesh = True

# --------------------------------------------
## The initial configuration and how the applied field should change

m0 = [1, 0, 1]  # Initial direction for the magnetisation
Beispiel #13
0
#--- Details about the mesh and its discretization

mesh_unit = SI(1e-9, "m")
d1 = 15 # in nm (Fe3O4)
d2 = 5  # in nm (CoFe2O4)
layers = [(0.0, d1), (d1, d1+d2)]
discretization = 1.0

#--------------------------------------------
#--- Details about the layers and the materials

# First we define Fe3O4
Ms = SI(0.5e6, "A/m")

anisotropy = \
  nmag.uniaxial_anisotropy(axis=[1, 0, 0], K1=SI(0.01e6, "J/m^3"))

# demag becomes a shape anisotropy
demag = \
  nmag.uniaxial_anisotropy(axis=[1, 0, 0], K1=-0.5*mu0*Ms**2)

mat_Fe3O4 = \
  nmag.MagMaterial(name="Fe3O4",
                   Ms=Ms,
                   exchange_coupling=SI(13.0e-11, "J/m"), # ?
                   anisotropy=anisotropy+demag,
                   llg_damping=0.5)

# Then we define CoFe2O4
Ms = SI(0.4e6, "A/m")
Beispiel #14
0
m_file = lambda num_stage: "%s/%s.h5" % (m_dir, num_stage)
m0_file = m_file('last')
go_fast = not os.path.exists(m0_file)

llg_damping = SI([0.02, 0.5][go_fast])

# Create the material for Fe2 in DyFe2 and YFe2
# A unique material can be used because the iron moment per unit volume
# in DyFe2 and YFe2 are the same.
# NOTE: The demagnetising field acts as a shape anisotropy in the 1D model:
# H_demag = -M_x which can be expressed as an uniaxial anisotropy
#   H_demag = (2 K_1 m*u) / (mu0*M_sat)
# where the axis u = (1, 0, 0) and K_1 = -mu0*M_sat^2/2
# NOTE: Strictly this is wrong
Ms_Fe2 = SI(0.54861229676e6, "A/m")
uni_anis = nmag.uniaxial_anisotropy(axis=[1, 0, 0], K1=-0.5*mu0*Ms_Fe2**2)
mat_Fe2 = \
  nmag.MagMaterial(name="Fe2",
                   Ms=Ms_Fe2,
                   exchange_coupling=SI(14.6e-12, "J/m"),
                   anisotropy=uni_anis,
                   llg_normalisationfactor=SI(0.001e12, "1/s"),
                   llg_damping=llg_damping,
                   llg_polarisation=SI(1.0))

# Create the material
Ms_DyFe2 = SI(1.18085121013e6, "A/m")
Ms_Dy = Ms_DyFe2 + Ms_Fe2
# the sum comes from taking the data from Jurgen's simulations
# where the total moment in DyFe2 is given Ms_DyFe2 = Ms_Dy - Ms_Fe2
cubic_Dy = \