Example #1
0
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,
        0.8 * math.cos(coords[0] / 1.0) * 1e6, 0.6 * 1e6
    ]


def initial_magnetization(coords, mag_type):
Example #2
0
                          )

# 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

sim=nmag.SimulationContext("debug-jacobian",do_demag=False)

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

sim.load_mesh("./debug-jacobian.mesh", [("Py", mat_Py)])

print "DDD loaded mesh!"

def initial_magnetization(coords,mag_type):
    # Note: length is not one here, but the system will internally
    # normalize M in set_magnetization!
    print "Setting magnetization for coords=",coords," mag_type=",mag_type
    return [0.0,
            0.8*math.cos(coords[0]/6.0),
            0.6*math.sin(coords[0]/6.0),