mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
pass reaction rates instead of op_results to depletion integrator
This commit is contained in:
parent
5e0405ab74
commit
9c8eddddd7
3 changed files with 10 additions and 17 deletions
|
|
@ -95,10 +95,10 @@ def cecm(operator, timesteps, power=None, power_density=None, print_out=True):
|
|||
# Scale reaction rates by ratio of powers
|
||||
power_res = operator.prev_res[-1].power
|
||||
ratio_power = p / power_res
|
||||
op_results[0].rates[0] *= ratio_power[0]
|
||||
op_results[0].rates *= ratio_power[0]
|
||||
|
||||
# Deplete for first half of timestep
|
||||
x_middle = deplete(chain, x[0], op_results[0], dt/2, print_out)
|
||||
x_middle = deplete(chain, x[0], op_results[0].rates, dt/2, print_out)
|
||||
|
||||
# Get middle-of-timestep reaction rates
|
||||
x.append(x_middle)
|
||||
|
|
@ -106,7 +106,7 @@ def cecm(operator, timesteps, power=None, power_density=None, print_out=True):
|
|||
|
||||
# Deplete for full timestep using beginning-of-step materials
|
||||
# and middle-of-timestep reaction rates
|
||||
x_end = deplete(chain, x[0], op_results[1], dt, print_out)
|
||||
x_end = deplete(chain, x[0], op_results[1].rates, dt, print_out)
|
||||
|
||||
# Create results, write to disk
|
||||
Results.save(operator, x, op_results, [t, t + dt], p, i_res + i)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import scipy.sparse.linalg as sla
|
|||
from .. import comm
|
||||
|
||||
|
||||
def deplete(chain, x, op_result, dt, print_out):
|
||||
def deplete(chain, x, rates, dt, print_out):
|
||||
"""Deplete materials using given reaction rates for a specified time
|
||||
|
||||
Parameters
|
||||
|
|
@ -23,8 +23,8 @@ def deplete(chain, x, op_result, dt, print_out):
|
|||
Depletion chain
|
||||
x : list of numpy.ndarray
|
||||
Atom number vectors for each material
|
||||
op_result : openmc.deplete.OperatorResult
|
||||
Result of applying transport operator (contains reaction rates)
|
||||
rates : openmc.deplete.ReactionRates
|
||||
Reaction rates (from transport operator)
|
||||
dt : float
|
||||
Time in [s] to deplete for
|
||||
print_out : bool
|
||||
|
|
@ -38,16 +38,9 @@ def deplete(chain, x, op_result, dt, print_out):
|
|||
"""
|
||||
t_start = time.time()
|
||||
|
||||
# Set up iterators
|
||||
n_mats = len(x)
|
||||
chains = repeat(chain, n_mats)
|
||||
vecs = (x[i] for i in range(n_mats))
|
||||
rates = (op_result.rates[i, :, :] for i in range(n_mats))
|
||||
dts = repeat(dt, n_mats)
|
||||
|
||||
# Use multiprocessing pool to distribute work
|
||||
with Pool() as pool:
|
||||
iters = zip(chains, vecs, rates, dts)
|
||||
iters = zip(repeat(chain), x, rates, repeat(dt))
|
||||
x_result = list(pool.starmap(_cram_wrapper, iters))
|
||||
|
||||
t_end = time.time()
|
||||
|
|
@ -63,7 +56,7 @@ def _cram_wrapper(chain, n0, rates, dt):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
chain : DepletionChain
|
||||
chain : openmc.deplete.Chain
|
||||
Depletion chain used to construct the burnup matrix
|
||||
n0 : numpy.array
|
||||
Vector to operate a matrix exponent on.
|
||||
|
|
|
|||
|
|
@ -90,10 +90,10 @@ def predictor(operator, timesteps, power=None, power_density=None,
|
|||
# Scale reaction rates by ratio of powers
|
||||
power_res = operator.prev_res[-1].power
|
||||
ratio_power = p / power_res
|
||||
op_results[0].rates[0] *= ratio_power[0]
|
||||
op_results[0].rates *= ratio_power[0]
|
||||
|
||||
# Deplete for full timestep
|
||||
x_end = deplete(chain, x[0], op_results[0], dt, print_out)
|
||||
x_end = deplete(chain, x[0], op_results[0].rates, dt, print_out)
|
||||
|
||||
# Advance time, update vector
|
||||
t += dt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue