Yes, I would be glad for you to add my script to the example scripts once I get it working. I hope others will be able to learn from it.
I realized that I do not have r1727. I was able to download revision r1730, but I do not think it is working, because when I run the simulation I still get: "'ActionContainer' object has no attribute 'addF' ". I am new to open-source code, as well as yade, so I am not sure if I am doing this correctly. Thanks, Roger 2009/3/25 Václav Šmilauer <[email protected]> > def applyForces(): > >> bex=BexContainer() >> for b in O.bodies: >> >> >> f=3,1,2,1,4,3,5,2,1,5,4,3,7,.2,1,3,2,6,3,2,3,3,4,3,5,7,8,6,7,3,1,2,1,2,3,1,2,1,.1,.3,1,.4,2,3,4,3,3,3,3 >> #hypothetical forces for testing >> bex.addForce(b.id <http://b.id>,f) >> > OK, I tried. > > 1. bex=O.actions, I already told you. > 2. bex.addF(b.id,f) is the correct thing, not addForce (my fault) > 3. you are adding the whole f to the body, which is not what you want (it > will not chage at all). And addF takes vector. You need something like this: > > f=1,2,3,4,5,6,7.... # hypothetical > def applyForces(): > bex=O.actions > for b in O.bodies: > ff=(0,0,f[O.iter%len(f)]) ## x,y components zero, z component is > taken from f based on iteration number wrapped to the length of f > bex.addF(b.id,ff) > > It adds the same force to all bodies though at each iteration, but you can > change that easily. Maybe you don't want to apply that force to all bodies, > but just the red ones? Then do something like > > redParticles=[] > # generate dynamic particles function here > > > redParticles+=o.bodies.append(utils.sphere([xs,ys,zs],rad,dynamic=True,color=[1,0,0],young=30e9,poisson=.3,density=2111.31)) > # O.bodies.append returns id of the body that you add to > redParticles, which will be list of ids at the end > > then in applyForces: > > for id in redParticles: > ff=... > bex.addF(id,ff) > > HTH, Vaclav > > PS. what you sent runs about 5x slower with the python engine. But it is > good to make a prototype like that, then the idea is clear and it can be > easily written in c++. > > PPS. Yade imports everything from math module automatically (sqrt, floor > etc) > > PPPS. Once you script works, would it be OK to put it under examples in the > source tree? >
_______________________________________________ Mailing list: https://launchpad.net/~yade-users Post to : [email protected] Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
_______________________________________________ yade-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/yade-users
