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

openmc-dev / openmc / 13763261523

10 Mar 2025 11:12AM UTC coverage: 85.133% (+0.004%) from 85.129%
13763261523

Pull #3252

github

web-flow
Merge bdc3a6ead into 906548db2
Pull Request #3252: Adding vtkhdf option to write vtk data

83 of 101 new or added lines in 1 file covered. (82.18%)

529 existing lines in 15 files now uncovered.

51616 of 60630 relevant lines covered (85.13%)

37229330.6 hits per line

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

88.81
/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()
480✔
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_;
480✔
34

35
  // Configure the domain for forward simulation
36
  FlatSourceDomain::adjoint_ = false;
480✔
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)
480✔
41
    header("FORWARD FLUX SOLVE", 3);
55✔
42

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

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

50
  // Declare forward flux so that it can be saved for later adjoint simulation
51
  vector<double> forward_flux;
480✔
52
  SourceRegionContainer forward_source_regions;
480✔
53
  SourceRegionContainer forward_base_source_regions;
480✔
54
  std::unordered_map<SourceRegionKey, int64_t, SourceRegionKey::HashFunctor>
55
    forward_source_region_map;
480✔
56

57
  {
58
    // Initialize Random Ray Simulation Object
59
    RandomRaySimulation sim;
480✔
60

61
    // Initialize fixed sources, if present
62
    sim.apply_fixed_sources_and_mesh_domains();
480✔
63

64
    // Begin main simulation timer
65
    simulation::time_total.start();
480✔
66

67
    // Execute random ray simulation
68
    sim.simulate();
480✔
69

70
    // End main simulation timer
71
    simulation::time_total.stop();
480✔
72

73
    // Normalize and save the final forward flux
74
    sim.domain()->serialize_final_fluxes(forward_flux);
480✔
75

76
    double source_normalization_factor =
77
      sim.domain()->compute_fixed_source_normalization_factor() /
480✔
78
      (settings::n_batches - settings::n_inactive);
480✔
79

80
#pragma omp parallel for
270✔
81
    for (uint64_t i = 0; i < forward_flux.size(); i++) {
1,016,790✔
82
      forward_flux[i] *= source_normalization_factor;
1,016,580✔
83
    }
84

85
    forward_source_regions = sim.domain()->source_regions_;
480✔
86
    forward_source_region_map = sim.domain()->source_region_map_;
480✔
87
    forward_base_source_regions = sim.domain()->base_source_regions_;
480✔
88

89
    // Finalize OpenMC
90
    openmc_simulation_finalize();
480✔
91

92
    // Output all simulation results
93
    sim.output_simulation_results();
480✔
94
  }
480✔
95

96
  //////////////////////////////////////////////////////////
97
  // Run adjoint simulation (if enabled)
98
  //////////////////////////////////////////////////////////
99

100
  if (adjoint_needed) {
480✔
101
    reset_timers();
80✔
102

103
    // Configure the domain for adjoint simulation
104
    FlatSourceDomain::adjoint_ = true;
80✔
105

106
    if (mpi::master)
80✔
107
      header("ADJOINT FLUX SOLVE", 3);
55✔
108

109
    // Initialize OpenMC general data structures
110
    openmc_simulation_init();
80✔
111

112
    // Initialize Random Ray Simulation Object
113
    RandomRaySimulation adjoint_sim;
80✔
114

115
    // Initialize adjoint fixed sources, if present
116
    adjoint_sim.prepare_fixed_sources_adjoint(forward_flux,
80✔
117
      forward_source_regions, forward_base_source_regions,
118
      forward_source_region_map);
119

120
    // Transpose scattering matrix
121
    adjoint_sim.domain()->transpose_scattering_matrix();
80✔
122

123
    // Swap nu_sigma_f and chi
124
    adjoint_sim.domain()->nu_sigma_f_.swap(adjoint_sim.domain()->chi_);
80✔
125

126
    // Begin main simulation timer
127
    simulation::time_total.start();
80✔
128

129
    // Execute random ray simulation
130
    adjoint_sim.simulate();
80✔
131

132
    // End main simulation timer
133
    simulation::time_total.stop();
80✔
134

135
    // Finalize OpenMC
136
    openmc_simulation_finalize();
80✔
137

138
    // Output all simulation results
139
    adjoint_sim.output_simulation_results();
80✔
140
  }
