mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Adressing PR comments from @gridley.
This commit is contained in:
parent
2b5224e006
commit
62ad52d969
3 changed files with 10 additions and 10 deletions
|
|
@ -360,7 +360,7 @@ enum class GeometryType { CSG, DAG };
|
|||
|
||||
//==============================================================================
|
||||
// Variance Reduction constants
|
||||
constexpr double WEIGHT_CUTOFF {1.0e-38}; // default low weight cutoff
|
||||
constexpr double DEFAULT_WEIGHT_CUTOFF {1.0e-38}; // default low weight cutoff
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ extern vector<unique_ptr<WeightWindows>> weight_windows;
|
|||
//==============================================================================
|
||||
|
||||
struct WeightWindow {
|
||||
double lower_weight {-1}; // -1 indicates not valid state
|
||||
double lower_weight {-1}; // -1 indicates invalid state
|
||||
double upper_weight {1};
|
||||
double survival_weight {0.5};
|
||||
double weight_cutoff {WEIGHT_CUTOFF};
|
||||
double weight_cutoff {DEFAULT_WEIGHT_CUTOFF};
|
||||
int max_split {1};
|
||||
|
||||
//! Whether the weight window is in a valid state
|
||||
operator bool() const { return lower_weight >= 0.0; }
|
||||
bool is_valid() const { return lower_weight >= 0.0; }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -74,7 +74,7 @@ public:
|
|||
//! \param[in] group HDF5 group to write to
|
||||
void to_hdf5(hid_t group) const;
|
||||
|
||||
//! Return a weight window at the specified index
|
||||
//! Retrieve the weight window for a particle
|
||||
//! \param[in] p Particle to get weight window for
|
||||
WeightWindow get_weight_window(const Particle& p) const;
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ private:
|
|||
vector<double> lower_ww_; //!< Lower weight window bounds
|
||||
vector<double> upper_ww_; //!< Upper weight window bounds
|
||||
double survival_ratio_ {3.0}; //!< Survival weight ratio
|
||||
double weight_cutoff_ {1.0e-38}; //!< Weight cutoff
|
||||
double weight_cutoff_ {DEFAULT_WEIGHT_CUTOFF}; //!< Weight cutoff
|
||||
int max_split_ {10}; //!< Maximum value for particle splitting
|
||||
int32_t mesh_idx_; //!< index in meshes vector
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ void apply_weight_windows(Particle& p)
|
|||
WeightWindow weight_window;
|
||||
for (const auto& ww : variance_reduction::weight_windows) {
|
||||
weight_window = ww->get_weight_window(p);
|
||||
if (weight_window)
|
||||
if (weight_window.is_valid())
|
||||
break;
|
||||
}
|
||||
// particle is not in any of the ww domains, do nothing
|
||||
if (!weight_window)
|
||||
if (!weight_window.is_valid())
|
||||
return;
|
||||
|
||||
// get the paramters
|
||||
|
|
@ -74,7 +74,7 @@ void apply_weight_windows(Particle& p)
|
|||
for (int l = 0; l < i_split - 1; l++) {
|
||||
p.create_secondary(weight / n_split, p.u(), p.E(), p.type());
|
||||
}
|
||||
// TODO: maybe weight should be weight - sum of child weight
|
||||
// remaining weight is applied to current particle
|
||||
p.wgt() = weight / n_split;
|
||||
|
||||
} else if (weight <= weight_window.lower_weight) {
|
||||
|
|
@ -104,7 +104,7 @@ void free_memory_weight_windows()
|
|||
WeightWindows::WeightWindows(pugi::xml_node node)
|
||||
{
|
||||
// Make sure required elements are present
|
||||
vector<std::string> required_elems {
|
||||
const vector<std::string> required_elems {
|
||||
"id", "particle_type", "energy_bins", "lower_ww_bounds", "upper_ww_bounds"};
|
||||
for (const auto& elem : required_elems) {
|
||||
if (!check_for_node(node, elem.c_str())) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue