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

openmc-dev / openmc / 17929219513

22 Sep 2025 09:36PM UTC coverage: 85.119% (-0.08%) from 85.197%
17929219513

Pull #3576

github

web-flow
Merge a2e2adf20 into ca63da91b
Pull Request #3576: Random Ray Base Source Region Refactor

159 of 166 new or added lines in 6 files covered. (95.78%)

48 existing lines in 5 files now uncovered.

53066 of 62343 relevant lines covered (85.12%)

40618625.22 hits per line

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

88.19
/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()
596✔
26
{
27
  //////////////////////////////////////////////////////////
28
  // Run forward simulation
29
  //////////////////////////////////////////////////////////
30

31
  // Check if adjoint calculation is needed. If it is, we will run the forward
32
  // calculation first and then the adjoint calculation later.
33
  bool adjoint_needed = FlatSourceDomain::adjoint_;
596✔
34

35
  // Configure the domain for forward simulation
36
  FlatSourceDomain::adjoint_ = false;
596✔
37

38
  // If we're going to do an adjoint simulation afterwards, report that this is
39
  // the initial forward flux solve.
40
  if (adjoint_needed && mpi::master)
596✔
41
    header("FORWARD FLUX SOLVE", 3);
61✔
42

43
  // Initialize OpenMC general data structures
44
  openmc_simulation_init();
596✔
45

46
  // Validate that inputs meet requirements for random ray mode
47
  if (mpi::master)
596✔
48
    validate_random_ray_inputs();
421✔
49

50
  // Initialize Random Ray Simulation Object
51
  RandomRaySimulation sim;
596✔
52

53
  // Initialize fixed sources, if present
54
  sim.apply_fixed_sources_and_mesh_domains();
596✔
55

56
  // Begin main simulation timer
57
  simulation::time_total.start();
596✔
58

59
  // Execute random ray simulation
60
  sim.simulate();
596✔
61

62
  // End main simulation timer
63
  simulation::time_total.stop();
596✔
64

65
  // Normalize and save the final forward flux
66
  double source_normalization_factor =
67
    sim.domain()->compute_fixed_source_normalization_factor() /
596✔
68
    (settings::n_batches - settings::n_inactive);
596✔
69

70
#pragma omp parallel for
316✔
71
  for (uint64_t se = 0; se < sim.domain()->n_source_elements(); se++) {
1,380,976✔
72
    sim.domain()->source_regions_.scalar_flux_final(se) *=
1,380,696✔
73
      source_normalization_factor;
74
  }
75

76
  // Finalize OpenMC
77
  openmc_simulation_finalize();
596✔
78

79
  // Output all simulation results
80
  sim.output_simulation_results();
596✔
81

82
  //////////////////////////////////////////////////////////
83
  // Run adjoint simulation (if enabled)
84
  //////////////////////////////////////////////////////////
85

86
  if (!adjoint_needed) {
596✔
87
    return;
510✔
88
  }
89

90
  reset_timers();
86✔
91

92
  // Configure the domain for adjoint simulation
93
  FlatSourceDomain::adjoint_ = true;
86✔
94

95
  if (mpi::master)
86✔
96
    header("ADJOINT FLUX SOLVE", 3);
61✔
97

98
  // Initialize OpenMC general data structures
99
  openmc_simulation_init();
86✔
100

101
  sim.domain()->k_eff_ = 1.0;
86✔
102

103
  // Initialize adjoint fixed sources, if present
104
  sim.prepare_fixed_sources_adjoint();
86✔
105

106
  // Transpose scattering matrix
107
  sim.domain()->transpose_scattering_matrix();
86✔
108

109
  // Swap nu_sigma_f and chi
110
  sim.domain()->nu_sigma_f_.swap(sim.domain()->chi_);
86✔
111

112
  // Begin main simulation timer
113
  simulation::time_total.start();
86✔
114

115
  // Execute random ray simulation
116
  sim.simulate();
86✔
117

118
  // End main simulation timer
119
  simulation::time_total.stop();
86✔
120

121
  // Finalize OpenMC
122
  openmc_simulation_finalize();
86✔
123

124
  // Output all simulation results
125
  sim.output_simulation_results();
86✔
126
}
596✔
127

128
// Enforces restrictions on inputs in random ray mode.  While there are
129
// many features that don't make sense in random ray mode, and are therefore
130
// unsupported, we limit our testing/enforcement operations only to inputs
131
// that may cause erroneous/misleading output or crashes from the solver.
132
void validate_random_ray_inputs()
421✔
133
{
134
  // Validate tallies
135
  ///////////////////////////////////////////////////////////////////
136
  for (auto& tally : model::tallies) {
1,346✔
137

138
    // Validate score types
139
    for (auto score_bin : tally->scores_) {
2,042✔
140
      switch (score_bin) {
1,117✔
141
      case SCORE_FLUX:
1,117✔
142
      case SCORE_TOTAL:
143
      case SCORE_FISSION:
144
      case SCORE_NU_FISSION:
145
      case SCORE_EVENTS:
146
        break;
1,117✔
147
      default:
×
148
        fatal_error(
×
149
          "Invalid score specified. Only flux, total, fission, nu-fission, and "
150
          "event scores are supported in random ray mode.");
151
      }
152
    }
153

154
    // Validate filter types
155
    for (auto f : tally->filters()) {
2,020✔
156
      auto& filter = *model::tally_filters[f];
1,095✔
157

158
      switch (filter.type()) {
1,095✔
159
      case FilterType::CELL:
1,095✔
160
      case FilterType::CELL_INSTANCE:
161
      case FilterType::DISTRIBCELL:
162
      case FilterType::ENERGY:
163
      case FilterType::MATERIAL:
164
      case FilterType::MESH:
165
      case FilterType::UNIVERSE:
166
      case FilterType::PARTICLE:
167
        break;
1,095✔
168
      default:
×
169
        fatal_error("Invalid filter specified. Only cell, cell_instance, "
×
170
                    "distribcell, energy, material, mesh, and universe filters "
171
                    "are supported in random ray mode.");
172
      }
173
    }
174
  }
175

176
  // Validate MGXS data
177
  ///////////////////////////////////////////////////////////////////
178
  for (auto& material : data::mg.macro_xs_) {
1,562✔
179
    if (!material.is_isotropic) {
1,141✔
180
      fatal_error("Anisotropic MGXS detected. Only isotropic XS data sets "
×
181
                  "supported in random ray mode.");
182
    }
183
    if (material.get_xsdata().size() > 1) {
1,141✔
184
      warning("Non-isothermal MGXS detected. Only isothermal XS data sets "
×
185
              "supported in random ray mode. Using lowest temperature.");
186
    }
187
    for (int g = 0; g < data::mg.num_energy_groups_; g++) {
6,027✔
188
      if (material.exists_in_model) {
4,886✔
189
        // Temperature and angle indices, if using multiple temperature
190
        // data sets and/or anisotropic data sets.
191
        // TODO: Currently assumes we are only using single temp/single angle
192
        // data.
193
        const int t = 0;
4,838✔
194
        const int a = 0;
4,838✔
195
        double sigma_t =
196
          material.get_xs(MgxsType::TOTAL, g, NULL, NULL, NULL, t, a);
4,838✔
197
        if (sigma_t <= 0.0) {
4,838✔
198
          fatal_error("No zero or negative total macroscopic cross sections "
×
199
                      "allowed in random ray mode. If the intention is to make "
200
                      "a void material, use a cell fill of 'None' instead.");
201
        }
202
      }
203
    }
204
  }
205

206
  // Validate ray source
207
  ///////////////////////////////////////////////////////////////////
208

209
  // Check for independent source
210
  IndependentSource* is =
211
    dynamic_cast<IndependentSource*>(RandomRay::ray_source_.get());
421✔
212
  if (!is) {
421✔
213
    fatal_error("Invalid ray source definition. Ray source must provided and "
×
214
                "be of type IndependentSource.");
215
  }
216

217
  // Check for box source
218
  SpatialDistribution* space_dist = is->space();
421✔
219
  SpatialBox* sb = dynamic_cast<SpatialBox*>(space_dist);
421✔
220
  if (!sb) {
421✔
221
    fatal_error(
×
222
      "Invalid ray source definition -- only box sources are allowed.");
223
  }
224

225
  // Check that box source is not restricted to fissionable areas
226
  if (sb->only_fissionable()) {
421✔
227
    fatal_error(
×
228
      "Invalid ray source definition -- fissionable spatial distribution "
229
      "not allowed.");
230
  }
231

232
  // Check for isotropic source
233
  UnitSphereDistribution* angle_dist = is->angle();
421✔
234
  Isotropic* id = dynamic_cast<Isotropic*>(angle_dist);
421✔
235
  if (!id) {
421✔
236
    fatal_error("Invalid ray source definition -- only isotropic sources are "
×
237
                "allowed.");
238
  }
239

240
  // Validate external sources
241
  ///////////////////////////////////////////////////////////////////
242
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
421✔
243
    if (model::external_sources.size() < 1) {
289✔
244
      fatal_error("Must provide a particle source (in addition to ray source) "
×
245
                  "in fixed source random ray mode.");
246
    }
247

248
    for (int i = 0; i < model::external_sources.size(); i++) {
578✔
249
      Source* s = model::external_sources[i].get();
289✔
250

251
      // Check for independent source
252
      IndependentSource* is = dynamic_cast<IndependentSource*>(s);
289✔
253

254
      if (!is) {
289✔
255
        fatal_error(
×
256
          "Only IndependentSource external source types are allowed in "
257
          "random ray mode");
258
      }
259

260
      // Check for isotropic source
261
      UnitSphereDistribution* angle_dist = is->angle();
289✔
262
      Isotropic* id = dynamic_cast<Isotropic*>(angle_dist);
289✔
263
      if (!id) {
289✔
264
        fatal_error(
×
265
          "Invalid source definition -- only isotropic external sources are "
266
          "allowed in random ray mode.");
267
      }
268

269
      // Validate that a domain ID was specified OR that it is a point source
270
      auto sp = dynamic_cast<SpatialPoint*>(is->space());
289✔
271
      if (is->domain_ids().size() == 0 && !sp) {
289✔
272
        fatal_error("Fixed sources must be point source or spatially "
×
273
                    "constrained by domain id (cell, material, or universe) in "
274
                    "random ray mode.");
275
      } else if (is->domain_ids().size() > 0 && sp) {
289✔
276
        // If both a domain constraint and a non-default point source location
277
        // are specified, notify user that domain constraint takes precedence.
278
        if (sp->r().x == 0.0 && sp->r().y == 0.0 && sp->r().z == 0.0) {
252✔
279
          warning("Fixed source has both a domain constraint and a point "
252✔
280
                  "type spatial distribution. The domain constraint takes "
281
                  "precedence in random ray mode -- point source coordinate "
282
                  "will be ignored.");
283
        }
284
      }
285

286
      // Check that a discrete energy distribution was used
287
      Distribution* d = is->energy();
289✔
288
      Discrete* dd = dynamic_cast<Discrete*>(d);
289✔
289
      if (!dd) {
289✔
290
        fatal_error(
×
291
          "Only discrete (multigroup) energy distributions are allowed for "
292
          "external sources in random ray mode.");
293
      }
294
    }
295
  }
