OpenMC/include/openmc/tallies/derivative.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.4 KiB
C
Raw Permalink Normal View History

2019-01-26 12:10:18 -05:00
#ifndef OPENMC_TALLIES_DERIVATIVE_H
#define OPENMC_TALLIES_DERIVATIVE_H
#include "openmc/particle.h"
#include "openmc/vector.h"
2019-01-26 12:10:18 -05:00
#include <unordered_map>
#include "pugixml.hpp"
//==============================================================================
//! Describes a first-order derivative that can be applied to tallies.
//==============================================================================
namespace openmc {
// Different independent variables
2020-01-21 13:04:39 -05:00
enum class DerivativeVariable { DENSITY, NUCLIDE_DENSITY, TEMPERATURE };
struct TallyDerivative {
2020-01-21 13:04:39 -05:00
DerivativeVariable variable; //!< Independent variable (like temperature)
2019-01-26 12:10:18 -05:00
int id; //!< User-defined identifier
int diff_material; //!< Material this derivative is applied to
int diff_nuclide; //!< Nuclide this material is applied to
TallyDerivative() {}
explicit TallyDerivative(pugi::xml_node node);
2019-01-26 12:10:18 -05:00
};
//==============================================================================
// Non-method functions
//==============================================================================
2019-02-20 23:34:36 -06:00
//! Read tally derivatives from a tallies.xml file
void read_tally_derivatives(pugi::xml_node node);
//! Scale the given score by its logarithmic derivative
void apply_derivative_to_score(const Particle& p, int i_tally, int i_nuclide,
double atom_density, int score_bin, double& score);
2019-02-19 21:48:20 -06:00
//! Adjust diff tally flux derivatives for a particle scattering event.
//
//! Note that this subroutine will be called after absorption events in
//! addition to scattering events, but any flux derivatives scored after an
//! absorption will never be tallied. The paricle will be killed before any
//! further tallies are scored.
//
//! \param p The particle being tracked
void score_collision_derivative(Particle& p);
2019-02-19 21:48:20 -06:00
//! Adjust diff tally flux derivatives for a particle tracking event.
//
//! \param p The particle being tracked
//! \param distance The distance in [cm] traveled by the particle
void score_track_derivative(Particle& p, double distance);
2019-01-26 12:10:18 -05:00
} // namespace openmc
//==============================================================================
// Global variables
//==============================================================================
namespace openmc {
namespace model {
extern std::unordered_map<int, int> tally_deriv_map;
extern vector<TallyDerivative> tally_derivs;
} // namespace model
} // namespace openmc
2019-01-26 12:10:18 -05:00
#endif // OPENMC_TALLIES_DERIVATIVE_H