From 960f71e276c753ec056978b182cff751728f81cc Mon Sep 17 00:00:00 2001 From: Adam G Nelson Date: Mon, 8 Oct 2018 14:01:52 -0400 Subject: [PATCH] whoops, including files --- include/openmc/physics_mg.h | 20 ++++++++++++++++++++ src/physics_mg.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 include/openmc/physics_mg.h create mode 100644 src/physics_mg.cpp diff --git a/include/openmc/physics_mg.h b/include/openmc/physics_mg.h new file mode 100644 index 0000000000..e570de917a --- /dev/null +++ b/include/openmc/physics_mg.h @@ -0,0 +1,20 @@ +//! \file physics_mg.h +//! Methods needed to perform the collision physics for multi-group mode + +#ifndef OPENMC_PHYSICS_MG_H +#define OPENMC_PHYSICS_MG_H + +#include "openmc/particle.h" + +namespace openmc { + +//============================================================================== +// SCATTER +//============================================================================== + +//! \brief Samples the scattering event +extern "C" void +scatter(Particle* p, const double* energy_bin_avg); + +} // namespace openmc +#endif // OPENMC_PHYSICS_MG_H diff --git a/src/physics_mg.cpp b/src/physics_mg.cpp new file mode 100644 index 0000000000..27379a2d6c --- /dev/null +++ b/src/physics_mg.cpp @@ -0,0 +1,32 @@ +#include "openmc/physics_mg.h" + +#include "openmc/constants.h" +#include "openmc/math_functions.h" +#include "openmc/mgxs_interface.h" + +namespace openmc { + +void scatter(Particle* p, const double* energy_bin_avg) +{ + // Adjust indices for Fortran to C++ indexing + // TODO: Remove when no longer needed + int gin = p->last_g - 1; + int gout = p->g - 1; + int i_mat = p->material - 1; + macro_xs[i_mat].sample_scatter(gin, gout, p->mu, p->wgt); + + // Adjust return value for fortran indexing + // TODO: Remove when no longer needed + p->g = gout + 1; + + // Rotate the angle + rotate_angle_c(p->coord[0].uvw, p->mu, nullptr); + + // Update energy value for downstream compatability (in tallying) + p->E = energy_bin_avg[gout]; + + // Set event component + p->event = EVENT_SCATTER; +} + +} //namespace openmc