yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #07739
Re: [Question #230139]: clumps generating randomly in 2D simulation
Question #230139 on Yade changed:
https://answers.launchpad.net/yade/+question/230139
Christian Jakob proposed the following answer:
Is this what you need?
#!/usr/bin/python
# -*- coding: utf-8 -*-
''' script for generating clumps in 2D'''
### user input:
numberOfClumps = 100
radius = 0.001
#boundaries:
mn,mx=Vector3(0,0,0),Vector3(0.07,0.07,0)
### definition of material and engines:
#define material for all bodies:
id_Mat=O.materials.append(FrictMat(young=1e7,poisson=0.3,density=1000,frictionAngle=1))
Mat=O.materials[id_Mat]
#define engines:
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(damping=0.7,gravity=[0,-10,0]) #gravity in y-direction
]
### generation of a 2D clump assembly
notCreated = 0
for ii in range(0,numberOfClumps):
#get a random point within boundaries:
rx = mn[0] + mx[0]*random.random()
ry = mn[1] + mx[1]*random.random()
point = Vector3(rx,ry,0)
print point
#now we check if clump members, that should be generated from this point would have overlaps with other clump members:
everythingIsFine = True
memberPointList = []
for x in [radius,-radius]:
for y in [radius,-radius]:
xmember = rx + x
ymember = ry + y
memberPoint = Vector3(xmember,ymember,0)
memberPointList.append(memberPoint)
for b in O.bodies:
if isinstance(b.shape,Sphere):
distance = memberPoint - b.state.pos
if abs(distance.norm()) < 2*radius:
everythingIsFine = False #overlapping spheres
if everythingIsFine:
memberList = []
for memberPoint in memberPointList:
memberList.append(O.bodies.append(sphere(memberPoint,radius=radius,material=Mat)))
#clump them together and adapt masses:
idClump=O.bodies.clump(memberList)
massInfo = O.bodies.adaptClumpMasses([],10000)
#make it 2D:
O.bodies[idClump].blockedDOFs='zXY'
else:
notCreated +=1
print '%i of specified %i clumps created'%(numberOfClumps-
notCreated,numberOfClumps)
#create a box:
O.bodies.append(box(((mx[0]-mn[0])/2,-2*radius,0),((mx[0]-mn[0])/2,0.001,0.001),fixed=True,material=Mat))
O.dt = 1e-5
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.