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

Python utils.sphere函数代码示例

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

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



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

示例1: testUserCreatedInteraction

	def testUserCreatedInteraction(self):
		O.engines=[
				ForceResetter(),
				InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Box_Aabb()],label="collider"),
				InteractionLoop(
					[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
					[Ip2_FrictMat_FrictMat_FrictPhys()],	#for linear model only
					[Law2_ScGeom_FrictPhys_CundallStrack(label="law")],	#for linear model only
					label="interactionLoop"
				),
				GlobalStiffnessTimeStepper(timeStepUpdateInterval=10,label="timeStepper"),
				NewtonIntegrator(label="newton")
			]
		O.bodies.append([utils.sphere((0,0,0),0.5),
			utils.sphere((2,0,0),0.5), #(0,1) no overlap , no contacts
			utils.sphere((0.9,0.9,0),0.5), #(0,2) overlapping bounds, no contacts
			utils.sphere((-0.99,0,0),0.5)]) #(0,3) overlaping + contact
		O.dt=0
		O.dynDt=False
		O.step()
		i=utils.createInteraction(0,1)
		self.assert_(i.iterBorn==1 and i.iterMadeReal==1)
		j=utils.createInteraction(0,2)
		self.assert_(j.iterBorn==1 and j.iterMadeReal==1)
		self.assertRaises(RuntimeError,lambda: utils.createInteraction(0,3))
开发者ID:yade,项目名称:trunk,代码行数:25,代码来源:utilsModule.py


示例2: testErasedAndNewlyCreatedSphere

	def testErasedAndNewlyCreatedSphere(self):
		"Bodies: The bug is described in LP:1001194. If the new body was created after deletion of previous, it has no bounding box"
		O.reset()
		id1 = O.bodies.append(utils.sphere([0.0, 0.0, 0.0],0.5))
		id2 = O.bodies.append(utils.sphere([0.0, 2.0, 0.0],0.5))
		O.engines=[
			ForceResetter(),
			InsertionSortCollider([Bo1_Sphere_Aabb()]),
			InteractionLoop(
				[Ig2_Sphere_Sphere_L3Geom()],
				[Ip2_FrictMat_FrictMat_FrictPhys()],
				[Law2_L3Geom_FrictPhys_ElPerfPl()]
			),
			NewtonIntegrator(damping=0.1,gravity=(0,0,-9.81))
		]
		O.dt=.5e-4*utils.PWaveTimeStep()
		#Before first step the bodies should not have bounds
		self.assert_(O.bodies[id1].bound==None and O.bodies[id2].bound==None)
		O.run(1, True)
		#After first step the bodies should have bounds
		self.assert_(O.bodies[id1].bound!=None and O.bodies[id2].bound!=None)
		#Add 3rd body
		id3 = O.bodies.append(utils.sphere([0.0, 4.0, 0.0],0.5))
		O.run(1, True)
		self.assert_(O.bodies[id1].bound!=None and O.bodies[id2].bound!=None and O.bodies[id3].bound!=None)
		#Remove 3rd body
		O.bodies.erase(id3)
		O.run(1, True)
		#Add 4th body
		id4 = O.bodies.append(utils.sphere([0.0, 6.0, 0.0],0.5))
		O.run(1, True)
		self.assert_(O.bodies[id1].bound!=None and O.bodies[id2].bound!=None and O.bodies[id4].bound!=None)
开发者ID:NauticalMile64,项目名称:trunk,代码行数:32,代码来源:core.py


