Skip to content

Commit 763da84

Browse files
committed
Update to latest version
1 parent 8649be3 commit 763da84

6 files changed

Lines changed: 57 additions & 58 deletions

File tree

include/openmc/tallies/sensitivity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class SensitivityTally : public Tally
5151

5252
double denominator_ {0.0}; //!< Denominator of the sensitivity, <\phi F \psi>
5353

54-
xt::xtensor<double, 3> previous_results_;
54+
tensor::Tensor<double> previous_results_;
5555

5656
bool gpt_ {false}; //!< if true, do not use denominator.
5757

src/particle.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void Particle::from_source(const SourceSite* src)
169169
surface() = (src->surf_id > 0) ? index_plus_one : -index_plus_one;
170170
}
171171

172-
if (src->particle == ParticleType::neutron) {
172+
if (type().pdg_number() == PDG_NEUTRON) {
173173
initialize_cum_sens();
174174
initialize_pprod_sens();
175175
}
@@ -437,8 +437,6 @@ void Particle::event_collide()
437437
// score_pprod_sensitivity(*this);
438438
}
439439

440-
#ifdef DAGMC
441-
442440
#ifdef OPENMC_DAGMC_ENABLED
443441
history().reset();
444442
#endif

src/simulation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ void initialize_history_partial(Particle& p)
676676
void initialize_history_in_part(Particle& p)
677677
{
678678

679-
if (p.type() == ParticleType::photon) return;
679+
if (p.type().is_photon()) return;
680680

681681
// for n-p coupled simulation
682682
// and sensitivity of photon responses (heating, dose) to neutron cross-sections

src/tallies/sensitivity.cpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,18 @@ void SensitivityTally::init_results()
244244
{
245245
int n_scores = 1;
246246
int n_filter_bins = model::tally_sens[sens_].n_bins_;
247-
results_ = xt::empty<double>({n_filter_bins, n_scores, 3});
248-
previous_results_ = xt::empty<double>({n_filter_bins, n_scores, 1});
247+
results_ = tensor::Tensor<double>({static_cast<size_t>(n_filter_bins),
248+
static_cast<size_t>(n_scores), size_t {3}});
249+
previous_results_ = tensor::Tensor<double>({static_cast<size_t>(n_filter_bins),
250+
static_cast<size_t>(n_scores), size_t {1}});
249251
}
250252

251253
void SensitivityTally::reset()
252254
{
253255
n_realizations_ = 0;
254256
if (results_.size() != 0) {
255-
xt::view(results_, xt::all()) = 0.0;
256-
xt::view(previous_results_, xt::all()) = 0.0;
257+
results_.fill(0.0);
258+
previous_results_.fill(0.0);
257259
}
258260
}
259261

@@ -357,7 +359,7 @@ TallySensitivity::TallySensitivity(pugi::xml_node node)
357359

358360
// ADD LOGIC TO SET THE SCORE TYPE
359361
auto reaction = get_node_value(node, "reaction");
360-
sens_reaction = reaction_type(reaction);
362+
sens_reaction = reaction_tally_mt(reaction);
361363

362364
} else if (variable_str == "multipole") {
363365
variable = SensitivityVariable::MULTIPOLE;
@@ -522,9 +524,9 @@ score_track_sensitivity(Particle& p, double distance)
522524
switch (sens.sens_reaction) {
523525
case SCORE_TOTAL:
524526
if (sens.sens_nuclide >=0 || sens.sens_element >=0){
525-
if (p.type() == ParticleType::neutron) {
527+
if (p.type().is_neutron()) {
526528
macro_xs = p.neutron_xs(sens.sens_nuclide).total * atom_density;
527-
} else if (p.type() == ParticleType::photon) {
529+
} else if (p.type().is_photon()) {
528530
macro_xs = p.photon_xs(sens.sens_element).total * atom_density;
529531
}
530532
} else {
@@ -533,38 +535,38 @@ score_track_sensitivity(Particle& p, double distance)
533535
break;
534536
case SCORE_SCATTER:
535537
if (sens.sens_nuclide >=0 || sens.sens_element >=0){
536-
if (p.type() == ParticleType::neutron) {
538+
if (p.type().is_neutron()) {
537539
macro_xs = (p.neutron_xs(sens.sens_nuclide).total
538540
- p.neutron_xs(sens.sens_nuclide).absorption) * atom_density;
539541
} else {
540542
macro_xs = (p.photon_xs(sens.sens_element).coherent
541543
+ p.photon_xs(sens.sens_element).incoherent) * atom_density;
542544
}
543545
} else {
544-
if (p.type() == ParticleType::neutron) {
546+
if (p.type().is_neutron()) {
545547
macro_xs = p.macro_xs().total - p.macro_xs().absorption;
546548
} else {
547549
macro_xs = p.macro_xs().coherent + p.macro_xs().incoherent;
548550
}
549551
}
550552
break;
551553
case ELASTIC:
552-
if (sens.sens_nuclide >= 0 && p.type() == ParticleType::neutron) {
554+
if (sens.sens_nuclide >= 0 && p.type().is_neutron()) {
553555
if (p.neutron_xs(sens.sens_nuclide).elastic == CACHE_INVALID)
554556
data::nuclides[sens.sens_nuclide]->calculate_elastic_xs(p);
555557
macro_xs = p.neutron_xs(sens.sens_nuclide).elastic * atom_density;
556558
}
557559
break;
558560
case SCORE_ABSORPTION:
559561
if (sens.sens_nuclide >=0 || sens.sens_element >=0){
560-
if (p.type() == ParticleType::neutron) {
562+
if (p.type().is_neutron()) {
561563
macro_xs = p.neutron_xs(sens.sens_nuclide).absorption * atom_density;
562564
} else {
563565
const auto& xs = p.photon_xs(sens.sens_element);
564566
macro_xs = (xs.total - xs.coherent - xs.incoherent) * atom_density;
565567
}
566568
} else {
567-
if (p.type() == ParticleType::neutron) {
569+
if (p.type().is_neutron()) {
568570
macro_xs = p.macro_xs().absorption;
569571
} else {
570572
macro_xs = p.macro_xs().photoelectric + p.macro_xs().pair_production;
@@ -602,7 +604,7 @@ score_track_sensitivity(Particle& p, double distance)
602604
case N_3N: m = 4; break;
603605
case N_4N: m = 5; break;
604606
}
605-
if (sens.sens_nuclide >= 0 && p.type() == ParticleType::neutron) {
607+
if (sens.sens_nuclide >= 0 && p.type().is_neutron()) {
606608
macro_xs = p.neutron_xs(sens.sens_nuclide).reaction[m] * atom_density;
607609
}
608610
break;
@@ -618,7 +620,7 @@ score_track_sensitivity(Particle& p, double distance)
618620
atom_density = model::materials[p.material()]->atom_density_(j);
619621
}
620622

621-
if (p.type() != ParticleType::photon) continue;
623+
if (!p.type().is_photon()) continue;
622624

623625
if (sens.sens_element >= 0) {
624626
const auto& micro = p.photon_xs(sens.sens_element);
@@ -630,7 +632,7 @@ score_track_sensitivity(Particle& p, double distance)
630632
}
631633
break;
632634
default:
633-
if (sens.sens_nuclide >= 0 && p.type() == ParticleType::neutron) {
635+
if (sens.sens_nuclide >= 0 && p.type().is_neutron()) {
634636
macro_xs = get_nuclide_xs_sens(p, sens.sens_nuclide, sens.sens_reaction) * atom_density;
635637
}
636638
break;
@@ -639,7 +641,7 @@ score_track_sensitivity(Particle& p, double distance)
639641
if (E >= sens.energy_bins_.front() && E <= sens.energy_bins_.back()) {
640642
auto bin = lower_bound_index(sens.energy_bins_.begin(), sens.energy_bins_.end(), E);
641643
cumulative_sensitivities[bin] -= distance * macro_xs;
642-
if (p.type() == ParticleType::neutron) {
644+
if (p.type().is_neutron()) {
643645
cum_sens[bin] -= distance * macro_xs;
644646
}
645647
}
@@ -788,13 +790,13 @@ void score_collision_sensitivity(Particle& p)
788790
break;
789791
case COHERENT:
790792
case INCOHERENT:
791-
if (p.type() != ParticleType::photon) continue;
793+
if (!p.type().is_photon()) continue;
792794
if (p.event_mt() != sens.sens_reaction) continue;
793795
score = 1.0;
794796
break;
795797
case PHOTOELECTRIC:
796798
case PAIR_PROD:
797-
if (p.type() != ParticleType::photon) continue;
799+
if (!p.type().is_photon()) continue;
798800
if (p.event_mt() != sens.sens_reaction) continue;
799801
score = 0.0;
800802
break;
@@ -808,7 +810,7 @@ void score_collision_sensitivity(Particle& p)
808810
if (E >= sens.energy_bins_.front() && E <= sens.energy_bins_.back()) {
809811
auto bin = lower_bound_index(sens.energy_bins_.begin(), sens.energy_bins_.end(), E);
810812
cumulative_sensitivities[bin] += score;
811-
if (p.type() == ParticleType::neutron) {
813+
if (p.type().is_neutron()) {
812814
cum_sens[bin] += score;
813815
}
814816
}
@@ -887,7 +889,7 @@ double get_photon_yield(int i_nuclide, const Particle& p, int score_bin)
887889
return 0.0;
888890
// double yield = (*rx.products_[0].yield_)(E_in);
889891
for (int j = 0; j < rx.products_.size(); ++j) {
890-
if (rx.products_[j].particle_ == ParticleType::photon) {
892+
if (rx.products_[j].particle_.is_photon()) {
891893

892894
// pprod_xs = xs * (*rx.products_[j].yield_)(p.E());
893895
pyld = (*rx.products_[j].yield_)(p.E());
@@ -905,7 +907,7 @@ void score_pprod_sensitivity(Particle& p)
905907
// Void material cannot be perturbed, it will not affect sensitivities.
906908
if (p.material() == MATERIAL_VOID) return;
907909

908-
if (p.type() == ParticleType::photon) return;
910+
if (p.type().is_photon()) return;
909911

910912
// Only scattering events produce secondary photons
911913
if (p.event() != TallyEvent::SCATTER) return;

src/tallies/tally.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,10 @@ void Tally::set_filters(span<Filter*> filters)
515515
energyout_filter_ = filters_.size();
516516
} else if (filter->type() == FilterType::DELAYED_GROUP) {
517517
delayedgroup_filter_ = filters_.size();
518-
} else if (filter->type() == FilterType::CELL) {
519-
cell_filter_ = filters_.size();
520-
} else if (filter->type() == FilterType::ENERGY) {
521-
energy_filter_ = filters_.size();
518+
// } else if (filter->type() == FilterType::CELL) {
519+
// cell_filter_ = filters_.size();
520+
// } else if (filter->type() == FilterType::ENERGY) {
521+
// energy_filter_ = filters_.size();
522522
}
523523
filters_.push_back(filter_idx);
524524
}
@@ -544,21 +544,21 @@ void Tally::set_filters(span<Filter*> filters)
544544
// filters_.push_back(filter_idx);
545545
// }
546546

547-
void Tally::add_filter(Filter* filter)
548-
{
549-
int32_t filter_idx = model::filter_map.at(filter->id());
550-
// if this filter is already present, do nothing and return
551-
if (std::find(filters_.begin(), filters_.end(), filter_idx) != filters_.end())
552-
return;
553-
554-
// Keep track of indices for special filters
555-
if (filter->type() == FilterType::ENERGY_OUT) {
556-
energyout_filter_ = filters_.size();
557-
} else if (filter->type() == FilterType::DELAYED_GROUP) {
558-
delayedgroup_filter_ = filters_.size();
559-
}
560-
filters_.push_back(filter_idx);
561-
}
547+
// void Tally::add_filter(Filter* filter)
548+
// {
549+
// int32_t filter_idx = model::filter_map.at(filter->id());
550+
// // if this filter is already present, do nothing and return
551+
// if (std::find(filters_.begin(), filters_.end(), filter_idx) != filters_.end())
552+
// return;
553+
//
554+
// // Keep track of indices for special filters
555+
// if (filter->type() == FilterType::ENERGY_OUT) {
556+
// energyout_filter_ = filters_.size();
557+
// } else if (filter->type() == FilterType::DELAYED_GROUP) {
558+
// delayedgroup_filter_ = filters_.size();
559+
// }
560+
// filters_.push_back(filter_idx);
561+
// }
562562

563563
void Tally::set_strides()
564564
{

src/tallies/tally_scoring.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ void score_collision_tally(Particle& p)
25412541
flux = p.wgt_last() / p.macro_xs().total;
25422542
}
25432543

2544-
if (p.type() == ParticleType::neutron) {
2544+
if (p.type().is_neutron()) {
25452545
double value = p.wgt_last() / p.macro_xs().total;
25462546
p.set_neutron_flux_last(value);
25472547
}
@@ -2663,8 +2663,7 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
26632663
score = p.wgt_last();
26642664
}
26652665

2666-
if (p.type() == ParticleType::neutron ||
2667-
p.type() == ParticleType::photon) {
2666+
if (p.type().is_neutron() || p.type().is_photon()) {
26682667
score *= flux / p.macro_xs().total;
26692668
} else {
26702669
score = 0.;
@@ -2689,9 +2688,9 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
26892688

26902689
} else {
26912690
if (i_nuclide >= 0) {
2692-
if (p.type() == ParticleType::neutron) {
2691+
if (p.type().is_neutron()) {
26932692
score = p.neutron_xs(i_nuclide).total * atom_density * flux;
2694-
} else if (p.type() == ParticleType::photon) {
2693+
} else if (p.type().is_photon()) {
26952694
score = p.photon_xs(i_nuclide).total * atom_density * flux;
26962695
}
26972696
} else {
@@ -2723,7 +2722,7 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
27232722

27242723

27252724
case SCORE_SCATTER:
2726-
if (p.type() != ParticleType::neutron && p.type() != ParticleType::photon)
2725+
if (!p.type().is_neutron() && !p.type().is_photon())
27272726
continue;
27282727

27292728
if (tally.estimator_ == TallyEstimator::ANALOG) {
@@ -2734,15 +2733,15 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
27342733
score = p.wgt_last() * flux;
27352734
} else {
27362735
if (i_nuclide >= 0) {
2737-
if (p.type() == ParticleType::neutron) {
2736+
if (p.type().is_neutron()) {
27382737
score = (p.neutron_xs(i_nuclide).total
27392738
- p.neutron_xs(i_nuclide).absorption) * atom_density * flux;
27402739
} else {
27412740
score = (p.photon_xs(i_nuclide).coherent
27422741
+ p.photon_xs(i_nuclide).incoherent) * atom_density * flux;
27432742
}
27442743
} else {
2745-
if (p.type() == ParticleType::neutron) {
2744+
if (p.type().is_neutron()) {
27462745
score = (p.macro_xs().total
27472746
- p.macro_xs().absorption) * flux;
27482747
} else {
@@ -2776,7 +2775,7 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
27762775

27772776

27782777
case SCORE_ABSORPTION:
2779-
if (p.type() != ParticleType::neutron && p.type() != ParticleType::photon)
2778+
if (!p.type().is_neutron() && !p.type().is_photon())
27802779
continue;
27812780

27822781
if (tally.estimator_ == TallyEstimator::ANALOG) {
@@ -2793,15 +2792,15 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
27932792
}
27942793
} else {
27952794
if (i_nuclide >= 0) {
2796-
if (p.type() == ParticleType::neutron) {
2795+
if (p.type().is_neutron()) {
27972796
score = p.neutron_xs(i_nuclide).absorption * atom_density * flux;
27982797
} else {
27992798
const auto& xs = p.photon_xs(i_nuclide);
28002799
score =
28012800
(xs.total - xs.coherent - xs.incoherent) * atom_density * flux;
28022801
}
28032802
} else {
2804-
if (p.type() == ParticleType::neutron) {
2803+
if (p.type().is_neutron()) {
28052804
score = p.macro_xs().absorption * flux;
28062805
} else {
28072806
score =
@@ -3420,7 +3419,7 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
34203419
case INCOHERENT:
34213420
case PHOTOELECTRIC:
34223421
case PAIR_PROD:
3423-
if (p.type() != ParticleType::photon)
3422+
if (!p.type().is_photon())
34243423
continue;
34253424

34263425
if (tally.estimator_ == TallyEstimator::ANALOG) {
@@ -3466,7 +3465,7 @@ void score_collision_sensitivity_tally(Particle& p, int i_tally, int start_index
34663465

34673466
// The default block is really only meant for redundant neutron reactions
34683467
// (e.g. 444, 901)
3469-
if (p.type() != ParticleType::neutron) continue;
3468+
if (!p.type().is_neutron()) continue;
34703469

34713470
if (tally.estimator_ == TallyEstimator::ANALOG) {
34723471

0 commit comments

Comments
 (0)