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

openmc-dev / openmc / 21269449529

23 Jan 2026 12:05AM UTC coverage: 81.986% (-0.01%) from 81.998%
21269449529

Pull #3742

github

web-flow
Merge ead91cc98 into 049a852e5
Pull Request #3742: Implement surface flux tallies

17250 of 24017 branches covered (71.82%)

Branch coverage included in aggregate %.

88 of 112 new or added lines in 5 files covered. (78.57%)

209 existing lines in 4 files now uncovered.

55705 of 64968 relevant lines covered (85.74%)

43383355.55 hits per line

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

83.27
/src/random_ray/random_ray_simulation.cpp
1
#include "openmc/random_ray/random_ray_simulation.h"
2

3
#include "openmc/eigenvalue.h"
4
#include "openmc/geometry.h"
5
#include "openmc/message_passing.h"
6
#include "openmc/mgxs_interface.h"
7
#include "openmc/output.h"
8
#include "openmc/plot.h"
9
#include "openmc/random_ray/flat_source_domain.h"
10
#include "openmc/random_ray/random_ray.h"
11
#include "openmc/simulation.h"
12
#include "openmc/source.h"
13
#include "openmc/tallies/filter.h"
14
#include "openmc/tallies/tally.h"
15
#include "openmc/tallies/tally_scoring.h"
16
#include "openmc/timer.h"
17
#include "openmc/weight_windows.h"
18

19
namespace openmc {
20

21
//==============================================================================
22
// Non-member functions
23
//==============================================================================
24

25
void openmc_run_random_ray()
673✔
26
{
27
  //////////////////////////////////////////////////////////
28
  // Run forward simulation
29
  //////////////////////////////////////////////////////////
30

31
  if (mpi::master) {
673✔
32
    if (FlatSourceDomain::adjoint_) {
463✔
33
      FlatSourceDomain::adjoint_ = false;
56✔
34
      openmc::print_adjoint_header();
56✔
35
      FlatSourceDomain::adjoint_ = true;
56✔
36
    }
37
  }
38

39
  // Initialize OpenMC general data structures
40
  openmc_simulation_init();
673✔
41

42
  // Validate that inputs meet requirements for random ray mode
43
  if (mpi::master)
673✔
44
    validate_random_ray_inputs();
463✔
45

46
  // Initialize Random Ray Simulation Object
47
  RandomRaySimulation sim;
673✔
48

49
  // Initialize fixed sources, if present
50
  sim.apply_fixed_sources_and_mesh_domains();
673✔
51

52
  // Run initial random ray simulation
53
  sim.simulate();
673✔
54

55
  //////////////////////////////////////////////////////////
56
  // Run adjoint simulation (if enabled)
57
  //////////////////////////////////////////////////////////
58

59
  if (sim.adjoint_needed_) {
673✔
60
    // Setup for adjoint simulation
61
    sim.prepare_adjoint_simulation();
81✔
62

63
    // Run adjoint simulation
64
    sim.simulate();
81✔
65
  }
66
}
673✔
67

68
// Enforces restrictions on inputs in random ray mode.  While there are
69
// many features that don't make sense in random ray mode, and are therefore
70
// unsupported, we limit our testing/enforcement operations only to inputs
71
// that may cause erroneous/misleading output or crashes from the solver.
72
void validate_random_ray_inputs()
463✔
73
{
74
  // Validate tallies
75
  ///////////////////////////////////////////////////////////////////
76
  for (auto& tally : model::tallies) {
1,388✔
77

78
    // Validate score types
79
    for (auto score_bin : tally->scores_) {
2,048✔
80
      switch (score_bin) {
1,123!
81
      case SCORE_FLUX:
1,123✔
82
      case SCORE_TOTAL:
83
      case SCORE_FISSION:
84
      case SCORE_NU_FISSION:
85
      case SCORE_EVENTS:
86
        break;
1,123✔
UNCOV
87
      default:
×
UNCOV
88
        fatal_error(
×
89
          "Invalid score specified. Only flux, total, fission, nu-fission, and "
90
          "event scores are supported in random ray mode.");
91
      }
92
    }
93

94
    // Validate filter types
95
    for (auto f : tally->filters()) {
2,017✔
96
      auto& filter = *model::tally_filters[f];
1,092✔
97

98
      switch (filter.type()) {
1,092!
99
      case FilterType::CELL:
1,092✔
100
      case FilterType::CELL_INSTANCE:
101
      case FilterType::DISTRIBCELL:
102
      case FilterType::ENERGY:
103
      case FilterType::MATERIAL:
104
      case FilterType::MESH:
105
      case FilterType::UNIVERSE:
106
      case FilterType::PARTICLE:
107
        break;
1,092✔
UNCOV
108
      default:
×
UNCOV
109
        fatal_error("Invalid filter specified. Only cell, cell_instance, "
×
110
                    "distribcell, energy, material, mesh, and universe filters "
111
                    "are supported in random ray mode.");
112
      }
113
    }
114
  }
115

116
  // Validate MGXS data
117
  ///////////////////////////////////////////////////////////////////
118
  for (auto& material : data::mg.macro_xs_) {
1,729✔
119
    if (!material.is_isotropic) {
1,266!
UNCOV
120
      fatal_error("Anisotropic MGXS detected. Only isotropic XS data sets "
×
121
                  "supported in random ray mode.");
122
    }
123
    if (material.get_xsdata().size() > 1) {
1,266!
UNCOV
124
      warning("Non-isothermal MGXS detected. Only isothermal XS data sets "
×
125
              "supported in random ray mode. Using lowest temperature.");
126
    }
127
    for (int g = 0; g < data::mg.num_energy_groups_; g++) {
7,021✔
128
      if (material.exists_in_model) {
5,755✔
129
        // Temperature and angle indices, if using multiple temperature
130
        // data sets and/or anisotropic data sets.
131
        // TODO: Currently assumes we are only using single temp/single angle
132
        // data.
133
        const int t = 0;
5,711✔
134
        const int a = 0;
5,711✔
135
        double sigma_t =
136
          material.get_xs(MgxsType::TOTAL, g, NULL, NULL, NULL, t, a);
5,711✔
137
        if (sigma_t <= 0.0) {
5,711!
UNCOV
138
          fatal_error("No zero or negative total macroscopic cross sections "
×
139
                      "allowed in random ray mode. If the intention is to make "
140
                      "a void material, use a cell fill of 'None' instead.");
141
        }
142
      }
143
    }
144
  }
145

146
  // Validate ray source
147
  ///////////////////////////////////////////////////////////////////
148

149
  // Check for independent source
150
  IndependentSource* is =
151
    dynamic_cast<IndependentSource*>(RandomRay::ray_source_.get());
463!
152
  if (!is) {
463!
UNCOV
153
    fatal_error("Invalid ray source definition. Ray source must provided and "
×
154
                "be of type IndependentSource.");
155
  }
156

157
  // Check for box source
158
  SpatialDistribution* space_dist = is->space();
463✔
159
  SpatialBox* sb = dynamic_cast<SpatialBox*>(space_dist);
463!
160
  if (!sb) {
463!
UNCOV
161
    fatal_error(
×
162
      "Invalid ray source definition -- only box sources are allowed.");
163
  }
164

165
  // Check that box source is not restricted to fissionable areas
166
  if (sb->only_fissionable()) {
463!
UNCOV
167
    fatal_error(
×
168
      "Invalid ray source definition -- fissionable spatial distribution "
169
      "not allowed.");
170
  }
171

172
  // Check for isotropic source
173
  UnitSphereDistribution* angle_dist = is->angle();
463✔
174
  Isotropic* id = dynamic_cast<Isotropic*>(angle_dist);
463!
175
  if (!id) {
463!
UNCOV
176
    fatal_error("Invalid ray source definition -- only isotropic sources are "
×
177
                "allowed.");
178
  }
179

180
  // Validate external sources
181
  ///////////////////////////////////////////////////////////////////
182
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
463✔
183
    if (model::external_sources.size() < 1) {
287!
184
      fatal_error("Must provide a particle source (in addition to ray source) "
×
185
                  "in fixed source random ray mode.");
186
    }
187

188
    for (int i = 0; i < model::external_sources.size(); i++) {
574✔
189
      Source* s = model::external_sources[i].get();
287✔
190

191
      // Check for independent source
192
      IndependentSource* is = dynamic_cast<IndependentSource*>(s);
287!
193

194
      if (!is) {
287!
UNCOV
195
        fatal_error(
×
196
          "Only IndependentSource external source types are allowed in "
197
          "random ray mode");
198
      }
199

200
      // Check for isotropic source
201
      UnitSphereDistribution* angle_dist = is->angle();
287✔
202
      Isotropic* id = dynamic_cast<Isotropic*>(angle_dist);
287!
203
      if (!id) {
287!
UNCOV
204
        fatal_error(
×
205
          "Invalid source definition -- only isotropic external sources are "
206
          "allowed in random ray mode.");
207
      }
208

209
      // Validate that a domain ID was specified OR that it is a point source
210
      auto sp = dynamic_cast<SpatialPoint*>(is->space());
287!
211
      if (is->domain_ids().size() == 0 && !sp) {
287!
UNCOV
212
        fatal_error("Fixed sources must be point source or spatially "
×
213
                    "constrained by domain id (cell, material, or universe) in "
214
                    "random ray mode.");
215
      } else if (is->domain_ids().size() > 0 && sp) {
287✔
216
        // If both a domain constraint and a non-default point source location
217
        // are specified, notify user that domain constraint takes precedence.
218
        if (sp->r().x == 0.0 && sp->r().y == 0.0 && sp->r().z == 0.0) {
253!
219
          warning("Fixed source has both a domain constraint and a point "
253✔
220
                  "type spatial distribution. The domain constraint takes "
221
                  "precedence in random ray mode -- point source coordinate "
222
                  "will be ignored.");
223
        }
224
      }
225

226
      // Check that a discrete energy distribution was used
227
      Distribution* d = is->energy();
287✔
228
      Discrete* dd = dynamic_cast<Discrete*>(d);
287!
229
      if (!dd) {
287!
UNCOV
230
        fatal_error(
×
231
          "Only discrete (multigroup) energy distributions are allowed for "
232
          "external sources in random ray mode.");
233
      }
234
    }
235
  }
236

237
  // Validate plotting files
238
  ///////////////////////////////////////////////////////////////////
239
  for (int p = 0; p < model::plots.size(); p++) {
463!
240

241
    // Get handle to OpenMC plot object
UNCOV
242
    const auto& openmc_plottable = model::plots[p];
×
UNCOV
243
    Plot* openmc_plot = dynamic_cast<Plot*>(openmc_plottable.get());
×
244

245
    // Random ray plots only support voxel plots
UNCOV
246
    if (!openmc_plot) {
×
UNCOV
247
      warning(fmt::format(
×
248
        "Plot {} will not be used for end of simulation data plotting -- only "
249
        "voxel plotting is allowed in random ray mode.",
UNCOV
250
        openmc_plottable->id()));
×
UNCOV
251
      continue;
×
UNCOV
252
    } else if (openmc_plot->type_ != Plot::PlotType::voxel) {
×
UNCOV
253
      warning(fmt::format(
×
254
        "Plot {} will not be used for end of simulation data plotting -- only "
255
        "voxel plotting is allowed in random ray mode.",
UNCOV
256
        openmc_plottable->id()));
×
UNCOV
257
      continue;
×
258
    }
259
  }
260

261
  // Warn about slow MPI domain replication, if detected
262
  ///////////////////////////////////////////////////////////////////
263
#ifdef OPENMC_MPI
264
  if (mpi::n_procs > 1) {
211✔
265
    warning(
210✔
266
      "MPI parallelism is not supported by the random ray solver. All work "
267
      "will be performed by rank 0. Domain decomposition may be implemented in "
268
      "the future to provide efficient MPI scaling.");
269
  }
270
#endif
271

272
  // Warn about instability resulting from linear sources in small regions
273
  // when generating weight windows with FW-CADIS and an overlaid mesh.
274
  ///////////////////////////////////////////////////////////////////
275
  if (RandomRay::source_shape_ == RandomRaySourceShape::LINEAR &&
639✔
276
      variance_reduction::weight_windows.size() > 0) {
176✔
277
    warning(
11✔
278
      "Linear sources may result in negative fluxes in small source regions "
279
      "generated by mesh subdivision. Negative sources may result in low "
280
      "quality FW-CADIS weight windows. We recommend you use flat source mode "
281
      "when generating weight windows with an overlaid mesh tally.");
282
  }
283
}
463✔
284