示例3: SpherePack_toSimulation

 def SpherePack_toSimulation(self,rot=Matrix3.Identity,**kw):
   """Append spheres directly to the simulation. In addition calling :yref:`O.bodies.append<BodyContainer.append>`,
 this method also appropriately sets periodic cell information of the simulation.
 
   >>> from yade import pack; from math import *
   >>> sp=pack.SpherePack()
 
 Create random periodic packing with 20 spheres:
 
   >>> sp.makeCloud((0,0,0),(5,5,5),rMean=.5,rRelFuzz=.5,periodic=True,num=20)
   20
 
 Virgin simulation is aperiodic:
 
   >>> O.reset()
   >>> O.periodic
   False
 
 Add generated packing to the simulation, rotated by 45° along +z
 
   >>> sp.toSimulation(rot=Quaternion((0,0,1),pi/4),color=(0,0,1))
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
 
 Periodic properties are transferred to the simulation correctly, including rotation (this could be avoided by explicitly passing "hSize=O.cell.hSize" as an argument):
 
   >>> O.periodic
   True
   >>> O.cell.refSize
   Vector3(5,5,5)
   >>> O.cell.hSize
   Matrix3(3.53553,-3.53553,0, 3.53553,3.53553,0, 0,0,5)
 
 The current state (even if rotated) is taken as mechanically undeformed, i.e. with identity transformation:
 
   >>> O.cell.trsf
   Matrix3(1,0,0, 0,1,0, 0,0,1)
 
 :param Quaternion/Matrix3 rot: rotation of the packing, which will be applied on spheres and will be used to set :yref:`Cell.trsf` as well.
 :param \*\*kw: passed to :yref:`yade.utils.sphere`
 :return: list of body ids added (like :yref:`O.bodies.append<BodyContainer.append>`)
 """
   if isinstance(rot,Quaternion): rot=rot.toRotationMatrix()
   assert(isinstance(rot,Matrix3))
   if self.isPeriodic: O.periodic=True
   if self.cellSize!=Vector3.Zero and self.isPeriodic:
     O.cell.hSize=rot*Matrix3(self.cellSize[0],0,0, 0,self.cellSize[1],0, 0,0,self.cellSize[2])
     O.cell.trsf=Matrix3.Identity
   if not self.hasClumps():
     return O.bodies.append([utils.sphere(rot*c,r,**kw) for c,r in self])
   else:
     standalone,clumps=self.getClumps()
     ids=O.bodies.append([utils.sphere(rot*c,r,**kw) for c,r in self]) # append all spheres first
     clumpIds=[]
     userColor='color' in kw
     for clump in clumps:
       clumpIds.append(O.bodies.clump(clump)) # clump spheres with given ids together, creating the clump object as well
       # make all spheres within one clump a single color, unless color was specified by the user
       if not userColor:
         for i in clump[1:]: O.bodies[i].shape.color=O.bodies[clump[0]].shape.color
     return ids+clumpIds
开发者ID:kelaogui,项目名称:trunk,代码行数:60,代码来源:pack.py


示例4: setUp

	def setUp(self):
		O.reset()
		r1,r2,p0,p1=1,.5,Vector3.Zero,Vector3(0,0,3)
		self.idC,(self.id1,self.id2)=O.bodies.appendClumped([
			utils.sphere(p0,r1),
			utils.sphere(p1,r2)
		])
开发者ID:cchalak,项目名称:trunk,代码行数:7,代码来源:clump.py


示例5: setUp

	def setUp(self):
		# common setup for all tests in this class
		O.reset()
		O.materials.append([
			FrictMat(young=1,label='materialZero'),
			ElastMat(young=100,label='materialOne')
		])
		O.bodies.append([
			utils.sphere([0,0,0],.5,material=0),
			utils.sphere([1,1,1],.5,material=0),
			utils.sphere([1,1,1],.5,material=1)
		])
开发者ID:NauticalMile64,项目名称:trunk,代码行数:12,代码来源:core.py


示例6: setUp

	def setUp(self):
		O.reset(); O.periodic=True;
		O.cell.setBox(2.5,2.5,3)
		self.cellDist=Vector3i(0,0,10) # how many cells away we go
		self.relDist=Vector3(0,.999999999999999999,0) # rel position of the 2nd ball within the cell
		self.initVel=Vector3(0,0,5)
		O.bodies.append(utils.sphere((1,1,1),.5))
		self.initPos=Vector3([O.bodies[0].state.pos[i]+self.relDist[i]+self.cellDist[i]*O.cell.refSize[i] for i in (0,1,2)])
		O.bodies.append(utils.sphere(self.initPos,.5))
		#print O.bodies[1].state.pos
		O.bodies[1].state.vel=self.initVel
		O.engines=[NewtonIntegrator(warnNoForceReset=False)]
		O.cell.velGrad=Matrix3(0,0,0, 0,0,0, 0,0,-1)
		O.dt=0 # do not change positions with dt=0 in NewtonIntegrator, but still update velocities from velGrad
开发者ID:tufubin,项目名称:trunk,代码行数:14,代码来源:pbc.py


示例7: gengeo

