mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Support minutes and hours for depletion timesteps rather than years
This commit is contained in:
parent
8771987bf4
commit
85264aa38c
3 changed files with 64 additions and 55 deletions
|
|
@ -31,8 +31,9 @@ __all__ = [
|
|||
"Integrator", "SIIntegrator", "DepSystemSolver"]
|
||||
|
||||
|
||||
_SECONDS_PER_MINUTE = 60
|
||||
_SECONDS_PER_HOUR = 60*60
|
||||
_SECONDS_PER_DAY = 24*60*60
|
||||
_SECONDS_PER_YEAR = 365.25*24*60*60
|
||||
|
||||
OperatorResult = namedtuple('OperatorResult', ['k', 'rates'])
|
||||
OperatorResult.__doc__ = """\
|
||||
|
|
@ -617,11 +618,11 @@ class Integrator(ABC):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -678,19 +679,21 @@ class Integrator(ABC):
|
|||
# Determine number of seconds for each timestep
|
||||
seconds = []
|
||||
for time, unit, watts in zip(times, units, power):
|
||||
if unit == 's':
|
||||
if unit in ('s', 'sec'):
|
||||
seconds.append(time)
|
||||
elif unit in ('min', 'minute'):
|
||||
seconds.append(time*_SECONDS_PER_MINUTE)
|
||||
elif unit in ('h', 'hr', 'hour'):
|
||||
seconds.append(time*_SECONDS_PER_HOUR)
|
||||
elif unit in ('d', 'day'):
|
||||
seconds.append(time*_SECONDS_PER_DAY)
|
||||
elif unit in ('a', 'yr', 'year'):
|
||||
seconds.append(time*_SECONDS_PER_YEAR)
|
||||
elif unit.lower() == 'mwd/kg':
|
||||
watt_days_per_kg = 1e6*time
|
||||
kilograms = 1e-3*mass
|
||||
days = watt_days_per_kg * kilograms / watts
|
||||
seconds.append(days*_SECONDS_PER_DAY)
|
||||
else:
|
||||
raise ValueError("Invalid timestep unit: {}".format(unit))
|
||||
raise ValueError("Invalid timestep unit '{}'".format(unit))
|
||||
|
||||
self.timesteps = asarray(seconds)
|
||||
self.power = asarray(power)
|
||||
|
|
@ -824,11 +827,11 @@ class SIIntegrator(Integrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
n_steps : int, optional
|
||||
Number of stochastic iterations per depletion interval.
|
||||
Must be greater than zero. Default : 10
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ class PredictorIntegrator(Integrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -137,11 +137,11 @@ class CECMIntegrator(Integrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -234,11 +234,11 @@ class CF4Integrator(Integrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -348,11 +348,11 @@ class CELIIntegrator(Integrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -449,11 +449,11 @@ class EPCRK4Integrator(Integrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -570,11 +570,11 @@ class LEQIIntegrator(Integrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -688,11 +688,11 @@ class SICELIIntegrator(SIIntegrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
n_steps : int, optional
|
||||
Number of stochastic iterations per depletion interval.
|
||||
Must be greater than zero. Default : 10
|
||||
|
|
@ -796,11 +796,11 @@ class SILEQIIntegrator(SIIntegrator):
|
|||
Power density of the reactor in [W/gHM]. It is multiplied by
|
||||
initial heavy metal inventory to get total power if ``power``
|
||||
is not speficied.
|
||||
timestep_units : {'s', 'd', 'a', 'MWd/kg'}
|
||||
timestep_units : {'s', 'min', 'h', 'd', 'MWd/kg'}
|
||||
Units for values specified in the `timesteps` argument. 's' means
|
||||
seconds, 'd' means days, 'a' means years, and 'MWd/kg' indicates that
|
||||
the values are given in burnup (MW-d of energy deposited per kilogram
|
||||
of heavy metal).
|
||||
seconds, 'min' means minutes, 'h' means hours, and 'MWd/kg' indicates
|
||||
that the values are given in burnup (MW-d of energy deposited per
|
||||
kilogram of heavy metal).
|
||||
n_steps : int, optional
|
||||
Number of stochastic iterations per depletion interval.
|
||||
Must be greater than zero. Default : 10
|
||||
|
|
|
|||
|
|
@ -190,23 +190,29 @@ def test_timesteps(integrator):
|
|||
day = 86400.0
|
||||
ref_timesteps = [1*day, 2*day, 5*day, 10*day]
|
||||
|
||||
# Case 1, timesteps in second
|
||||
# Case 1, timesteps in seconds
|
||||
timesteps = ref_timesteps
|
||||
x = integrator(op, timesteps, power, timestep_units='s')
|
||||
assert np.allclose(x.timesteps, ref_timesteps)
|
||||
|
||||
# Case 2, timesteps in days
|
||||
# Case 2, timesteps in minutes
|
||||
minute = 60
|
||||
timesteps = [t / minute for t in ref_timesteps]
|
||||
x = integrator(op, timesteps, power, timestep_units='min')
|
||||
assert np.allclose(x.timesteps, ref_timesteps)
|
||||
|
||||
# Case 3, timesteps in hours
|
||||
hour = 60*60
|
||||
timesteps = [t / hour for t in ref_timesteps]
|
||||
x = integrator(op, timesteps, power, timestep_units='h')
|
||||
assert np.allclose(x.timesteps, ref_timesteps)
|
||||
|
||||
# Case 4, timesteps in days
|
||||
timesteps = [t / day for t in ref_timesteps]
|
||||
x = integrator(op, timesteps, power, timestep_units='d')
|
||||
assert np.allclose(x.timesteps, ref_timesteps)
|
||||
|
||||
# Case 3, timesteps in years
|
||||
year = 365.25*day
|
||||
timesteps = [t / year for t in ref_timesteps]
|
||||
x = integrator(op, timesteps, power, timestep_units='a')
|
||||
assert np.allclose(x.timesteps, ref_timesteps)
|
||||
|
||||
# Case 4, timesteps in MWd/kg
|
||||
# Case 5, timesteps in MWd/kg
|
||||
kilograms = op.heavy_metal / 1000.0
|
||||
days = [t/day for t in ref_timesteps]
|
||||
megawatts = power / 1000000.0
|
||||
|
|
@ -214,7 +220,7 @@ def test_timesteps(integrator):
|
|||
x = integrator(op, burnup, power, timestep_units='MWd/kg')
|
||||
assert np.allclose(x.timesteps, ref_timesteps)
|
||||
|
||||
# Case 5, mixed units
|
||||
# Case 6, mixed units
|
||||
burnup_per_day = (1e-6*power) / kilograms
|
||||
timesteps = [(burnup_per_day, 'MWd/kg'), (2*day, 's'), (5, 'd'),
|
||||
(10*burnup_per_day, 'MWd/kg')]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue