mit-crpg / opendeplete

A depletion framework for OpenMC
MIT License
15 stars 5 forks source link

Units on OpenMCSettings.power #40

Open paulromano opened 6 years ago

paulromano commented 6 years ago

The docstring of the OpenMCSettings class currently says that power should be given in MeV/sec-cm. The same units are mentioned in scripts/example_run.py as well. I'm really not understanding where the cm comes from there. Taking a look at Operator.unpack_tallies_and_normalize, it looks like the energy per source particle is calculated in the local variable power:

sum(reaction rates [rx / source particle] Q [eV/rx] 1e-6 [MeV/eV]) = [MeV/source particle]

Then the reaction rates are multipled by settings.power/power and divided by the number density which would give:

reaction rate [rx/source particle] * settings.power [MeV/sec-cm] / power [MeV/source particle] / number [atoms] = [rx/sec-cm]

Based on this, it seems that the units on OpenMCSettings.power are really MeV/sec (which seems more intuitive to me) rather than MeV/sec-cm. Am I missing something here?

Along the same lines, I would propose that we change settings.power to simply use Watts rather than whatever it currently is. Every MC depletion code I've seen uses W or MW, so I think it would be best to be consistent.

cjosey commented 6 years ago

The units in the example problem are correct under the assumption that the volumes are in cm^2 (as it is in 2D). In this case, number is actually number/cm and the units work out. The documentation in operator is wrong, having been kept in from when I was only testing this on 2D problems.

A while back, I considered adding basic unit support for user-inputable values (say, power = unit(2, "W")) and converting to MKS internally for speed. The __init__ function would do unit analysis to verify that the problem is consistent and output / store the end result units.

Of course, this is a bulky solution that could be supplanted by requiring MKS input and asking the user to make sure the units make sense.