def gengeo(mntable,shift=Vector3.Zero,scale=1.0,**kw):
	""" Imports geometry from LSMGenGeo library and creates spheres.
	Since 2012 the package is available in Debian/Ubuntu and known as python-demgengeo
	http://packages.qa.debian.org/p/python-demgengeo.html

	:Parameters:
		`mntable`: mntable
			object, which creates by LSMGenGeo library, see example
		`shift`: [float,float,float]
			[X,Y,Z] parameter moves the specimen.
		`scale`: float
			factor scales the given data.
		`**kw`: (unused keyword arguments)
				is passed to :yref:`yade.utils.sphere`
	
	LSMGenGeo library allows one to create pack of spheres
	with given [Rmin:Rmax] with null stress inside the specimen.
	Can be useful for Mining Rock simulation.
	
	Example: :ysrc:`examples/packs/packs.py`, usage of LSMGenGeo library in :ysrc:`examples/test/genCylLSM.py`.
	
	* https://answers.launchpad.net/esys-particle/+faq/877
	* http://www.access.edu.au/lsmgengeo_python_doc/current/pythonapi/html/GenGeo-module.html
	* https://svn.esscc.uq.edu.au/svn/esys3/lsm/contrib/LSMGenGeo/"""
	try:
		from GenGeo import MNTable3D,Sphere
	except ImportError:
		from gengeo import MNTable3D,Sphere
	ret=[]
	sphereList=mntable.getSphereListFromGroup(0)
	for i in range(0, len(sphereList)):
		r=sphereList[i].Radius()
		c=sphereList[i].Centre()
		ret.append(utils.sphere([shift[0]+scale*float(c.X()),shift[1]+scale*float(c.Y()),shift[2]+scale*float(c.Z())],scale*float(r),**kw))
	return ret
开发者ID:YananHe,项目名称:myyade,代码行数:35,代码来源:ymport.py


示例8: filterSpherePack

def filterSpherePack(predicate, spherePack, returnSpherePack=None, **kw):
    """Using given SpherePack instance, return spheres the satisfy predicate.
	The packing will be recentered to match the predicate and warning is given if the predicate
	is larger than the packing."""
    if returnSpherePack == None:
        warnings.warn(
            'The default behavior will change; specify returnSpherePack=True for the new behavior, and False to get rid of this warning (your code will break in the future, however). The returned SpherePack object can be added to the simulation using SpherePack.toSimulation()',
            category=FutureWarning)
        returnSpherePack = False
    mn, mx = predicate.aabb()
    dimP, centP = predicate.dim(), predicate.center()
    dimS, centS = spherePack.dim(), spherePack.center()
    if dimP[0] > dimS[0] or dimP[1] > dimS[1] or dimP[2] > dimS[2]:
        warnings.warn(
            "Packing's dimension (%s) doesn't fully contain dimension of the predicate (%s)."
            % (dimS, dimP))
    spherePack.translate(centP - centS)
    if returnSpherePack:
        ret = SpherePack()
        for c, r in spherePack:
            if predicate(c, r): ret.add(c, r)
        return ret
    else:
        # return particles to be added to O.bodies
        ret = []
        for s in spherePack:
            if predicate(s[0], s[1]):
                ret += [utils.sphere(s[0], radius=s[1], **kw)]
        return ret
开发者ID:8803104,项目名称:trunk,代码行数:29,代码来源:pack.py


示例9: regularHexa

def regularHexa(predicate, radius, gap, **kw):
    """Return set of spheres in regular hexagonal grid, clipped inside solid given by predicate.
	Created spheres will have given radius and will be separated by gap space."""
    ret = []
    a = 2 * radius + gap
    # thanks to Nasibeh Moradi for finding bug here:
    # http://www.mail-archive.com/[email protected]/msg01424.html
    hy, hz = a * sqrt(3) / 2., a * sqrt(6) / 3.
    mn, mx = predicate.aabb()
    dim = [mx[i] - mn[i] for i in 0, 1, 2]
    if (max(dim) == float('inf')):
        raise ValueError(
            "Aabb of the predicate must not be infinite (didn't you use union | instead of intersection & for unbounded predicate such as notInNotch?"
        )
    ii, jj, kk = [
        range(0,
              int(dim[0] / a) + 1),
        range(0,
              int(dim[1] / hy) + 1),
        range(0,
              int(dim[2] / hz) + 1)
    ]
    for i, j, k in itertools.product(ii, jj, kk):
        x, y, z = mn[0] + radius + i * a, mn[1] + radius + j * hy, mn[
            2] + radius + k * hz
        if j % 2 == 0: x += a / 2. if k % 2 == 0 else -a / 2.
        if k % 2 != 0:
            x += a / 2.
            y += hy / 2.
        if predicate((x, y, z), radius):
            ret += [utils.sphere((x, y, z), radius=radius, **kw)]
    return ret
开发者ID:8803104,项目名称:trunk,代码行数:32,代码来源:pack.py


示例10: randomPeriPack

def randomPeriPack(radius,initSize,rRelFuzz=0.0,memoizeDb=None,noPrint=False):
	"""Generate periodic dense packing.

	A cell of initSize is stuffed with as many spheres as possible, then we run periodic compression with PeriIsoCompressor, just like with
	randomDensePack.

	:param radius: mean sphere radius
	:param rRelFuzz: relative fuzz of sphere radius (equal distribution); see the same param for randomDensePack.
	:param initSize: initial size of the periodic cell.

	:return: SpherePack object, which also contains periodicity information.
	"""
	from math import pi
	sp=_getMemoizedPacking(memoizeDb,radius,rRelFuzz,initSize[0],initSize[1],initSize[2],fullDim=Vector3(0,0,0),wantPeri=True,fillPeriodic=False,spheresInCell=-1,memoDbg=True,noPrint=noPrint)
	if sp: return sp
	O.switchScene(); O.resetThisScene()
	sp=SpherePack()
	O.periodic=True
	#O.cell.refSize=initSize
	O.cell.setBox(initSize)
	sp.makeCloud(Vector3().Zero,O.cell.refSize,radius,rRelFuzz,-1,True)
	O.engines=[ForceResetter(),InsertionSortCollider([Bo1_Sphere_Aabb()],nBins=2,verletDist=.05*radius),InteractionLoop([Ig2_Sphere_Sphere_ScGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_ScGeom_FrictPhys_CundallStrack()]),PeriIsoCompressor(charLen=2*radius,stresses=[-100e9,-1e8],maxUnbalanced=1e-2,doneHook='O.pause();',globalUpdateInt=20,keepProportions=True),NewtonIntegrator(damping=.8)]
	O.materials.append(FrictMat(young=30e9,frictionAngle=.1,poisson=.3,density=1e3))
	for s in sp: O.bodies.append(utils.sphere(s[0],s[1]))
	O.dt=utils.PWaveTimeStep()
	O.timingEnabled=True
	O.run(); O.wait()
	ret=SpherePack()
	ret.fromSimulation()
	_memoizePacking(memoizeDb,ret,radius,rRelFuzz,wantPeri=True,fullDim=Vector3(0,0,0),noPrint=noPrint) # fullDim unused
	O.switchScene()
	return ret
开发者ID:kelaogui,项目名称:trunk,代码行数:32,代码来源:pack.py


示例11: testEraseBodiesInInteraction

	def testEraseBodiesInInteraction(self):
		O.reset()
		id1 = O.bodies.append(utils.sphere([0.5,0.5,0.0+0.095],.1))
		id2 = O.bodies.append(utils.sphere([0.5,0.5,0.0+0.250],.1))
		O.engines=[
			ForceResetter(),
			InsertionSortCollider([Bo1_Sphere_Aabb()]),
			InteractionLoop(
				[Ig2_Sphere_Sphere_L3Geom()],
				[Ip2_FrictMat_FrictMat_FrictPhys()],
				[Law2_L3Geom_FrictPhys_ElPerfPl()]
			),
			NewtonIntegrator(damping=0.1,gravity=(0,0,-9.81))
		]
		O.dt=.5e-4*utils.PWaveTimeStep()
		O.step()
		O.bodies.erase(id1)
		O.step()
开发者ID:NauticalMile64,项目名称:trunk,代码行数:18,代码来源:core.py


示例12: textExt

