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

openmc-dev / openmc / 13546000884

26 Feb 2025 02:19PM UTC coverage: 85.015% (-0.2%) from 85.186%
13546000884

Pull #3328

github

web-flow
Merge 67a173195 into e060534ff
Pull Request #3328: NCrystal becomes runtime rather than buildtime dependency

81 of 108 new or added lines in 6 files covered. (75.0%)

467 existing lines in 21 files now uncovered.

51062 of 60062 relevant lines covered (85.02%)

32488887.43 hits per line

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

15.38
/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]; }
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_; }
66,172,656✔
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
UNCOV
298
  Position& r_last() { return r_last_; }
×
299
  const Position& r_last() const { return r_last_; }
300
  Position& u_last() { return u_last_; }
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 mu_;
438
  double time_ {0.0};
439
  double time_last_ {0.0};
440
  double wgt_last_ {1.0};
441

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

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

454
  int cell_born_ {-1};
455

456
  int n_collision_ {0};
457

458
  bool write_track_ {false};
459

460
  uint64_t seeds_[N_STREAMS];
461
  int stream_;
462

463
  vector<SourceSite> secondary_bank_;
464

465
  int64_t current_work_;
466

467
  vector<double> flux_derivs_;
468

469
  vector<FilterMatch> filter_matches_;
470

471
  vector<TrackStateHistory> tracks_;
472

473
  vector<NuBank> nu_bank_;
474

475
  vector<double> pht_storage_;
476

477
  double keff_tally_absorption_ {0.0};
478
  double keff_tally_collision_ {0.0};
479
  double keff_tally_tracklength_ {0.0};
480
  double keff_tally_leakage_ {0.0};
481

482
  bool trace_ {false};
483

484
  double collision_distance_;
485

486
  int n_event_ {0};
487

488
  int n_split_ {0};
489
  double ww_factor_ {0.0};
490

491
  int64_t n_progeny_ {0};
492

493
public:
494
  //----------------------------------------------------------------------------
495
  // Constructors
496
  ParticleData();
497

498
  //==========================================================================
499
  // Methods and accessors
500

501
  // Cross section caches
502
  NuclideMicroXS& neutron_xs(int i)
503
  {
504
    return neutron_xs_[i];
505
  } // Microscopic neutron cross sections
506
  const NuclideMicroXS& neutron_xs(int i) const { return neutron_xs_[i]; }
507

508
  // Microscopic photon cross sections
UNCOV
509
  ElementMicroXS& photon_xs(int i) { return photon_xs_[i]; }
×
510

511
  // Macroscopic cross sections
512
  MacroXS& macro_xs() { return macro_xs_; }
513
  const MacroXS& macro_xs() const { return macro_xs_; }
514

515
  // Multigroup macroscopic cross sections
516
  CacheDataMG& mg_xs_cache() { return mg_xs_cache_; }
517
  const CacheDataMG& mg_xs_cache() const { return mg_xs_cache_; }
518

519
  // Particle type (n, p, e, gamma, etc)
520
  ParticleType& type() { return type_; }
521
  const ParticleType& type() const { return type_; }
522

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

535
  // Statistic weight of particle. Setting to zero
536
  // indicates that the particle is dead.
537
  double& wgt() { return wgt_; }
×
538
  double wgt() const { return wgt_; }
539
  double& wgt_last() { return wgt_last_; }
540
  const double& wgt_last() const { return wgt_last_; }
541
  bool alive() const { return wgt_ != 0.0; }
542

543
  // Polar scattering angle after a collision
544
  double& mu() { return mu_; }
545
  const double& mu() const { return mu_; }
546

547
  // Tracks the time of a particle as it traverses the problem.
548
  // Units are seconds.
549
  double& time() { return time_; }
550
  const double& time() const { return time_; }
551
  double& time_last() { return time_last_; }
552
  const double& time_last() const { return time_last_; }
553

554
  // What event took place, described in greater detail below
555
  TallyEvent& event() { return event_; }
556
  const TallyEvent& event() const { return event_; }
557
  bool& fission() { return fission_; }            // true if implicit fission
558
  int& event_nuclide() { return event_nuclide_; } // index of collision nuclide
559
  const int& event_nuclide() const { return event_nuclide_; }
560
  int& event_mt() { return event_mt_; }           // MT number of collision
561
  int& delayed_group() { return delayed_group_; } // delayed group
562
  const int& parent_nuclide() const { return parent_nuclide_; }
