Apply forces from previous simulation

Asked by Klaus Thoeni on 2012-03-01

Hi guys,

I have a model with several load steps. One load step consists in applying forces from the previous simulation. Well, I can save the forces with saveVars and load them into the current simulation. Now I have to apply these forces to a list of particles. The forces are not the same for all the particles and I want to keep them the same during the simulation. So basically, the let's call them external "constant" forces are always acting on the particles in addition to the forces which come from the simulation.

I was wondering if there is a efficient way to set such forces. I had a look at ForceEngine, but the problem is that this engine applies a constant force to a list of particles. In my case the forces are not the same for the list of particles. I think in order to get it right I would have to call ForceEngine or maybe O.forces.addF for each particle in each iteration. This isn't efficient at all.

What do you suggest?

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Klaus Thoeni
Solved:
2012-03-05
Last query:
2012-03-05
Last reply:
Klaus Thoeni (klaus.thoeni) said : #1

Ok, I have a solution but it might not be the most efficient one. I created a periodic engine, e.g. PyRunner, which executes O.forces.addF for each particle in each iteration. It works :-)

liucheng83 (lcheng83) said : #2

Really, I want to build an array like this
tt=[]
tt=[ForceEngine(ids=[i],force=(0,0,i),label="ttForce") for i in ids_sp]
and tt[0],tt[i] are the ForceEngine,
but I donnot know how to add it to the O.engine if ids_sp is a big number.
a loop method like "for i in ids_sp " cannot be insert to O.engine like this:

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=interactionRadius,label='aabb'),Bo1_Facet_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,label='Ig2ssGeom'),
  Ig2_Facet_Sphere_ScGeom(),],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 ## Apply tt Force to some particles
 ForceEngine(ids=[i],force=(0,0,i),label="dragForce"+str(i)) for i in ids_spSlurry # a message SyntaxError: invalid syntax is given
 NewtonIntegrator(damping=0.1,gravity=(0,0,-9.81)),
 PyRunner(command='checkInteraction()',iterPeriod=iterPeriod_checkInteraction,label='checker')
]

# a message SyntaxError: invalid syntax is given because of using for loop

PyRunner, which executes O.forces.addF for each particle in each iteration may be a method, but it is not the most efficient one, maybe the force keep as a constant for a time, and then anoter constant for a next time.

How to solve it, please give some advice, somebody, thank you!

Jan Stránský (honzik) said : #3

Hello,

> Really, I want to build an array like this
> tt=[]
> tt=[ForceEngine(ids=[i],force=(0,0,i),label="ttForce") for i in ids_sp]
> and tt[0],tt[i] are the ForceEngine,
> but I donnot know how to add it to the O.engine if ids_sp is a big number.
> a loop method like "for i in ids_sp " cannot be insert to O.engine like
> this:
>

you can achieve this by:

tt=[ForceEngine(ids=[i],force=(0,0,i),label="ttForce"+str(i)) for i in
ids_sp]
O.engines = [ ... ] + tt + [ ... ]

where [ ... ] stands for standard code you would write before / after your
ForceEngines

>
> # a message SyntaxError: invalid syntax is given because of using for
> loop
>

it is not because of using for loop, it is because of using it incorectly.

>
> PyRunner, which executes O.forces.addF for each particle in each
> iteration may be a method, but it is not the most efficient one, maybe
> the force keep as a constant for a time, and then anoter constant for a
> next time.
>

I am not sure what would be faster (you can test it :-), but I would say
that anyway it should not be significant in comparison to other engines (at
least with applying force to only some particles)

cheers
Jan

liucheng83 (lcheng83) said : #4

Hi, Jan Stránský (honzik)
Thank you very much! O.engines = [ ... ] + tt + [ ... ] is a good way to solve the problem!