def textExt(fileName,format='x_y_z_r',shift=Vector3.Zero,scale=1.0,attrs=[],**kw):
	"""Load sphere coordinates from file in specific format, returns a list of corresponding bodies; that may be inserted to the simulation with O.bodies.append().
	
	:param str filename: file name
	:param str format: the name of output format. Supported `x_y_z_r`(default), `x_y_z_r_matId`, 'x_y_z_r_attrs'
	:param [float,float,float] shift: [X,Y,Z] parameter moves the specimen.
	:param float scale: factor scales the given data.
	:param list attrs: attrs read from file if export.textExt(format='x_y_z_r_attrs') were used ('passed by refernece' style)
	:param \*\*kw: (unused keyword arguments) is passed to :yref:`yade.utils.sphere`
	:returns: list of spheres.

	Lines starting with # are skipped
	"""
	infile = open(fileName,"r")
	lines = infile.readlines()
	infile.close()
	ret=[]
	for line in lines:
		data = line.split()
		if (data[0] == "#format"):
			format=data[1]
			continue
		elif (data[0][0] == "#"): continue
		
		if (format=='x_y_z_r'):
			pos = Vector3(float(data[0]),float(data[1]),float(data[2]))
			ret.append(utils.sphere(shift+scale*pos,scale*float(data[3]),**kw))
		elif (format=='x_y_z_r_matId'):
			pos = Vector3(float(data[0]),float(data[1]),float(data[2]))
			ret.append(utils.sphere(shift+scale*pos,scale*float(data[3]),material=int(data[4]),**kw))
		
		elif (format=='id_x_y_z_r_matId'):
			pos = Vector3(float(data[1]),float(data[2]),float(data[3]))
			ret.append(utils.sphere(shift+scale*pos,scale*float(data[4]),material=int(data[5]),**kw))

		elif (format=='x_y_z_r_attrs'):
			pos = Vector3(float(data[0]),float(data[1]),float(data[2]))
			s = utils.sphere(shift+scale*pos,scale*float(data[3]),**kw)
			ret.append(s)
			attrs.append(data[4:])
			
		else:
			raise RuntimeError("Please, specify a correct format output!");
	return ret
开发者ID:YananHe,项目名称:myyade,代码行数:44,代码来源:ymport.py


示例13: regularOrtho

def regularOrtho(predicate,radius,gap,**kw):
	"""Return set of spheres in regular orthogonal grid, clipped inside solid given by predicate.
	Created spheres will have given radius and will be separated by gap space."""
	ret=[]
	mn,mx=predicate.aabb()
	if(max([mx[i]-mn[i] for i in 0,1,2])==float('inf')): raise ValueError("Aabb of the predicate must not be infinite (didn't you use union | instead of intersection & for unbounded predicate such as notInNotch?");
	xx,yy,zz=[arange(mn[i]+radius,mx[i]-radius,2*radius+gap) for i in 0,1,2]
	for xyz in itertools.product(xx,yy,zz):
		if predicate(xyz,radius): ret+=[utils.sphere(xyz,radius=radius,**kw)]
	return ret
开发者ID:kelaogui,项目名称:trunk,代码行数:10,代码来源:pack.py


示例14: textClumps

def textClumps(fileName,shift=Vector3.Zero,discretization=0,orientation=Quaternion((0,1,0),0.0),scale=1.0,**kw):
	"""Load clumps-members from file, insert them to the simulation.
	
	:param str filename: file name
	:param str format: the name of output format. Supported `x_y_z_r`(default), `x_y_z_r_clumpId`
	:param [float,float,float] shift: [X,Y,Z] parameter moves the specimen.
	:param float scale: factor scales the given data.
	:param \*\*kw: (unused keyword arguments) is passed to :yref:`yade.utils.sphere`
	:returns: list of spheres.

	Lines starting with # are skipped
	"""
	infile = open(fileName,"r")
	lines = infile.readlines()
	infile.close()
	ret=[]
	
	curClump=[]
	newClumpId = -1
	
	for line in lines:
		data = line.split()
		if (data[0][0] == "#"): continue
		pos = orientation*Vector3(float(data[0]),float(data[1]),float(data[2]))
	
		if (newClumpId<0 or newClumpId==int(data[4])):
			idD = curClump.append(utils.sphere(shift+scale*pos,scale*float(data[3]),**kw))
			newClumpId = int(data[4])
		else:
			newClumpId = int(data[4])
			ret.append(O.bodies.appendClumped(curClump,discretization=discretization))
			curClump=[]
			idD = curClump.append(utils.sphere(shift+scale*pos,scale*float(data[3]),**kw))
	
	if (len(curClump)<>0):
		ret.append(O.bodies.appendClumped(curClump,discretization=discretization))
	
	# Set the mask to a clump the same as the first member of it
	for i in range(len(ret)):
		O.bodies[ret[i][0]].mask = O.bodies[ret[i][1][0]].mask
	return ret