80✔
141
}
480✔
142

143
// Enforces restrictions on inputs in random ray mode.  While there are
144
// many features that don't make sense in random ray mode, and are therefore
145
// unsupported, we limit our testing/enforcement operations only to inputs
146
// that may cause erroneous/misleading output or crashes from the solver.
147
void validate_random_ray_inputs()
330✔
148
{
149
  // Validate tallies
150
  ///////////////////////////////////////////////////////////////////
151
  for (auto& tally : model::tallies) {
1,144✔
152

153
    // Validate score types
154
    for (auto score_bin : tally->scores_) {
1,804✔
155
      switch (score_bin) {
990✔
156
      case SCORE_FLUX:
990✔
157
      case SCORE_TOTAL:
158
      case SCORE_FISSION:
159
      case SCORE_NU_FISSION:
160
      case SCORE_EVENTS:
161
        break;
990✔
UNCOV
162
      default:
×
UNCOV
163
        fatal_error(
×
164
          "Invalid score specified. Only flux, total, fission, nu-fission, and "
165
          "event scores are supported in random ray mode.");
166
      }
167
    }
168

169
    // Validate filter types
170
    for (auto f : tally->filters()) {
1,782✔
171
      auto& filter = *model::tally_filters[f];
968✔
172

173
      switch (filter.type()) {
968✔
174
      case FilterType::CELL:
968✔
175
      case FilterType::CELL_INSTANCE:
176
      case FilterType::DISTRIBCELL:
177
      case FilterType::ENERGY:
178
      case FilterType::MATERIAL:
179
      case FilterType::MESH:
180
      case FilterType::UNIVERSE:
181
      case FilterType::PARTICLE:
182
        break;
968✔
UNCOV
183
      default:
×
UNCOV
184
        fatal_error("Invalid filter specified. Only cell, cell_instance, "
×
185
                    "distribcell, energy, material, mesh, and universe filters "
186
                    "are supported in random ray mode.");
187
      }
188
    }
189
  }
190

191
  // Validate MGXS data
192
  ///////////////////////////////////////////////////////////////////
193
  for (auto& material : data::mg.macro_xs_) {
1,210✔
194
    if (!material.is_isotropic) {
880✔
UNCOV
195
      fatal_error("Anisotropic MGXS detected. Only isotropic XS data sets "
×
196
                  "supported in random ray mode.");
197
    }
198
    if (material.get_xsdata().size() > 1) {
880✔
UNCOV
199
      fatal_error("Non-isothermal MGXS detected. Only isothermal XS data sets "
×
200
                  "supported in random ray mode.");
201
    }
202
    for (int g = 0; g < data::mg.num_energy_groups_; g++) {
2,816✔
203
      if (material.exists_in_model) {
1,936✔
204
        // Temperature and angle indices, if using multiple temperature
205
        // data sets and/or anisotropic data sets.
206
        // TODO: Currently assumes we are only using single temp/single angle
207
        // data.
208
        const int t = 0;
1,892✔
209
        const int a = 0;
1,892✔
210
        double sigma_t =
211
          material.get_xs(MgxsType::TOTAL, g, NULL, NULL, NULL, t, a);
1,892✔
212
        if (sigma_t <= 0.0) {
1,892✔
UNCOV
213
          fatal_error("No zero or negative total macroscopic cross sections "
×
214
                      "allowed in random ray mode. If the intention is to make "
215
                      "a void material, use a cell fill of 'None' instead.");
216
        }
217
      }
218
    }
219
  }
220

221
  // Validate ray source
222
  ///////////////////////////////////////////////////////////////////
223

224
  // Check for independent source
225
  IndependentSource* is =
226
    dynamic_cast<IndependentSource*>(RandomRay::ray_source_.get());
330✔
227
  if (!is) {
330✔
UNCOV
228
    fatal_error("Invalid ray source definition. Ray source must provided and "
×
229
                "be of type IndependentSource.");
230
  }
231

232
  // Check for box source
233
  SpatialDistribution* space_dist = is->space();
330✔
234
  SpatialBox* sb = dynamic_cast<SpatialBox*>(space_dist);
330✔
235
  if (!sb) {
330✔
UNCOV
236
    fatal_error(
×
237
      "Invalid ray source definition -- only box sources are allowed.");
238
  }
239

240
  // Check that box source is not restricted to fissionable areas
241
  if (sb->only_fissionable()) {
330✔
UNCOV
242
    fatal_error(
×
243
      "Invalid ray source definition -- fissionable spatial distribution "
244
      "not allowed.");
245
  }
246

247
  // Check for isotropic source
248
  UnitSphereDistribution* angle_dist = is->angle();
330✔
249
  Isotropic* id = dynamic_cast<Isotropic*>(angle_dist);
330✔
250
  if (!id) {
330✔
UNCOV
251
    fatal_error("Invalid ray source definition -- only isotropic sources are "
×
252
                "allowed.");
253
  }
254

255
  // Validate external sources
256
  ///////////////////////////////////////////////////////////////////
257
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
330✔
258
    if (model::external_sources.size() < 1) {
253✔
UNCOV
259
      fatal_error("Must provide a particle source (in addition to ray source) "
×
260
                  "in fixed source random ray mode.");
261
    }
262

263
    for (int i = 0; i < model::external_sources.size(); i++) {
506✔
264
      Source* s = model::external_sources[i].get();
253✔
265

266
      // Check for independent source
267
      IndependentSource* is = dynamic_cast<IndependentSource*>(s);
253✔
268

269
      if (!is) {
253✔
UNCOV
270
        fatal_error(
×
271
          "Only IndependentSource external source types are allowed in "
272
          "random ray mode");
273
      }
274

275
      // Check for isotropic source
276
      UnitSphereDistribution* angle_dist = is->angle();
253✔
277
      Isotropic* id = dynamic_cast<Isotropic*>(angle_dist);
253✔
278
      if (!id) {
253✔
UNCOV
279
        fatal_error(
×
280
          "Invalid source definition -- only isotropic external sources are "
281
          "allowed in random ray mode.");
282
      }
283

284
      // Validate that a domain ID was specified
285
      if (is->domain_ids().size() == 0) {
253✔
UNCOV
286
        fatal_error("Fixed sources must be specified by domain "
×
287
                    "id (cell, material, or universe) in random ray mode.");
288
      }
289

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

301
  // Validate plotting files
302
  ///////////////////////////////////////////////////////////////////
303
  for (int p = 0; p < model::plots.size(); p++) {
330✔
304

305
    // Get handle to OpenMC plot object
UNCOV
306
    Plot* openmc_plot = dynamic_cast<Plot*>(model::plots[p].get());
×
307

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

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

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

349
void openmc_reset_random_ray()
6,516✔
350
{
351
  FlatSourceDomain::volume_estimator_ = RandomRayVolumeEstimator::HYBRID;
6,516✔
352
  FlatSourceDomain::volume_normalized_flux_tallies_ = false;
6,516✔
353
  FlatSourceDomain::adjoint_ = false;
6,516✔
354
  FlatSourceDomain::mesh_domain_map_.clear();
6,516✔
355
  RandomRay::ray_source_.reset();
6,516✔
356
  RandomRay::source_shape_ = RandomRaySourceShape::FLAT;
6,516✔
357
  RandomRay::mesh_subdivision_enabled_ = false;
6,516✔
358
  RandomRay::sample_method_ = RandomRaySampleMethod::PRNG;
6,516✔
359
}
6,516✔
360

361
//==============================================================================
362
// RandomRaySimulation implementation
363
//==============================================================================
364

365
RandomRaySimulation::RandomRaySimulation()
560✔
366
  : negroups_(data::mg.num_energy_groups_)
560✔
367
{
368
  // There are no source sites in random ray mode, so be sure to disable to
369
  // ensure we don't attempt to write source sites to statepoint
370
  settings::source_write = false;
560✔
371

372
  // Random ray mode does not have an inner loop over generations within a
373
  // batch, so set the current gen to 1
374
  simulation::current_gen = 1;
560✔
375

376
  switch (RandomRay::source_shape_) {
560✔
377
  case RandomRaySourceShape::FLAT:
368✔
378
    domain_ = make_unique<FlatSourceDomain>();
368✔
379
    break;
368✔
380
  case RandomRaySourceShape::LINEAR:
192✔
381
  case RandomRaySourceShape::LINEAR_XY:
382
    domain_ = make_unique<LinearSourceDomain>();
192✔
383
    break;
192✔
UNCOV
384
  default:
×
UNCOV
385
    fatal_error("Unknown random ray source shape");
×
386
  }
387

388
  // Convert OpenMC native MGXS into a more efficient format
389
  // internal to the random ray solver
390
  domain_->flatten_xs();
560✔
391
}
560✔
392

393
void RandomRaySimulation::apply_fixed_sources_and_mesh_domains()
480✔
394
{
395
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
480✔
396
    // Transfer external source user inputs onto random ray source regions
397
    domain_->convert_external_sources();
368✔
398
    domain_->count_external_source_regions();
368✔
399
  }
400
  domain_->apply_meshes();
480✔
401
}
480✔
402

403
void RandomRaySimulation::prepare_fixed_sources_adjoint(
80✔
404
  vector<double>& forward_flux, SourceRegionContainer& forward_source_regions,
405
  SourceRegionContainer& forward_base_source_regions,
406
  std::unordered_map<SourceRegionKey, int64_t, SourceRegionKey::HashFunctor>&
407
    forward_source_region_map)
408
{
409
  if (settings::run_mode == RunMode::FIXED_SOURCE) {
80✔
410
    if (RandomRay::mesh_subdivision_enabled_) {
64✔
411
      domain_->source_regions_ = forward_source_regions;
32✔
412
      domain_->source_region_map_ = forward_source_region_map;
32✔
413
      domain_->base_source_regions_ = forward_base_source_regions;
32✔
414
      domain_->source_regions_.adjoint_reset();
32✔
415
    }
416
    domain_->set_adjoint_sources(forward_flux);
64✔
417
  }
418
}
80✔
419

420
void RandomRaySimulation::simulate()
560✔
421
{
422
  // Random ray power iteration loop
423
  while (simulation::current_batch < settings::n_batches) {
16,080✔
424
    // Initialize the current batch
425
    initialize_batch();
15,520✔
426
    initialize_generation();
15,520✔
427

428
    // MPI not supported in random ray solver, so all work is done by rank 0
429
    // TODO: Implement domain decomposition for MPI parallelism
430
    if (mpi::master) {
15,520✔
431

432
      // Reset total starting particle weight used for normalizing tallies
433
      simulation::total_weight = 1.0;
10,670✔
434

435
      // Update source term (scattering + fission)
436
      domain_->update_neutron_source(k_eff_);
10,670✔
437

438
      // Reset scalar fluxes, iteration volume tallies, and region hit flags to
439
      // zero
440
      domain_->batch_reset();
10,670✔
441

442
      // At the beginning of the simulation, if mesh subvivision is in use, we
443
      // need to swap the main source region container into the base container,
444
      // as the main source region container will be used to hold the true
445
      // subdivided source regions. The base container will therefore only
446
      // contain the external source region information, the mesh indices,
447
      // material properties, and initial guess values for the flux/source.
448
      if (RandomRay::mesh_subdivision_enabled_ &&
10,670✔
449
          simulation::current_batch == 1 && !FlatSourceDomain::adjoint_) {
2,090✔
450
        domain_->prepare_base_source_regions();
55✔
451
      }
452

453
      // Start timer for transport
454
      simulation::time_transport.start();
10,670✔
455

456
// Transport sweep over all random rays for the iteration
457
#pragma omp parallel for schedule(dynamic)                                     \
5,820✔
458
  reduction(+ : total_geometric_intersections_)
5,820✔
459
      for (int i = 0; i < settings::n_particles; i++) {
810,350✔
460
        RandomRay ray(i, domain_.get());
805,500✔
461
        total_geometric_intersections_ +=
805,500✔
462
          ray.transport_history_based_single_ray();
805,500✔
463
      }
805,500✔
464

465
      simulation::time_transport.stop();
10,670✔
466

467
      // If using mesh subdivision, add any newly discovered source regions
468
      // to the main source region container.
469
      if (RandomRay::mesh_subdivision_enabled_) {
10,670✔
470
        domain_->finalize_discovered_source_regions();
2,090✔
471
      }
472

473
      // Normalize scalar flux and update volumes
474
      domain_->normalize_scalar_flux_and_volumes(
10,670✔
475
        settings::n_particles * RandomRay::distance_active_);
476

477
      // Add source to scalar flux, compute number of FSR hits
478
      int64_t n_hits = domain_->add_source_to_scalar_flux();
10,670✔
479

480
      if (settings::run_mode == RunMode::EIGENVALUE) {
10,670✔
481
        // Compute random ray k-eff
482
        k_eff_ = domain_->compute_k_eff(k_eff_);
1,540✔
483

484
        // Store random ray k-eff into OpenMC's native k-eff variable
485
        global_tally_tracklength = k_eff_;
1,540✔
486
      }
487

488
      // Execute all tallying tasks, if this is an active batch
489
      if (simulation::current_batch > settings::n_inactive) {
10,670✔
490

491
        // Add this iteration's scalar flux estimate to final accumulated
492
        // estimate
493
        domain_->accumulate_iteration_flux();
4,290✔
494

495
        // Generate mapping between source regions and tallies
496
        if (!domain_->mapped_all_tallies_) {
4,290✔
497
          domain_->convert_source_regions_to_tallies();
385✔
498
        }
499

500
        // Use above mapping to contribute FSR flux data to appropriate
501
        // tallies
502
        domain_->random_ray_tally();
4,290✔
503
      }
504

505
      // Set phi_old = phi_new
506
      domain_->flux_swap();
10,670✔
507

508
      // Check for any obvious insabilities/nans/infs
509
      instability_check(n_hits, k_eff_, avg_miss_rate_);
10,670✔
510
    } // End MPI master work
511

512
    // Finalize the current batch
513
    finalize_generation();
15,520✔
514
    finalize_batch();
15,520✔
515
  } // End random ray power iteration loop
516
}
560✔
517

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

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

541
  if (mpi::master) {
10,670✔
542
    if (percent_missed > 10.0) {
10,670✔
543
      warning(fmt::format(
638✔
544
        "Very high FSR miss rate detected ({:.3f}%). Instability may occur. "
545
        "Increase ray density by adding more rays and/or active distance.",
546
        percent_missed));
547
    } else if (percent_missed > 1.0) {
10,032✔
UNCOV
548
      warning(
×
UNCOV
549
        fmt::format("Elevated FSR miss rate detected ({:.3f}%). Increasing "
×
550
                    "ray density by adding more rays and/or active "
551
                    "distance may improve simulation efficiency.",
552
          percent_missed));
553
    }
554

555
    if (k_eff > 10.0 || k_eff < 0.01 || !(std::isfinite(k_eff))) {
10,670✔
UNCOV
556
      fatal_error("Instability detected");
×
557
    }
558
  }
559
}
10,670✔
560

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

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

576
    header("Simulation Statistics", 4);
385✔
577
    fmt::print(
385✔
578
      " Total Iterations                  = {}\n", settings::n_batches);
579
    fmt::print(" Flat Source Regions (FSRs)        = {}\n", n_source_regions);
385✔
580
    fmt::print(
315✔
581
      " FSRs Containing External Sources  = {}\n", n_external_source_regions);
582
    fmt::print(" Total Geometric Intersections     = {:.4e}\n",
315✔
583
      static_cast<double>(total_geometric_intersections));
385✔
584
    fmt::print("   Avg per Iteration               = {:.4e}\n",
315✔
585
      static_cast<double>(total_geometric_intersections) / settings::n_batches);
385✔
586
    fmt::print("   Avg per Iteration per FSR       = {:.2f}\n",
315✔
587
      static_cast<double>(total_geometric_intersections) /
385✔
588
        static_cast<double>(settings::n_batches) / n_source_regions);
770✔
589
    fmt::print(" Avg FSR Miss Rate per Iteration   = {:.4f}%\n", avg_miss_rate);
385✔
590
    fmt::print(" Energy Groups                     = {}\n", negroups);
385✔
591
    fmt::print(
315✔
592
      " Total Integrations                = {:.4e}\n", total_integrations);
593
    fmt::print("   Avg per Iteration               = {:.4e}\n",
315✔
594
      total_integrations / settings::n_batches);
385✔
595

596
    std::string estimator;
385✔
597
    switch (domain_->volume_estimator_) {
385✔
598
    case RandomRayVolumeEstimator::SIMULATION_AVERAGED:
22✔
599
      estimator = "Simulation Averaged";
22✔
600
      break;
22✔
601
    case RandomRayVolumeEstimator::NAIVE:
66✔
602
      estimator = "Naive";
66✔
603
      break;
66✔
604
    case RandomRayVolumeEstimator::HYBRID:
297✔
605
      estimator = "Hybrid";
297✔
606
      break;
297✔
UNCOV
607
    default:
×
UNCOV
608
      fatal_error("Invalid volume estimator type");
×
609
    }
610
    fmt::print(" Volume Estimator Type             = {}\n", estimator);
315✔
611

612
    std::string adjoint_true = (FlatSourceDomain::adjoint_) ? "ON" : "OFF";
1,155✔
613
    fmt::print(" Adjoint Flux Mode                 = {}\n", adjoint_true);
315✔
614

615
    header("Timing Statistics", 4);
385✔
616
    show_time("Total time for initialization", time_initialize.elapsed());
385✔
617
    show_time("Reading cross sections", time_read_xs.elapsed(), 1);
385✔
618
    show_time("Total simulation time", time_total.elapsed());
385✔
619
    show_time("Transport sweep only", time_transport.elapsed(), 1);
385✔
620
    show_time("Source update only", time_update_src.elapsed(), 1);
385✔
621
    show_time("Tally conversion only", time_tallies.elapsed(), 1);
385✔
622
    show_time("MPI source reductions only", time_bank_sendrecv.elapsed(), 1);
385✔
623
    show_time("Other iteration routines", misc_time, 1);
385✔
624
    if (settings::run_mode == RunMode::EIGENVALUE) {
385✔
625
      show_time("Time in inactive batches", time_inactive.elapsed());
88✔
626
    }
627
    show_time("Time in active batches", time_active.elapsed());
385✔
628
    show_time("Time writing statepoints", time_statepoint.elapsed());
385✔
629
    show_time("Total time for finalization", time_finalize.elapsed());
385✔
630
    show_time("Time per integration", time_per_integration);
385✔
631
  }
385✔
632

633
  if (settings::verbosity >= 4 && settings::run_mode == RunMode::EIGENVALUE) {
385✔
634
    header("Results", 4);
88✔
635
    fmt::print(" k-effective                       = {:.5f} +/- {:.5f}\n",
88✔
636
      simulation::keff, simulation::keff_std);
637
  }
638
}
385✔
639

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

© 2025 Coveralls, Inc