Specifying Runtime of Multiple Particle Releases #1151
adeleanderson
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi @adeleanderson. The easiest solution to stop a particle is to keep track of its 'age' and either delete it or stop it when it has reached a certain age. This can be done with a constant, particle class and kernel like the one below fieldset.add_constant('maxage', 365.*86400)
class AgingParticle(JITParticle):
age = Variable('age', dtype=np.float32, initial=0.)
def Age(particle, fieldset, time, dt):
particle.age = particle.age + math.fabs(dt)
if particle.age > fieldset.maxage:
particle.delete() |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm new-ish to Python and would be grateful for anyone's input on my question.
I have 18 years of velocity data. I wrote a program that releases particles from the same location every 5 days for all 18 years using this very helpful Delay Start Tutorial (I utilized the "repeatdt" method).
However, I really only need each release of particles to run for 1 year (although I would like particles to continue being released every 5 days for all 18 years). The tutorial clearly describes how to STOP delay start releases (using pset.repeatdt= None) and then continue running the existing particles for a specified duration, but I'm seeking how to terminate my delayed-start particles after a given time while still allowing new delayed releases for all 18 years, all of which should have a runtime of 1 year.
Thank you for any ideas or suggestions you might have!
Beta Was this translation helpful? Give feedback.
All reactions