开发者ID:YananHe,项目名称:myyade,代码行数:41,代码来源:ymport.py


示例15: textExt

def textExt(fileName,format='x_y_z_r',shift=Vector3.Zero,scale=1.0,**kw):
	"""Load sphere coordinates from file in specific format, create spheres, insert them to the simulation.
	
	:Parameters:
		`filename`: string
		`format`:
			the name of output format. Supported `x_y_z_r`(default), `x_y_z_r_matId`
		`shift`: [float,float,float]
			[X,Y,Z] parameter moves the specimen.
		`scale`: float
			factor scales the given data.
		`**kw`: (unused keyword arguments)
				is passed to :yref:`yade.utils.sphere`
	:Returns: list of spheres.
	Lines starting with # are skipped
	"""
	infile = open(fileName,"r")
	lines = infile.readlines()
	infile.close()
	ret=[]
	for line in lines:
		data = line.split()
		if (data[0] == "#format"):
			format=data[1]
			continue
		elif (data[0][0] == "#"): continue
		
		if (format=='x_y_z_r'):
			pos = Vector3(float(data[0]),float(data[1]),float(data[2]))
			ret.append(utils.sphere(shift+scale*pos,scale*float(data[3]),**kw))
		elif (format=='x_y_z_r_matId'):
			pos = Vector3(float(data[0]),float(data[1]),float(data[2]))
			ret.append(utils.sphere(shift+scale*pos,scale*float(data[3]),material=int(data[4]),**kw))
		
		elif (format=='id_x_y_z_r_matId'):
			pos = Vector3(float(data[1]),float(data[2]),float(data[3]))
			ret.append(utils.sphere(shift+scale*pos,scale*float(data[4]),material=int(data[5]),**kw))
			
		else:
			raise RuntimeError("Please, specify a correct format output!");
	return ret
开发者ID:hohiroki,项目名称:trunk,代码行数:41,代码来源:ymport.py


示例16: fill_cylinder_with_spheres

def fill_cylinder_with_spheres(sphereRadius,cylinderRadius,cylinderHeight,cylinderOrigin,cylinderSlope):
	spheresCount=0
	for h in xrange(0,int(cylinderHeight/sphereRadius/2)):
			for r in xrange(1,int(cylinderRadius/sphereRadius/2)):
				dfi = asin(0.5/r)*2
				for a in xrange(0,int(6.28/dfi)):
					x = cylinderOrigin[0]+2*r*sphereRadius*cos(dfi*a)
					y = cylinderOrigin[1]+2*r*sphereRadius*sin(dfi*a)
					z = cylinderOrigin[2]+h*2*sphereRadius
					s=utils.sphere([x,y*cos(cylinderSlope)+z*sin(cylinderSlope),z*cos(cylinderSlope)-y*sin(cylinderSlope)],sphereRadius)
					O.bodies.append(s)
					spheresCount+=1
	return spheresCount
开发者ID:franckbourrier,项目名称:trunk,代码行数:13,代码来源:ringCundallDamping.py


示例17: regularHexa

def regularHexa(predicate,radius,gap,**kw):
	"""Return set of spheres in regular hexagonal grid, clipped inside solid given by predicate.
	Created spheres will have given radius and will be separated by gap space."""
	ret=[]
	a=2*radius+gap
	hy,hz=a*sqrt(3)/2.,a*sqrt(6)/3.
	mn,mx=predicate.aabb()
	dim=[mx[i]-mn[i] for i in 0,1,2]
	if(max(dim)==float('inf')): raise ValueError("Aabb of the predicate must not be infinite (didn't you use union | instead of intersection & for unbounded predicate such as notInNotch?");
	ii,jj,kk=[range(0,int(dim[0]/a)+1),range(0,int(dim[1]/hy)+1),range(0,int(dim[2]/hz)+1)]
	for i,j,k in itertools.product(ii,jj,kk):
		#Simple HCP-lattice packing
		#http://en.wikipedia.org/wiki/Close-packing_of_equal_spheres#Simple_hcp_lattice
		coordSph = Vector3((2*i + ((j + k) % 2 ) ),
											(sqrt(3.)*(j + 1./3.*(k % 2))),
											(2.*sqrt(6.)/3.*k))*(a/2.0) + mn
		if predicate(coordSph,radius): ret+=[utils.sphere(coordSph,radius=radius,**kw)]
	if (len(ret)==0):
		warnings.warn('No spheres are produced by regularHexa-function',category=RuntimeWarning)
	return ret
