Move score_all_nuclides to C++

This commit is contained in:
Sterling Harper 2019-02-05 20:57:13 -05:00
parent cb87aeff7c
commit c24a9c18b1
2 changed files with 38 additions and 50 deletions

View file

@ -2029,53 +2029,6 @@ contains
end associate
end subroutine score_general_mg
!===============================================================================
! SCORE_ALL_NUCLIDES tallies individual nuclide reaction rates specifically when
! the user requests <nuclides>all</nuclides>.
!===============================================================================
subroutine score_all_nuclides(p, i_tally, flux, filter_index) bind(C)
type(Particle), intent(in) :: p
integer(C_INT), intent(in), value :: i_tally
real(C_DOUBLE), intent(in), value :: flux
integer(C_INT), intent(in), value :: filter_index
integer :: i ! loop index for nuclides in material
integer :: i_nuclide ! index in nuclides array
real(8) :: atom_density ! atom density of single nuclide in atom/b-cm
associate (t => tallies(i_tally) % obj)
! ==========================================================================
! SCORE ALL INDIVIDUAL NUCLIDE REACTION RATES
NUCLIDE_LOOP: do i = 1, material_nuclide_size(p % material)
! Determine index in nuclides array and atom density for i-th nuclide in
! current material
i_nuclide = material_nuclide(p % material, i) - 1
atom_density = material_atom_density(p % material, i)
! Determine score for each bin
call score_general(p, i_tally, i_nuclide*t % n_score_bins(), filter_index, &
i_nuclide, atom_density, flux)
end do NUCLIDE_LOOP
! ==========================================================================
! SCORE TOTAL MATERIAL REACTION RATES
i_nuclide = -1
atom_density = ZERO
! Determine score for each bin
call score_general(p, i_tally, n_nuclides*t % n_score_bins(), filter_index, &
i_nuclide, atom_density, flux)
end associate
end subroutine score_all_nuclides
!===============================================================================
! SCORE_FISSION_EOUT handles a special case where we need to store neutron
! production rate with an outgoing energy filter (think of a fission matrix). In

View file

@ -42,9 +42,6 @@ extern "C" void
score_general_mg(Particle* p, int i_tally, int start_index, int filter_index,
int i_nuclide, double atom_density, double flux);
extern "C" void
score_all_nuclides(Particle* p, int i_tally, double flux, int filter_index);
//==============================================================================
// Global variable definitions
//==============================================================================
@ -663,6 +660,44 @@ adaptor_type<3> tally_results(int idx)
return xt::adapt(results, size, xt::no_ownership(), shape);
}
//! Tally rates for when the user requests a tally on all nuclides.
void
score_all_nuclides(Particle* p, int i_tally, double flux, int filter_index)
{
//TODO: off-by-one
const Tally& tally {*model::tallies[i_tally-1]};
const Material& material {*model::materials[p->material-1]};
// Score all individual nuclide reaction rates.
for (auto i = 0; i < material.nuclide_.size(); ++i) {
auto i_nuclide = material.nuclide_[i];
auto atom_density = material.atom_density_(i);
//TODO: consider replacing this "if" with pointers or templates
if (settings::run_CE) {
score_general_ce(p, i_tally, i_nuclide*tally.scores_.size(), filter_index,
i_nuclide, atom_density, flux);
} else {
score_general_mg(p, i_tally, i_nuclide*tally.scores_.size(), filter_index,
i_nuclide, atom_density, flux);
}
}
// Score total material reaction rates.
int i_nuclide = -1;
double atom_density = 0.;
auto n_nuclides = data::nuclides.size();
//TODO: consider replacing this "if" with pointers or templates
if (settings::run_CE) {
score_general_ce(p, i_tally, n_nuclides*tally.scores_.size(), filter_index,
i_nuclide, atom_density, flux);
} else {
score_general_mg(p, i_tally, n_nuclides*tally.scores_.size(), filter_index,
i_nuclide, atom_density, flux);
}
}
//! Score tallies based on a simple count of events (for continuous energy).
//
//! Analog tallies ar etriggered at every collision, not every event.