← Back to team overview

yade-dev team mailing list archive

Re: need help on ClumpTemplate

 

Jan, Anton and Bruno,

Thank you very much for your comments.

I want to have a command, that can create 20 % clumps of type A (e.g. peanuts), 30 % clumps of type B (e.g. dyads), ... and so on. Also it should be possible to create clumps and spheres with this command (e.g. 20 % clumps, 80 % spheres).

sp.makeClumpCloud always creats 100 % clumps. Also all clumps seem to be equal in size, right? But it is nearest to want I want.
sp.makeCloud always creates 100 % spheres.

So I wanted to write a replaceByClumps() method in yadeWrapper, that replaces given amount of EXISTING particles by clumps (using template(s)).

I see, that ClumpTemplate is not really needed ...
But I do not see how to combine makeCloud and makeClumpCloud ...
I think the only way to do this is by following procedure:

1. create spheres (e.g. with makeCloud() and SpherePack())
2. create templates (new method needed?)
3. replaces spheres by clumps (using templates), whereby clump volume == sphere volume

@jan:

rads = [1,1]
poss = [(1,1,1),(0,0,0)]
spheres = [utils.sphere(pos,rad) for pos,rad in zip(poss,rads)]
O.bodies.appendClumped(spheres)

This is not what I want: rads and poss are absolute values, not relative ones!

For better understanding, I give you some PFC code and a picture (see attachment: spheres in black, dyads in blue, peanuts in orange, sticks in red).

;############ code for PFC 4.0:

; generate balls:

gen id = 1,500 rad .006 .015 x 0 .24 y 0 .24 z 0 .24
prop dens = 1000 kn = 1e4 ks = .5e4 fric = .5

; create clump templates:
clump template make dyad 2 radii 1.0 1.0 pos (1 0 0) (0 0 0)

clump template make peanut 3 radii .5 1 .5 pos (-1 0 0) (0 0 0) (1 0 0)

clump template make stick 5 radii 1.0 1.0 1.0 1.0 1.0  &
                              pos   (1.0,0.0,0.0)        &
                                    (2.0,0.0,0.0)        &
                                    (3.0,0.0,0.0)        &
                                    (4.0,0.0,0.0)        &
                                    (5.0,0.0,0.0)
; replace balls by clumps:

clump replace 3 dyad,.3 peanut,.2 stick,.1
;-> 30 percent dyads, 20 percent peanuts, 10 percent sticks (, 40 percent spheres)


Regards,

Christian.


Zitat von Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>:

You have to make the class inherit from "Serializable" if you want to
handle it easily in python (using all the macros that yade defines). You
could use Body.hpp as an example.

As for the user's side, it make no difference if the function is
implemented in c++ or python (but the latest is sometimes more "light
weight" for the devs). See for instance, the source file
py/bodiesHandling.py.
Saving them with O.save sounds a little bit involved, since templates
are not bodies of the simulation and only them are saved currently.


in hpp. How can I set the length of the vector, after construction of
the object in makeClumpTemplate() in yadeWrapper ?
shared_ptr<ClumpTemplate> ct=shared_ptr<ClumpTemplate>(new
ClumpTemplate());
ct->rad ???
ct->pos ???

The vector will have null length by default, which should be ok.
If you register the vectors using python binding (like e.g. "ids" in
PartialEngine), you should be able to modify the list like this:
ct.rad.append(x) #or
ct.rad=[1,1,1]

Still, I don't see why there is a pointer to a template in the template.

Note also that the current interface uses something quite similar to a
template. In triax-tutorial/script1.py, you find this:

## define a unique clump type (we could have many, see clumpCloud
documentation)
c1=pack.SpherePack([((-0.2*mean_rad,0,0),0.5*mean_rad),((0.2*mean_rad,0,0),0.5*mean_rad)])
 ## generate positions and input them in the simulation
 sp.makeClumpCloud(mn,mx,[c1],periodic=False)

c1 is a sort of template, isn't it? So if I understand correctly you
want something that would take c1 but would also be more flexible (i.e.
that would not require one to use ClumpCloud)?

Bruno


_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to     : yade-dev@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~yade-dev
More help   : https://help.launchpad.net/ListHelp




Follow ups

References