开发者ID:DEMANY,项目名称:trunk,代码行数:20,代码来源:pack.py


示例18: gengeoFile

def gengeoFile(fileName="file.geo",shift=Vector3.Zero,scale=1.0,orientation=Quaternion((0,1,0),0.0),**kw):
	""" Imports geometry from LSMGenGeo .geo file and creates spheres. 
	Since 2012 the package is available in Debian/Ubuntu and known as python-demgengeo
	http://packages.qa.debian.org/p/python-demgengeo.html
	
	:Parameters:
		`filename`: string
			file which has 4 colums [x, y, z, radius].
		`shift`: Vector3
			Vector3(X,Y,Z) parameter moves the specimen.
		`scale`: float
			factor scales the given data.
		`orientation`: quaternion
			orientation of the imported geometry
		`**kw`: (unused keyword arguments)
				is passed to :yref:`yade.utils.sphere`
	:Returns: list of spheres.
	
	LSMGenGeo library allows one to create pack of spheres
	with given [Rmin:Rmax] with null stress inside the specimen.
	Can be useful for Mining Rock simulation.
	
	Example: :ysrc:`examples/packs/packs.py`, usage of LSMGenGeo library in :ysrc:`examples/test/genCylLSM.py`.
	
	* https://answers.launchpad.net/esys-particle/+faq/877
	* http://www.access.edu.au/lsmgengeo_python_doc/current/pythonapi/html/GenGeo-module.html
	* https://svn.esscc.uq.edu.au/svn/esys3/lsm/contrib/LSMGenGeo/"""
	from yade.utils import sphere

	infile = open(fileName,"r")
	lines = infile.readlines()
	infile.close()

	numSpheres = int(lines[6].split()[0])
	ret=[]
	for line in lines[7:numSpheres+7]:
		data = line.split()
		pos = orientation*Vector3(float(data[0]),float(data[1]),float(data[2]))
		ret.append(utils.sphere(shift+scale*pos,scale*float(data[3]),**kw))
	return ret
开发者ID:YananHe,项目名称:myyade,代码行数:40,代码来源:ymport.py


示例19: testMatchMakerCollisions

	def testMatchMakerCollisions(self):
		fr = 0.5;rho=2000
		tc = 0.001; en = 0.5; et = 0.5;
		mat1 = O.materials.append(ViscElMat(frictionAngle=fr,tc=tc,en=en,et=et,density=rho))
		mat2 = O.materials.append(ViscElMat(frictionAngle=fr,tc=tc,en=en,et=et,density=rho))
		mat3 = O.materials.append(ViscElMat(frictionAngle=fr,tc=tc,en=en,et=et,density=rho))
		r1 = 0.002381
		r2 = 0.002381
		id11 = O.bodies.append(utils.sphere(center=[0,0,0],radius=r1,material=mat1,fixed=True,color=[0,0,1]))
		id12 = O.bodies.append(utils.sphere(center=[0,0,(r1+r2)],radius=r2,material=mat2,fixed=False,color=[0,0,1]))
		
		id21 = O.bodies.append(utils.sphere(center=[3*r1,0,0],radius=r1,material=mat1,fixed=True,color=[0,1,0]))
		id22 = O.bodies.append(utils.sphere(center=[3*r1,0,(r1+r2)],radius=r2,material=mat3,fixed=False,color=[0,1,0]))
		
		id31 = O.bodies.append(utils.sphere(center=[6*r1,0,0],radius=r1,material=mat2,fixed=True,color=[1,0,0]))
		id32 = O.bodies.append(utils.sphere(center=[6*r1,0,(r1+r2)],radius=r2,material=mat3,fixed=False,color=[1,0,0]))
		
		O.engines = [
			ForceResetter(),
			InsertionSortCollider([Bo1_Sphere_Aabb()],verletDist=r1*10.0),
			InteractionLoop(
				[Ig2_Sphere_Sphere_ScGeom()],
				[Ip2_ViscElMat_ViscElMat_ViscElPhys( 
					en=MatchMaker(matches=((mat1,mat2,.1),(mat1,mat3,.2),(mat2,mat3,.4))),
					et=MatchMaker(matches=((mat1,mat2,.7),(mat1,mat3,.8),(mat2,mat3,.9))),
					frictAngle=MatchMaker(matches=((mat1,mat2,.1),(mat1,mat3,.2),(mat2,mat3,.3)))
				)],
				[Law2_ScGeom_ViscElPhys_Basic()],
				),
			NewtonIntegrator(damping=0,gravity=[0,0,-9.81]),
		]
		
		O.step()
		self.assertTrue((atan(O.interactions[id11,id12].phys.tangensOfFrictionAngle)-0.1)==0)
		self.assertTrue((atan(O.interactions[id21,id22].phys.tangensOfFrictionAngle)-0.2)==0)
		self.assertTrue((atan(O.interactions[id31,id32].phys.tangensOfFrictionAngle)-0.3)==0)
		
		self.assertTrue(round(O.interactions[id11,id12].phys.cn, 3) - 0.26 == 0)
		self.assertTrue(round(O.interactions[id21,id22].phys.cn, 3) - 0.182 == 0)
		self.assertTrue(round(O.interactions[id31,id32].phys.cn, 3) - 0.104 == 0)

		self.assertTrue(round(O.interactions[id11,id12].phys.cs, 3) - 0.012== 0)
		self.assertTrue(round(O.interactions[id21,id22].phys.cs, 3) - 0.007 == 0)
		self.assertTrue(round(O.interactions[id31,id32].phys.cs, 3) - 0.003 == 0)
开发者ID:yade,项目名称:trunk,代码行数:44,代码来源:core.py


示例20: testKinematicEngines

	def testKinematicEngines(self):
		'Engines: kinematic engines'
		tolerance = 1e-5
		rotIndex=1.0
		angVelTemp = pi/rotIndex
		O.reset()
		id_fixed_transl = O.bodies.append(utils.sphere((0.0,0.0,0.0),1.0,fixed=True))
		id_nonfixed_transl = O.bodies.append(utils.sphere((0.0,5.0,0.0),1.0,fixed=False))
		id_fixed_rot = O.bodies.append(utils.sphere((0.0,10.0,10.0),1.0,fixed=True))
		id_nonfixed_rot = O.bodies.append(utils.sphere((0.0,15.0,10.0),1.0,fixed=False))
		id_fixed_helix = O.bodies.append(utils.sphere((0.0,20.0,10.0),1.0,fixed=True))
		id_nonfixed_helix = O.bodies.append(utils.sphere((0.0,25.0,10.0),1.0,fixed=False))
		O.engines=[
			TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_fixed_transl]),
			TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_nonfixed_transl]),
			RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_rot]),
			RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_rot]),
			HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_helix]),
			HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_helix]),
			ForceResetter(),
			NewtonIntegrator()
		]
		O.dt = 1.0
		for i in range(0,2):
			O.step()
			self.assertTrue(abs(O.bodies[id_fixed_transl].state.pos[0] - O.iter) < tolerance)												#Check translation of fixed bodies
			self.assertTrue(abs(O.bodies[id_nonfixed_transl].state.pos[0] - O.iter) < tolerance)										#Check translation of nonfixed bodies
			
			self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[0]-10.0*sin(pi/angVelTemp*O.iter))<tolerance)			#Check rotation of fixed bodies X
			self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[2]-10.0*cos(pi/angVelTemp*O.iter))<tolerance)			#Check rotation of fixed bodies Y
			self.assertTrue(abs(O.bodies[id_fixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance)		#Check rotation of fixed bodies, angle
			
			self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance)		#Check rotation of nonfixed bodies X
			self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance)		#Check rotation of nonfixed bodies Y
			self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance)		#Check rotation of nonfixed bodies, angle
						
			self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance)		#Check helixEngine of fixed bodies X
			self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance)		#Check helixEngine of fixed bodies Y
			self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[1]-20.0 - O.iter)<tolerance)		#Check helixEngine of fixed bodies Z
			
			self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance)		#Check helixEngine of nonfixed bodies X
			self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance)		#Check helixEngine of nonfixed bodies Y
			self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[1]-25.0 - O.iter)<tolerance)		#Check helixEngine of nonfixed bodies Z
开发者ID:yade,项目名称:trunk,代码行数:43,代码来源:engines.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python yael.numpy_to_fvec_ref函数代码示例发布时间:2022-05-26
下一篇:
Python utils.facet函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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