285
void openmc_reset_random_ray()
8,050✔
286
{
287
  FlatSourceDomain::volume_estimator_ = RandomRayVolumeEstimator::HYBRID;
8,050✔
288
  FlatSourceDomain::volume_normalized_flux_tallies_ = false;
8,050✔
289
  FlatSourceDomain::adjoint_ = false;
8,050✔
290
  FlatSourceDomain::mesh_domain_map_.clear();
8,050✔
291
  RandomRay::ray_source_.reset();
8,050✔
292
  RandomRay::source_shape_ = RandomRaySourceShape::FLAT;
8,050✔
293
  RandomRay::sample_method_ = RandomRaySampleMethod::PRNG;
8,050✔
294
}
8,050✔
295

296
void print_adjoint_header()
112✔
297
{
298
  if (!FlatSourceDomain::adjoint_)
112✔
299
    // If we're going to do an adjoint simulation afterwards, report that this
300
    // is the initial forward flux solve.
301
    header("FORWARD FLUX SOLVE", 3);
56✔
302
  else
303
    // Otherwise report that we are doing the adjoint simulation
304
    header("ADJOINT FLUX SOLVE", 3);
56✔
305
}
112✔
306

307
//==============================================================================
308
// RandomRaySimulation implementation
309
//==============================================================================
310

