← 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:
     Thanks for helping me last time and now I can sucessfully get 2D clumps using these codes:

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

def Parameters():  # input some basic parameters for clumps generation
    
    global q,mn,mx,lengX,lengY
    q = (input( "the number of clumps " ) )  
    mn,mx=Vector3(0,0,0),Vector3(0.07,0.07,0.1)
    [lengX,lengY] = [(mx[0] - mn[0]),(mx[1] - mn[1])]

def Radius():  # assign radius according to the size of pack area
    
    global NX,NY,radius
    
    if lengX > lengY :

       NX = int ( pow ( 2 * q , 0.5 ) )
       NY = int ( ( lengY / lengX ) * NX )
       rx = lengX / NX ; ry = lengY / NY

       if rx > ry :
          radius = ry * 0.22
       else :
          radius = rx * 0.22

    else:

       NY = int ( pow ( 2 * q , 0.5) )
       NX = int ( ( lengX / lengY ) * NY )
       rx = lengX / NX ; ry = lengY / NY

       if rx > ry :
          radius = ry * 0.22
       else :
          radius = rx * 0.22

    print ('The X-direction is equally divided into {0}'.format(NX) )
    print ('The Y-direction is equally divided into {0}'.format(NY) )
    print ('The radius of clumps desired is {0}'.format(radius) )

def Coor():  # determine the coordinations of each point for generating

    global coorint,coordes
    coorint = [] 
    coordes = [] 

    for i in xrange(q): 
        coorX = lengX / NX * random.randint( 0, NX ) 
        coorY = lengY / NY * random.randint( 0, NY ) 
        coorint.append( [coorX , coorY] )   

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

    a = len(coorint); b = len(coordes)
    print ('There are {0} clumps desired'.format(a) )
    print ('There are {0} clumps generated'.format(b) ) 

def Unitcells(): # define unitcell for clumps

    global sphereList
    sphereList = []

    for b in coordes:
        coors1 = [ b[0] - radius , b[1] - radius , 0 ]
        coors2 = [ b[0] + radius , b[1] - radius , 0 ]
        coors3 = [ b[0] + radius , b[1] + radius , 0 ]
        coors4 = [ b[0] - radius , b[1] + radius , 0 ]        
        spherepara1 = sphere ( coors1 , radius  )
        spherepara2 = sphere ( coors2 , radius  )
        spherepara3 = sphere ( coors3 , radius  )
        spherepara4 = sphere ( coors4 , radius  )    
        sphere1 = O.bodies.append ( spherepara1 )
        sphere2 = O.bodies.append ( spherepara2 )
        sphere3 = O.bodies.append ( spherepara3 )
        sphere4 = O.bodies.append ( spherepara4 )
        sphereList.append ([sphere1 , sphere2 , sphere3 , sphere4])

def Clumps(): # generate the clumps desired

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

def material():
   
    for b in O.bodies:
        if b.isClumps:
           O.bodies[b].material = O.material[clumpsmat]

def DOF(): # of course, DOF condition only for 2D simulation

    for b in O.bodies:
        if b.isClump:
           b.state.blockedDOFs = 'zXY'
           
# control flows 
Parameters()
Radius()
Coor()
Unitcells()
Clumps()
DOF()

###########################################################################################

And I have taken a correct testing with it in gravity condition
simulation. But when it is employed in 2D biaxial compression
simulation, it does not work any more. The python shell gave me these
warning:

###########################################################################################
File "new-test.py", line 140, in <module>
    Clumps()
  File "new-test.py", line 121, in Clumps
    clump_ids = O.bodies.clump (b)
RuntimeError: Clump::updateProperties: NaNs in eigen-decomposition of inertia matrix?!
###########################################################################################

When I forced to run this simulation, the shell noticed that
"ValueError: cannot convert float NaN to integer" I do not understand
why and wanna know how to solve this problem. Seeking your help!

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