563
  int& parent_nuclide() { return parent_nuclide_; } // Parent nuclide
564

565
  // Post-collision data
566
  double& bank_second_E()
567
  {
568
    return bank_second_E_;
569
  } // energy of last reaction secondaries
570
  const double& bank_second_E() const { return bank_second_E_; }
571

572
  int& n_bank() { return n_bank_; }        // number of banked fission sites
573
  double& wgt_bank() { return wgt_bank_; } // weight of banked fission sites
574
  int* n_delayed_bank()
575
  {
576
    return n_delayed_bank_;
577
  } // number of delayed fission sites
578
  int& n_delayed_bank(int i)
579
  {
580
    return n_delayed_bank_[i];
581
  } // number of delayed fission sites
582

583
  // Index of cell particle is born in
584
  int& cell_born() { return cell_born_; }
585
  const int& cell_born() const { return cell_born_; }
586

587
  // Total number of collisions suffered by particle
588
  int& n_collision() { return n_collision_; }
589
  const int& n_collision() const { return n_collision_; }
590

591
  // whether this track is to be written
592
  bool& write_track() { return write_track_; }
593

594
  // RNG state
595
  uint64_t& seeds(int i) { return seeds_[i]; }
596
  uint64_t* seeds() { return seeds_; }
597
  int& stream() { return stream_; }
598

599
  // secondary particle bank
600
  SourceSite& secondary_bank(int i) { return secondary_bank_[i]; }
601
  decltype(secondary_bank_)& secondary_bank() { return secondary_bank_; }
602

603
  // Current simulation work index
604
  int64_t& current_work() { return current_work_; }
605
  const int64_t& current_work() const { return current_work_; }
606

607
  // Used in tally derivatives
608
  double& flux_derivs(int i) { return flux_derivs_[i]; }
609
  const double& flux_derivs(int i) const { return flux_derivs_[i]; }
610

611
  // Matches of tallies
612
  decltype(filter_matches_)& filter_matches() { return filter_matches_; }
2,147,483,647✔
613
  FilterMatch& filter_matches(int i) { return filter_matches_[i]; }
614

615
  // Tracks to output to file
616
  decltype(tracks_)& tracks() { return tracks_; }
617

618
  // Bank of recently fissioned particles
619
  decltype(nu_bank_)& nu_bank() { return nu_bank_; }
620
  NuBank& nu_bank(int i) { return nu_bank_[i]; }
621

622
  // Interim pulse height tally storage
623
  vector<double>& pht_storage() { return pht_storage_; }
624

625
  // Global tally accumulators
626
  double& keff_tally_absorption() { return keff_tally_absorption_; }
627
  double& keff_tally_collision() { return keff_tally_collision_; }
628
  double& keff_tally_tracklength() { return keff_tally_tracklength_; }
629
  double& keff_tally_leakage() { return keff_tally_leakage_; }
630

631
  // Shows debug info
632
  bool& trace() { return trace_; }
633

634
  // Distance to the next collision
635
  double& collision_distance() { return collision_distance_; }
636

637
  // Number of events particle has undergone
638
  int& n_event() { return n_event_; }
639

640
  // Number of times variance reduction has caused a particle split
641
  int n_split() const { return n_split_; }
642
  int& n_split() { return n_split_; }
643

644
  // Particle-specific factor for on-the-fly weight window adjustment
645
  double ww_factor() const { return ww_factor_; }
646
  double& ww_factor() { return ww_factor_; }
647

648
  // Number of progeny produced by this particle
649
  int64_t& n_progeny() { return n_progeny_; }
650

651
  //! Gets the pointer to the particle's current PRN seed
652
  uint64_t* current_seed() { return seeds_ + stream_; }
×
653
  const uint64_t* current_seed() const { return seeds_ + stream_; }
654

655
  //! Force recalculation of neutron xs by setting last energy to zero
656
  void invalidate_neutron_xs()
657
  {
658
    for (auto& micro : neutron_xs_)
659
      micro.last_E = 0.0;
660
  }
661

662
  //! Get track information based on particle's current state
663
  TrackState get_track_state() const;
664

665
  void zero_delayed_bank()
666
  {
667
    for (int& n : n_delayed_bank_) {
668
      n = 0;
669
    }
670
  }
671

672
  void zero_flux_derivs()
673
  {
674
    for (double& d : flux_derivs_) {
675
      d = 0;
676
    }
677
  }
678
};
679

680
} // namespace openmc
681

682
#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

© 2026 Coveralls, Inc