← Back to team overview

yade-users team mailing list archive

[Question #628595]: Problem creating clumps from existing spheres

 

New question #628595 on Yade:
https://answers.launchpad.net/yade/+question/628595

Hi everybody, 

I have been using the agglomerate examples that can be found in the docs from yadedaily, in order to generate a packed sample of clumped particles. In the example this was done in three scripts (Makecloud, divide and compress) , creating at the end of each file a temporary file that was reloaded in the subsequent simulation.

I figured that I would like to have those three scripts all in one go, in order to launch this simulation, have the package and then save it to be used in other simulations.

But I am having trouble when it comes to actually clump assemblies of particle. The strange thing is I haven't been changing much of the existing code !

The code creates a list of groups of spheres, which are to be later on assembled in a clump. 
So the spheres are added one after another, based on their agglomerate number, that has been set previously by creating an initial sphere pack, and then packing in each of the spheres another sphere pack. So the agglomerate number would be the id of the initials bigger spheres, I guess.

Once they are all stored in the same occurence of the list, each element of the list ( that is, each group of spheres), is called in order to be clumped.
and then I get this error :

Traceback (most recent call last):
  File "/usr/bin/yadedaily", line 182, in runScript
    execfile(script,globals())
  File "agglomerate.py", line 74, in <module>
    O.bodies.appendClumped(g)
IndexError: Body already has id 0 set; appending such body (for the second time) is not allowed.

I am not sure what this means, but it seems like the program is trying to append the spheres once again, when they are already in the simulation. But that results strange to me, since I thought the appendClumped function could work with existing spheres..

Here is the full script :

# -*- coding: utf-8 -*-

from yade import export
from yade import export,ymport
import random

def getClumpInfo():
	for b in O.bodies:
		if b.isClump:
			print 'Clump ',b.id,' has following members:'
			keys = b.shape.members.keys()
			for ii in range(0,len(keys)):
				print '- Body ',keys[ii]
			print 'inertia:',b.state.inertia
			print 'mass:',b.state.mass,'\n'
		else: 
			print 'no clumps'
	
dim    = (15,15,15) # dimensions for makeCloud
radius = 1
fuzz   = 0.2

# use of makeCloud function
sp = pack.SpherePack()
sp.makeCloud((0,0,0), dim, rMean=radius, rRelFuzz=fuzz, seed=1)



random.seed(1) # to make colors always the same

attrs = []

colors = [randomColor() for s in sp]
# each macroparticle is filled randomDensePack
for si,s in enumerate(sp):
	sphere = pack.inSphere(s[0],s[1])
	sp1 = pack.randomDensePack(
		sphere,
		spheresInCell = 500,
		radius = .2,
		memoizeDb = '/tmp/agglomeratepackaux.db',
		returnSpherePack = True,
	)
	ids = sp1.toSimulation(color=colors[si]) # add the result to simulation with uniform color

	for i in ids:
		O.bodies[i].agglomerate = si # tell each particle who is its agglomerate
		attrs.append(O.bodies[i].agglomerate)

#random.seed(1)

sp2 = []
for b in O.bodies : 
	sp2.append(b)

# add walls first
dim = (15,15,15)
walls = aabbWalls(((0,0,0),(dim)))
wallIds = O.bodies.append(walls)

# clump agglomerates
n = max(a for a in attrs)+1
colors = [randomColor() for _ in xrange(n)]
agglomerates = [[] for _ in xrange(n)]


for s,a in zip(sp2,attrs):
        aa = a
	s.agglomerate = aa
	s.shape.color = colors[aa]
        agglomerates[aa].append(s)

for g in agglomerates:
	O.bodies.appendClumped(g)


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()]
	),
	TriaxialStressController(
		thickness = 0,
		stressMask = 7,
		internalCompaction = False,
		label = 'compressor',
	),
	NewtonIntegrator(damping=.6),
]
O.dt = PWaveTimeStep()

# compress the sample
compressor.goal1 = compressor.goal2 = compressor.goal3 = -1e-7
O.run(50000,True)
compressor.goal1 = compressor.goal2 = compressor.goal3 = -1e-5
O.run(30000,True)

# save the result, including information of agglomerates which the particle belongs to
export.textExt('/tmp/compressed.txt','x_y_z_r_attrs',attrs=['b.agglomerate'])

try:
	from yade import qt
	qt.View()
except:
	pass



Welle, if anybody has an idea, it would be of great help !


-- 
You received this question notification because your team yade-users is
an answer contact for Yade.