Skip to content

Commit 85db78b

Browse files
committed
quality of life updates
- PROPOGATION -> PROPAGATION - Write random ray data to HDF5 - Write some extra HDF5 data - Typo fixes
1 parent 4e04a33 commit 85db78b

10 files changed

Lines changed: 74 additions & 28 deletions

File tree

include/openmc/constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ enum class SolverType { MONTE_CARLO, RANDOM_RAY };
370370
enum class RandomRayVolumeEstimator { NAIVE, SIMULATION_AVERAGED, HYBRID };
371371
enum class RandomRaySourceShape { FLAT, LINEAR, LINEAR_XY };
372372
enum class RandomRaySampleMethod { PRNG, HALTON };
373-
enum class RandomRayTimeMethod { ISOTROPIC, PROPOGATION };
373+
enum class RandomRayTimeMethod { ISOTROPIC, PROPAGATION };
374374

375375
//==============================================================================
376376
// Geometry Constants

include/openmc/random_ray/random_ray_simulation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ void rename_tallies_file(int i);
7373

7474
} // namespace openmc
7575

76-
#endif // OPENMC_RANDOM_RAY_SIMUgATION_H
76+
#endif // OPENMC_RANDOM_RAY_SIMULATION_H

openmc/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class Settings:
233233
:time_derivative_method:
234234
Method for resolving :math:`\\frac{\\partial}{\\partial t}
235235
\\psi_{r,g}(s,t)` in the time-dependent charactersitic equation.
236-
Options are 'isotropic' (default), or 'propogation'.
236+
Options are 'isotropic' (default), or 'propagation'.
237237
238238
.. versionadded:: 0.15.0
239239
resonance_scattering : dict
@@ -1409,7 +1409,7 @@ def random_ray(self, random_ray: dict):
14091409
cv.check_less_than('BD order', value, 7)
14101410
elif key == 'time_derivative method':
14111411
cv.check_value('time derivative method', value,
1412-
('isotropic', 'propogation'))
1412+
('isotropic', 'propagation'))
14131413
else:
14141414
raise ValueError(f'Unable to set random ray to "{key}" which is '
14151415
'unsupported by OpenMC')

src/random_ray/flat_source_domain.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void FlatSourceDomain::set_flux_to_flux_plus_source(
232232
source_regions_.scalar_flux_td_new(sr, g) /= (sigma_t_td * volume);
233233
source_regions_.scalar_flux_td_new(sr, g) +=
234234
source_regions_.source_td(sr, g);
235-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
235+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
236236
// TODO: may need to adjust sigma t division here
237237
double inverse_vbar =
238238
inverse_vbar_[source_regions_.material(sr) * negroups_ + g];
@@ -1815,7 +1815,7 @@ SourceRegionHandle FlatSourceDomain::get_subdivided_source_region_handle(
18151815
update_single_neutron_source(handle);
18161816
if (settings::kinetic_simulation && !settings::is_initial_condition) {
18171817
update_single_neutron_source_td(handle);
1818-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
1818+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
18191819
compute_single_neutron_source_time_derivative(handle);
18201820
compute_single_scalar_flux_time_derivative_2(handle);
18211821
}
@@ -2091,7 +2091,7 @@ void FlatSourceDomain::update_all_neutron_sources_td()
20912091
for (int64_t sr = 0; sr < n_source_regions(); sr++) {
20922092
SourceRegionHandle srh = source_regions_.get_source_region_handle(sr);
20932093
update_single_neutron_source_td(srh);
2094-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
2094+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
20952095
compute_single_neutron_source_time_derivative(srh);
20962096
compute_single_scalar_flux_time_derivative_2(srh);
20972097
}
@@ -2228,7 +2228,7 @@ void FlatSourceDomain::accumulate_iteration_quantities()
22282228
for (int g = 0; g < negroups_; g++) {
22292229
source_regions_.scalar_flux_td_final(sr, g) +=
22302230
source_regions_.scalar_flux_td_new(sr, g);
2231-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
2231+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
22322232
if (settings::is_initial_condition)
22332233
source_regions_.source_final(sr, g) +=
22342234
source_regions_.source(sr, g);
@@ -2260,7 +2260,7 @@ void FlatSourceDomain::normalize_final_quantities()
22602260
if (settings::kinetic_simulation)
22612261
source_regions_.scalar_flux_td_final(sr, g) *=
22622262
source_normalization_factor;
2263-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
2263+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
22642264
source_regions_.source_td_final(sr, g) *= normalization_factor;
22652265
}
22662266
}
@@ -2308,12 +2308,12 @@ void FlatSourceDomain::store_time_step_quantities(bool increment_not_initialize)
23082308
for (int64_t sr = 0; sr < n_source_regions(); sr++) {
23092309
for (int g = 0; g < negroups_; g++) {
23102310
int j = 0;
2311-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION)
2311+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION)
23122312
j = 1;
23132313
add_value_to_bd_vector(source_regions_.scalar_flux_bd(sr, g),
23142314
source_regions_.scalar_flux_td_final(sr, g), increment_not_initialize,
23152315
RandomRay::bd_order_ + j);
2316-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
2316+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
23172317
// Multiply out sigma_t to store the base source
23182318
double sigma_t;
23192319
if (settings::is_initial_condition) {
@@ -2344,7 +2344,7 @@ void FlatSourceDomain::compute_rhs_bd_quantities()
23442344
rhs_backwards_difference(source_regions_.scalar_flux_bd(sr, g),
23452345
RandomRay::bd_order_, settings::dt);
23462346

2347-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
2347+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
23482348
source_regions_.source_rhs_bd(sr, g) = rhs_backwards_difference(
23492349
source_regions_.source_bd(sr, g), RandomRay::bd_order_, settings::dt);
23502350

src/random_ray/random_ray.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void RandomRay::attenuate_flux_flat_source(
463463
cjosey_exponential(tau_td); // exponential = 1 - exp(-tau)
464464
float new_delta_psi_td =
465465
(angular_flux_td_[g] - srh.source_td(g)) * exponential_td;
466-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
466+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
467467
float source_derivative = srh.source_time_derivative(g);
468468
float flux_derivative_2 = srh.scalar_flux_time_derivative_2(g);
469469
float T1 = (source_derivative - flux_derivative_2);
@@ -864,7 +864,7 @@ void RandomRay::initialize_ray(uint64_t ray_id, FlatSourceDomain* domain)
864864
for (int g = 0; g < negroups_; g++) {
865865
angular_flux_td_[g] = srh.source_td(g);
866866
}
867-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
867+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
868868
for (int g = 0; g < negroups_; g++) {
869869
double sigma_t_td =
870870
domain_->sigma_t_td_[srh.material() * negroups_ + g];

src/random_ray/random_ray_simulation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ void openmc_run_random_ray()
9595

9696
// Print simulation information
9797
if (mpi::master) {
98-
std::string message =
99-
fmt::format("TIME DEPENDENT SOLVE {0}", settings::current_timestep);
98+
std::string message = fmt::format(
99+
"KINETIC SIMULATION TIME STEP {0}", settings::current_timestep);
100100
const char* msg = message.c_str();
101101
header(msg, 3);
102102
}
@@ -499,7 +499,7 @@ void write_random_ray_hdf5(hid_t group)
499499
case RandomRayTimeMethod::ISOTROPIC:
500500
write_dataset(random_ray_group, "time_method", "isotropic");
501501
break;
502-
case RandomRayTimeMethod::PROPOGATION:
502+
case RandomRayTimeMethod::PROPAGATION:
503503
write_dataset(random_ray_group, "time_method", "propogation");
504504
break;
505505
default:
@@ -850,7 +850,7 @@ void RandomRaySimulation::print_results_random_ray() const
850850
std::string time_method =
851851
(RandomRay::time_method_ == RandomRayTimeMethod::ISOTROPIC)
852852
? "ISOTROPIC"
853-
: "PROPOGATION";
853+
: "PROPAGATION";
854854
fmt::print(" Time Method = {}\n", time_method);
855855
fmt::print(
856856
" Backwards Difference Order = {}\n", RandomRay::bd_order_);

src/random_ray/source_region.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ SourceRegion::SourceRegion(int negroups, int ndgroups, bool is_linear)
8888
scalar_flux_rhs_bd_.resize(negroups);
8989

9090
// Source Derivative Propogation arrays
91-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
91+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
9292
source_final_.assign(negroups, 0.0);
9393

9494
source_td_final_.assign(negroups, 0.0);
@@ -178,7 +178,7 @@ void SourceRegionContainer::push_back(const SourceRegion& sr)
178178
scalar_flux_rhs_bd_.push_back(sr.scalar_flux_rhs_bd_[g]);
179179

180180
// Source Derivative Propogation arrays
181-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
181+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
182182
source_final_.push_back(sr.source_final_[g]);
183183

184184
source_td_final_.push_back(sr.source_final_[g]);
@@ -262,7 +262,7 @@ void SourceRegionContainer::assign(
262262
scalar_flux_bd_.clear();
263263
scalar_flux_rhs_bd_.clear();
264264

265-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
265+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
266266
source_final_.clear();
267267

268268
source_time_derivative_.clear();
@@ -349,7 +349,7 @@ SourceRegionHandle SourceRegionContainer::get_source_region_handle(int64_t sr)
349349
handle.scalar_flux_bd_ = &scalar_flux_bd(sr, 0);
350350
handle.scalar_flux_rhs_bd_ = &scalar_flux_rhs_bd(sr, 0);
351351

352-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
352+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
353353
handle.source_final_ = &source_final(sr, 0);
354354

355355
handle.source_td_final_ = &source_td_final(sr, 0);
@@ -423,7 +423,7 @@ void SourceRegionContainer::adjoint_reset()
423423
// BD Vectors
424424
std::fill(scalar_flux_rhs_bd_.begin(), scalar_flux_rhs_bd_.end(), 0.0);
425425

426-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION) {
426+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
427427
std::fill(
428428
source_time_derivative_.begin(), source_time_derivative_.end(), 0.0);
429429
std::fill(scalar_flux_time_derivative_2_.begin(),
@@ -456,7 +456,7 @@ void SourceRegionContainer::time_step_reset()
456456
std::fill(scalar_flux_final_.begin(), scalar_flux_final_.end(), 0.0);
457457
std::fill(scalar_flux_td_final_.begin(), scalar_flux_td_final_.end(), 0.0);
458458
std::fill(precursors_final_.begin(), precursors_final_.end(), 0.0);
459-
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPOGATION)
459+
if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION)
460460
std::fill(source_td_final_.begin(), source_td_final_.end(), 0.0);
461461
}
462462

src/settings.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ void get_run_parameters(pugi::xml_node node_base)
264264
// Kinetic variables
265265
if (check_for_node(node_base, "kinetic_simulation")) {
266266
kinetic_simulation = get_node_value_bool(node_base, "kinetic_simulation");
267+
if (solver_type != SolverType::RANDOM_RAY) {
268+
fatal_error("Unsupported solver selected for kinetic simulation. Kinetic "
269+
"simulations currently only support the random ray solver.");
270+
}
271+
if (run_mode != RunMode::EIGENVALUE) {
272+
fatal_error(
273+
"Unsupported run mode selected for kinetic simulation. Kinetic "
274+
"simulations currently only support run mode based on an eigenvalue "
275+
"simulation establishing an initial condition.");
276+
}
267277
}
268278

269279
// Get timestep parameters for kinetic simulations
@@ -429,8 +439,8 @@ void get_run_parameters(pugi::xml_node node_base)
429439
get_node_value(random_ray_node, "time_derivative_method", true, true);
430440
if (temp_str == "isotropic") {
431441
RandomRay::time_method_ = RandomRayTimeMethod::ISOTROPIC;
432-
} else if (temp_str == "propogation") {
433-
RandomRay::time_method_ = RandomRayTimeMethod::PROPOGATION;
442+
} else if (temp_str == "propagation") {
443+
RandomRay::time_method_ = RandomRayTimeMethod::PROPAGATION;
434444
} else {
435445
fatal_error("Unrecognized time derivative method: " + temp_str);
436446
}

src/state_point.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "openmc/mgxs_interface.h"
2323
#include "openmc/nuclide.h"
2424
#include "openmc/output.h"
25+
#include "openmc/random_ray/random_ray_simulation.h"
2526
#include "openmc/settings.h"
2627
#include "openmc/simulation.h"
2728
#include "openmc/tallies/derivative.h"
@@ -96,6 +97,10 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source)
9697
// Write run information
9798
write_dataset(file_id, "energy_mode",
9899
settings::run_CE ? "continuous-energy" : "multi-group");
100+
if (!settings::run_CE) {
101+
write_dataset(file_id, "n_energy_groups", data::mg.num_energy_groups_);
102+
write_dataset(file_id, "n_delay_groups", data::mg.num_delayed_groups_);
103+
}
99104
switch (settings::run_mode) {
100105
case RunMode::FIXED_SOURCE:
101106
write_dataset(file_id, "run_mode", "fixed source");
@@ -106,10 +111,32 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source)
106111
default:
107112
break;
108113
}
114+
switch (settings::solver_type) {
115+
case SolverType::MONTE_CARLO:
116+
write_dataset(file_id, "solver_type", "monte carlo");
117+
break;
118+
case SolverType::RANDOM_RAY:
119+
write_dataset(file_id, "solver_type", "random ray");
120+
write_random_ray_hdf5(file_id);
121+
break;
122+
default:
123+
break;
124+
}
109125
write_attribute(file_id, "photon_transport", settings::photon_transport);
110126
write_dataset(file_id, "n_particles", settings::n_particles);
111127
write_dataset(file_id, "n_batches", settings::n_batches);
112128

129+
write_dataset(file_id, "kinetic_simulation",
130+
settings::kinetic_simulation ? true : false);
131+
if (settings::kinetic_simulation) {
132+
hid_t timestep_group = create_group(file_id, "timestep_data");
133+
write_dataset(timestep_group, "dt", settings::dt);
134+
write_dataset(
135+
timestep_group, "current_timestep", settings::current_timestep);
136+
write_dataset(timestep_group, "current_time", simulation::current_time);
137+
close_group(timestep_group);
138+
}
139+
113140
// Write out current batch number
114141
write_dataset(file_id, "current_batch", simulation::current_batch);
115142

@@ -315,6 +342,15 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source)
315342
write_dataset(runtime_group, "inactive batches", time_inactive.elapsed());
316343
}
317344
write_dataset(runtime_group, "active batches", time_active.elapsed());
345+
if (settings::solver_type == SolverType::RANDOM_RAY) {
346+
write_dataset(runtime_group, "source_update", time_update_src.elapsed());
347+
if (settings::kinetic_simulation) {
348+
write_dataset(
349+
runtime_group, "source_td_update", time_update_src_td.elapsed());
350+
write_dataset(
351+
runtime_group, "precursor_update", time_compute_precursors.elapsed());
352+
}
353+
}
318354
if (settings::run_mode == RunMode::EIGENVALUE) {
319355
write_dataset(
320356
runtime_group, "synchronizing fission bank", time_bank.elapsed());

tests/unit_tests/test_settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_export_to_xml(run_in_tmpdir, kinetic_simulation):
8787
}
8888
if kinetic_simulation:
8989
s.random_ray['bd_order'] = 3
90-
s.random_ray['time_derivative_method'] = 'propogation'
90+
s.random_ray['time_derivative_method'] = 'propagation'
9191
s.max_particle_events = 100
9292
s.max_secondaries = 1_000_000
9393
s.source_rejection_fraction = 0.01
@@ -187,7 +187,7 @@ def test_export_to_xml(run_in_tmpdir, kinetic_simulation):
187187
assert s.random_ray['sample_method'] == 'halton'
188188
if kinetic_simulation:
189189
assert s.random_ray['bd_order'] == 3
190-
assert s.random_ray['time_derivative_method'] == 'propogation'
190+
assert s.random_ray['time_derivative_method'] == 'propagation'
191191
assert s.max_secondaries == 1_000_000
192192
assert s.source_rejection_fraction == 0.01
193193
assert s.free_gas_threshold == 800.0

0 commit comments

Comments
 (0)