Skip to content

Commit

Permalink
Updated Mgxs::calculate_xs interface to use the particle, matching in…
Browse files Browse the repository at this point in the history
…terface for continuous energy equivalent
  • Loading branch information
nelsonag committed Nov 12, 2019
1 parent 7d285b4 commit fe8cbcc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
11 changes: 3 additions & 8 deletions include/openmc/mgxs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "openmc/constants.h"
#include "openmc/hdf5_interface.h"
#include "openmc/particle.h"
#include "openmc/xsdata.h"


Expand Down Expand Up @@ -167,15 +168,9 @@ class Mgxs {

//! \brief Calculates cross section quantities needed for tracking.
//!
//! @param gin Incoming energy group.
//! @param sqrtkT Temperature of the material.
//! @param u Incoming particle direction.
//! @param total_xs Resultant total cross section.
//! @param abs_xs Resultant absorption cross section.
//! @param nu_fiss_xs Resultant nu-fission cross section.
//! @param p The particle whose attributes set which MGXS to get.
void
calculate_xs(int gin, double sqrtkT, Direction u,
double& total_xs, double& abs_xs, double& nu_fiss_xs);
calculate_xs(Particle& p);

//! \brief Sets the temperature index in cache given a temperature
//!
Expand Down
15 changes: 7 additions & 8 deletions src/mgxs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,22 +600,21 @@ Mgxs::sample_scatter(int gin, int& gout, double& mu, double& wgt)
//==============================================================================

void
Mgxs::calculate_xs(int gin, double sqrtkT, Direction u,
double& total_xs, double& abs_xs, double& nu_fiss_xs)
Mgxs::calculate_xs(Particle& p)
{
// Set our indices
#ifdef _OPENMP
int tid = omp_get_thread_num();
#else
int tid = 0;
#endif
set_temperature_index(sqrtkT);
set_angle_index(u);
set_temperature_index(p.sqrtkT_);
set_angle_index(p.u_local());
XsData* xs_t = &xs[cache[tid].t];
total_xs = xs_t->total(cache[tid].a, gin);
abs_xs = xs_t->absorption(cache[tid].a, gin);

nu_fiss_xs = fissionable ? xs_t->nu_fission(cache[tid].a, gin) : 0.;
p.macro_xs_.total = xs_t->total(cache[tid].a, p.g_);
p.macro_xs_.absorption = xs_t->absorption(cache[tid].a, p.g_);
p.macro_xs_.nu_fission =
fissionable ? xs_t->nu_fission(cache[tid].a, p.g_) : 0.;
}

//==============================================================================
Expand Down
10 changes: 5 additions & 5 deletions src/particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ Particle::transport()
model::materials[material_]->calculate_xs(*this);
}
} else {
// Get the MG data
data::mg.macro_xs_[material_].calculate_xs(g_, sqrtkT_,
this->u_local(), macro_xs_.total, macro_xs_.absorption,
macro_xs_.nu_fission);
// Get the MG data; unlike the CE case above, we have to re-calculate
// cross sections for every collision since the cross sections may
// be angle-dependent
data::mg.macro_xs_[material_].calculate_xs(*this);

// Finally, update the particle group since we know we are multi-group
// Update the particle's group while we know we are multi-group
g_last_ = g_;
}
} else {
Expand Down

0 comments on commit fe8cbcc

Please sign in to comment.