Example #1
0
#nmag.set_log_level('debug')

intensive_param_by_name = {"H_x": 0.1, "H_y": 0.0, "H_z": 0.0}
# very slightly pulling in x-direction


def test_anisotropy_energy(v):  # direction is unit-normalized!
    print "DDD anisotropy dir=", v
    result = (1.0 * v[0] * v[0] + 2.0 * v[1] * v[1] + 3.5 * v[2] * v[2])
    return result * 0.0


mat_Py = nmag.MagMaterial(
    "Py",
    Ms=SI(1e6, "A/m"),
    J=SI(13.0e-12, "J/m"),
    #Ms=1.,                #Matteo, very strange: if I use the SI units above,
    #J=13.,                #then I get a wierd magsim-brain failure!
    anisotropy_order=2,
    anisotropy=test_anisotropy_energy)

sim = nmag.SimulationContext("sphere")

# sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults...
sim.timestepper_tuning_params = [1e-6, 1e-6, 2, 300]

sim.defregion("Py", nm.ellipsoid([3.0, 3.0, 3.0]), mag_mat=mat_Py)


def initial_magnetization_0(coords, mag_type):
    return [
        0.8 * math.sin(coords[0] / 1.0) * 1e6,
Example #2
0
import nmag2 as nmag, nmesh as nm, sys, math, time
import nfem
# import nfem.visual

import ocaml #need this as long as we use ocaml.probe_field

from nmag2.si_units import SI

#nmag.set_global_log_level('debug')
#nmag.set_log_level('debug')

intensive_param_by_name={"H_x":0.0,"H_y":0.0,"H_z":0.0}
# Not applying any external field.

mat_Py = nmag.MagMaterial("Py",
                          Ms=SI(1e6,"A/m"),
                          J=SI(13.0e-12,"J/m"),
                          )

# We afterwards hack the parameters of that material definition
# that actually enter the LLG:

print "LLG length control: ", mat_Py.su_llg_gamma 
# THIS RETURNS: LLG length control:  1e-24
# That is completely bogus!
# BUGFIX REQUIRED!

mat_Py.su_llg_coeff1=  -0.5*1.0 # M x H
mat_Py.su_llg_coeff2= -0.02*0.0 # M x (M x H) -- NOTE that the coefficient MUST be negative here.
# mat_Py.su_llg_gamma=2.0 # length control
mat_Py.su_llg_gamma=0.2 # length control
Example #3
0
#produce more output for now
nmag.set_global_log_level('debug')
nmag.set_log_level('debug')

intensive_param_by_name={"H_x":0.0,"H_y":0.0,"H_z":0.0}
# very slightly pulling in x-direction

def test_anisotropy_energy(v): # direction is unit-normalized!
    print "DDD anisotropy dir=",v
    result=(1.0*v[0]*v[0]+2.0*v[1]*v[1]+3.5*v[2]*v[2])
    return result*0.0

mat_Py = nmag.MagMaterial("Py",
                          Ms=SI(1e6,"A/m"),
                          exchange_coupling=SI(13.0e-12,"J/m"),
                          #Ms=1.,      
                          #J=13.,      
                          anisotropy_order=2,
                          anisotropy=test_anisotropy_energy
                          )

sim=nmag.SimulationContext("sphere")

# sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults...
sim.timestepper_tuning_params=[1e-6,1e-6,4,300]

sim.set_magnetization([0.0,1.0,0.0])
# ^ just to show we can place set_magnetization() where we want...

sim.defregion("Py", nm.ellipsoid([3.0,3.0,3.0]), mag_mat=mat_Py)

def initial_magnetization(coords,mag_type):
Example #4
0
#
# (C) 2006 Dr. Thomas Fischbacher
# Relaxation of the homogeneously magnetized sphere

import nmag2 as nmag, nmesh as nm, sys, math, time
import nfem
import nfem.visual

intensive_param_by_name = {"H_x": 0.1, "H_y": 0.0, "H_z": 0.0}
# very slightly pulling in x-direction

mat_Py = nmag.MagMaterial(
    "Py",
    Ms=1.0,
    J=13.0,  # A = exchange constant
    alpha=0.5,
    beta=0.2,
    gamma=2.0,
)

sim = nmag.SimulationContext("sphere", )

sim.defregion("Py", nm.ellipsoid([3.0, 3.0, 3.0]), mag_mat=mat_Py)


def initial_magnetization(dof_name, coords):
    direction = dof_name[1][0]
    if direction == 2:
        return 0.6
    elif direction == 1:
        return 0.8 * math.cos(coords[0] / 3.0)
Example #5
0
import ocaml  #need this as long as we use ocaml.probe_field

intensive_param_by_name = {"H_x": 0.2, "H_y": 0.0, "H_z": 0.0}
# very slightly pulling in x-direction


def test_anisotropy_energy(v):  # direction is unit-normalized!
    print "DDD anisotropy dir=", v
    result = (1.0 * v[0] * v[0] + 2.0 * v[1] * v[1] + 3.5 * v[2] * v[2])
    return result


mat_Py = nmag.MagMaterial("Py",
                          Ms=1.0,
                          J=13.0,
                          anisotropy_order=2,
                          anisotropy=test_anisotropy_energy)

mat_Fe = nmag.MagMaterial("Fe", Ms=SI(1.7e6, "A/m"), J=SI(2.07e-11, "J/m"))

sim = nmag.SimulationContext("sphere")

# sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults...
sim.timestepper_tuning_params = [1e-6, 1e-6, 4, 300]

sim.set_magnetization([0.0, 1.0, 0.0])
# ^ just to show we can place set_magnetization() where we want...

sim.defregion("Py",
              nmesh.ellipsoid([2.0, 2.0, 2.0],
Example #6
0
import ocaml  #need this as long as we use ocaml.probe_field

from nmag2.si_units import SI

time_init = time.time()

#produce more output for now
#nmag.set_global_log_level('debug')
#nmag.set_log_level('debug')

intensive_param_by_name = {"H_x": 0.1, "H_y": 0.0, "H_z": 0.0}
# very slightly pulling in x-direction

mat_Py = nmag.MagMaterial(
    "Py",
    Ms=SI(1e6, "A/m"),
    exchange_coupling=SI(13.0e-12, "J/m"),
)

sim = nmag.SimulationContext("sphere")

# sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults...
sim.timestepper_tuning_params = [1e-6, 1e-6, 2, 300]

sim.defregion("Py", nm.ellipsoid([3.0, 3.0, 3.0]), mag_mat=mat_Py)


def initial_magnetization(coords, mag_type):
    return [
        0.8 * math.sin(coords[0] / 1.0) * 1e6,
        0.8 * math.cos(coords[0] / 1.0) * 1e6, 0.6 * 1e6