296

297
  // Validate plotting files
298
  ///////////////////////////////////////////////////////////////////
299
  for (int p = 0; p < model::plots.size(); p++) {
421✔
300

301
    // Get handle to OpenMC plot object
302
    const auto& openmc_plottable = model::plots[p];
×
303
    Plot* openmc_plot = dynamic_cast<Plot*>(openmc_plottable.get());
×
304

305
    // Random ray plots only support voxel plots
306
    if (!openmc_plot) {
×
307
      warning(fmt::format(
×
308
        "Plot {} will not be used for end of simulation data plotting -- only "
309
        "voxel plotting is allowed in random ray mode.",
310
        openmc_plottable->id()));
×
311
      continue;
×
312
    } else if (openmc_plot->type_ != Plot::PlotType::voxel) {
×
313
      warning(fmt::format(
×
314
        "Plot {} will not be used for end of simulation data plotting -- only "
315
        "voxel plotting is allowed in random ray mode.",
316
        openmc_plottable->id()));
×
317
      continue;
×
318
    }
319
  }
320

321
  // Warn about slow MPI domain replication, if detected
322
  ///////////////////////////////////////////////////////////////////
323
#ifdef OPENMC_MPI
324
  if (mpi::n_procs > 1) {
176✔
325
    warning(
175✔
326
      "MPI parallelism is not supported by the random ray solver. All work "
327
      "will be performed by rank 0. Domain decomposition may be implemented in "
328
      "the future to provide efficient MPI scaling.");
329
  }
