Skip to content

Commit 24de76f

Browse files
committed
Removed the ray tracing track-length estimator part of Volume Calculation from PR #3645
1 parent 668d61a commit 24de76f

10 files changed

Lines changed: 85 additions & 381 deletions

File tree

docs/source/usersguide/volume.rst

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ Stochastic Volume Calculations
77
.. currentmodule:: openmc
88

99
OpenMC has a capability to stochastically determine volumes of cells, materials,
10-
and universes by two methods. The first method works by overlaying a bounding
11-
box, sampling points from within the box, and seeing what fraction of points were
12-
found in a desired domain. The benefit of doing this stochastically (as opposed
13-
to equally-spaced points), is that it is possible to give reliable error estimates
14-
on each stochastic quantity. The second method uses ray tracing in random
15-
directions from sampled via the first method points, and seeing what fraction of
16-
rays inside the box were found in a desired domain. This method is predominantly
17-
intended for low-fraction volume calculations and geometry testing. By default,
18-
volume calculations are provided using the first method.
10+
and universes. The method works by overlaying a bounding box, sampling points
11+
from within the box, and seeing what fraction of points were found in a desired
12+
domain. The benefit of doing this stochastically (as opposed to equally-spaced
13+
points), is that it is possible to give reliable error estimates on each
14+
stochastic quantity.
1915

2016
To specify that a volume calculation be run, you first need to create an
2117
instance of :class:`openmc.VolumeCalculation`. The constructor takes a list of
@@ -26,16 +22,10 @@ the specified domains::
2622
lower_left = (-0.62, -0.62, -50.)
2723
upper_right = (0.62, 0.62, 50.)
2824
vol_calc = openmc.VolumeCalculation([fuel, clad, moderator], 1000000,
29-
lower_left, upper_right)
30-
31-
To specify the same volume calculation but using ray tracing, you need to pass
32-
an argument::
33-
34-
vol_calc = openmc.VolumeCalculation([fuel, clad, moderator], 1000000,
35-
lower_left, upper_right, 'ray')
25+
lower_left, upper_right)
3626

3727
For domains contained within regions that have simple definitions, OpenMC can
38-
sometimes automatically determine a bounding box. In this case, the bounding box
28+
sometimes automatically determine a bounding box. In this case, the last two
3929
arguments are not necessary. For example,
4030

4131
::

