示例#1
0
文件: mumag.py 项目: fangohr/nmag-src
 def new_mwe_and_field(self, name, indices=[], where=None, initial_values=set_to_zero):
   if where == None: where = self.where
   element = nfem.make_element(name, indices, self.mesh.dim, self.order)
   associations = list((body_nr, element) for body_nr in where)
   mwe = nfem.make_mwe(name, associations, mesh=self.mesh)
   field = nfem.make_field(mwe, initial_values=field_function(initial_values))
   self.mwes[name] = mwe
   self.fields[name] = field
   return (mwe, field)
示例#2
0
文件: mumag.py 项目: anyint/nmag-src
 def new_mwe_and_field(self,
                       name,
                       indices=[],
                       where=None,
                       initial_values=set_to_zero):
     if where == None: where = self.where
     element = nfem.make_element(name, indices, self.mesh.dim, self.order)
     associations = list((body_nr, element) for body_nr in where)
     mwe = nfem.make_mwe(name, associations, mesh=self.mesh)
     field = nfem.make_field(mwe,
                             initial_values=field_function(initial_values))
     self.mwes[name] = mwe
     self.fields[name] = field
     return (mwe, field)
示例#3
0
    neigh_force_scale=1.,
    initial_settling_steps=50,
    max_relaxation=4,
    max_steps=400)

nfem.set_default_mesh(the_mesh)

the_mesh.save("themesh.nmesh")

# conductivity (scalar)
element_sigma = nfem.make_element("sigma", [])
element_drho_by_dt = nfem.make_element("drho_by_dt", [])
element_phi = nfem.make_element("phi", [])
element_J = nfem.make_element("J", [2])

mwe_sigma = nfem.make_mwe("mwe_sigma", [(1, element_sigma)])
mwe_drho_by_dt = nfem.make_mwe("mwe_drho_by_dt", [(1, element_drho_by_dt)])
mwe_phi = nfem.make_mwe("mwe_phi", [(1, element_phi)])
mwe_J = nfem.make_mwe("mwe_J", [(1, element_J)])

diffop_laplace = nfem.diffop("-<d/dxj drho_by_dt|sigma|d/dxj phi>, j:2")
diffop_J = nfem.diffop("<J(k)|sigma|d/dxk phi>, k:2")


def fun_sigma0(dof_name_indices, position):
    return sigma0


field_sigma = nfem.make_field(mwe_sigma, fun_sigma0)

示例#4
0
                      max_steps=200
                      )

nfem.set_default_mesh(the_mesh)

##### Making the elements... #####

empty_element=ocaml.empty_element;

# conductivity (scalar)
element_sigma     = nfem.make_element("sigma",[]);
element_drho_by_dt= nfem.make_element("drho_by_dt",[]);
element_phi       = nfem.make_element("phi",[]);
element_J         = nfem.make_element("J",[2]);

mwe_sigma      = nfem.make_mwe("mwe_sigma",     [(1,element_sigma)])
mwe_drho_by_dt = nfem.make_mwe("mwe_drho_by_dt",[(1,element_drho_by_dt)])
mwe_phi        = nfem.make_mwe("mwe_phi",       [(1,element_phi)])
mwe_J          = nfem.make_mwe("mwe_J",         [(1,element_J)])

diffop_laplace=nfem.diffop("-<d/dxj drho_by_dt|sigma|d/dxj phi>, j:2")
diffop_J=nfem.diffop("<J(k)|sigma|d/dxk phi>, k:2")

# Initial conductivity is spatially constant:

def fun_sigma0(dof_name_indices,position):
    return sigma0

# Later on, we will modify this field:

field_sigma=nfem.make_field(mwe_sigma,fun_sigma0)
示例#5
0
                      density = density,
                      initial_settling_steps = 50,
                      max_relaxation = 4,
                      max_steps=500
                      )

nfem.set_default_mesh(the_mesh)

##### Making the elements... #####

element_M     = nfem.make_element("M",[3]);
element_H     = nfem.make_element("H",[3]);
element_rho_M = nfem.make_element("rho_M",[]);
element_phi_M = nfem.make_element("phi_M",[]);

mwe_M      = nfem.make_mwe("mwe_M",     [(1,element_M)])
mwe_H      = nfem.make_mwe("mwe_H",     [(1,element_H)])
mwe_rho_M  = nfem.make_mwe("mwe_rho_M",     [(1,element_rho_M)])
mwe_phi_M  = nfem.make_mwe("mwe_phi_M",     [(1,element_phi_M)])

log.info("OK 1!")

# Initial magnetization is spatially constant: M=(1 0 0)

