• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python nmesh.ellipsoid函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nmesh.ellipsoid函数的典型用法代码示例。如果您正苦于以下问题:Python ellipsoid函数的具体用法?Python ellipsoid怎么用?Python ellipsoid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ellipsoid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: create_mesh

def create_mesh():

    nx = 3 #how many ellipsoids in x direction
    x0 = 3. #spacing of ellipsoids in x
    ny = 3 #how many ellipsoids in y direction
    y0 = 3. #spacing of ellipsoids in x
    nz = 3 #how many ellipsoids in y direction
    z0 = 3. #spacing of ellipsoids in x
    rx,ry,rz = 0.8,1.2,1#radii of ellipsoids

    #create list 'objects' with ellipsoids
    objects = []
    for i in range(nx):
        for j in range(ny):
            for k in range(nz):
                objects.append( nmesh.ellipsoid([rx,ry,rz], [("shift",[i*x0,j*y0,k*z0])]))

    #bounding box
    bbox = [[-2,-2,-2],[(nx-1)*x0+2,(ny-1)*y0+2,(nz-1)*z0+2]]

    #create the mesh
    mesh = nmesh.mesh(objects=objects,a0=0.75,bounding_box=bbox,mesh_bounding_box=True)
    #save plot to file
    mesh.save("test.nmesh",directory='.')

    return mesh
开发者ID:fangohr,项目名称:nmag-src,代码行数:26,代码来源:speedtest.py


示例2: execfile

# This example handles both demag and exchange.

import os,time,sys,math
import nmesh

execfile("../../interface/nsim/linalg_machine.py")

#ocaml.init_hlib("/home/fangohr/build/HLib-1.3/Library/.libs/libhmatrix-1.3.so")
ocaml.init_hlib("/home/tf/HLib-1.3/Library/.libs/libhmatrix-1.3.so")

objects=[nmesh.ellipsoid([3.0,3.0,3.0])
         ]


mesh = nmesh.mesh(objects=objects,
                  a0=1.0,
                  bounding_box=[[-5.0,-5.0,-5.0],[5.0,5.0,5.0]],
                  cache_name="geometry.mesh",
                  )

raw_mesh=mesh.raw_mesh

if ocaml.petsc_is_mpi():
    print "*** PARALLEL EXECUTION ***"
    nr_nodes=ocaml.petsc_mpi_nr_nodes()
    nr_points=ocaml.mesh_nr_points(raw_mesh)
    z=nr_points/nr_nodes
    distrib = [int(round(z*(i+1)))-int(round(z*i)) for i in range(0,nr_nodes)]
    slack=nr_points-reduce(lambda x,y:x+y,distrib)
    distrib[0] = distrib[0] + slack
    print "*** RAW MESH %s *** DISTRIB %s ***" %(repr(raw_mesh),repr(distrib))
开发者ID:fangohr,项目名称:nmag-doc,代码行数:31,代码来源:03_h_demag_exch_vtkvis.py


示例3:

import nmesh

cigar = nmesh.ellipsoid( [4,2] )

bbox = [[-5,-5],[5,5]]

mesh = nmesh.mesh(objects=[cigar], bounding_box=bbox, a0=0.5,
		  mesh_bounding_box=True)

nmesh.visual.plot2d_ps( mesh, "tutorial3.ps")
开发者ID:fangohr,项目名称:nmag-src,代码行数:10,代码来源:tutorial3.py


示例4:

nfem.set_default_dimension(2)
nfem.set_default_order(1)

# Simulation parameters
sigma0 = 1.0

print
"""
** Example: meshing half ring and compute current density for contacts at either side.
This is for possible collaboration with Uni Hamburg. **
"""

##### Creating the mesh #####

ring = nmesh.difference(
    nmesh.ellipsoid([4.0, 4.0]), [nmesh.ellipsoid([2.5, 2.5])])

halfring = nmesh.intersect([ring, nmesh.box([-4.0, -0.0], [4.0, 4.0])])

the_mesh = nmesh.mesh(
    objects=[halfring],
    cache_name="halfring",
    a0=0.2,
    bounding_box=[[-4.0, -4], [4.0, 4.0]],
    neigh_force_scale=1.,
    initial_settling_steps=50,
    max_relaxation=4,
    max_steps=400)

nfem.set_default_mesh(the_mesh)
开发者ID:fangohr,项目名称:nmag-doc,代码行数:30,代码来源:bug-fem2-halfring.py


示例5: range

import nmesh


nx = 2  #how many ellipsoids in x direction
x0 = 3. #spacing of ellipsoids in x
ny = 3  #how many ellipsoids in y direction
y0 = 3. #spacing of ellipsoids in x
rx,ry = 1,1.5 #radii of ellipsoids
angle = 45    #orientation of ellipsoids

#create list 'objects' with ellipsoids
objects = []
for i in range(nx):
    for j in range(ny):
        objects.append( nmesh.ellipsoid([rx,ry], \
                                        [("rotate2d",angle),\
                                         ("shift",[i*x0,j*y0])]))

#bounding box
bbox = [[-2,-2],[(nx-1)*x0+2,(ny-1)*y0+2]]

#create the mesh
mesh = nmesh.mesh(objects=objects,a0=0.5,bounding_box=bbox)

#Create post script plot of mesh
nmesh.visual.plot2d_ps(mesh,"ellipsoid_array.ps")

#save plot to file
mesh.save('ellipsoid_array.nmesh')
开发者ID:fangohr,项目名称:nmag-src,代码行数:29,代码来源:ellipsoid_array.py


示例6:

import nmesh

ellipsoid = nmesh.ellipsoid([0.75,1.25,1])

# create mesh
bbox = [[-0.75,-1.25,-1],[0.75,1.25,1]]

mesh = nmesh.mesh(objects = [ellipsoid], bounding_box=bbox,a0=0.5)

#create 3d-plot of surfaces and export eps
vis = nmesh.visual.show_bodies_mayavi(mesh)
nmesh.visual.export_visualisation(vis,"simple3d.eps")

#save mesh also as nmesh file
mesh.save('simple3d.nmesh')

开发者ID:fangohr,项目名称:nmag-src,代码行数:15,代码来源:simple3d.py


示例7: gnuplot_2d_points

import nmesh

ellipsoid = nmesh.ellipsoid([0.75, 1.25, 1, 0.9])

bbox = [[-1, -1.5, -1.5, -1], [1, 1.5, 1.5, 1]]

mesh = nmesh.mesh(objects=[ellipsoid], bounding_box=bbox, a0=0.5)

mesh.save("simple4d.nmesh")
print "should have saved mesh now"

# create gnuplot plot for manual (in other file not relevant here)


import os, os.path, sys, time

filename = "run_simple4d/simple4d.nmesh"
if not os.path.exists(filename):
    print "You need to run simple4d.py first to compute %s" % filename
    sys.exit(1)


def gnuplot_2d_points(points, filename):

    print "Starting to write %s" % filename,
    print time.asctime()

    """Given a list of pairs like
      points = [ [x0,y0], [x1,y1], [x2,y2], ..., [xN,yN]]

      and a filename, this will create a postscriptfile of name
开发者ID:fangohr,项目名称:nmag-src,代码行数:31,代码来源:simple4d.py


示例8: set_magnetization

                          J=SI(13.0e-12,"J/m"),
                          #Ms=1.,                #Matteo, very strange: if I use the SI units above,
                          #J=13.,                #then I get a wierd magsim-brain failure!
                          anisotropy_order=2,
                          anisotropy=test_anisotropy_energy
                          )

sim=nmag.SimulationContext("sphere")

# sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults...
sim.timestepper_tuning_params=[1e-6,1e-6,4,300]

sim.set_magnetization([0.0,1.0,0.0])
# ^ just to show we can place set_magnetization() where we want...

sim.defregion("Py", nm.ellipsoid([4.0,4.0,5.0]), mag_mat=mat_Py)

def initial_magnetization(coords,mag_type):
    return [0.8*math.sin(coords[0]/1.0)*1e6,
            0.8*math.cos(coords[0]/1.0)*1e6,
            0.6*1e6
            ]

sim.generate_mesh(([-30.0,-30.0,-50.0],[30.0,30.0,50.0]), # bounding box
                  a0=2.0,
                  max_steps=400,
                  cache_name="sphere3"
                  )

#
#sim.set_magnetization(initial_magnetization)
开发者ID:fangohr,项目名称:nmag-doc,代码行数:31,代码来源:sphere3.py


示例9: outer_skin

"""Compounds outer_skin() with order_mesh() to obtain a cross-section
   of the outer skin of an ellipsoid.

   Author: James Kenny           Last modified: $Date$