include/openmc/position.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ struct Position {
8383
return x * other.x + y * other.y + z * other.z;
8484
}
8585
inline double norm() const { return std::sqrt(x * x + y * y + z * z); }
86-
inline double norm_sq() const { return x * x + y * y + z * z; }
8786
inline Position cross(Position other) const
8887
{
8988
return {y * other.z - z * other.y, z * other.x - x * other.z,

include/openmc/volume_calc.h

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "openmc/array.h"
1010
#include "openmc/cell.h"
1111
#include "openmc/openmp_interface.h"
12-
#include "openmc/plot.h"
1312
#include "openmc/position.h"
1413
#include "openmc/tallies/trigger.h"
1514
#include "openmc/timer.h"
@@ -78,9 +77,6 @@ class VolumeCalculation {
7877
//! \brief Online results of calculation specific for each thread
7978
struct CalcResults {
8079
uint64_t n_samples; //!< Number of samples
81-
uint64_t n_rays; //!< Number of traced rays
82-
uint64_t n_segs; //!< Number of traced ray segments
83-
uint64_t n_errors; //!< Number of tracing errors
8480
int iterations; //!< Number of iterations needed to obtain the results
8581
double cost; //!< Product of spent time and number of threads/processes
8682
Timer sampling_time; // Timer for measurment of the simulation
@@ -116,6 +112,9 @@ class VolumeCalculation {
116112
//! \return Vector of results for each user-specified domain
117113
void execute(CalcResults& results) const;
118114

115+
//! \brief Rejection estimator
116+
inline void score_hit(const Particle& p, CalcResults& results) const;
117+
119118
//! \brief Check whether a material has already been hit for a given domain.
120119
//! If not, add new entries to the vectors
121120
//
@@ -166,8 +165,6 @@ class VolumeCalculation {
166165

167166
// Tally filter and map types
168167
enum class TallyDomain { UNIVERSE, MATERIAL, CELL };
169-
// Volume estimator type
170-
enum class EstMode { REJECTION, RAYTRACE };
171168

172169
// Data members
173170
TallyDomain domain_type_; //!< Type of domain (cell, material, etc.)
@@ -182,7 +179,6 @@ class VolumeCalculation {
182179
Position lower_left_; //!< Lower-left position of bounding box
183180
Position upper_right_; //!< Upper-right position of bounding box
184181
vector<int> domain_ids_; //!< IDs of domains to find volumes of
185-
EstMode mode_; //!< Volume estimator type
186182

187183
#ifdef OPENMC_MPI
188184
//! \brief Creates MPI structs for passing data between threads
@@ -197,14 +193,6 @@ class VolumeCalculation {
197193
-999; //!< Index of zero-element tally for entire domain totals should be
198194
//!< out of material ID range
199195

200-
//! \brief Computes lengths of the two segments of a bounding box chord
201-
//
202-
//! \param[in] r Location inside bounding sphere splits the chord
203-
//! \param[in] u Direction of chord to compute (normalized)
204-
//! \return Array of backward (first) and forward (second) chord segments
205-
std::pair<double, double> get_box_chord(
206-
const Position& r, const Direction& u) const;
207-
208196
//! \brief Computes estimated mean and std.dev. for a tally
209197
//
210198
//! \param[in] n_samples Statistic's size
@@ -215,63 +203,6 @@ class VolumeCalculation {
215203
const double coeff_norm, const VolTally& vol_tally) const;
216204
};
217205

218-
//==============================================================================
219-
// Volume estimator ray class
220-
//==============================================================================
221-
222-
class VolEstRay : public Ray {
223-
friend class VolumeCalculation; // for access to the CalcResults struct and
224-
// EstMode variable, not sure that this is
225-
// a good practice in C++
226-
227-
public:
228-
//! \brief Constructs a ray of given length emitted from a given point for the
229-
//! volume track length estimator into given tallies
230-
//
231-
//! \param[in] r Coordinates of the ray origin
232-
//! \param[in] u Direction of the ray
233-
//! \param[in] dist Target length of the ray
234-
//! \param[in] coeff_mult Coefficient for scores multiplcation, it should
235-
//! contain the reciprocal chord lenght and may contain stat. weight, etc.
236-
//! \param[in] vol_calc Volume calculation parameters
237-
//! \param[in,out] results Tallies for scoring during tracing etc.
238-
VolEstRay(Position& r, Direction& u, const double dist,
239-
const double coeff_mult, const VolumeCalculation& vol_calc,
240-
VolumeCalculation::CalcResults& results)
241-
: Ray(r, u), traversal_distance_max_(dist), coeff_mult_(coeff_mult),
242-
vol_calc_(vol_calc), results_(results)
243-
{}
244-
245-
//! \brief Track length estimator on intersection events
246-
virtual void on_intersection() override;
247-
248-
private:
249-
const double traversal_distance_max_; //!< Target ray length
250-
double traversal_distance_last_ =
251-
0.; //!< One segment beyond traversal_distance
252-
const double coeff_mult_; //!< Coefficient for scoring multiplcation
253-
const VolumeCalculation& vol_calc_; //!< Parameters of volume calculation
254-
VolumeCalculation::CalcResults&
255-
results_; //!< Tallies for scoring and other statistics collector
256-
257-
//! \brief Rejection estimator
258-
inline void score_hit();
259-
260-
//! \brief Contributes to volume tallies
261-
//
262-
//! \param[in] mode Type of used estimator
263-
//! \param[in] score Contribution value
264-
//! \param[in] id_mat Material ID required due to the material() and
265-
//! material_lst() disagreement (see the on_intersection() body for details)
266-
inline void vol_scoring(const VolumeCalculation::EstMode mode,
267-
const double score, const int id_mat);
268-
269-
//! \brief Returns a pointer to either current point location cell or last ray
270-
//! segment cell
271-
inline std::unique_ptr<Cell>& current_cell(
272-
VolumeCalculation::EstMode mode, int level);
273-
};
274-
275206
//==============================================================================
276207
// Global variables
277208
//==============================================================================

openmc/volume.py

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ class VolumeCalculation:
3232
Upper-right coordinates of bounding box used to sample points. If this
3333
argument is not supplied, an attempt is made to automatically determine
3434
a bounding box.
35-
estimator_type : {'hit', 'ray'}
36-
Type of volume estimator (default: 'hit').
37-
38-
.. versionadded:: 0.15.x
3935
4036
Attributes
4137
----------
@@ -77,8 +73,7 @@ class VolumeCalculation:
7773
.. versionadded:: 0.15.x
7874
7975
"""
80-
def __init__(self, domains, samples, lower_left=None, upper_right=None,
81-
estimator_type='hit'):
76+
def __init__(self, domains, samples, lower_left=None, upper_right=None):
8277
self._atoms = {}
8378
self._volumes = {}
8479
self._threshold = None
@@ -136,8 +131,6 @@ def __init__(self, domains, samples, lower_left=None, upper_right=None,
136131
raise ValueError('Lower-left and upper-right bounding box '
137132
'coordinates must be finite.')
138133

139-
self.estimator_type = estimator_type
140-
141134
@property
142135
def ids(self):
143136
return self._ids
@@ -223,16 +216,6 @@ def iterations(self, iterations):
223216
cv.check_greater_than(name, iterations, 0)
224217
self._iterations = iterations
225218

226-
@property
227-
def estimator_type(self):
228-
return self._estimator_type
229-
230-
@estimator_type.setter
231-
def estimator_type(self, estimator_type):
232-
cv.check_value('volume estimator mode', estimator_type,
233-
('hit', 'ray'))
234-
self._estimator_type = estimator_type
235-
236219
@property
237220
def domain_type(self):
238221
return self._domain_type
@@ -283,18 +266,6 @@ def set_trigger(self, threshold, trigger_type, max_iterations=None):
283266
self.threshold = threshold
284267
self.max_iterations = max_iterations
285268

286-
def set_estimator(self, estimator_type):
287-
"""Define type of volume estimator
288-
289-
.. versionadded:: 0.15
290-
291-
Parameters
292-
----------
293-
estimator_type : {'hit', 'ray'}
294-
Either rejection or ray tracing volume estimator
295-
"""
296-
self.estimator_type = estimator_type
297-
298269
@classmethod
299270
def from_hdf5(cls, filename):
300271
"""Load stochastic volume calculation results from HDF5 file.
@@ -323,8 +294,6 @@ def from_hdf5(cls, filename):
323294
max_iterations = f.attrs.get('max_iterations')
324295
iterations = f.attrs.get('iterations', 1)
325296

326-
estimator_type = f.attrs.get('estimator_type')
327-
328297
volumes = {}
329298
atoms = {}
330299
ids = []
@@ -354,8 +323,7 @@ def from_hdf5(cls, filename):
354323
domains = [openmc.Universe(uid) for uid in ids]
355324

356325
# Instantiate the class and assign results
357-
vol = cls(domains, samples, lower_left, upper_right,
358-
estimator_type.decode())
326+
vol = cls(domains, samples, lower_left, upper_right)
359327

360328
if trigger_type is not None:
361329
vol.set_trigger(threshold, trigger_type.decode(), max_iterations)
@@ -411,8 +379,6 @@ def to_xml_element(self):
411379
trigger_elem.set("threshold", str(self.threshold))
412380
if self.max_iterations is not None:
413381
trigger_elem.set("max_iterations", str(self.max_iterations))
414-
et_elem = ET.SubElement(element, "estimator_type")
415-
et_elem.text = str(self.estimator_type)
416382
return element
417383

418384
@classmethod
@@ -437,7 +403,6 @@ def from_xml_element(cls, elem):
437403
samples = int(get_text(elem, "samples"))
438404
lower_left = tuple(get_elem_list(elem, "lower_left", float))
439405
upper_right = tuple(get_elem_list(elem, "upper_right", float))
440-
estimator_type = get_text(elem, "estimator_type")
441406

442407
# Instantiate some throw-away domains that are used by the constructor
443408
# to assign IDs
@@ -450,7 +415,7 @@ def from_xml_element(cls, elem):
450415
elif domain_type == 'universe':
451416
domains = [openmc.Universe(uid) for uid in ids]
452417

453-
vol = cls(domains, samples, lower_left, upper_right, estimator_type)
418+
vol = cls(domains, samples, lower_left, upper_right)
454419

455420
# Check for trigger
456421
trigger_elem = elem.find("threshold")

src/plot.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,10 +1695,6 @@ void Ray::trace()
16951695
coord(lev).r() += boundary().distance() * coord(lev).u();
16961696
}
16971697
surface() = boundary().surface();
1698-
// Initialize last cells from current cell
1699-
for (int j = 0; j < n_coord(); ++j) {
1700-
cell_last(j) = coord(j).cell();
1701-
}
17021698
n_coord_last() = n_coord();
17031699
n_coord() = boundary().coord_level();
17041700
if (boundary().lattice_translation()[0] != 0 ||

0 commit comments

Comments
 (0)