330
#endif
331

332
  // Warn about instability resulting from linear sources in small regions
333
  // when generating weight windows with FW-CADIS and an overlaid mesh.
334
  ///////////////////////////////////////////////////////////////////
335
  if (RandomRay::source_shape_ == RandomRaySourceShape::LINEAR &&
565✔
336
      variance_reduction::weight_windows.size() > 0) {
144✔
337
    warning(
12✔
338
      "Linear sources may result in negative fluxes in small source regions "
339
      "generated by mesh subdivision. Negative sources may result in low "
340
      "quality FW-CADIS weight windows. We recommend you use flat source mode "
341
      "when generating weight windows with an overlaid mesh tally.");
342
  }
343
}
421✔
344

345
void openmc_reset_random_ray()
8,532✔
346
{
347
  FlatSourceDomain::volume_estimator_ = RandomRayVolumeEstimator::HYBRID;
8,532✔
348
  FlatSourceDomain::volume_normalized_flux_tallies_ = false;
8,532✔
349
  FlatSourceDomain::adjoint_ = false;
8,532✔
350
  FlatSourceDomain::mesh_domain_map_.clear();
8,532✔
351
  RandomRay::ray_source_.reset();
8,532✔
352
  RandomRay::source_shape_ = RandomRaySourceShape::FLAT;
8,532✔
353
  RandomRay::sample_method_ = RandomRaySampleMethod::PRNG;
8,532✔
354
}
8,532✔
355

356
//==============================================================================
357
// RandomRaySimulation implementation
358
//==============================================================================
359

360
RandomRaySimulation::RandomRaySimulation()
596✔
361
  : negroups_(data::mg.num_energy_groups_)
596✔
362
{
363
  // There are no source sites in random ray mode, so be sure to disable to
364
  // ensure we don't attempt to write source sites to statepoint
365
  settings::source_write = false;
596✔
366

367
  // Random ray mode does not have an inner loop over generations within a
368
  // batch, so set the current gen to 1
369
  simulation::current_gen = 1;
596✔
370

371
  switch (RandomRay::source_shape_) {
596✔
372
  case RandomRaySourceShape::FLAT:
341✔
373
    domain_ = make_unique<FlatSourceDomain>();
341✔
374
    break;
341✔
375
  case RandomRaySourceShape::LINEAR:
255✔
376
  case RandomRaySourceShape::LINEAR_XY:
377
    domain_ = make_unique<LinearSourceDomain>();
255✔
378
    break;
255✔
379
  default:
×
380
    fatal_error("Unknown random ray source shape");
×
381
  }
382

383
  // Convert OpenMC native MGXS into a more efficient format
384
  // internal to the random ray solver
385
  domain_->flatten_xs();
596✔
386
}
596✔
387

388
void RandomRaySimulation::apply_fixed_sources_and_mesh_domains()
596✔
389
{
390
  domain_->apply_meshes();
596✔
391
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
596✔
392
    // Transfer external source user inputs onto random ray source regions
393
    domain_->convert_external_sources();
409✔
394
    domain_->count_external_source_regions();
409✔
395
  }
396
}
596✔
397

