Clump templates

Asked by behzad

Hey Guys,

I have some issues with clump templates definition.
First one all it does not work with Yade and I can only define templates with Yadedaily. Like, when I run the script with Yade I get the error :
" templates.append(clumpTemplate(relRadii=relRadList3,relPositions=relPosList3))
NameError: name 'clumpTemplate' is not defined"

Anyways, it works with Yadedaily. However, it is very slow for clumps made of around 20 balls. I have already made som clumps using imaging techniques to represent some irregular-shape particles. An example is as follows;

relRadList3 =[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]

relPosList3 = [[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.29082e-005,-0.000364611,-0.000799481],[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]]

and then I write:
templates= []
templates.append(clumpTemplate(relRadii=relRadList3,relPositions=relPosList3))

This simply doesn't work without any error message!
But when I change the coordinates of some balls it works! Does any body have an idea of what the hell is the problem here?

Thanks

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
Klaus Thoeni (klaus.thoeni) said :
#1

Hi,

I never used templates but what I amusing is one clump made of several 100 particles. Yes, it is very slow because it is updating the properties, i.e. mass, intertia. You can avoid the updating by using "integrateInertia=False" or decreasing "discretization=5" (see e.g. appendClumped, replaceByClumps). This means your properties are not so accurate and depending on what kind of simulations you do it might be okay. Nevertheless, it makes testing much faster.

The example you posted is working for me, but I am using the latest trunk version.

Did you try to use the latest version [1]? You have to compile it but just follow the steps on the doc page [2].

HTH,
Klaus

[1] https://launchpad.net/yade/trunk/yade-1.00.0/+download/yade-1.07.0.tar.gz
[2] https://yade-dem.org/doc/installation.html#source-code

Revision history for this message
Hicham BENNIOU (benniou-hicham-deactivatedaccount) said :
#2

Hi behzad majidi,

Just one question, Is this the full script ?

Hicham

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

Hi

Thanks Klaus. I'm now installing the latest version. It's now compiling...
So, probably that's the problem. I'll keep you posted.

As for Hicham;
No, it's not the full script. I just copied the clump template and it's replacement command to you.

Thanks

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

I compiled the sources (yade-1.07.0.tar.gz) on Ubuntu 12.04. I tried to install yade in a folder on my home and I did not get any error, but when I launch yade I get the following error message:

bemaj3@GCI-REGAL-ETU5:~/code/yade/bin$ ./yade-1.07.0
Welcome to Yade 1.07.0
Traceback (most recent call last):
  File "./yade-1.07.0", line 125, in <module>
    import yade
  File "/home/bemaj3/code/yade/lib/x86_64-linux-gnu/yade-1.07.0/py/yade/__init__.py", line 65, in <module>
    import boot
ImportError: /home/bemaj3/code/yade/lib/x86_64-linux-gnu/yade-1.07.0/py/yade/qt/_GLViewer.so: undefined symbol: _ZN9QGLViewer28setPlayPathKeyboardModifiersE6QFlagsIN2Qt16KeyboardModifierEE

The file _GLViewer.so is present:

ls -lh /home/bemaj3/code/yade/lib/x86_64-linux-gnu/yade-1.07.0/py/yade/qt/_GLViewer.so-rw-r--r-- 1 bemaj3 fsg-etudiants_linux 2.7M Feb 24 11:03 /home/bemaj3/code/yade/lib/x86_64-linux-gnu/yade-1.07.0/py/yade/qt/_GLViewer.so

Any advice about how to solve this problem?

Thanks

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

I am just guessing but do you have libqglviewer-qt4-dev package installed? On the installation page it says:

If you have Ubuntu 12.10 or older, you need to install libqglviewer-qt4-dev package instead of libqglviewer-dev.

HTH
Klaus

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

Klaus,

Yeah I just installed libqglviewer-qt4-dev. But the problem still exists.

Look this is the full script which is not working;

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

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])
]

from yade import qt
qt.Controller()
qt.View()

id_box = O.bodies.append(box((0,0,0),(2,2,.1),fixed=True,material=Mat))

sp=pack.SpherePack()
sp.makeCloud(minCorner=(-1.5,-1.5,.1),maxCorner=(1.5,1.5,2),rMean=.2,rRelFuzz=.5,num=50,periodic=False)
O.bodies.append([sphere(c,r,material=Mat) for c,r in sp])

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

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

templates= []
templates.append(utils.clumpTemplate(relRadii=relRadList4,relPositions=relPosList4))
O.bodies.replaceByClumps(templates,[1.0])
O.dt=1e-6

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

It doesn't give any error as yuo see;

bemaj3@GCI-REGAL-ETU5:~$ yadedaily replaceByClumps-example12.py
Welcome to Yade 1.07.0-50-d835182~precise
TCP python prompt on localhost:9000, auth cookie `yskcds'
XMLRPC info provider on http://localhost:21000
Running script replaceByClumps-example12.py
[[ ^L clears screen, ^U kills line. F12 controller, F11 3d view (use h-key for showing help), F10 both, F9 generator, F8 plot. ]]

Yade [1]:

But, it doesn't create the clump. But if I decrease the number of balls making the clump, it works!!

Thanks

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#7

Hi Behzad,

Some time ago Francois Kneib detected this bug in clump generation:

https://bugs.launchpad.net/yade/+bug/1273172

Please have a look at this.
Is it the same in your case?

Christian

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

Christian,

I don't think it's the same problem. Because the number of balls in the clump I have is not that much. I have around 30 balls for clumps in my work. But, Francois is talking about 256 balls.

Christian and Klaus,
what is the exact version of yade and ubuntu you guys are using and do not have any issue which the script I posted?

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

Hi,

the script you posted is having the same problem on my machine. It seems that the clumps/bodies are initialised with many nans. len(O.bodies) tells you the bodies are there, but if you check the state of a body you get something like this:

{'angMom': Vector3(0,0,0),
 'angVel': Vector3(nan,-nan,-nan),
 'blockedDOFs': 0,
 'densityScaling': 1.0,
 'inertia': Vector3(-nan,-nan,-nan),
 'isDamped': True,
 'mass': 0.40971235825627106,
 'refOri': Quaternion((1,0,0),0),
 'refPos': Vector3(0,0,0),
 'se3': (Vector3(nan,-nan,nan),
  Quaternion((-nan,-nan,-nan),6.2831853071795862)),
 'vel': Vector3(-nan,-nan,-nan)}

I am not sure what's going on here but could be a bug.

Klaus

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

Actually, i think it is the same problem as here [1]. However, the problem is not the number of clump members and it seems that setting integrateInertia=False doesns't fix the problem.

Klaus

[1] https://bugs.launchpad.net/yade/+bug/1273172

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#11

> setting integrateInertia=False doesns't fix the problem.

confirmed

One problem I detected with my own script is, that

> I don't think it's the same problem. Because the number of balls in the clump I have is not that much.
> I have around 30 balls for clumps in my work. But, Francois is talking about 256 balls.

ok

> Christian and Klaus,
> what is the exact version of yade and ubuntu you guys are using and do not have any
> issue which the script I posted?

I am using latest trunk version (development version) [1]. Latest change in clump logic has been done in october 2013 [2]. So there was no change for versions >= 1.0.0 ...

[1] https://github.com/yade/trunk
[2] https://github.com/yade/trunk/commit/8202468e7b483c936dbd099b2b03b79ee7150ab4

how do you get your script working? can you post a combination of relRadList and relPosList, that is working?

christian

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#12

sorry forgot to end my sentence:

One problem I detected with my own script is, that when using replaceByClumps in a periodic space sometimes balls are created outside periodic cell. To fix this one has to decrease generation area for sphere before using replacebyClumps, but it is not the problem here...

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#13

I didn't follow the discussion, but this is attracting me:
>when using replaceByClumps in a periodic space sometimes balls are created outside periodic cell

It should not be a problem. Is it? In yade's PBC particles can be everywhere.

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#14

>> when using replaceByClumps in a periodic space sometimes balls are created outside periodic cell

> It should not be a problem. Is it? In yade's PBC particles can be everywhere.

I do not remember the error message, but it is breaking the code somewhere.

@behzad:

While investigating the code I found a bug, but not the one I was looking for ^^

I propose to continue this conversation at the bug report, I am quite sure it is related somehow:

https://bugs.launchpad.net/yade/+bug/1273172

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

Thanks guys for the follow up.

Christian, check this out;

#======================================
O.reset()
from yade import utils
from yade import pack, qt

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])
]

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])
O.dt=1e-6
qt.View()

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

This simply works. But if we change two lines of clumpTemplate commads to;

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

It's not gonna work. Because the the first template (relRadList1, relPosList1) is the problematic! It contains 30 balls. The second one has 20 balls.

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#16

Hi again,

I have a good and a bad message for you:

The good one is: I found the problem and fixed it [1].

The bad one is: For multiple overlapping clump members an additional space grid integration is needed for getting volume of the clump templates. It is done once for each template.

I checked the volumes of spheres and corresponding clumps (using discretization=5) and it is ok now:

Volume of shpere before replacement: 0.110894
Volume of clump: 0.110879
Volume of shpere before replacement: 0.106574
Volume of clump: 0.106577
Volume of shpere before replacement: 0.102368
Volume of clump: 0.102379
...

While deactivating integration scheme (integrateInertia=False) properties (volume/mass/inertia) are not valid, but initialization is much faster:

Volume of shpere before replacement: 0.110894
Volume of clump: 0.330293
Volume of shpere before replacement: 0.106574
Volume of clump: 0.317426
Volume of shpere before replacement: 0.102368
Volume of clump: 0.304897
...

Have fun with this new feature!

Now I am thinking about a parallelizing integration scheme ...

Cheers,

Christian

Oh I forgot: It does not fix the other bug [2].

[1] https://github.com/yade/trunk/commit/f60e0c0315595842c853a0f154121a5d4e1449a2
[2] https://bugs.launchpad.net/yade/+bug/1273172

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

Thanks Christian,

Would you please let me know how can I update my code to get change you made? I appreciate it.

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#18

> Would you please let me know how can I update my code to get change you made? I appreciate it.

There are different possibilities:

https://yade-dem.org/doc/installation.html

1) The fastest option is to download trunk.zip at github

https://github.com/yade/trunk

unzip, compile, use

2) If you use yade-daily, the update should be available in the coming hours/days/weeks? I do not know...

3) Wait for the next official release ...

Cheers,

Christian

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

Hi Christian,

Yeah, it works well with the new trunk version which I just complied it. Thank you!

cheers,
Behzad

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#20

Hi Behzad,

I hope you enjoy this new feature too ;)

https://github.com/yade/trunk/commit/828893babba373d7c376c084a288e6af2f910512

Cheers,

Christian

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

Hi Christian,

What does it do the new feature?

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#22

> What does it do the new feature?

Well for your script replacing 50 spheres by clumps I got a generation time about 35 seconds. The new feature allows you to run it at all your cpu cores, which leads to less generation time. For your script with 50 particles I achieved approx. 8 seconds using 8 cores (command: yade -j8 scriptname.py). Imagine you want to create a model consisting of 1000 particles or more ...

cheers,

christian

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

yeah, I got it. That's awesome. Sure, that will be so helpful, because I'm gonna have thousands of clumps in my model.

cheers,