311
RandomRaySimulation::RandomRaySimulation()
673✔
312
  : negroups_(data::mg.num_energy_groups_)
673✔
313
{
314
  // There are no source sites in random ray mode, so be sure to disable to
315
  // ensure we don't attempt to write source sites to statepoint
316
  settings::source_write = false;
673✔
317

318
  // Random ray mode does not have an inner loop over generations within a
319
  // batch, so set the current gen to 1
320
  simulation::current_gen = 1;
673✔
321

322
  switch (RandomRay::source_shape_) {
673!
323
  case RandomRaySourceShape::FLAT:
369✔
324
    domain_ = make_unique<FlatSourceDomain>();
369✔
325
    break;
369✔
326
  case RandomRaySourceShape::LINEAR:
304✔
327
  case RandomRaySourceShape::LINEAR_XY:
328
    domain_ = make_unique<LinearSourceDomain>();
304✔
329
    break;
304✔
UNCOV
330
  default:
×
UNCOV
331
    fatal_error("Unknown random ray source shape");
×
332
  }
333

334
  // Convert OpenMC native MGXS into a more efficient format
335
  // internal to the random ray solver
336
  domain_->flatten_xs();
673✔
337

338
  // Check if adjoint calculation is needed. If it is, we will run the forward
339
  // calculation first and then the adjoint calculation later.
340
  adjoint_needed_ = FlatSourceDomain::adjoint_;
673✔
341

342
  // Adjoint is always false for the forward calculation
343
  FlatSourceDomain::adjoint_ = false;
673✔
344

345
  // The first simulation is run after initialization
346
  is_first_simulation_ = true;
673✔
347
}
673✔
348

349
void RandomRaySimulation::apply_fixed_sources_and_mesh_domains()
673✔
350
{
351
  domain_->apply_meshes();
673✔
352
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
673✔
353
    // Transfer external source user inputs onto random ray source regions
354
    domain_->convert_external_sources();
417✔
355
    domain_->count_external_source_regions();
417✔
356
  }
357
}
673✔
358

359
void RandomRaySimulation::prepare_fixed_sources_adjoint()
81✔
360
{
361
  domain_->source_regions_.adjoint_reset();
81✔
362
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
81✔
363
    domain_->set_adjoint_sources();
65✔
364
  }
365
}
81✔
366

367
void RandomRaySimulation::prepare_adjoint_simulation()
81✔
368
{
369
  // Configure the domain for adjoint simulation
370
  FlatSourceDomain::adjoint_ = true;
81✔
371

372
  // Reset k-eff
373
  domain_->k_eff_ = 1.0;
81✔
374

375
  // Initialize adjoint fixed sources, if present
376
  prepare_fixed_sources_adjoint();
81✔
377

378
  // Transpose scattering matrix
379
  domain_->transpose_scattering_matrix();
81✔
380

381
  // Swap nu_sigma_f and chi
382
  domain_->nu_sigma_f_.swap(domain_->chi_);
81✔
383
}
81✔
384

385
void RandomRaySimulation::simulate()
754✔
386
{
387
  if (!is_first_simulation_) {
754✔
388
    if (mpi::master && adjoint_needed_)
81!
389
      openmc::print_adjoint_header();
56✔
390

391
    // Reset the timers and reinitialize the general OpenMC datastructures if
392
    // this is after the first simulation
393
    reset_timers();
81✔
394

395
    // Initialize OpenMC general data structures
396
    openmc_simulation_init();
81✔
397
  }
398

399
  // Begin main simulation timer
400
  simulation::time_total.start();
754✔
401

402
  // Random ray power iteration loop
403
  while (simulation::current_batch < settings::n_batches) {
18,686✔
404
    // Initialize the current batch
405
    initialize_batch();
17,932✔
406
    initialize_generation();
17,932✔
407

408
    // MPI not supported in random ray solver, so all work is done by rank 0
409
    // TODO: Implement domain decomposition for MPI parallelism
410
    if (mpi::master) {
17,932✔
411

412
      // Reset total starting particle weight used for normalizing tallies
413
      simulation::total_weight = 1.0;
12,332✔
414

415
      // Update source term (scattering + fission)
416
      domain_->update_all_neutron_sources();
12,332✔
417

418
      // Reset scalar fluxes, iteration volume tallies, and region hit flags
419
      // to zero
420
      domain_->batch_reset();
12,332✔
421

422
      // At the beginning of the simulation, if mesh subdivision is in use, we
423
      // need to swap the main source region container into the base container,
424
      // as the main source region container will be used to hold the true
425
      // subdivided source regions. The base container will therefore only
426
      // contain the external source region information, the mesh indices,
427
      // material properties, and initial guess values for the flux/source.
428

429
      // Start timer for transport
430
      simulation::time_transport.start();
12,332✔
431

432
// Transport sweep over all random rays for the iteration
433
#pragma omp parallel for schedule(dynamic)                                     \
6,732✔
434
  reduction(+ : total_geometric_intersections_)
6,732✔
435
      for (int i = 0; i < settings::n_particles; i++) {
883,600✔
436
        RandomRay ray(i, domain_.get());
878,000✔
437
        total_geometric_intersections_ +=
878,000✔
438
          ray.transport_history_based_single_ray();
878,000✔
439
      }
878,000✔
440

441
      simulation::time_transport.stop();
12,332✔
442

443
      // Add any newly discovered source regions to the main source region
444
      // container.
445
      domain_->finalize_discovered_source_regions();
12,332✔
446

447
      // Normalize scalar flux and update volumes
448
      domain_->normalize_scalar_flux_and_volumes(
12,332✔
449
        settings::n_particles * RandomRay::distance_active_);
450

451
      // Add source to scalar flux, compute number of FSR hits
452
      int64_t n_hits = domain_->add_source_to_scalar_flux();
12,332✔
453

454
      // Apply transport stabilization factors
455
      domain_->apply_transport_stabilization();
12,332✔
456

457
      if (settings::run_mode == RunMode::EIGENVALUE) {
12,332✔
458
        // Compute random ray k-eff
459
        domain_->compute_k_eff();
2,640✔
460

461
        // Store random ray k-eff into OpenMC's native k-eff variable
462
        global_tally_tracklength = domain_->k_eff_;
2,640✔
463
      }
464

465
      // Execute all tallying tasks, if this is an active batch
466
      if (simulation::current_batch > settings::n_inactive) {
12,332✔
467

468
        // Add this iteration's scalar flux estimate to final accumulated
469
        // estimate
470
        domain_->accumulate_iteration_flux();
5,066✔
471

472
        // Use above mapping to contribute FSR flux data to appropriate
473
        // tallies
474
        domain_->random_ray_tally();
5,066✔
475
      }
476

477
      // Set phi_old = phi_new
478
      domain_->flux_swap();
12,332✔
479

480
      // Check for any obvious insabilities/nans/infs
481
      instability_check(n_hits, domain_->k_eff_, avg_miss_rate_);
12,332✔
482
    } // End MPI master work
483

484
    // Finalize the current batch
485
    finalize_generation();
17,932✔
486
    finalize_batch();
17,932✔
487
  } // End random ray power iteration loop
488

489
  domain_->count_external_source_regions();
754✔
490

491
  // End main simulation timer
492
  simulation::time_total.stop();
754✔
493

494
  // Normalize and save the final flux
495
  double source_normalization_factor =
496
    domain_->compute_fixed_source_normalization_factor() /
754✔
497
    (settings::n_batches - settings::n_inactive);
754✔
498

499
#pragma omp parallel for
425✔
500
  for (uint64_t se = 0; se < domain_->n_source_elements(); se++) {
1,342,709✔
501
    domain_->source_regions_.scalar_flux_final(se) *=
1,342,380✔
502
      source_normalization_factor;
503
  }
504

505
  // Finalize OpenMC
506
  openmc_simulation_finalize();
754✔
507

508
  // Output all simulation results
509
  output_simulation_results();
754✔
510

511
  // Toggle that the simulation object has been initialized after the first
512
  // simulation
513
  if (is_first_simulation_)
754✔
514
    is_first_simulation_ = false;
673✔
515
}
754✔
516

517
void RandomRaySimulation::output_simulation_results() const
754✔
518
{
519
  // Print random ray results
520
  if (mpi::master) {
754✔
521
    print_results_random_ray(total_geometric_intersections_,
519✔
522
      avg_miss_rate_ / settings::n_batches, negroups_,
519✔
523
      domain_->n_source_regions(), domain_->n_external_source_regions_);
519✔
524
    if (model::plots.size() > 0) {
519!
UNCOV
525
      domain_->output_to_vtk();
×
526
    }
527
  }
528
}
754✔
529

530
// Apply a few sanity checks to catch obvious cases of numerical instability.
531
// Instability typically only occurs if ray density is extremely low.
532
void RandomRaySimulation::instability_check(
12,332✔
533
  int64_t n_hits, double k_eff, double& avg_miss_rate) const
534
{
535
  double percent_missed = ((domain_->n_source_regions() - n_hits) /
12,332✔
536
                            static_cast<double>(domain_->n_source_regions())) *
12,332✔
537
                          100.0;
12,332✔
538
  avg_miss_rate += percent_missed;
12,332✔
539

540
  if (mpi::master) {
12,332!
541
    if (percent_missed > 10.0) {
12,332✔
542
      warning(fmt::format(
957✔
543
        "Very high FSR miss rate detected ({:.3f}%). Instability may occur. "
544
        "Increase ray density by adding more rays and/or active distance.",
545
        percent_missed));
546
    } else if (percent_missed > 1.0) {
11,375✔
547
      warning(
2!
548
        fmt::format("Elevated FSR miss rate detected ({:.3f}%). Increasing "
4!
549
                    "ray density by adding more rays and/or active "
550
                    "distance may improve simulation efficiency.",
551
          percent_missed));
552
    }
553

554
    if (k_eff > 10.0 || k_eff < 0.01 || !(std::isfinite(k_eff))) {
12,332!
UNCOV
555
      fatal_error(fmt::format("Instability detected: k-eff = {:.5f}", k_eff));
×
556
    }
557
  }
558
}
12,332✔
559

560
// Print random ray simulation results
561
void RandomRaySimulation::print_results_random_ray(
519✔
562
  uint64_t total_geometric_intersections, double avg_miss_rate, int negroups,
563
  int64_t n_source_regions, int64_t n_external_source_regions) const
564
{
565
  using namespace simulation;
566

567
  if (settings::verbosity >= 6) {
519!
568
    double total_integrations = total_geometric_intersections * negroups;
519✔
569
    double time_per_integration =
570
      simulation::time_transport.elapsed() / total_integrations;
519✔
571
    double misc_time = time_total.elapsed() - time_update_src.elapsed() -
519✔
572
                       time_transport.elapsed() - time_tallies.elapsed() -
519✔
573
                       time_bank_sendrecv.elapsed();
519✔
574

575
    header("Simulation Statistics", 4);
519✔
576
    fmt::print(
519✔
577
      " Total Iterations                  = {}\n", settings::n_batches);
578
    fmt::print(
519✔
579
      " Number of Rays per Iteration      = {}\n", settings::n_particles);
580
    fmt::print(" Inactive Distance                 = {} cm\n",
519✔
581
      RandomRay::distance_inactive_);
582
    fmt::print(" Active Distance                   = {} cm\n",
519✔
583
      RandomRay::distance_active_);
584
    fmt::print(" Source Regions (SRs)              = {}\n", n_source_regions);
519✔
585
    fmt::print(
425✔
586
      " SRs Containing External Sources   = {}\n", n_external_source_regions);
587
    fmt::print(" Total Geometric Intersections     = {:.4e}\n",
425✔
588
      static_cast<double>(total_geometric_intersections));
519✔
589
    fmt::print("   Avg per Iteration               = {:.4e}\n",
425✔
590
      static_cast<double>(total_geometric_intersections) / settings::n_batches);
519✔
591
    fmt::print("   Avg per Iteration per SR        = {:.2f}\n",
425✔
592
      static_cast<double>(total_geometric_intersections) /
519✔
593
        static_cast<double>(settings::n_batches) / n_source_regions);
1,038✔
594
    fmt::print(" Avg SR Miss Rate per Iteration    = {:.4f}%\n", avg_miss_rate);
519✔
595
    fmt::print(" Energy Groups                     = {}\n", negroups);
519✔
596
    fmt::print(
425✔
597
      " Total Integrations                = {:.4e}\n", total_integrations);
598
    fmt::print("   Avg per Iteration               = {:.4e}\n",
425✔
599
      total_integrations / settings::n_batches);
519✔
600

601
    std::string estimator;
519✔
602
    switch (domain_->volume_estimator_) {
519!
603
    case RandomRayVolumeEstimator::SIMULATION_AVERAGED:
22✔
604
      estimator = "Simulation Averaged";
22✔
605
      break;
22✔
606
    case RandomRayVolumeEstimator::NAIVE:
68✔
607
      estimator = "Naive";
68✔
608
      break;
68✔
609
    case RandomRayVolumeEstimator::HYBRID:
429✔
610
      estimator = "Hybrid";
429✔
611
      break;
429✔
612
    default:
×
613
      fatal_error("Invalid volume estimator type");
×
614
    }
615
    fmt::print(" Volume Estimator Type             = {}\n", estimator);
425✔
616

617
    std::string adjoint_true = (FlatSourceDomain::adjoint_) ? "ON" : "OFF";
1,557✔
618
    fmt::print(" Adjoint Flux Mode                 = {}\n", adjoint_true);
425✔
619

620
    std::string shape;
1,038✔
621
    switch (RandomRay::source_shape_) {
519!
622
    case RandomRaySourceShape::FLAT:
299✔
623
      shape = "Flat";
299✔
624
      break;
299✔
625
    case RandomRaySourceShape::LINEAR:
187✔
626
      shape = "Linear";
187✔
627
      break;
187✔
628
    case RandomRaySourceShape::LINEAR_XY:
33✔
629
      shape = "Linear XY";
33✔
630
      break;
33✔
UNCOV
631
    default:
×
UNCOV
632
      fatal_error("Invalid random ray source shape");
×
633
    }
634
    fmt::print(" Source Shape                      = {}\n", shape);
425✔
635
    std::string sample_method =
636
      (RandomRay::sample_method_ == RandomRaySampleMethod::PRNG) ? "PRNG"
519✔
637
                                                                 : "Halton";
1,557✔
638
    fmt::print(" Sample Method                     = {}\n", sample_method);
425✔
639

640
    if (domain_->is_transport_stabilization_needed_) {
519✔
641
      fmt::print(" Transport XS Stabilization Used   = YES (rho = {:.3f})\n",
11✔
642
        FlatSourceDomain::diagonal_stabilization_rho_);
643
    } else {
644
      fmt::print(" Transport XS Stabilization Used   = NO\n");
508✔
645
    }
646

647
    header("Timing Statistics", 4);
519✔
648
    show_time("Total time for initialization", time_initialize.elapsed());
519✔
649
    show_time("Reading cross sections", time_read_xs.elapsed(), 1);
519✔
650
    show_time("Total simulation time", time_total.elapsed());
519✔
651
    show_time("Transport sweep only", time_transport.elapsed(), 1);
519✔
652
    show_time("Source update only", time_update_src.elapsed(), 1);
519✔
653
    show_time("Tally conversion only", time_tallies.elapsed(), 1);
519✔
654
    show_time("MPI source reductions only", time_bank_sendrecv.elapsed(), 1);
519✔
655
    show_time("Other iteration routines", misc_time, 1);
519✔
656
    if (settings::run_mode == RunMode::EIGENVALUE) {
519✔
657
      show_time("Time in inactive batches", time_inactive.elapsed());
187✔
658
    }
659
    show_time("Time in active batches", time_active.elapsed());
519✔
660
    show_time("Time writing statepoints", time_statepoint.elapsed());
519✔
661
    show_time("Total time for finalization", time_finalize.elapsed());
519✔
662
    show_time("Time per integration", time_per_integration);
519✔
663
  }
519✔
664

665
  if (settings::verbosity >= 4 && settings::run_mode == RunMode::EIGENVALUE) {
519!
666
    header("Results", 4);
187✔
667
    fmt::print(" k-effective                       = {:.5f} +/- {:.5f}\n",
187✔
668
      simulation::keff, simulation::keff_std);
669
  }
670
}
519✔
671

672
} // namespace openmc
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