398
void RandomRaySimulation::prepare_fixed_sources_adjoint()
86✔
399
{
400
  domain_->source_regions_.adjoint_reset();
86✔
401
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
86✔
402
    domain_->set_adjoint_sources();
69✔
403
  }
404
}
86✔
405

406
void RandomRaySimulation::simulate()
682✔
407
{
408
  // Random ray power iteration loop
409
  while (simulation::current_batch < settings::n_batches) {
18,544✔
410
    // Initialize the current batch
411
    initialize_batch();
17,862✔
412
    initialize_generation();
17,862✔
413

414
    // MPI not supported in random ray solver, so all work is done by rank 0
415
    // TODO: Implement domain decomposition for MPI parallelism
416
    if (mpi::master) {
17,862✔
417

418
      // Reset total starting particle weight used for normalizing tallies
419
      simulation::total_weight = 1.0;
12,612✔
420

421
      // Update source term (scattering + fission)
422
      domain_->update_all_neutron_sources();
12,612✔
423

424
      // Reset scalar fluxes, iteration volume tallies, and region hit flags
425
      // to zero
426
      domain_->batch_reset();
12,612✔
427

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

435
      // Start timer for transport
436
      simulation::time_transport.start();
12,612✔
437

438
// Transport sweep over all random rays for the iteration
439
#pragma omp parallel for schedule(dynamic)                                     \
6,312✔
440
  reduction(+ : total_geometric_intersections_)
6,312✔
441
      for (int i = 0; i < settings::n_particles; i++) {
1,019,100✔
442
        RandomRay ray(i, domain_.get());
1,012,800✔
443
        total_geometric_intersections_ +=
1,012,800✔
444
          ray.transport_history_based_single_ray();
1,012,800✔
445
      }
1,012,800✔
446

447
      simulation::time_transport.stop();
12,612✔
448

449
      // Add any newly discovered source regions to the main source region
450
      // container.
451
      domain_->finalize_discovered_source_regions();
12,612✔
452

453
      // Normalize scalar flux and update volumes
454
      domain_->normalize_scalar_flux_and_volumes(
12,612✔
455
        settings::n_particles * RandomRay::distance_active_);
456

457
      // Add source to scalar flux, compute number of FSR hits
458
      int64_t n_hits = domain_->add_source_to_scalar_flux();
12,612✔
459

460
      // Apply transport stabilization factors
461
      domain_->apply_transport_stabilization();
12,612✔
462

463
      if (settings::run_mode == RunMode::EIGENVALUE) {
12,612✔
464
        // Compute random ray k-eff
465
        domain_->compute_k_eff();
2,280✔
466

467
        // Store random ray k-eff into OpenMC's native k-eff variable
468
        global_tally_tracklength = domain_->k_eff_;
2,280✔
469
      }
470

471
      // Execute all tallying tasks, if this is an active batch
472
      if (simulation::current_batch > settings::n_inactive) {
12,612✔
473

474
        // Add this iteration's scalar flux estimate to final accumulated
475
        // estimate
476
        domain_->accumulate_iteration_flux();
5,106✔
477

478
        // Use above mapping to contribute FSR flux data to appropriate
479
        // tallies
480
        domain_->random_ray_tally();
5,106✔
481
      }
482

483
      // Set phi_old = phi_new
484
      domain_->flux_swap();
12,612✔
485

486
      // Check for any obvious insabilities/nans/infs
487
      instability_check(n_hits, domain_->k_eff_, avg_miss_rate_);
12,612✔
488
    } // End MPI master work
489

490
    // Finalize the current batch
491
    finalize_generation();
17,862✔
492
    finalize_batch();
17,862✔
493
  } // End random ray power iteration loop
494

495
  domain_->count_external_source_regions();
682✔
496
}
682✔
497

498
void RandomRaySimulation::output_simulation_results() const
682✔
499
{
500
  // Print random ray results
501
  if (mpi::master) {
682✔
502
    print_results_random_ray(total_geometric_intersections_,
482✔
503
      avg_miss_rate_ / settings::n_batches, negroups_,
482✔
504
      domain_->n_source_regions(), domain_->n_external_source_regions_);
482✔
505
    if (model::plots.size() > 0) {
482✔
506
      domain_->output_to_vtk();
×
507
    }
508
  }
509
}
682✔
510

