← Back to team overview

yade-users team mailing list archive

Re: [Question #660533]: dynamic change of gravity vector

 

Question #660533 on Yade changed:
https://answers.launchpad.net/yade/+question/660533

Robert Caulk proposed the following answer:
I guess I should also tell you how a PyRunner works [1]. It serves the
purpose of executing some function according to some iteration period.
So in your case, each iteration of your simulation will execute
"gravity()". So I hope it is obvious that the PyRunner in this example
will simply keep redefining gravity to the same value (0,0,1).

If you want to change gravity according to time, your gravity() function
simply needs to reflect that. It needs to incorporate O.time:

maxTime = some time when you want gravity to be -9.8

def gravity():
    correction = O.time/maxTime
    newtonInt.gravity = (0,0,-9.8*correction)

so in this case, PyRunner will execute gravity() every iteration, and
the gravity will change according to how far along you are in your
simulation.

[1]https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.PyRunner

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