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)

mag.set_magnetization(initial_m)

# mag.advance_time([0.0,0.0,0.0],time=0.001)

import nfem.visual

# nfem.visual.fields2vtkfile([mag.default_simulation_context.field_M],'data%05d.vtk' % 0,mesh=mag.default_simulation_context.mesh)

def print_field():
    for i in range(1,299):
        x=i*0.01
        probed=mag.probe([x])
        m_y_fe = 0.0
        m_y_dy = 0.0
        if len(probed)==2:
            m_y_fe=probed[1][1][1]
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)


mag.set_magnetization(initial_m)

# mag.advance_time([0.0,0.0,0.0],time=0.001)

import nfem.visual

nfem.visual.fields2vtkfile([mag.default_simulation_context.field_M],
                           'data%05d.vtk' % 0,
                           mesh=mag.default_simulation_context.mesh)


def print_field():
    for i in range(1, 299):
        x = i * 0.01
        probed = mag.probe([x])
        m_y_fe = 0.0
Beispiel #3
0
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!

# NOTE: set_magnetization should also be able
# to take just a constant vector as an argument.

print "Total magnetization: ", mag.integrate()

f = open("data.dat", "w")

import nfem
import nfem.visual

frame = 0
Beispiel #4
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)

Beispiel #5
0
# 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!

# NOTE: set_magnetization should also be able
# to take just a constant vector as an argument.

print "Total magnetization: ", mag.integrate()

f=open("data.dat","w")

import nfem
import nfem.visual


frame = 0
Beispiel #6
0
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!

# NOTE: set_magnetization should also be able
# to take just a constant vector as an argument.

print "Total magnetization: ", mag.integrate()

# XXXDDDXXXDDD
for n in range(1, 100):
    print "T=", mag.default_simulation_context.timestepper.advance_time(
        [0.0, 0.0, 0.0, 0.0, 0.0])
    # this needs the intensive params!

# time.sleep(1000) # so we do not lose the dynamically generated C code...
Beispiel #7
0
# 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!

# NOTE: set_magnetization should also be able
# to take just a constant vector as an argument.

print "Total magnetization: ", mag.integrate()

# XXXDDDXXXDDD
for n in range(1,100):
    print "T=",mag.default_simulation_context.timestepper.advance_time([0.0,0.0,0.0,0.0,0.0])
    # this needs the intensive params!

# time.sleep(1000) # so we do not lose the dynamically generated C code...