← Back to team overview

yade-users team mailing list archive

Re: [Question #230139]: clumps generating randomly in 2D simulation

 

Question #230139 on Yade changed:
https://answers.launchpad.net/yade/+question/230139

    Status: Answered => Open

Fu zuoguang is still having a problem:
Dear Christian Jakob and all producers:
     Working for a long time in these days made me forget to check emails. Thanks for provide me such a perfect script and sorry for this very late responding.
     I have taken a correct running in YADE with your script and there is nothing wrong in it. I think that the core conception of getting clumps generation is according to the distances between any two points. If the value of this distance is larger than (2*radius), allow to generate the clumps, else allow to generate no. I am afraid that that method can only be employed in small-scale simulations, but in large-scale it can not be used any more for that it need to spend a long time in determinative calculations. For instance, I wanna get 1000 clumps, the times of determinative calculations is approximately (1000-1)!. It is a terrible thing when 10000 clumps should be needed.
     As a student pythonner, I have finished my own codes for solution with very simple and basic commands in python, that can be described as that:

#################################################################################################
from yade import pack,os,utils
import random
from numpy import arange

########################################## clumps generation in 2D-simulation ###################
i = (input( "the number of clumps " ) )  # sphere numbers desired
N = int (pow (2*i,0.5) )  # assigning the number of meshes and nodes of pack area, which is 2*i.
mn = Vector3 ( 0,0,0 ) ; mx = Vector3 ( 0.07,0.07,0 )
areaX = mx[0] - mn[0] ; areaY = mx[1] - mn[1]
coorint = [] ; coordes = [] ; sphereList = []

if areaX > areaY :
   radius = (mx[1] - mn[1]) / N * 0.2

else: 
   radius = (mx[0] - mn[0]) / N * 0.2

for i in xrange(i): 
    coorX = (mx[0]-mn[0]) / N * random.randint(0,N) 
    coorY = (mx[1]-mn[1]) / N * random.randint(0,N) 
    coorint.append([coorX,coorY])   

    if not coorint[i] in coordes:        
       coordes.append(coorint[i])

print len(coorint) ; print len(coordes)

for b in coordes:
    coorb1 = [b[0] - radius , b[1] - radius , 0 ]
    coorb2 = [b[0] + radius , b[1] - radius , 0 ]
    coorb3 = [b[0] + radius , b[1] + radius , 0 ]
    coorb4 = [b[0] - radius , b[1] + radius , 0 ]

    sphere1 = O.bodies.append ( sphere ( coorb1 , radius = radius , color=(1,1,1) ) )
    sphere2 = O.bodies.append ( sphere ( coorb2 , radius = radius , color=(1,1,1) ) )
    sphere3 = O.bodies.append ( sphere ( coorb3 , radius = radius , color=(1,1,1) ) )
    sphere4 = O.bodies.append ( sphere ( coorb4 , radius = radius , color=(1,1,1) ) ) 
    sphereList.append ([sphere1 , sphere2 , sphere3 , sphere4])

print len(sphereList)

for b in sphereList:    
    clump_ids = O.bodies.clump (b)

for b in O.bodies:
    O.bodies[clump_ids].blockedDOFs='zXY'

print ( O.bodies[clump_ids].shape.members.keys()[0] )

##################################### some codes only for testing ############
id_Mat=O.materials.append(FrictMat(young=1e7,poisson=0.3,density=1000,frictionAngle=1))
Mat=O.materials[id_Mat]

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,0,-10])	#gravity in z-direction
]
    
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 = 0.2e-4
##########################################################################################

My conception of these codes can be described step by step as follows:
(1).generate meshes and nodes in pack area, which are related to the number of clumps desired. After it is assigned(the number is i), the whole pack area should be divided equally into (2*i) and the number of nodes in this area is also equal to it and it is obvious that the coordinates of all these nodes can be calculated by:

          N = √(2*i)
          coorX = (mx[0]-mn[0]) / N * random.randint(0,N) 
          coorY = (mx[1]-mn[1]) / N * random.randint(0,N)

All these things done here is to assure these two things: one is that
the number of nodes is enough for generating clumps and the other is
that the minimum distance of any two nodes can be easily predicted.

(2).After determining the types and shapes of desired clumps, the radius
of spheres for creating clumps can be confirmed according to the minimum
distance of any two nodes so that there is no overlaps occuring.

(3).make clumps with nodes and input some necessary testing codes in
script in order to essure that all steps of generation can be
sucessfully done one by one.

Though there is nothing wrong after testing, the srcipt is not flexible
enough for adapting complex requirements for that it can only be used in
unique type and size clumps generation. And there are some problems
occuring in these codes. So my questions today are that:

(1).What can I do to optimize this srcipt for adapting complex
requirements(such as random orientation and size of clumps)

(2).How to get the information of all clumps. I have used this command
"print ( O.bodies[clump_ids].shape.members.keys()[0] )" but it does not
work any more.

(3).How to define DOF condition to all clumps. I have used this command "for b in O.bodies:
O.bodies[clump_ids].blockedDOFs='zXY' " and then have done "gravity in z-direction" with codes "NewtonIntegrator(damping=0.7,gravity=[0,0,-10])" but there is still a movement in z-direction. What can I do to correct this error. 

Seeking your help!

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.