"""
import nmesh

ellipsoid = nmesh.ellipsoid([1.5,2.5,2])

# create mesh
bbox = [[-1.5,-2.5,-2],[1.5,2.5,2]]

mesh = nmesh.mesh(objects = [ellipsoid], bounding_box=bbox,a0=0.5)

# now extract the outer layer of cells and order the mesh in the y-axis
# to see an outer skin with only elements containing at least 2 surface
# points, the user should uncomment the end of the 2nd following line
mesh_info = mesh.tolists()
mesh_info = nmesh.visual.outer_skin(mesh_info)#, condition='>=2')


# visualise with in2circ as a solid and order it in the y-axis
v = nmesh.visual.solid_in2circ(mesh_info, order=1)

    




开发者ID:fangohr,项目名称:nmag-src,代码行数:23,代码来源:visual_cross_section.py


示例10:

import nmesh

ell = nmesh.ellipsoid([3,2])            # create ellipsoid
cone = nmesh.conic([-3,0],2,[3,0],0)    # create cone

inters = nmesh.intersect([ell, cone])   # create intersection of objects 

bbox = [[-5.,-4.],[5.,4.]]
mesh_ex = nmesh.mesh(objects = [inters], a0=0.4, bounding_box=bbox)

nmesh.visual.plot2d_ps(mesh_ex,"intersection.ps")


开发者ID:fangohr,项目名称:nmag-src,代码行数:11,代码来源:intersection.py


示例11:

import nmesh

radius = 4
sphere = nmesh.ellipsoid([radius,radius])

bbox = [[-5.,-5.],[5.,5.]]

# periodicity on x-axis
mesh_ex = nmesh.mesh(objects = [sphere], bounding_box=bbox, 
		     mesh_bounding_box=True,periodic=[True,False])

nmesh.visual.plot2d_ps(mesh_ex,"periodic.ps")


mesh_ex.save('periodic.nmesh')
开发者ID:fangohr,项目名称:nmag-src,代码行数:15,代码来源:periodic.py


示例12:

import nmesh

big = nmesh.ellipsoid([4.0,3.0])    # create a big ellipsoid
small = nmesh.ellipsoid([3.0,2.0])  # small ellipsoid

diff = nmesh.difference(big,[small])# create difference of ellipsoids 

bbox = [[-5.,-4.],[5.,4.]]
mesh_ex = nmesh.mesh(objects = [diff], a0=0.4, bounding_box=bbox)

# plot mesh
nmesh.visual.plot2d_ps(mesh_ex,"difference.ps")


开发者ID:fangohr,项目名称:nmag-src,代码行数:12,代码来源:difference.py


示例13: range

import nmesh

nx = 3 #how many ellipsoids in x direction
x0 = 3. #spacing of ellipsoids in x
ny = 3 #how many ellipsoids in y direction
y0 = 3. #spacing of ellipsoids in x
nz = 3 #how many ellipsoids in y direction
z0 = 3. #spacing of ellipsoids in x
rx,ry,rz = 0.8,1.2,1#radii of ellipsoids

#create list 'objects' with ellipsoids
objects = []
for i in range(nx):
    for j in range(ny):
        for k in range(nz):
            objects.append( nmesh.ellipsoid([rx,ry,rz], [("shift",[i*x0,j*y0,k*z0])]))

#bounding box
bbox = [[-2,-2,-2],[(nx-1)*x0+2,(ny-1)*y0+2,(nz-1)*z0+2]]

#create the mesh
mesh = nmesh.mesh(objects=objects,a0=0.75,bounding_box=bbox)
#save plot to file
mesh.save("ellipsoid_array3d.nmesh")

#create 3d-plot of surfaces and export eps
vis = nmesh.visual.show_bodies_mayavi(mesh)
nmesh.visual.export_visualisation(vis,"ellipsoid_array3d.eps")
开发者ID:fangohr,项目名称:nmag-src,代码行数:28,代码来源:ellipsoid_array3d.py


示例14:

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])]))

# 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")
开发者ID:fangohr,项目名称:nmag-doc,代码行数:31,代码来源:nmag1testLLG1.py


示例15: scale_list_of_lists

import nmesh


def scale_list_of_lists( vec_data, factor ):
    """silly function -- just to change the vector data somehow.

    In real life, the simulation would provide this data, obviously."""
    v2=[]
    for i in range(len(vec_data)):
        v2.append(vec_data[i] + Numeric.array([-1,0,0])*factor)

    return v2


#create mesh
ellipsoid = nmesh.ellipsoid([1,1,0.5])
bbox = [[-1,-1,-1],[1,1,1]]
mesh = nmesh.mesh(objects=[ellipsoid],bounding_box=bbox,a0=0.5,cache_name="visual_plot_vectorfield")

#visualise
import nmesh.visual
meshinfo=mesh.tolists()

#create some vector field defind on vertices (=nodes)
vec_data = []
points=meshinfo[0][2]
origin = Numeric.array([0,0,0])
for point in points:
    vec_data.append(Numeric.array(point) - origin) 

#plot the vector field with changing data
开发者ID:fangohr,项目名称:nmag-src,代码行数:31,代码来源:visual_plot_vectorfield.py


示例16: range

rings_box = nmesh.box([-16.95, -14.95],
                      [16.95,14.95])

bbox = [[-half_bbox_dimx,-half_bbox_dimy],[half_bbox_dimx,half_bbox_dimy]]

fix_pts = []
rings = []
voltage_probes = []

for x in range(-1,2):
    for y in range(-1,2):
        
        # external ring
        R = nmesh.ellipsoid(
            [outer_radius, outer_radius],
            transform=[("shift",[x*centres_distance, y*centres_distance])]
            )
        #internal ring
        r = nmesh.ellipsoid(
            [inner_radius, inner_radius],
            transform=[("shift",[x*centres_distance, y*centres_distance])]
            )
        # take the difference
        rings.append(nmesh.difference(R,[r]))

# cut the rings at top and bottom
union_rings = nmesh.union(rings)
rings_array = nmesh.intersect([union_rings,rings_box])


# semiaxis of a rhombus on the diagonals of the array 
开发者ID:fangohr,项目名称:nmag-src,代码行数:31,代码来源:load9rings.py


示例17:

import nmesh

# create a number of objects
one = nmesh.ellipsoid([3.0,3.0])
two = nmesh.ellipsoid([3.0,3.0],transform=[("shift",[7,0])])
three=nmesh.box( [-4.0,-6], [10,-4] )

bbox = [[-5.,-8.],[11.,5.]]

# create mesh of three objects and bounding box
mesh_ex = nmesh.mesh(objects = [one,two,three], bounding_box=bbox,
                     mesh_bounding_box=True)

# plot mesh
nmesh.visual.plot2d_ps(mesh_ex,"multiobjects.ps")


开发者ID:fangohr,项目名称:nmag-src,代码行数:15,代码来源:multiobjects.py


示例18: set_magnetization

                          )

mat_Fe = nmag.MagMaterial("Fe",
                          Ms=SI(1.7e6,"A/m"),
                          J=SI(2.07e-11,"J/m")
                          )

sim=nmag.SimulationContext("sphere")

# sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults...
sim.timestepper_tuning_params=[1e-6,1e-6,4,300]

sim.set_magnetization([0.0,1.0,0.0])
# ^ just to show we can place set_magnetization() where we want...

sim.defregion("Py", nmesh.ellipsoid([2.0,2.0,2.0],transform=[('shift',[5,0,0])]), mag_mat=mat_Py)
sim.defregion("Fe", nmesh.ellipsoid([2.0,2.0,2.0]), mag_mat=mat_Fe)


def initial_magnetization(coords,mag_type):
    if mag_type == "m_Fe":
        return [1,0,0]
    else:
        return [0.8*math.sin(coords[0]/3.0)*1e6,
                0.8*math.cos(coords[0]/3.0)*1e6,
                0.6*1e6
                ]

sim.generate_mesh(([-2.5,-2.5,-2.5],[7.5,2.5,2.5]), # bounding box
                  a0=1.0,
                  max_steps=1200,
开发者ID:fangohr,项目名称:nmag-doc,代码行数:31,代码来源:twomaterials.py


示例19:

"""
** Example: meshing four rings & solving the laplace equation
   for a space-dependent resistivity that depends on outer parameters

   (Presumably, we will encounter bugs at our first try)
