openmc icon indicating copy to clipboard operation
openmc copied to clipboard

mismatch between max_tracks in python and c++

Open shimwell opened this issue 1 year ago • 4 comments

the settings.max_tracks defaults to None in the python layer

https://github.com/openmc-dev/openmc/blob/e27c3b4a5bb6ac97ffe1f01a06b96a6d65d83471/openmc/settings.py#L298

and the docs state all particles will be written if run in tracks mode

https://github.com/openmc-dev/openmc/blob/e27c3b4a5bb6ac97ffe1f01a06b96a6d65d83471/openmc/model/model.py#L519-L520

https://github.com/openmc-dev/openmc/blob/e27c3b4a5bb6ac97ffe1f01a06b96a6d65d83471/openmc/settings.py#L108-L109

However it defaults to 1000 in the C++ layer.

https://github.com/openmc-dev/openmc/blob/e27c3b4a5bb6ac97ffe1f01a06b96a6d65d83471/src/settings.cpp#L98

This could result in a user not realizing that max_tracks must be set to a larger number if more than 1000 particles are needed

Thanks very much to @zoranpesic for reporting this.

I am happy to put in a PR to clear this up if this issue gets a :+1:

I would recommend

  • we set the default Settings.max_tracks to 1000 on the python side to match the c++ side
  • we remove the word all from the doc string of model tracks to say Write tracks for particles. Defaults to False.

shimwell avatar Aug 11 '22 15:08 shimwell

Setting max_tracks to 1000 on the Python side will result in it always getting written to settings.xml, which is undesirable in my opinion. I think we should just update our documentation to reflect the default of 1000 on the C++ side.

paulromano avatar Aug 11 '22 18:08 paulromano

I had a go at replacing this doc string Write tracks for all particles. Defaults to False. but it is not very elegant

Enables the writing of particles tracks. The number of particle tracks written to tracks.h5 is limited by
whichever is smaller between the number of particles set by Settings.max_tracks and 1000. Defaults to False. 

shimwell avatar Aug 12 '22 09:08 shimwell

limited by whichever is smaller between the number of particles set by Settings.max_tracks and 1000

If max_tracks is set by the user, that value will always be used. The default of 1000 only applies if max_tracks hasn't been specified and a user enables particle track writing.

paulromano avatar Aug 12 '22 12:08 paulromano

Perhaps edging closer

Enables the writing of particles tracks. The number of particle tracks written to 
tracks.h5 is limited to 1000 unless Settings.max_tracks is set. Defaults to False. 

shimwell avatar Aug 12 '22 13:08 shimwell

@shimwell Since you're on a PR spree, do you want to submit a PR changing the description of the tracks argument in Model.run, openmc.run, etc.? :smile:

paulromano avatar Sep 09 '22 03:09 paulromano