mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Only call statepoint_write from C API if cmfd_run
This commit is contained in:
parent
c47f2d1c0a
commit
055842b5cb
6 changed files with 22 additions and 14 deletions
|
|
@ -27,6 +27,7 @@ extern bool assume_separate; //!< assume tallies are spatially separate
|
|||
extern bool check_overlaps; //!< check overlaps in geometry?
|
||||
extern bool confidence_intervals; //!< use confidence intervals for results?
|
||||
extern bool create_fission_neutrons; //!< create fission neutrons (fixed source)?
|
||||
extern "C" bool cmfd_run; //!< is a CMFD run?
|
||||
extern "C" bool dagmc; //!< indicator of DAGMC geometry
|
||||
extern "C" bool entropy_on; //!< calculate Shannon entropy?
|
||||
extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular?
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ _dll.openmc_get_seed.restype = c_int64
|
|||
class _Settings(object):
|
||||
# Attributes that are accessed through a descriptor
|
||||
batches = _DLLGlobal(c_int32, 'n_batches')
|
||||
cmfd_run = _DLLGlobal(c_bool, 'cmfd_run')
|
||||
entropy_on = _DLLGlobal(c_bool, 'entropy_on')
|
||||
generations_per_batch = _DLLGlobal(c_int32, 'gen_per_batch')
|
||||
inactive = _DLLGlobal(c_int32, 'n_inactive')
|
||||
|
|
|
|||
|
|
@ -753,6 +753,8 @@ class CMFDRun(object):
|
|||
# Initialize simulation
|
||||
openmc.capi.simulation_init()
|
||||
|
||||
openmc.capi.settings.cmfd_run = True
|
||||
|
||||
def next_batch(self):
|
||||
# TODO add function description
|
||||
# Initialize CMFD batch
|
||||
|
|
@ -790,7 +792,6 @@ class CMFDRun(object):
|
|||
|
||||
# Call C API statepoint_write to save source distribution with CMFD
|
||||
# feedback
|
||||
# TODO don't call statepoint_write in openmc if settings::cmfd_run
|
||||
openmc.capi.statepoint_write(filename=filename)
|
||||
|
||||
# Append CMFD data to statepoint file using h5py
|
||||
|
|
@ -1119,7 +1120,8 @@ class CMFDRun(object):
|
|||
self._cmfd_on = True
|
||||
|
||||
# Check to reset tallies
|
||||
if (self._n_resets > 0 and current_batch in self._reset) or self._reset_every:
|
||||
if ((self._n_resets > 0 and current_batch in self._reset)
|
||||
or self._reset_every):
|
||||
self._cmfd_tally_reset()
|
||||
|
||||
def _execute_cmfd(self):
|
||||
|
|
@ -1417,9 +1419,11 @@ class CMFDRun(object):
|
|||
with np.errstate(divide='ignore', invalid='ignore'):
|
||||
self._weightfactors = (np.divide(self._cmfd_src * norm,
|
||||
sourcecounts, where=div_condition,
|
||||
out=np.ones_like(self._cmfd_src), dtype=np.float32))
|
||||
out=np.ones_like(self._cmfd_src),
|
||||
dtype=np.float32))
|
||||
|
||||
if not self._feedback or openmc.capi.current_batch() < self._feedback_begin:
|
||||
if (not self._feedback
|
||||
or openmc.capi.current_batch() < self._feedback_begin):
|
||||
return
|
||||
|
||||
# Broadcast weight factors to all procs
|
||||
|
|
@ -1972,9 +1976,9 @@ class CMFDRun(object):
|
|||
self._scatt_rate = np.append(self._scatt_rate, reshape_scattrr,
|
||||
axis=5)
|
||||
|
||||
# Compute scattering xs as aggregate of banked scatt_rate over tally window
|
||||
# divided by flux. Flux dimensionality increased to account for extra
|
||||
# dimensionality of scattering xs
|
||||
# Compute scattering xs as aggregate of banked scatt_rate over tally
|
||||
# window divided by flux. Flux dimensionality increased to account for
|
||||
# extra dimensionality of scattering xs
|
||||
extended_flux = self._flux[:,:,:,:,np.newaxis]
|
||||
with np.errstate(divide='ignore', invalid='ignore'):
|
||||
self._scattxs = np.divide(np.sum(self._scatt_rate, axis=5),
|
||||
|
|
@ -1999,9 +2003,9 @@ class CMFDRun(object):
|
|||
self._nfiss_rate = np.append(self._nfiss_rate, reshape_nfissrr,
|
||||
axis=5)
|
||||
|
||||
# Compute nu-fission xs as aggregate of banked nfiss_rate over tally window
|
||||
# divided by flux. Flux dimensionality increased to account for extra
|
||||
# dimensionality of nu-fission xs
|
||||
# Compute nu-fission xs as aggregate of banked nfiss_rate over tally
|
||||
# window divided by flux. Flux dimensionality increased to account for
|
||||
# extra dimensionality of nu-fission xs
|
||||
with np.errstate(divide='ignore', invalid='ignore'):
|
||||
self._nfissxs = np.divide(np.sum(self._nfiss_rate, axis=5),
|
||||
extended_flux, where=extended_flux > 0,
|
||||
|
|
@ -2062,7 +2066,7 @@ class CMFDRun(object):
|
|||
# Reshape and extract only p1 data from tally results as there is
|
||||
# no need for p0 data
|
||||
reshape_p1scattrr = np.swapaxes(p1scattrr.reshape(target_tally_shape),
|
||||
0, 2)[:,:,:,1,:,:]
|
||||
0, 2)[:,:,:,1,:,:]
|
||||
|
||||
# p1-scatter rr is flipped in energy axis as tally results are given in
|
||||
# reverse order of energy group
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ namespace settings {
|
|||
// Default values for boolean flags
|
||||
bool assume_separate {false};
|
||||
bool check_overlaps {false};
|
||||
bool cmfd_run {false};
|
||||
bool confidence_intervals {false};
|
||||
bool create_fission_neutrons {true};
|
||||
bool dagmc {false};
|
||||
|
|
|
|||
|
|
@ -364,8 +364,10 @@ void finalize_batch()
|
|||
settings::statepoint_batch.insert(simulation::current_batch);
|
||||
}
|
||||
|
||||
// Write out state point if it's been specified for this batch
|
||||
if (contains(settings::statepoint_batch, simulation::current_batch)) {
|
||||
// Write out state point if it's been specified for this batch and is not
|
||||
// a CMFD run instance
|
||||
if (contains(settings::statepoint_batch, simulation::current_batch)
|
||||
&& !settings::cmfd_run) {
|
||||
if (contains(settings::sourcepoint_batch, simulation::current_batch)
|
||||
&& settings::source_write && !settings::source_separate) {
|
||||
bool b = true;
|
||||
|
|
|
|||
|
|
@ -312,7 +312,6 @@ openmc_load_cmfd_tallies(const int* tally_ids, const int* sp_tally_ids)
|
|||
|
||||
hid_t tallies_group = open_group(file_id, "tallies");
|
||||
|
||||
// TODO pass this in as argument?
|
||||
int n_tallies = 4;
|
||||
for (int i =0; i < n_tallies; i++) {
|
||||
std::string name = "tally " + std::to_string(sp_tally_ids[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue