is it possible to manually modify interaction forces using PyRunner?

Asked by Zixuan Xu

Hi, all

I modeled a spring-mass system in yade, using the remote interaction function of JCFpmMat. But i want to change the value of the interaction forces during the simulation. So I put PyRunner before NewtonIntegrator in O.engines, in order to change the interaction forces before it was used for calculation. But it seems it doesn't work out as I expected. parts of my script are as follows.

##################################################
def changeForce():
    for i in O.interactions:
        i.phys.normalForce=someValue # for example, someValue=(0,0,0)

O.engines=[
    ...
    PyRunner(command='changeForce()',iterPeriod=1),
    NewtonIntegrator(gravity=[0,0,0],damping=0.2)
]
##################################################

Thanks,

Zixuan Xu

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jérôme Duriez
Solved:
Last query:
Last reply:
Revision history for this message
Best Jérôme Duriez (jduriez) said :
#1

Hello,

The problem is that NewtonIntegrator moves bodies according to sum of forces/torques, wich is another variable than the (sum of) contact forces.

In correctly written contact laws (all in Yade !) these two kind of variables are consistently dealt at the same time. But, if you want to do the job yourself, you'll have to take care of both tasks. So, you have also (*) to modify O.forces.f/t(idOfTheBody). See https://www.yade-dem.org/doc/yade.wrapper.html#forcecontainer

Jérôme

(*) In fact, for such tricks, modifying the interaction force is no more necessary. It is enough to modify O.forces.f

Revision history for this message
Zixuan Xu (xuzixuanatsjtu) said :
#2

Hello, Jérôme

Thanks for your reply ! Then all I need to do is to modify O.forces.f(id) instead of O.interactions[id1,id2].normalForce.

I had a look at the source code and found out how exactly it works.

Zixuan xu

Revision history for this message
Zixuan Xu (xuzixuanatsjtu) said :
#3

Thanks Jérôme Duriez, that solved my question.