예제 #1
0
    ["H_x", "H_y", "H_z"],  # may also set T,p,E, etc.
    external_magnetization=["H_x", "H_y", "H_z"])

# mag.set_default_order(1) # default anyway...

mag.set_features({
    "demag": False,
    "exchange": True,
    "timestep": True
})  # XXX change usage!

mat_Dy = mag.MagMaterial(
    "Dy",
    Ms=2.5,
    A=0.0,  # A = exchange constant
    anisotropy=(
        2, lambda r: -4.0 * r[2] * r[2]
    ),  # XXX BUG: nsim must include an extra minus sign here: need -grad E!
    extra_H="H_total_Dy(0) -= mag[0]*2.5;",
)

mat_Fe = mag.MagMaterial("Fe",
                         Ms=1.2,
                         A=4.0,
                         extra_H="""H_total_Fe(0) -= mag[0]*1.2;
                         if(X(0)<0.01 || X(0)>2.99) /* pin the M field at boundaries */
                         {
                          H_total_Fe(0)=0.0;
                          H_total_Fe(1)=0.0;
                          H_total_Fe(2)=0.0;
                         }
예제 #2
0
import nmag1 as mag, nmesh as nm, sys
import math

import time

# Note: we should make a habit of always starting out by defining
# the additional intensive parameters of our model.

#This adds a Zeeman field:
PermAlloy = mag.MagMaterial("Funny",
                            extra_H="""
h_total_Funny[0] += 0.0;
h_total_Funny[1] += 1.0;
h_total_Funny[2] += 0.0;
""")

mag.set_default_material(PermAlloy)

mag.set_intensive_parameters(["T", "p", "H_x", "H_y", "H_z"])

#mag.defregion("Ball 1",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[-3.0,0.0,0.0])]))

print "OK 1"
sys.stdout.flush()

#mag.defregion("Ball 2",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[3.0,0.0,0.0])]))

mag.defregion(
    "Ball 2",
    nm.ellipsoid([2.0, 2.0, 2.0], transform=[("shift", [3.0, 0.0, 0.0])]))
예제 #3
0
mag.set_intensive_parameters(
    ["H_x", "H_y", "H_z"],  # may also set T,p,E, etc.
    external_magnetization=["H_x", "H_y", "H_z"])

mag.set_features({
    "demag": False,
    "exchange": True,
    "timestep": True
})  # XXX change usage!

mat_Dy = mag.MagMaterial(
    "Dy",
    Ms=2.5,
    A=1.5,  # A = exchange constant
    anisotropy=(
        2,
        lambda r: -10.0 * r[2] * r[2] + 6.0 * r[1] * r[2] - 4.0 * r[2] * r[2]),
    extra_H="H_total_Dy(0) -= mag[0]*2.5;",
)

mat_Fe = mag.MagMaterial("Fe",
                         Ms=1.2,
                         A=4.0,
                         extra_H="""H_total_Fe(0) -= mag[0]*1.2;
                         if(X(0)<0.01 || X(0)>3.99) /* pin the M field at boundaries */
                         {
                          H_total_Fe(0)=0.0;
                          H_total_Fe(1)=0.0;
                          H_total_Fe(2)=0.0;
                         }
예제 #4
0
import nmag1 as mag, nmesh as nm, sys, math, time
import nfem # for debugging

#mag.set_intensive_parameters(["H_x","H_y","H_z"], # may also set T,p,E, etc.
#                             external_magnetization=["H_x","H_y","H_z"])
# ^ XXX not used yet, as we are going to use the experimental cvode integrator...

mag.set_intensive_parameters([])


# mag.set_default_order(1) # default anyway...

mag.set_features({"demag":True,"exchange":True,"timestep":True}) # XXX change usage!

mat_Py = mag.MagMaterial("Py",Ms=1.0,A=13.0,  # A = exchange constant
                         )

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

mag.set_meshing_parameters(cache_name="exchange-spring-mesh",
                           bounding_box=([-4.0,-4.0,-4.0],[4.0,4.0,4.0]),
                           a0=1.0,
                           max_steps=600,
                           )

mag.create_mesh()

mag.set_magnetization([0.0,0.0,1.0]) # providing a vector rather than a function

import nfem.visual
import nmag1 as mag, nmesh as nm, sys
import math

import time

# Note: we should make a habit of always starting out by defining
# the additional intensive parameters of our model.

#This adds a Zeeman field:
PermAlloy=mag.MagMaterial("Funny",extra_H="""
h_total_Funny[0] += H_x;
h_total_Funny[1] += H_y;
h_total_Funny[2] += H_z;
""")

mag.set_default_material(PermAlloy)



mag.set_intensive_parameters(["T","p","H_x","H_y","H_z"])

mag.defregion("Ball 1",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[-3.0,0.0,0.0])]))

print "OK 1"
sys.stdout.flush()

mag.defregion("Ball 2",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[3.0,0.0,0.0])]))

# Note: clearly, we DO need a better way to specify geometries. Ideally, I would like to be
# able to write instead: