# Is particle lifetime tracked?

**URL:** <https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407>\
**Category:** User Support\
**Created:** [September 2, 2021, 12:35pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407 "2021-09-02T12:35:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![slilley](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@slilley](https://openmc.discourse.group/u/slilley)\
**Post date:** [September 2, 2021, 12:35pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/1 "2021-09-02T12:35:45Z")

</div>

Hi,  
Looking at the code it appears that currently there is no time dependence and that particles don’t keep track of the time since the start of the history is this correct?  
Specifically thinking of fixed source problems.

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [September 3, 2021, 8:35pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/2 "2021-09-03T20:35:56Z")

</div>

Hi @slilley and welcome to the forum! You are correct that we don’t actually keep track of time currently. I know some people have added this in developmental branches but it has never made it back to the main branch of OpenMC. It would be a pretty easy addition though. Is this something of interest to you?

---

<div class="post-metadata">

**Author:** ![slilley](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@slilley](https://openmc.discourse.group/u/slilley)\
**Post date:** [September 8, 2021, 8:04am UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/3 "2021-09-08T08:04:07Z")

</div>

Hi,

Yes, Currently looking at options for simulating pulsed sources for areas such as pulsed neutron die away experiments using a DD or DT generator, and detector development  
If you can point me to the relevant branches i can look at, that would be very helpful

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [September 10, 2021, 7:04pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/4 "2021-09-10T19:04:14Z")

</div>

Hi @slilley. I put together an [initial cut at an implementation](https://github.com/paulromano/openmc/tree/time-filter) for a time filter (along with tracking time for particles). I’ve only done some very light testing to make sure it passes a few sanity checks, but nothing very rigorous. If you want to try it out and let me know things go, that would be much appreciated.

To use the time filter, there is a new `TimeFilter` class that fundamentally behaves like `EnergyFilter`. You give it a list of times and it creates bins for each pair of values in the list. The units are specified in seconds.

---

<div class="post-metadata">

**Author:** ![slilley](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@slilley](https://openmc.discourse.group/u/slilley)\
**Post date:** [September 11, 2021, 10:47am UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/5 "2021-09-11T10:47:54Z")

</div>

Many thanks @paulromano, I will give it a go on a few test cases. A quick look through the commit makes me wonder if time also needs to be passed to the create secondary particle function. I’m not certain but I think secondaries will be created at time 0.

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [September 13, 2021, 9:04pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/6 "2021-09-13T21:04:01Z")

</div>

@slilley Yes, you’re absolutely right. I’ve just added some changes to my `time-filter` branch that should propagate time to secondary particles.

---

<div class="post-metadata">

**Author:** ![arief.rahman](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@arief.rahman](https://openmc.discourse.group/u/arief.rahman)\
**Post date:** [September 14, 2021, 5:39am UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/7 "2021-09-14T05:39:21Z")

</div>

Hi @paulromano , I did a quick test on my project with this time-filter branch.  
I am not sure whether I did any mistakes or not, but it seems that the problem still exist. The clock for secondary, tertiary, etc particles are still being restarted.

Could you please take a look on my notebook? I’ve sent my notebook to your pm.

edit2: add tag

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [September 14, 2021, 11:48am UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/8 "2021-09-14T11:48:15Z")

</div>

@arief.rahman Thanks for the test case. Your suspicion was correct – fission neutrons did have their clock reset. I’ve now fixed that on my `time-filter` branch, so in your test case you should see no scores below 0.0001 s as expected.

---

<div class="post-metadata">

**Author:** ![slilley](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@slilley](https://openmc.discourse.group/u/slilley)\
**Post date:** [December 16, 2021, 8:19pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/9 "2021-12-16T20:19:14Z")

</div>

@paulromano thank you for the time filter branch & apologies it has taken a while to look at this in more detail with @bakingbad,  
In a simple vacuum only model with scoring current with a surface filter and time filter a set distance from a monoenergetic monodirectional source the result is clearly not correct with non-zero results in all time bins. A check using an energy filter correctly shows all the particles with the same energy. If however we split the model to have a second thin cell at the edge just before the surface tally then the time filter result looks a lot closer to what it should be.  
My thoughts are:

- As looking in the code I think the values are averaged over each time bin since the last update value/(n\_bins in range t -t\_last) which might be right for flux in cell tally (although i’m not certain that is right) it is not right for a surface tally. I think for surface tallies it should just be the particle time as it crosses the surface (assuming the surface crossing event is processed and the particle time updated before the tally is scored)

@bakingbad can supply a couple of test inputs demonstrating the issue if needed

.thanks so much for all your help

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [December 17, 2021, 3:02pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/10 "2021-12-17T15:02:14Z")

</div>

@slilley Many thanks to you and @bakingbad for testing this out and providing feedback! You’re absolutely right – as written, it is designed for a volumetric tally but not for a surface tally. I’ll have to think about how to handle these two situations and will post an update here if/when I have something new ready to test that accounts for surface tallies.

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [December 23, 2021, 6:24pm UTC](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/11 "2021-12-23T18:24:37Z")

</div>

I just opened a pull request for this feature (surface current issue has been fixed):

> <https://github.com/openmc-dev/openmc/pull/1934>
>
> Up to now, particles being transported in OpenMC know nothing about time. This i…s mostly due to the origin of the code being focused on static k-eigenvalue problems, where time is not really a factor. However, with the increasing usage of the code in other areas, it would be beneficial to have an ability to track the particle's time and filter tallies based on the observed time. This PR extends the \`Particle\` and \`SourceSite\` data structures to keep track of time and adds a new \`TimeFilter\` that allows both volume and surface tallies to filter events based on the particle's clock. The calculation of the particle's velocity is done using relativistic equations so time dilation effects are accounted for.
> 
> @cfichtlscherer @ojschumann Let me know what you guys think about the changes here and if they're in line with what you've done previously in your own work.
> 
> @py1sl The issue \[you mentioned\](https://openmc.discourse.group/t/is-particle-lifetime-tracked/1407/9?u=paulromano) with surface tallies should be fixed now. One of the unit tests covers this case (tallying current on a purely absorbing surface a given distance from a monoenergetic, monodirectional point source).
