openmc-dev / openmc

OpenMC Monte Carlo Code
https://docs.openmc.org
Other
699 stars 444 forks source link

Allow int-like floats for particles #2937

Open MicahGale opened 4 weeks ago

MicahGale commented 4 weeks ago

Description

model.settings.particles is quite often set to be large numbers that >=1e6. This makes it very annoying and error prone to specify as ints, since python treats all scientific notation as a float.

I propose that:

model.settings.particles = 1e6 be allowed but model.seetings.particles = 1.23e1 not be allowed as it not close to an integer value.

Alternatives

Teach users to use 10_000_000 notation. This isn't ideal as it relies on users being aware of certain features and not making mistakes.

Compatibility

This should have little impact on the user facing API, but will impact the test suite.

gridley commented 2 weeks ago

Why not just have people use int(1e6)?

MicahGale commented 2 weeks ago

That is a viable alternative too but is very annoying IMO and I don't think an apparent solution to the average novice.