**
"""

##### Creating the mesh #####

# For now, we use a very very simple mesh...

rings = nmesh.union(
    [
        nmesh.difference(
            nmesh.ellipsoid([3.0, 3.0], transform=[("shift", [-2.5, 0.0])]),
            [nmesh.ellipsoid([1.0, 1.0], transform=[("shift", [-2.5, 0.0])])],
        ),
        nmesh.difference(
            nmesh.ellipsoid([3.0, 3.0], transform=[("shift", [2.5, 0.0])]),
            [nmesh.ellipsoid([1.0, 1.0], transform=[("shift", [2.5, 0.0])])],
        ),
    ]
)

boxed_rings = nmesh.intersect([rings, nmesh.box([-8.0, -2.5], [8.0, 2.5])])

N = 100
density = "density=1.;"

the_mesh = nmesh.mesh(
开发者ID:fangohr,项目名称:nmag-doc,代码行数:31,代码来源:fem-rings.py


示例20: initial_magnetization

#nmag.set_log_level('debug')

intensive_param_by_name={"H_x":0.1,"H_y":0.0,"H_z":0.0}
# very slightly pulling in x-direction

mat_Py = nmag.MagMaterial("Py",
                          Ms=SI(1e6,"A/m"),
                          exchange_coupling=SI(13.0e-12,"J/m"),
                          )

sim=nmag.SimulationContext("sphere")

# sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults...
sim.timestepper_tuning_params=[1e-6,1e-6,2,300]

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

def initial_magnetization(coords,mag_type):
    return [0.8*math.sin(coords[0]/1.0)*1e6,
            0.8*math.cos(coords[0]/1.0)*1e6,
            0.6*1e6
            ]

sim.generate_mesh(([-5.0,-5.0,-5.0],[5.0,5.0,5.0]), # bounding box
                  a0=0.7,
                  max_steps=450,
                  cache_name="sphere"
                  )

#sim.set_magnetization([1.0,0.0,0.0])
#sim.set_magnetization([0.0,1.0,0.0])
开发者ID:fangohr,项目名称:nmag-doc,代码行数:31,代码来源:speedtest.py



注:本文中的nmesh.ellipsoid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nmesh.mesh函数代码示例发布时间:2022-05-27
下一篇:
Python nmap.PortScanner类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap