}
                         """)

mag.set_local_magnetic_coupling(mat_Dy, mat_Fe, -80.0)

mag.defregion("DyFe2", nm.box([1.0], [2.0]), mag_mat=[mat_Dy, mat_Fe])

mag.defregion(
    "YFe2",
    nm.union([nm.box([0.0], [1.0]), nm.box([2.0], [3.0])]),
    mag_mat=mat_Fe  # can pass either a material or a list of materials
)

mag.set_meshing_parameters(
    cache_name="exchange-spring-mesh",
    bounding_box=([-1.0], [5.0]),
    a0=0.25,
    max_steps=100,
)

mag.create_mesh()


def initial_m(dof_name, coords):
    print "DDD initial_M(dof_name=\"", dof_name, "\",coords=", coords, ")\n"
    dir = dof_name[1][0]
    if dir == 0:
        return 0.0
    elif dir == 1:
        return math.cos(2.0 * math.pi * coords[0] / 6.0)
    else:
        return math.sin(2.0 * math.pi * coords[0] / 6.0)
Example #2
0
                         )

mag.set_local_magnetic_coupling(mat_Dy,mat_Fe,-80.0)

mag.defregion("DyFe2",nm.box([1.0],[2.0]),
              mag_mat=[mat_Dy,mat_Fe]
              )


mag.defregion("YFe2", nm.union([nm.box([0.0],[1.0]),nm.box([2.0],[3.0])]),
              mag_mat=mat_Fe # can pass either a material or a list of materials
              )

mag.set_meshing_parameters(cache_name="exchange-spring-mesh",
                           bounding_box=([-1.0],[5.0]),
                           a0=0.25,
                           max_steps=100,
                           )

mag.create_mesh()

def initial_m(dof_name,coords):
    print "DDD initial_M(dof_name=\"",dof_name,"\",coords=",coords,")\n"
    dir=dof_name[1][0]
    if dir==0:
        return 0.0
    elif dir==1:
        return math.cos(2.0*math.pi*coords[0]/6.0)
    else:
        return math.sin(2.0*math.pi*coords[0]/6.0)
Example #3
0
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

nfem.visual.fields2vtkfile([mag.default_simulation_context.field_M],'sphere-initial.vtk',mesh=mag.default_simulation_context.mesh)

mag.advance_time_cvode(0.02)
    
nfem.visual.fields2vtkfile([mag.default_simulation_context.field_M],'sphere-final.vtk',mesh=mag.default_simulation_context.mesh)
Example #4
0
    "Ball 2",
    nm.ellipsoid([2.0, 2.0, 2.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:
#
# mag.defregion("Ball 1",nm.shifted([-3,0,0],nm.sphere(3)))
# mag.defregion("Ball 2",nm.shifted([ 3,0,0],nm.sphere(3)))
#
# or alternatively:
#
# sphere = nm.sphere(3)
# mag.defregion("Ball 1",nm.shifted([-3,0,0],sphere))
# mag.defregion("Ball 2",nm.shifted([ 3,0,0],sphere))

mag.set_meshing_parameters(cache_name="two-balls")

mag.create_mesh()


def initial_M(dof_name, coords):
    dir = dof_name[1][0]
    if dir == 0:
        return math.cos(coords[0])
    elif dir == 1:
        return math.sin(coords[0])
    else:
        return 0


mag.set_magnetization([1.0, 0.0, 0.0])  # may also provide a function here!
Example #5
0
mag.defregion("Ball 2",nm.ellipsoid([2.0,2.0,2.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:
#
# mag.defregion("Ball 1",nm.shifted([-3,0,0],nm.sphere(3)))
# mag.defregion("Ball 2",nm.shifted([ 3,0,0],nm.sphere(3)))
#
# or alternatively:
#
# sphere = nm.sphere(3)
# mag.defregion("Ball 1",nm.shifted([-3,0,0],sphere))
# mag.defregion("Ball 2",nm.shifted([ 3,0,0],sphere))


mag.set_meshing_parameters(cache_name="two-balls")

mag.create_mesh()

def initial_M(dof_name,coords):
    dir=dof_name[1][0]
    if dir==0:
        return math.cos(coords[0])
    elif dir==1:
        return math.sin(coords[0])
    else: return 0
    
mag.set_magnetization([1.0,0.0,0.0]) # may also provide a function here!

#mag.set_magnetization(initial_M) # may also provide a function here!