Exemple #1
0
    neigh_force_scale=1.,
    density=density,
    initial_settling_steps=50,
    max_relaxation=4,
    # callback=(my_function, N),
    # max_steps=677
    max_steps=200)

the_mesh.save("/tmp/example.mesh")

nfem2.set_default_mesh(the_mesh)

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

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

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

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

# Initial conductivity is spatially constant:

the_mesh = nmesh.load("ring.nmesh")

meshinfo = nmesh.tolists(the_mesh)
tmp = meshinfo[2][2]
nfem2.set_default_mesh(the_mesh)

##### Loading the mesh node positions #####
meshinfo = the_mesh.tolists()
node_position = meshinfo[0][2]
# print initial_magn


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

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


# in make_mwe "1" is the region where I set the field
mwe_sigma = nfem2.make_mwe("mwe_sigma", [(1, element_sigma)])
mwe_drho_by_dt = nfem2.make_mwe("mwe_drho_by_dt", [(1, element_drho_by_dt)])
mwe_phi = nfem2.make_mwe("mwe_phi", [(1, element_phi)])
mwe_J = nfem2.make_mwe("mwe_J", [(1, element_J)])
mwe_M = nfem2.make_mwe("mwe_M", [(1, element_M)])


diffop_laplace = nfem2.diffop("-<d/dxj drho_by_dt|sigma|d/dxj phi>, j:2")
                                             (6, ), (7, )])

# the node_position is used to fill the
# magnetization mwe_M and therefore
# only the nodes of the ring are used
node_position = meshinfo_ring[0][2]

##print "#######################################"
##print "##          RING NODES               ##"
##print "#######################################"
##for n in range(len(node_position)):
##    print n, node_position[n]

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

element_sigma_Py = nfem2.make_element("sigma_Py", [])
element_sigma_Au = nfem2.make_element("sigma_Au", [])
element_drho_by_dt = nfem2.make_element("drho_by_dt", [])
element_phi = nfem2.make_element("phi", [])
element_J = nfem2.make_element("J", [3])
element_M = nfem2.make_element("M", [3])

# sigma = sigma_Py for element 1 (ring) and sigma = sigma_Au for elements [2:7] (contacts)
mwe_sigma = nfem2.make_mwe("mwe_sigma", [(1, element_sigma_Py)] +
                           [(body_nr, element_sigma_Au)
                            for body_nr in range(2, 8)])
mwe_drho_by_dt = nfem2.make_mwe("mwe_drho_by_dt",
                                [(body_nr, element_drho_by_dt)
                                 for body_nr in range(1, 8)])
mwe_phi = nfem2.make_mwe("mwe_phi",
                         [(body_nr, element_phi) for body_nr in range(1, 8)])
Exemple #4
0
 meshinfo_contact12] = nmesh.visual.separate_parts(meshinfo, listOfParts=[(1,),(2,),(3,),(4,),(5,),(6,),(7,)])

# the node_position is used to fill the
# magnetization mwe_M and therefore
# only the nodes of the ring are used
node_position = meshinfo_ring[0][2]

##print "#######################################"
##print "##          RING NODES               ##"
##print "#######################################"
##for n in range(len(node_position)):
##    print n, node_position[n]

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

element_sigma_Py     = nfem2.make_element("sigma_Py",[]);
element_sigma_Au     = nfem2.make_element("sigma_Au",[]);
element_drho_by_dt= nfem2.make_element("drho_by_dt",[]);
element_phi       = nfem2.make_element("phi",[]);
element_J         = nfem2.make_element("J",[3]);
element_M         = nfem2.make_element("M",[3]);


# sigma = sigma_Py for element 1 (ring) and sigma = sigma_Au for elements [2:7] (contacts)   
mwe_sigma      = nfem2.make_mwe("mwe_sigma",     [(1, element_sigma_Py)]+[(body_nr, element_sigma_Au) for body_nr in range(2,8)])
mwe_drho_by_dt = nfem2.make_mwe("mwe_drho_by_dt",[(body_nr,element_drho_by_dt) for body_nr in range(1,8)])
mwe_phi        = nfem2.make_mwe("mwe_phi",       [(body_nr,element_phi) for body_nr in range(1,8)])
mwe_J          = nfem2.make_mwe("mwe_J",         [(body_nr,element_J) for body_nr in range(1,8)])
mwe_M          = nfem2.make_mwe("mwe_M",         [(1,element_M)])