Clumps,sphere and walls IDs

Asked by behzad

Hi everybody,

I have made an assembly of clumps using clump templates. There are some atand-alone sphere and of course some walls in the model.
I have difficulty in assiging different colors to each type of bodies(clump, sphere and walls) in the model. It seems that the IDs are very polluted.

In a very simple script as follows when I try;

for i in O.bodies:
         if i.isClump:
             O.bodies[i.id].shape.color=(.1,.7,.9)
         else:
             O.bodies[i.id].shape.color=(1,1,1)

Changes the color of all bodies (yes, including the wall) to (1,1,1) means that it does not consider them as clump members.

Any idea? What's going on here?

#=================================================================================
#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,0,-10])
]

#create a box:
id_box = O.bodies.append(box((0,0,0),(8,8,.5),fixed=True,material=Mat))

s1=utils.sphere([3,-1,8],2.015,material=Mat)
s2=utils.sphere([0,5,8],2.015,material=Mat)

O.bodies.append(s1)
O.bodies.append(s2)

relRadList1 =[0.000471583,0.00060213,0.000631454,0.000493144,0.000695336,0.000395284,0.000550567,0.00037674,0.000656561,0.000218143,0.000223094,0.000484354,0.00036813,0.000514327,0.000395357,0.000377391,0.000454081,0.000355504,0.00061375,0.00068747,0.000508243,0.000447592,0.000549008,0.000486356,0.000664425,0.000587608,0.00015184,0.000695789,0.000484995,0.000443755]

relPosList1 = [[0.000213504,0.000920219,5.17294e-005],[0.000181129,-0.000693148,-0.000301356],[0.000191565,0.000550929,0.000472726],[-6.9806e-005,0.000814473,0.000504795],[-0.00016687,-4.19741e-005,0.000273102],[-0.000632058,-0.000285906,0.000255655],[8.5103e-005,-2.87712e-006,0.000608655],[-0.000369852,6.12296e-006,-0.00056701],[7.38905e-005,0.000497426,2.97204e-005],[0.000135818,0.000562643,-0.000842692],[0.000748387,0.00077499,0.000784656],[7.88683e-005,0.000626452,-0.00032004],[0.000526651,-0.000553811,0.000109479],[0.000136113,0.000176874,-0.000254769],[-0.000209755,-0.000765094,-0.000832511],[-0.000945048,-0.00034182,-0.000150738],[0.000425963,-0.000381421,-0.000472185],[0.000544025,0.000492145,0.000918189],[-0.000262527,0.000319288,0.000244014],[-0.0002573,-0.000432994,-0.000293022],[0.000500309,-0.000741747,-0.000145635],[0.000354013,4.94286e-005,0.000772469],[7.59e-005,-0.0014,-0.00029],[0.00015904,0.000954791,0.00058286],[0.000106567,-0.000252692,2.9281e-005],[-0.000616653,-0.000235914,-0.000163413],[-0.00114642,8.90673e-005,-0.000146111],[-0.000361004,-0.000311422,-0.000152367],[-0.000655366,-2.8257e-005,-0.000169021],[-0.000501808,-6.06848e-005,-0.000385601]]

relRadList2 =[0.000471583,0.00060213,0.000631454,0.000493144,0.000695336,0.000395284,0.000550567,0.00037674,0.000656561,0.000218143,0.000223094,0.000484354,0.00036813,0.000514327,0.000395357,0.000377391,0.000454081,0.000355504,0.00061375,0.00068747]

relPosList2 = [[0.000213504,0.000920219,5.17294e-005],[0.000181129,-0.000693148,-0.000301356],[0.000191565,0.000550929,0.000472726],[-6.9806e-005,0.000814473,0.000504795],[-0.00016687,-4.19741e-005,0.000273102],[-0.000632058,-0.000285906,0.000255655],[8.5103e-005,-2.87712e-006,0.000608655],[-0.000369852,6.12296e-006,-0.00056701],[7.38905e-005,0.000497426,2.97204e-005],[0.000135818,0.000562643,-0.000842692],[0.000748387,0.00077499,0.000784656],[7.88683e-005,0.000626452,-0.00032004],[0.000526651,-0.000553811,0.000109479],[0.000136113,0.000176874,-0.000254769],[-0.000209755,-0.000765094,-0.000832511],[-0.000945048,-0.00034182,-0.000150738],[0.000425963,-0.000381421,-0.000472185],[0.000544025,0.000492145,0.000918189],[-0.000262527,0.000319288,0.000244014],[-0.0002573,-0.000432994,-0.000293022]]

templates= []
templates.append(clumpTemplate(relRadii=relRadList1,relPositions=relPosList1))
templates.append(clumpTemplate(relRadii=relRadList2,relPositions=relPosList2))

O.bodies.replaceByClumps(templates,[.5,.5])
O.dt=1e-6

s3=utils.sphere([11,5,18],5.0,material=Mat)

O.bodies.append(s3)

qt.View()

#=============================================================================

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
behzad
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hi Behzad,

> for i in O.bodies:
> if i.isClump:
> O.bodies[i.id].shape.color=(.1,.7,.9)
> else:
> O.bodies[i.id].shape.color=(1,1,1)
>
> Changes the color of all bodies (yes, including the wall) to (1,1,1)
> means that it does not consider them as clump members.
>

actually you already answered yourself :-) try something like:

for i in O.bodies:
  if i.isClumpMember: # different property
    i.shape.color = whatever # you can use directly i.shape instead of
O.bodies[i.id].shape, but the result should be the same
  else:
    whateverElse

cheers
Jan

Revision history for this message
behzad (behzad-majidi) said :
#2

Hi Jan,

Thanks for the answer. I tried it and it works.

But, still the IDs of clumps are kind of strange for me.
I tried the following commands in the above mentioned script;
 for t in O.bodies:
    if t.isClump:
        print 'Clump ',t.id,' has following members: '
        keys=t.shape.members.keys()
        for ii in range(0,len(keys)):
            print '- Body',keys[ii]

and what I get is :

Clump 33 has following members:
- Body 3
- Body 4
- Body 5
- Body 6
- Body 7
- Body 8
- Body 9
- Body 10
- Body 11
- Body 12
- Body 13
- Body 14
- Body 15
- Body 16
- Body 17
- Body 18
- Body 19
- Body 20
- Body 21
- Body 22
- Body 23
- Body 24
- Body 25
- Body 26
- Body 27
- Body 28
- Body 29
- Body 30
- Body 31
- Body 32
Clump 53 has following members:
- Body 1
- Body 34
- Body 35
- Body 36
- Body 37
- Body 38
- Body 39
- Body 40
- Body 41
- Body 42
- Body 43
- Body 44
- Body 45
- Body 46
- Body 47
- Body 48
- Body 49
- Body 50
- Body 51
- Body 52

As you see the IDs of clumps are polluted with the spheres IDs. Imagine a model with thousands of clumps and stand-alone spheres. This makes it very difficult to assign properties to certain clumps. Like here, we hav only two clumps but the IDs are 33 and 53.
For me it's pretty normal to have Clump id 1 and 2 in this case.

thank you!

Revision history for this message
Jan Stránský (honzik) said :
#3

Hi Behzad,

the IDs of bodies are assigned as you use O.bodies.append(...). I don't
know the implementation of replaceByClumps, but appearently firstly the
spheres of a clump are created and added to O.bodies and after that the
clump is created and added to O.bodies, repeating sequentially for all
templates, so you get this numbering.

Does the ids matters so much? To create a list of clumps, you can use
something like

clumps = []
for b in O.bodies:
  if b.isClump:
    clump.append(b)
# or more pythonic
clumps = [b for b in O.bodies if b.isClump]

and then call clumps[localClumpIDs] numbers as they would be ascending form
0..

cheers
Jan

2014-03-04 20:11 GMT+01:00 behzad majidi <
<email address hidden>>:

> Question #244984 on Yade changed:
> https://answers.launchpad.net/yade/+question/244984
>
> behzad majidi posted a new comment:
> Hi Jan,
>
> Thanks for the answer. I tried it and it works.
>
> But, still the IDs of clumps are kind of strange for me.
> I tried the following commands in the above mentioned script;
> for t in O.bodies:
> if t.isClump:
> print 'Clump ',t.id,' has following members: '
> keys=t.shape.members.keys()
> for ii in range(0,len(keys)):
> print '- Body',keys[ii]
>
> and what I get is :
>
>
> Clump 33 has following members:
> - Body 3
> - Body 4
> - Body 5
> - Body 6
> - Body 7
> - Body 8
> - Body 9
> - Body 10
> - Body 11
> - Body 12
> - Body 13
> - Body 14
> - Body 15
> - Body 16
> - Body 17
> - Body 18
> - Body 19
> - Body 20
> - Body 21
> - Body 22
> - Body 23
> - Body 24
> - Body 25
> - Body 26
> - Body 27
> - Body 28
> - Body 29
> - Body 30
> - Body 31
> - Body 32
> Clump 53 has following members:
> - Body 1
> - Body 34
> - Body 35
> - Body 36
> - Body 37
> - Body 38
> - Body 39
> - Body 40
> - Body 41
> - Body 42
> - Body 43
> - Body 44
> - Body 45
> - Body 46
> - Body 47
> - Body 48
> - Body 49
> - Body 50
> - Body 51
> - Body 52
>
>
> As you see the IDs of clumps are polluted with the spheres IDs. Imagine a
> model with thousands of clumps and stand-alone spheres. This makes it very
> difficult to assign properties to certain clumps. Like here, we hav only
> two clumps but the IDs are 33 and 53.
> For me it's pretty normal to have Clump id 1 and 2 in this case.
>
> thank you!
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
behzad (behzad-majidi) said :
#4

Yeah, sure there're some ways, as you mentioned, to treat the clump numbers.
You know I was using PFC for frour years and these stuff are pretty straightforward there. Clump IDs and ball IDs are seperated. It's why I was wondering why I do not have a clump ID=1.

It's not that much annoying, but it makes the thing a little bit complicated. Like, in some simulattions of particle packing I measure the number of contacts between the clumps with certain sizes. (like, I have a binary packing and I'd like to measure the number of conatcts between large particles, or number of large-small contacts).

Anyways, by creating a new list like clumps=[] it can be treated somehow.

Thanks for following it up.

Cheers,
Behzad

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#5

I just wanted to add, O.bodies.replaceByClumps returns a tuple of [(clumpId1,[memberId1,memberId2,...]),(clumpId2,[memberId1,memberId2,...]),...], so you have your list already. No need to loop over the whole bodies.

Klaus