← Back to team overview

yade-users team mailing list archive

Re: [Question #189288]: Apply forces from previous simulation

 

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

Jan Stránský posted a new comment:
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

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.