511
// Apply a few sanity checks to catch obvious cases of numerical instability.
512
// Instability typically only occurs if ray density is extremely low.
513
void RandomRaySimulation::instability_check(
12,612✔
514
  int64_t n_hits, double k_eff, double& avg_miss_rate) const
515
{
516
  double percent_missed = ((domain_->n_source_regions() - n_hits) /
12,612✔
517
                            static_cast<double>(domain_->n_source_regions())) *
12,612✔
518
                          100.0;
12,612✔
519
  avg_miss_rate += percent_missed;
12,612✔
520

521
  if (mpi::master) {
12,612✔
522
    if (percent_missed > 10.0) {
12,612✔
523
      warning(fmt::format(
1,044✔
524
        "Very high FSR miss rate detected ({:.3f}%). Instability may occur. "
525
        "Increase ray density by adding more rays and/or active distance.",
526
        percent_missed));
527
    } else if (percent_missed > 1.0) {
11,568✔
528
      warning(
2✔
529
        fmt::format("Elevated FSR miss rate detected ({:.3f}%). Increasing "
4✔
530
                    "ray density by adding more rays and/or active "
531
                    "distance may improve simulation efficiency.",
532
          percent_missed));
533
    }
534

535
    if (k_eff > 10.0 || k_eff < 0.01 || !(std::isfinite(k_eff))) {
12,612✔
NEW
536
      fatal_error(fmt::format("Instability detected: k-eff = {:.5f}", k_eff));
×
537
    }
538
  }
539
}
12,612✔
540

541
// Print random ray simulation results
542
void RandomRaySimulation::print_results_random_ray(
482✔
543
  uint64_t total_geometric_intersections, double avg_miss_rate, int negroups,
544
  int64_t n_source_regions, int64_t n_external_source_regions) const
545
{
546
  using namespace simulation;
547

548
  if (settings::verbosity >= 6) {
482✔
549
    double total_integrations = total_geometric_intersections * negroups;
482✔
550
    double time_per_integration =
551
      simulation::time_transport.elapsed() / total_integrations;
482✔
552
    double misc_time = time_total.elapsed() - time_update_src.elapsed() -
482✔
553
                       time_transport.elapsed() - time_tallies.elapsed() -
482✔
554
                       time_bank_sendrecv.elapsed();
482✔
555

556
    header("Simulation Statistics", 4);
482✔
557
    fmt::print(
482✔
558
      " Total Iterations                  = {}\n", settings::n_batches);
559
    fmt::print(
482✔
560
      " Number of Rays per Iteration      = {}\n", settings::n_particles);
561
    fmt::print(" Inactive Distance                 = {} cm\n",
482✔
562
      RandomRay::distance_inactive_);
563
    fmt::print(" Active Distance                   = {} cm\n",
482✔
564
      RandomRay::distance_active_);
565
    fmt::print(" Source Regions (SRs)              = {}\n", n_source_regions);
482✔
566
    fmt::print(
402✔
567
      " SRs Containing External Sources   = {}\n", n_external_source_regions);
568
    fmt::print(" Total Geometric Intersections     = {:.4e}\n",
402✔
569
      static_cast<double>(total_geometric_intersections));
482✔
570
    fmt::print("   Avg per Iteration               = {:.4e}\n",
402✔
571
      static_cast<double>(total_geometric_intersections) / settings::n_batches);
482✔
572
    fmt::print("   Avg per Iteration per SR        = {:.2f}\n",
402✔
573
      static_cast<double>(total_geometric_intersections) /
482✔
574
        static_cast<double>(settings::n_batches) / n_source_regions);
964✔
575
    fmt::print(" Avg SR Miss Rate per Iteration    = {:.4f}%\n", avg_miss_rate);
482✔
576
    fmt::print(" Energy Groups                     = {}\n", negroups);
482✔
577
    fmt::print(
402✔
578
      " Total Integrations                = {:.4e}\n", total_integrations);
579
    fmt::print("   Avg per Iteration               = {:.4e}\n",
402✔
580
      total_integrations / settings::n_batches);
482✔
581

582
    std::string estimator;
482✔
583
    switch (domain_->volume_estimator_) {
482✔
584
    case RandomRayVolumeEstimator::SIMULATION_AVERAGED:
24✔
585
      estimator = "Simulation Averaged";
24✔
586
      break;
24✔
587
    case RandomRayVolumeEstimator::NAIVE:
74✔
588
      estimator = "Naive";
74✔
589
      break;
74✔
590
    case RandomRayVolumeEstimator::HYBRID:
384✔
591
      estimator = "Hybrid";
384✔
592
      break;
384✔
593
    default:
×
594
      fatal_error("Invalid volume estimator type");
×
595
    }
596
    fmt::print(" Volume Estimator Type             = {}\n", estimator);
402✔
597

598
    std::string adjoint_true = (FlatSourceDomain::adjoint_) ? "ON" : "OFF";
1,446✔
599
    fmt::print(" Adjoint Flux Mode                 = {}\n", adjoint_true);
402✔
600

601
    std::string shape;
964✔
602
    switch (RandomRay::source_shape_) {
482✔
603
    case RandomRaySourceShape::FLAT:
290✔
604
      shape = "Flat";
290✔
605
      break;
290✔
606
    case RandomRaySourceShape::LINEAR:
156✔
607
      shape = "Linear";
156✔
608
      break;
156✔
609
    case RandomRaySourceShape::LINEAR_XY:
36✔
610
      shape = "Linear XY";
36✔
611
      break;
36✔
612
    default:
×
613
      fatal_error("Invalid random ray source shape");
×
614
    }
615
    fmt::print(" Source Shape                      = {}\n", shape);
402✔
616
    std::string sample_method =
617
      (RandomRay::sample_method_ == RandomRaySampleMethod::PRNG) ? "PRNG"
482✔
618
                                                                 : "Halton";
1,446✔
619
    fmt::print(" Sample Method                     = {}\n", sample_method);
402✔
620

621
    if (domain_->is_transport_stabilization_needed_) {
482✔
622
      fmt::print(" Transport XS Stabilization Used   = YES (rho = {:.3f})\n",
12✔
623
        FlatSourceDomain::diagonal_stabilization_rho_);
624
    } else {
625
      fmt::print(" Transport XS Stabilization Used   = NO\n");
470✔
626
    }
627

628
    header("Timing Statistics", 4);
482✔
629
    show_time("Total time for initialization", time_initialize.elapsed());
482✔
630
    show_time("Reading cross sections", time_read_xs.elapsed(), 1);
482✔
631
    show_time("Total simulation time", time_total.elapsed());
482✔
632
    show_time("Transport sweep only", time_transport.elapsed(), 1);
482✔
633
    show_time("Source update only", time_update_src.elapsed(), 1);
482✔
634
    show_time("Tally conversion only", time_tallies.elapsed(), 1);
482✔
635
    show_time("MPI source reductions only", time_bank_sendrecv.elapsed(), 1);
482✔
636
    show_time("Other iteration routines", misc_time, 1);
482✔
637
    if (settings::run_mode == RunMode::EIGENVALUE) {
482✔
638
      show_time("Time in inactive batches", time_inactive.elapsed());
144✔
639
    }
640
    show_time("Time in active batches", time_active.elapsed());
482✔
641
    show_time("Time writing statepoints", time_statepoint.elapsed());
482✔
642
    show_time("Total time for finalization", time_finalize.elapsed());
482✔
643
    show_time("Time per integration", time_per_integration);
482✔
644
  }
482✔
645

646
  if (settings::verbosity >= 4 && settings::run_mode == RunMode::EIGENVALUE) {
482✔
647
    header("Results", 4);
144✔
648
    fmt::print(" k-effective                       = {:.5f} +/- {:.5f}\n",
144✔
649
      simulation::keff, simulation::keff_std);
650
  }
651
}
482✔
652

653
} // 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