Skip to content

Commit d4b973c

Browse files
committed
cleanup
1 parent 7459ffd commit d4b973c

5 files changed

Lines changed: 59 additions & 62 deletions

File tree

include/openmc/random_ray/flat_source_domain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class FlatSourceDomain {
191191
// 3D arrays stored in 1D representing values for all materials x energy
192192
// groups x delay groups
193193
vector<double> nu_d_sigma_f_;
194-
vector<double> chi_d_;
194+
vector<double> chi_d_lambda_; // chi-delayed * lambda in each delay group
195195

196196
// 2D arrays stored in 1D representing values for all materials x energy
197197
// groups

include/openmc/random_ray/source_region.h

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ class SourceRegionHandle {
209209

210210
// Energy group-wise 2D BD arrays (g x time step)
211211
std::deque<double>* scalar_flux_bd_;
212-
std::deque<double>* precursors_bd_;
212+
std::deque<float>* source_bd_;
213213

214214
// Delay group-wise 2D BD arrays (dg x time step)
215-
std::deque<float>* source_bd_;
215+
std::deque<double>* precursors_bd_;
216216

217217
// Energy group-wise 1D RHS BD arrays
218218
double* scalar_flux_rhs_bd_;
@@ -374,15 +374,15 @@ class SourceRegionHandle {
374374
return scalar_flux_bd_[g];
375375
}
376376

377+
std::deque<float>& source_bd(int g) { return source_bd_[g]; }
378+
const std::deque<float>& source_bd(int g) const { return source_bd_[g]; }
379+
377380
std::deque<double>& precursors_bd(int dg) { return precursors_bd_[dg]; }
378381
const std::deque<double>& precursors_bd(int dg) const
379382
{
380383
return precursors_bd_[dg];
381384
}
382385

383-
std::deque<float>& source_bd(int g) { return source_bd_[g]; }
384-
const std::deque<float>& source_bd(int g) const { return source_bd_[g]; }
385-
386386
double& scalar_flux_rhs_bd(int g) { return scalar_flux_rhs_bd_[g]; }
387387
const double scalar_flux_rhs_bd(int g) const
388388
{
@@ -522,17 +522,17 @@ class SourceRegion {
522522
//!< finite number of previous time steps (used for
523523
//!< computing the first order (and second order, for SDP)
524524
//!< scalar flux time derivative)
525-
vector<std::deque<double>>
526-
precursors_bd_; //!< The final scalar flux in each energy group from a
527-
//!< finite number of previous time steps (used for
528-
//!< computing the first order source time derivative for
529-
//!< SDP)
525+
vector<std::deque<float>>
526+
source_bd_; //!< The final scalar flux in each energy group from a
527+
//!< finite number of previous time steps (used for
528+
//!< computing the first order source time derivative for
529+
//!< SDP)
530530

531531
// Delay group-wise 2D BD arrays (dg x time step)
532-
vector<std::deque<float>>
533-
source_bd_; //!< The final precursor population in each energy group from a
534-
//!< finite number of previous time steps (used for computing
535-
//!< the first order precursor time derivative)
532+
vector<std::deque<double>>
533+
precursors_bd_; //!< The final precursor population in each energy group
534+
//!< from a finite number of previous time steps (used for
535+
//!< computing the first order precursor time derivative)
536536

537537
// Energy group-wise 1D RHS BD arrays
538538
vector<double>
@@ -877,20 +877,6 @@ class SourceRegionContainer {
877877
return scalar_flux_bd_[se];
878878
}
879879

880-
std::deque<double>& precursors_bd(int64_t sr, int dg)
881-
{
882-
return precursors_bd_[dindex(sr, dg)];
883-
}
884-
const std::deque<double>& precursors_bd(int64_t sr, int dg) const
885-
{
886-
return precursors_bd_[dindex(sr, dg)];
887-
}
888-
std::deque<double>& precursors_bd(int64_t de) { return precursors_bd_[de]; }
889-
const std::deque<double>& precursors_bd(int64_t de) const
890-
{
891-
return precursors_bd_[de];
892-
}
893-
894880
std::deque<float>& source_bd(int64_t sr, int g)
895881
{
896882
return source_bd_[index(sr, g)];
@@ -905,6 +891,20 @@ class SourceRegionContainer {
905891
return source_bd_[se];
906892
}
907893

894+
std::deque<double>& precursors_bd(int64_t sr, int dg)
895+
{
896+
return precursors_bd_[dindex(sr, dg)];
897+
}
898+
const std::deque<double>& precursors_bd(int64_t sr, int dg) const
899+
{
900+
return precursors_bd_[dindex(sr, dg)];
901+
}
902+
std::deque<double>& precursors_bd(int64_t de) { return precursors_bd_[de]; }
903+
const std::deque<double>& precursors_bd(int64_t de) const
904+
{
905+
return precursors_bd_[de];
906+
}
907+
908908
double& scalar_flux_rhs_bd(int64_t sr, int g)
909909
{
910910
return scalar_flux_rhs_bd_[index(sr, g)];
@@ -1067,11 +1067,13 @@ class SourceRegionContainer {
10671067
vector<double> precursors_new_;
10681068
vector<double> precursors_final_;
10691069

1070-
// SoA energy group-wise 3D BD arrays (sr x g/dg X timestep) flattened to 2D
1070+
// SoA energy group-wise 3D BD arrays (sr x g X timestep) flattened to 2D
10711071
vector<std::deque<double>> scalar_flux_bd_;
1072-
vector<std::deque<double>> precursors_bd_;
10731072
vector<std::deque<float>> source_bd_;
10741073

1074+
// SoA delay group-wise 3D BD arrays (sr x dg X timestep) flattened to 2D
1075+
vector<std::deque<double>> precursors_bd_;
1076+
10751077
// SoA energy group-wise 2D RHS BD arrays flattened to 1D
10761078
vector<double> scalar_flux_rhs_bd_;
10771079
vector<float> source_rhs_bd_;

src/random_ray/flat_source_domain.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,10 @@ void FlatSourceDomain::update_single_neutron_source(SourceRegionHandle& srh)
158158
settings::create_delayed_neutrons) {
159159
double delayed_source = 0.0;
160160
for (int dg = 0; dg < ndgroups_; dg++) {
161-
double chi_d =
162-
chi_d_[material * negroups_ * ndgroups_ + dg * negroups_ + g_out];
163-
double lambda = lambda_[material * ndgroups_ + dg];
161+
double chi_d_lambda = chi_d_lambda_[material * negroups_ * ndgroups_ +
162+
dg * negroups_ + g_out];
164163
double precursors = srh.precursors_old(dg);
165-
delayed_source += chi_d * precursors * lambda;
164+
delayed_source += chi_d_lambda * precursors;
166165
}
167166
total_source += delayed_source;
168167
}
@@ -1400,13 +1399,13 @@ void FlatSourceDomain::flatten_xs()
14001399
// material is fissionable but has very small sigma_f.
14011400
chi_d = 0.0;
14021401
}
1403-
chi_d_.push_back(chi_d);
1402+
chi_d_lambda_.push_back(chi_d * lambda);
14041403
}
14051404
} else {
14061405
lambda_.push_back(0);
14071406
for (int g_out = 0; g_out < negroups_; g_out++) {
14081407
nu_d_sigma_f_.push_back(0);
1409-
chi_d_.push_back(0);
1408+
chi_d_lambda_.push_back(0);
14101409
}
14111410
}
14121411
}

src/random_ray/random_ray_simulation.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -510,24 +510,23 @@ void RandomRaySimulation::prepare_adjoint_simulation()
510510
// TODO: Add support for time-dependent restart
511511
void RandomRaySimulation::kinetic_single_time_step(int i)
512512
{
513-
if (i == -1) {
514-
// Set flag for k_eff correction if initial condition
515-
simulation::k_eff_correction = true;
516-
517-
// Store average keff from initial simulation
518-
static_avg_k_eff_ = simulation::keff;
519-
}
520-
521513
// Increment time step
522514
simulation::current_timestep = i + 1;
523-
if (i == -1)
524-
// Current time is zero for initial condition
525-
simulation::current_time = 0;
526-
else
527-
// Else, increment the current time
515+
if (i >= 0)
516+
// Increment the current time
528517
simulation::current_time += settings::dt;
529518

530-
domain_->k_eff_ = static_avg_k_eff_;
519+
// Set eigenvalue if needed
520+
if (settings::run_mode == RunMode::EIGENVALUE) {
521+
if (i == -1) {
522+
// Set flag for k_eff correction if initial condition
523+
simulation::k_eff_correction = true;
524+
525+
// Store average keff from initial simulation
526+
static_avg_k_eff_ = simulation::keff;
527+
}
528+
domain_->k_eff_ = static_avg_k_eff_;
529+
}
531530
domain_->source_regions_.adjoint_reset();
532531
domain_->propagate_final_quantities();
533532
domain_->source_regions_.time_step_reset();
@@ -543,25 +542,22 @@ void RandomRaySimulation::kinetic_single_time_step(int i)
543542
// Run the initial condition
544543
simulate();
545544

546-
if (i == -1)
545+
if (i == -1) {
547546
// Initialize the BD arrays if initial condition
548547
domain_->store_time_step_quantities(false);
549-
else
548+
// Reset flags for kinetic simulation if initial condition
549+
simulation::is_initial_condition = false;
550+
simulation::k_eff_correction = false;
551+
} else {
550552
// Else, store final quantities for the current time step
551553
domain_->store_time_step_quantities();
554+
}
552555

553556
// Rename statepoint and tallies file for the current time step
554557
rename_time_step_file(fmt::format("statepoint.{0}", settings::n_batches),
555558
".h5", simulation::current_timestep);
556-
if (settings::output_tallies) {
559+
if (settings::output_tallies)
557560
rename_time_step_file("tallies", ".out", simulation::current_timestep);
558-
}
559-
560-
if (i == -1) {
561-
// Reset flags for kinetic simulation if initial condition
562-
simulation::is_initial_condition = false;
563-
simulation::k_eff_correction = false;
564-
}
565561
}
566562

567563
void RandomRaySimulation::simulate()

src/simulation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ vector<int64_t> work_index;
338338

339339
bool is_initial_condition {true};
340340
int current_timestep;
341-
double current_time;
341+
double current_time {0.0};
342342
bool k_eff_correction {false};
343343

344344
} // namespace simulation

0 commit comments

Comments
 (0)