#def fun_M0(dof_name_indices,pos):
#    r=math.sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2])
#    if dof_name_indices[1][0] == 0 and r < 2.9:
#        return 1.0
#    else:
#        return 0.0
示例#6
0
    a0=0.7,
    bounding_box=[[-6.0, -3.0, -3.0], [6.0, 3.0, 3.0]],
    neigh_force_scale=1.,
    # density = density,
    initial_settling_steps=50,
    max_relaxation=4,
    # callback=(my_function, N),
    # max_steps=677
    max_steps=500)

nfem.set_default_mesh(the_mesh)

element_M = nfem.make_element("M", [3])
element_H = nfem.make_element("H", [3])

mwe_M = nfem.make_mwe("mwe_M", [(1, element_M)])
mwe_H = nfem.make_mwe("mwe_H", [(1, element_H)])

diffop_v_laplace = nfem.diffop("-<d/dxj H(k) || d/dxj M(k)>, j:3, k:3")


# Note that this magnetization is "mostly zero":
def fun_M0(dof_name_indices, position):
    if dof_name_indices[1][0] == 1:  # y-direction
        x = position[0]
        return 1.0 / (1.0 + (x * x / 4.0))
    else:
        return 0.0


field_M = nfem.make_field(mwe_M, fun_M0)
示例#7
0
                     max_relaxation = 4,
                     max_steps=500
                     )

# === The 2.5d computation ===

nfem.set_default_mesh(mesh_2d)

##### Making the elements... #####

elem2d_M     = nfem.make_element("M",[3],dim=2);
elem2d_H     = nfem.make_element("H",[3],dim=2);
elem2d_rho_M = nfem.make_element("rho_M",[],dim=2);
elem2d_phi_M = nfem.make_element("phi_M",[],dim=2);

mwe2d_M      = nfem.make_mwe("mwe2d_M",     [(1,elem2d_M)])
mwe2d_H      = nfem.make_mwe("mwe2d_H",     [(1,elem2d_H)])
mwe2d_rho_M  = nfem.make_mwe("mwe2d_rho_M", [(1,elem2d_rho_M)])
mwe2d_phi_M  = nfem.make_mwe("mwe2d_phi_M", [(1,elem2d_phi_M)])

#This is " $\ laplace -phi = =rho_M$
pmx2d_laplace=nfem.prematrix(diffop_laplace,mwe2d_rho_M,mwe2d_phi_M)
pmx2d_div_M=nfem.prematrix(diffop_div_M,mwe2d_rho_M,mwe2d_M,ignore_jumps=False)
pmx2d_grad_phi=nfem.prematrix(diffop_grad_phi,mwe2d_H,mwe2d_phi_M)

solve_bem_2d=nfem.laplace_solver_bem(pmx2d_laplace,inside_regions=[1], thickness=thickness2d)

compute_div_M_2d=nfem.prematrix_applicator(pmx2d_div_M,interface_coeffs=[(1,-1,1.0)])
compute_grad_phi_2d=nfem.prematrix_applicator(pmx2d_grad_phi)

field2d_M0=nfem.make_field(mwe2d_M,fun_M0)
示例#8
0
                      neigh_force_scale = 1.,
                      # density = density,
                      initial_settling_steps = 50,
                      max_relaxation = 4,
                      # callback=(my_function, N),
                      # max_steps=677
                      max_steps=500
                      )

nfem.set_default_mesh(the_mesh)

element_M = nfem.make_element("M",[3])
element_M2 = nfem.make_element("M2",[3],ord=2)
element_H = nfem.make_element("H",[3])

mwe_M      = nfem.make_mwe("mwe_M", [(1,element_M)])
mwe_M2      = nfem.make_mwe("mwe_M2", [(1,element_M2)])
mwe_H      = nfem.make_mwe("mwe_H", [(1,element_H)])

diffop_v_laplace = nfem.diffop("-<d/dxj H(k) || d/dxj M(k)>, j:3, k:3")

print "Made MWEs"
sys.stdout.flush()

# Note that this magnetization is "mostly zero":
def fun_M0(dof_name_indices,position):
    if dof_name_indices[1][0]==1: # y-direction
        x=position[0]
        return 1.0/(1.0+(x*x/4.0))
    else:
        return 0.0
示例#9
0
文件: mumag.py 项目: fangohr/nmag-src
 def new_mwe(self, name, indices=[], where=None):
   if where == None: where = self.where
   element = nfem.make_element(name, indices, self.mesh.dim, self.order)
   associations = list((body_nr, element) for body_nr in where)
   mwe = nfem.make_mwe(name, associations, mesh=self.mesh)
   return mwe
示例#10
0
文件: mumag.py 项目: anyint/nmag-src
 def new_mwe(self, name, indices=[], where=None):
     if where == None: where = self.where
     element = nfem.make_element(name, indices, self.mesh.dim, self.order)
     associations = list((body_nr, element) for body_nr in where)
     mwe = nfem.make_mwe(name, associations, mesh=self.mesh)
     return mwe