gravity for certain material instance

Asked by behzad

Hi there,

I was wondering if we can assign normal (negative in z direction) gravity for the model, but for certain bodies which have a different and known material we put gravity in positive z direction.

The idea is to mimic a sort of evaporation phenomena in a compacted particle assembly. I tried to put negative density but it did not work.

If you guys have any idea, please let me know.

Bests,
Behzad

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,
you can mimic (anti)gravity by prescribin permanent force on certain bodies.

########################################
bs = (
   sphere(( 0,0,0),1),
   sphere(( 5,0,0),2),
   sphere((11,0,0),3),
   sphere((20,0,0),4),
)
O.bodies.append(bs)

for i,b in enumerate(bs):
   m = b.state.mass
   g = ((-1)**i) * Vector3(0,1e-6,0)
   f = m*g
   O.forces.addF(i,f,permanent=True)
########################################

Cheers
Jan

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

Thanks Jan. It's a good idea. However, my concern is that this is supposed to cover future bodies as well. What you suggest can take care of only already existing bodies.
Can we do similar thing but specify the material type (like let's say vaporMat which can be a FrictMat instance) so whenever a body with this material is created during iteration, it applies the anti-gravity force?

cheers

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

sure:
######################
vaporMat = FrictMat(...)
...
b = ...
O.bodies.append(b)
if b.mat == vaporMat:
   O.forces.addF(b.id,f,permanent=True)
######################
Jan

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

Well, this won't cover future bodies. I need to repeat this command whenever a new vaporMat is generated. Or embed it in a pyRunner which I didn't want to.

Thanks anyway. :)

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

> I need to repeat this command

Is it a problem? from source code point of view, you can of course wrap all it into one function
#
def myOBodiesAppend(b):
   O.bodies.append(b)
   if b.mat == vaporMat:
      O.forces.addF(b.id,f,permanent=True)
#
Then you just call this one function
cheers
Jan

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

Good, that's what I meant!