• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 14840340664

05 May 2025 03:38PM UTC coverage: 85.195% (-0.009%) from 85.204%
14840340664

Pull #3392

github

web-flow
Merge 5bc1ec35f into 1e7d8324e
Pull Request #3392: Map Compton subshell data to atomic relaxation data

14 of 14 new or added lines in 2 files covered. (100.0%)

330 existing lines in 19 files now uncovered.

52194 of 61264 relevant lines covered (85.2%)

37398320.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/include/openmc/particle_data.h
1
#ifndef OPENMC_PARTICLE_DATA_H
2
#define OPENMC_PARTICLE_DATA_H
3

4
#include "openmc/array.h"
5
#include "openmc/constants.h"
6
#include "openmc/position.h"
7
#include "openmc/random_lcg.h"
8
#include "openmc/tallies/filter_match.h"
9
#include "openmc/vector.h"
10

11
#ifdef DAGMC
12
#include "DagMC.hpp"
13
#endif
14

15
namespace openmc {
16

17
//==============================================================================
18
// Constants
19
//==============================================================================
20

21
// Since cross section libraries come with different numbers of delayed groups
22
// (e.g. ENDF/B-VII.1 has 6 and JEFF 3.1.1 has 8 delayed groups) and we don't
23
// yet know what cross section library is being used when the tallies.xml file
24
// is read in, we want to have an upper bound on the size of the array we
25
// use to store the bins for delayed group tallies.
26
constexpr int MAX_DELAYED_GROUPS {8};
27

28
constexpr double CACHE_INVALID {-1.0};
29

30
//==========================================================================
31
// Aliases and type definitions
32

33
//! Particle types
34
enum class ParticleType { neutron, photon, electron, positron };
35

36
//! Saved ("banked") state of a particle
37
//! NOTE: This structure's MPI type is built in initialize_mpi() of
38
//! initialize.cpp. Any changes made to the struct here must also be
39
//! made when building the Bank MPI type in initialize_mpi().
40
//! NOTE: This structure is also used on the python side, and is defined
41
//! in lib/core.py. Changes made to the type here must also be made to the
42
//! python defintion.
43
struct SourceSite {
44
  Position r;
45
  Direction u;
46
  double E;
47
  double time {0.0};
48
  double wgt {1.0};
49
  int delayed_group {0};
50
  int surf_id {0};
51
  ParticleType particle;
52

53
  // Extra attributes that don't show up in source written to file
54
  int parent_nuclide {-1};
55
  int64_t parent_id;
56
  int64_t progeny_id;
57
};
58

59
//! State of a particle used for particle track files
60
struct TrackState {
61
  Position r;           //!< Position in [cm]
62
  Direction u;          //!< Direction
63
  double E;             //!< Energy in [eV]
64
  double time {0.0};    //!< Time in [s]
65
  double wgt {1.0};     //!< Weight
66
  int cell_id;          //!< Cell ID
67
  int cell_instance;    //!< Cell instance
68
  int material_id {-1}; //!< Material ID (default value indicates void)
69
};
70

71
//! Full history of a single particle's track states
72
struct TrackStateHistory {
73
  ParticleType particle;
74
  std::vector<TrackState> states;
75
};
76

77
//! Saved ("banked") state of a particle, for nu-fission tallying
78
struct NuBank {
79
  double E;          //!< particle energy
80
  double wgt;        //!< particle weight
81
  int delayed_group; //!< particle delayed group
82
};
83

84
class LocalCoord {
85
public:
86
  void rotate(const vector<double>& rotation);
87

88
  //! clear data from a single coordinate level
89
  void reset();
90

91
  Position r;  //!< particle position
92
  Direction u; //!< particle direction
93
  int cell {-1};
94
  int universe {-1};
95
  int lattice {-1};
96
  array<int, 3> lattice_i {{-1, -1, -1}};
97
  bool rotated {false}; //!< Is the level rotated?
98
};
99

100
//==============================================================================
101
//! Cached microscopic cross sections for a particular nuclide at the current
102
//! energy
103
//==============================================================================
104

105
struct NuclideMicroXS {
106
  // Microscopic cross sections in barns
107
  double total;      //!< total cross section
108
  double absorption; //!< absorption (disappearance)
109
  double fission;    //!< fission
110
  double nu_fission; //!< neutron production from fission
111

112
  double elastic;         //!< If sab_frac is not 1 or 0, then this value is
113
                          //!<   averaged over bound and non-bound nuclei
114
  double thermal;         //!< Bound thermal elastic & inelastic scattering
115
  double thermal_elastic; //!< Bound thermal elastic scattering
116
  double photon_prod;     //!< microscopic photon production xs
117

118
  // Cross sections for depletion reactions (note that these are not stored in
119
  // macroscopic cache)
120
  double reaction[DEPLETION_RX.size()];
121

122
  // Indicies and factors needed to compute cross sections from the data tables
123
  int index_grid;       //!< Index on nuclide energy grid
124
  int index_temp;       //!< Temperature index for nuclide
125
  double interp_factor; //!< Interpolation factor on nuc. energy grid
126
  int index_sab {-1};   //!< Index in sab_tables
127
  int index_temp_sab;   //!< Temperature index for sab_tables
128
  double sab_frac;      //!< Fraction of atoms affected by S(a,b)
129
  bool use_ptable;      //!< In URR range with probability tables?
130

131
  // Energy and temperature last used to evaluate these cross sections.  If
132
  // these values have changed, then the cross sections must be re-evaluated.
133
  double last_E {0.0};      //!< Last evaluated energy
134
  double last_sqrtkT {0.0}; //!< Last temperature in sqrt(Boltzmann constant
135
                            //!< * temperature (eV))
136
};
137

138
//==============================================================================
139
//! Cached microscopic photon cross sections for a particular element at the
140
//! current energy
141
//==============================================================================
142

143
struct ElementMicroXS {
144
  int index_grid;         //!< index on element energy grid
145
  double last_E {0.0};    //!< last evaluated energy in [eV]
146
  double interp_factor;   //!< interpolation factor on energy grid
147
  double total;           //!< microscopic total photon xs
148
  double coherent;        //!< microscopic coherent xs
149
  double incoherent;      //!< microscopic incoherent xs
150
  double photoelectric;   //!< microscopic photoelectric xs
151
  double pair_production; //!< microscopic pair production xs
152
};
153

154
//==============================================================================
155
// MacroXS contains cached macroscopic cross sections for the material a
156
// particle is traveling through
157
//==============================================================================
158

159
struct MacroXS {
160
  double total;       //!< macroscopic total xs
161
  double absorption;  //!< macroscopic absorption xs
162
  double fission;     //!< macroscopic fission xs
163
  double nu_fission;  //!< macroscopic production xs
164
  double photon_prod; //!< macroscopic photon production xs
165

166
  // Photon cross sections
167
  double coherent;        //!< macroscopic coherent xs
168
  double incoherent;      //!< macroscopic incoherent xs
169
  double photoelectric;   //!< macroscopic photoelectric xs
170
  double pair_production; //!< macroscopic pair production xs
171
};
172

173
//==============================================================================
174
// Cache contains the cached data for an MGXS object
175
//==============================================================================
176

177
struct CacheDataMG {
178
  int material {-1}; //!< material index
179
  double sqrtkT;     //!< last temperature corresponding to t
180
  int t {0};         //!< temperature index
181
  int a {0};         //!< angle index
182
  Direction u;       //!< angle that corresponds to a
183
};
184

185
//==============================================================================
186
// Information about nearest boundary crossing
187
//==============================================================================
188

189
struct BoundaryInfo {
190
  double distance {INFINITY}; //!< distance to nearest boundary
191
  int surface {
192
    SURFACE_NONE}; //!< surface token, non-zero if boundary is surface
193
  int coord_level; //!< coordinate level after crossing boundary
194
  array<int, 3>
195
    lattice_translation {}; //!< which way lattice indices will change
196

197
  void reset()
198
  {
199
    distance = INFINITY;
200
    surface = SURFACE_NONE;
201
    coord_level = 0;
202
    lattice_translation = {0, 0, 0};
203
  }
204
  // TODO: off-by-one
205
  int surface_index() const { return std::abs(surface) - 1; }
206
};
207

208
/*
209
 * Contains all geometry state information for a particle.
210
 */
211
class GeometryState {
212
public:
213
  GeometryState();
214

215
  /*
216
   * GeometryState does not store any ID info, so give some reasonable behavior
217
   * here. The Particle class redefines this. This is only here for the error
218
   * reporting behavior that occurs in geometry.cpp. The explanation for
219
   * mark_as_lost is the same.
220
   */
221
  virtual void mark_as_lost(const char* message);
222
  void mark_as_lost(const std::string& message);
223
  void mark_as_lost(const std::stringstream& message);
224

225
  // resets all coordinate levels for the particle
226
  void clear()
227
  {
228
    for (auto& level : coord_) {
229
      level.reset();
230
    }
231
    n_coord_ = 1;
232

233
    for (auto& cell : cell_last_) {
234
      cell = C_NONE;
235
    }
236
    n_coord_last_ = 1;
237
  }
238

239
  //! moves the particle by the specified distance to its next location
240
  //! \param distance the distance the particle is moved
241
  void move_distance(double distance);
242

243
  void advance_to_boundary_from_void();
244

245
  // Initialize all internal state from position and direction
246
  void init_from_r_u(Position r_a, Direction u_a)
247
  {
248
    clear();
249
    surface() = SURFACE_NONE;
250
    material() = C_NONE;
251
    r() = r_a;
252
    u() = u_a;
253
    r_last_current() = r_a;
254
    r_last() = r_a;
255
    u_last() = u_a;
256
  }
257

258
  // Unique ID. This is not geometric info, but the
259
  // error reporting in geometry.cpp requires this.
260
  // We could save this to implement it in Particle,
261
  // but that would require virtuals.
262
  int64_t& id() { return id_; }
×
263
  const int64_t& id() const { return id_; }
264

265
  // Number of current coordinate levels
266
  int& n_coord() { return n_coord_; }
×
267
  const int& n_coord() const { return n_coord_; }
268

269
  // Offset for distributed properties
270
  int& cell_instance() { return cell_instance_; }
×
271
  const int& cell_instance() const { return cell_instance_; }
272

273
  // Coordinates for all nesting levels
274
  LocalCoord& coord(int i) { return coord_[i]; }
×
275
  const LocalCoord& coord(int i) const { return coord_[i]; }
UNCOV
276
  const vector<LocalCoord>& coord() const { return coord_; }
×
277

278
  // Innermost universe nesting coordinates
279
  LocalCoord& lowest_coord() { return coord_[n_coord_ - 1]; }
×
280
  const LocalCoord& lowest_coord() const { return coord_[n_coord_ - 1]; }
281

282
  // Last coordinates on all nesting levels, before crossing a surface
283
  int& n_coord_last() { return n_coord_last_; }
284
  const int& n_coord_last() const { return n_coord_last_; }
285
  int& cell_last(int i) { return cell_last_[i]; }
286
  const int& cell_last(int i) const { return cell_last_[i]; }
287

288
  // Coordinates at birth
289
  Position& r_born() { return r_born_; }
290
  const Position& r_born() const { return r_born_; }
291

292
  // Coordinates of last collision or reflective/periodic surface
293
  // crossing for current tallies
294
  Position& r_last_current() { return r_last_current_; }
295
  const Position& r_last_current() const { return r_last_current_; }
296

297
  // Previous direction and spatial coordinates before a collision
298
  Position& r_last() { return r_last_; }
299
  const Position& r_last() const { return r_last_; }
300
  Position& u_last() { return u_last_; }
UNCOV
301
  const Position& u_last() const { return u_last_; }
×
302

303
  // Accessors for position in global coordinates
304
  Position& r() { return coord_[0].r; }
×
305
  const Position& r() const { return coord_[0].r; }
306

307
  // Accessors for position in local coordinates
308
  Position& r_local() { return coord_[n_coord_ - 1].r; }
309
  const Position& r_local() const { return coord_[n_coord_ - 1].r; }
310

311
  // Accessors for direction in global coordinates
312
  Direction& u() { return coord_[0].u; }
×
313
  const Direction& u() const { return coord_[0].u; }
314

315
  // Accessors for direction in local coordinates
316
  Direction& u_local() { return coord_[n_coord_ - 1].u; }
317
  const Direction& u_local() const { return coord_[n_coord_ - 1].u; }
318

319
  // Surface token for the surface that the particle is currently on
320
  int& surface() { return surface_; }
321
  const int& surface() const { return surface_; }
322

323
  // Surface index based on the current value of the surface_ attribute
324
  int surface_index() const
325
  {
326
    // TODO: off-by-one
327
    return std::abs(surface_) - 1;
328
  }
329

330
  // Boundary information
331
  BoundaryInfo& boundary() { return boundary_; }
×
332

333
#ifdef DAGMC
334
  // DagMC state variables
335
  moab::DagMC::RayHistory& history() { return history_; }
336
  Direction& last_dir() { return last_dir_; }
337
#endif
338

339
  // material of current and last cell
340
  int& material() { return material_; }
×
341
  const int& material() const { return material_; }
342
  int& material_last() { return material_last_; }
343
  const int& material_last() const { return material_last_; }
344

345
  // temperature of current and last cell
346
  double& sqrtkT() { return sqrtkT_; }
347
  const double& sqrtkT() const { return sqrtkT_; }
348
  double& sqrtkT_last() { return sqrtkT_last_; }
349

350
private:
351
  int64_t id_ {-1}; //!< Unique ID
352

353
  int n_coord_ {1};          //!< number of current coordinate levels
354
  int cell_instance_;        //!< offset for distributed properties
355
  vector<LocalCoord> coord_; //!< coordinates for all levels
356

357
  int n_coord_last_ {1};  //!< number of current coordinates
358
  vector<int> cell_last_; //!< coordinates for all levels
359

360
  Position r_born_;         //!< coordinates at birth
361
  Position r_last_current_; //!< coordinates of the last collision or
362
                            //!< reflective/periodic surface crossing for
363
                            //!< current tallies
364
  Position r_last_;         //!< previous coordinates
365
  Direction u_last_;        //!< previous direction coordinates
366

367
  int surface_ {
368
    SURFACE_NONE}; //!< surface token for surface the particle is currently on
369

370
  BoundaryInfo boundary_; //!< Info about the next intersection
371

372
  int material_ {-1};      //!< index for current material
373
  int material_last_ {-1}; //!< index for last material
374

375
  double sqrtkT_ {-1.0};     //!< sqrt(k_Boltzmann * temperature) in eV
376
  double sqrtkT_last_ {0.0}; //!< last temperature
377

378
#ifdef DAGMC
379
  moab::DagMC::RayHistory history_;
380
  Direction last_dir_;
381
#endif
382
};
383

384
//============================================================================
385
//! Defines how particle data is laid out in memory
386
//============================================================================
387

388
/*
389
 * This class was added in order to separate the layout and access of particle
390
 * data from particle physics operations during a development effort to get
391
 * OpenMC running on GPUs. In the event-based Monte Carlo method, one creates
392
 * an array of particles on which actions like cross section lookup and surface
393
 * crossing are done en masse, which works best on vector computers of yore and
394
 * modern GPUs. It has been shown in the below publication [1] that arranging
395
 * particle data into a structure of arrays rather than an array of structures
396
 * enhances performance on GPUs. For instance, rather than having an
397
 * std::vector<Particle> where consecutive particle energies would be separated
398
 * by about 400 bytes, one would create a structure which has a single
399
 * std::vector<double> of energies.  The motivation here is that more coalesced
400
 * memory accesses occur, in the parlance of GPU programming.
401
 *
402
 * So, this class enables switching between the array-of-structures and
403
 * structure- of-array data layout at compile time. In GPU branches of the
404
 * code, our Particle class inherits from a class that provides an array of
405
 * particle energies, and can access them using the E() method (defined below).
406
 * In the CPU code, we inherit from this class which gives the conventional
407
 * layout of particle data, useful for history-based tracking.
408
 *
409
 * As a result, we always use the E(), r_last(), etc. methods to access
410
 * particle data in order to keep a unified interface between
411
 * structure-of-array and array-of-structure code on either CPU or GPU code
412
 * while sharing the same physics code on each codebase.
413
 *
414
 * [1] Hamilton, Steven P., Stuart R. Slattery, and Thomas M. Evans.
415
 *   “Multigroup Monte Carlo on GPUs: Comparison of History- and Event-Based
416
 *   Algorithms.” Annals of Nuclear Energy 113 (March 2018): 506–18.
417
 *   https://doi.org/10.1016/j.anucene.2017.11.032.
418
 */
419
class ParticleData : public GeometryState {
420
private:
421
  //==========================================================================
422
  // Data members -- see public: below for descriptions
423

424
  vector<NuclideMicroXS> neutron_xs_;
425
  vector<ElementMicroXS> photon_xs_;
426
  MacroXS macro_xs_;
427
  CacheDataMG mg_xs_cache_;
428

429
  ParticleType type_ {ParticleType::neutron};
430

431
  double E_;
432
  double E_last_;
433
  int g_ {0};
434
  int g_last_;
435

436
  double wgt_ {1.0};
437
  double wgt_born_ {1.0};
438
  double mu_;
439
  double time_ {0.0};
440
  double time_last_ {0.0};
441
  double wgt_last_ {1.0};
442

443
  bool fission_ {false};
444
  TallyEvent event_;
445
  int event_nuclide_;
446
  int event_mt_;
447
  int delayed_group_ {0};
448
  int parent_nuclide_ {-1};
449

450
  int n_bank_ {0};
451
  double bank_second_E_ {0.0};
452
  double wgt_bank_ {0.0};
453
  int n_delayed_bank_[MAX_DELAYED_GROUPS];
454

455
  int cell_born_ {-1};
456

457
  // Iterated Fission Probability
458
  double lifetime_ {0.0}; //!< neutron lifetime [s]
459

460
  int n_collision_ {0};
461

462
  bool write_track_ {false};
463

464
  uint64_t seeds_[N_STREAMS];
465
  int stream_;
466

467
  vector<SourceSite> secondary_bank_;
468

469
  int64_t current_work_;
470

471
  vector<double> flux_derivs_;
472

473
  vector<FilterMatch> filter_matches_;
474

475
  vector<TrackStateHistory> tracks_;
476

477
  vector<NuBank> nu_bank_;
478

479
  vector<double> pht_storage_;
480

481
  double keff_tally_absorption_ {0.0};
482
  double keff_tally_collision_ {0.0};
483
  double keff_tally_tracklength_ {0.0};
484
  double keff_tally_leakage_ {0.0};
485

486
  bool trace_ {false};
487

488
  double collision_distance_;
489

490
  int n_event_ {0};
491

492
  int n_split_ {0};
493
  double ww_factor_ {0.0};
494

495
  int64_t n_progeny_ {0};
496

497
public:
498
  //----------------------------------------------------------------------------
499
  // Constructors
500
  ParticleData();
501

502
  //==========================================================================
503
  // Methods and accessors
504

505
  // Cross section caches
506
  NuclideMicroXS& neutron_xs(int i)
507
  {
508
    return neutron_xs_[i];
509
  } // Microscopic neutron cross sections
510
  const NuclideMicroXS& neutron_xs(int i) const { return neutron_xs_[i]; }
511

512
  // Microscopic photon cross sections
513
  ElementMicroXS& photon_xs(int i) { return photon_xs_[i]; }
514

515
  // Macroscopic cross sections
516
  MacroXS& macro_xs() { return macro_xs_; }
517
  const MacroXS& macro_xs() const { return macro_xs_; }
518

519
  // Multigroup macroscopic cross sections
520
  CacheDataMG& mg_xs_cache() { return mg_xs_cache_; }
521
  const CacheDataMG& mg_xs_cache() const { return mg_xs_cache_; }
522

523
  // Particle type (n, p, e, gamma, etc)
524
  ParticleType& type() { return type_; }
525
  const ParticleType& type() const { return type_; }
526

527
  // Current particle energy, energy before collision,
528
  // and corresponding multigroup group indices. Energy
529
  // units are eV.
530
  double& E() { return E_; }
531
  const double& E() const { return E_; }
532
  double& E_last() { return E_last_; }
533
  const double& E_last() const { return E_last_; }
534
  int& g() { return g_; }
535
  const int& g() const { return g_; }
536
  int& g_last() { return g_last_; }
537
  const int& g_last() const { return g_last_; }
538

539
  // Statistic weight of particle. Setting to zero indicates that the particle
540
  // is dead.
541
  double& wgt() { return wgt_; }
×
542
  double wgt() const { return wgt_; }
543

544
  // Statistic weight of particle at birth
545
  double& wgt_born() { return wgt_born_; }
546
  double wgt_born() const { return wgt_born_; }
547

548
  // Statistic weight of particle at last collision
549
  double& wgt_last() { return wgt_last_; }
550
  const double& wgt_last() const { return wgt_last_; }
551

552
  // Whether particle is alive
553
  bool alive() const { return wgt_ != 0.0; }
×
554

555
  // Polar scattering angle after a collision
556
  double& mu() { return mu_; }
UNCOV
557
  const double& mu() const { return mu_; }
×
558

559
  // Tracks the time of a particle as it traverses the problem.
560
  // Units are seconds.
561
  double& time() { return time_; }
562
  const double& time() const { return time_; }
563
  double& time_last() { return time_last_; }
564
  const double& time_last() const { return time_last_; }
565

566
  // Particle lifetime
567
  double& lifetime() { return lifetime_; }
568
  const double& lifetime() const { return lifetime_; }
569

570
  // What event took place, described in greater detail below
571
  TallyEvent& event() { return event_; }
572
  const TallyEvent& event() const { return event_; }
573
  bool& fission() { return fission_; }            // true if implicit fission
574
  int& event_nuclide() { return event_nuclide_; } // index of collision nuclide
575
  const int& event_nuclide() const { return event_nuclide_; }
576
  int& event_mt() { return event_mt_; }           // MT number of collision
577
  int& delayed_group() { return delayed_group_; } // delayed group
578
  const int& parent_nuclide() const { return parent_nuclide_; }
579
  int& parent_nuclide() { return parent_nuclide_; } // Parent nuclide
580

581
  // Post-collision data
582
  double& bank_second_E()
583
  {
584
    return bank_second_E_;
585
  } // energy of last reaction secondaries
586
  const double& bank_second_E() const { return bank_second_E_; }
587

588
  int& n_bank() { return n_bank_; }        // number of banked fission sites
589
  double& wgt_bank() { return wgt_bank_; } // weight of banked fission sites
590
  int* n_delayed_bank()
591
  {
592
    return n_delayed_bank_;
593
  } // number of delayed fission sites
594
  int& n_delayed_bank(int i)
595
  {
596
    return n_delayed_bank_[i];
597
  } // number of delayed fission sites
598

599
  // Index of cell particle is born in
600
  int& cell_born() { return cell_born_; }
×
601
  const int& cell_born() const { return cell_born_; }
602

603
  // Total number of collisions suffered by particle
604
  int& n_collision() { return n_collision_; }
605
  const int& n_collision() const { return n_collision_; }
606

607
  // whether this track is to be written
608
  bool& write_track() { return write_track_; }
609

610
  // RNG state
611
  uint64_t& seeds(int i) { return seeds_[i]; }
612
  uint64_t* seeds() { return seeds_; }
×
613
  int& stream() { return stream_; }
×
614

615
  // secondary particle bank
616
  SourceSite& secondary_bank(int i) { return secondary_bank_[i]; }
617
  decltype(secondary_bank_)& secondary_bank() { return secondary_bank_; }
618

619
  // Current simulation work index
620
  int64_t& current_work() { return current_work_; }
621
  const int64_t& current_work() const { return current_work_; }
622

623
  // Used in tally derivatives
624
  double& flux_derivs(int i) { return flux_derivs_[i]; }
625
  const double& flux_derivs(int i) const { return flux_derivs_[i]; }
626

627
  // Matches of tallies
628
  decltype(filter_matches_)& filter_matches() { return filter_matches_; }
629
  FilterMatch& filter_matches(int i) { return filter_matches_[i]; }
630

631
  // Tracks to output to file
632
  decltype(tracks_)& tracks() { return tracks_; }
633

634
  // Bank of recently fissioned particles
635
  decltype(nu_bank_)& nu_bank() { return nu_bank_; }
636
  NuBank& nu_bank(int i) { return nu_bank_[i]; }
637

638
  // Interim pulse height tally storage
639
  vector<double>& pht_storage() { return pht_storage_; }
640

641
  // Global tally accumulators
642
  double& keff_tally_absorption() { return keff_tally_absorption_; }
643
  double& keff_tally_collision() { return keff_tally_collision_; }
644
  double& keff_tally_tracklength() { return keff_tally_tracklength_; }
645
  double& keff_tally_leakage() { return keff_tally_leakage_; }
646

647
  // Shows debug info
648
  bool& trace() { return trace_; }
649

650
  // Distance to the next collision
651
  double& collision_distance() { return collision_distance_; }
652

653
  // Number of events particle has undergone
654
  int& n_event() { return n_event_; }
×
655

656
  // Number of times variance reduction has caused a particle split
657
  int n_split() const { return n_split_; }
658
  int& n_split() { return n_split_; }
659

660
  // Particle-specific factor for on-the-fly weight window adjustment
661
  double ww_factor() const { return ww_factor_; }
662
  double& ww_factor() { return ww_factor_; }
663

664
  // Number of progeny produced by this particle
665
  int64_t& n_progeny() { return n_progeny_; }
666

667
  //! Gets the pointer to the particle's current PRN seed
668
  uint64_t* current_seed() { return seeds_ + stream_; }
×
669
  const uint64_t* current_seed() const { return seeds_ + stream_; }
670

671
  //! Force recalculation of neutron xs by setting last energy to zero
672
  void invalidate_neutron_xs()
673
  {
674
    for (auto& micro : neutron_xs_)
675
      micro.last_E = 0.0;
676
  }
677

678
  //! Get track information based on particle's current state
679
  TrackState get_track_state() const;
680

681
  void zero_delayed_bank()
682
  {
683
    for (int& n : n_delayed_bank_) {
684
      n = 0;
685
    }
686
  }
687

688
  void zero_flux_derivs()
689
  {
690
    for (double& d : flux_derivs_) {
691
      d = 0;
692
    }
693
  }
694
};
695

696
} // namespace openmc
697

698
#endif // OPENMC_PARTICLE_DATA_H
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc