2019-01-26 12:10:18 -05:00
|
|
|
#ifndef OPENMC_TALLIES_DERIVATIVE_H
|
|
|
|
|
#define OPENMC_TALLIES_DERIVATIVE_H
|
|
|
|
|
|
2019-02-10 21:45:54 -05:00
|
|
|
#include "openmc/particle.h"
|
2021-04-22 16:46:23 -04:00
|
|
|
#include "openmc/vector.h"
|
2019-02-10 21:45:54 -05:00
|
|
|
|
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 {
|
|
|
|
|
|
2020-01-16 15:41:45 -05:00
|
|
|
// Different independent variables
|
2020-01-21 13:04:39 -05:00
|
|
|
enum class DerivativeVariable { DENSITY, NUCLIDE_DENSITY, TEMPERATURE };
|
2020-01-16 15:41:45 -05:00
|
|
|
|
2019-02-12 17:10:25 -05:00
|
|
|
struct TallyDerivative {
|
2020-01-16 15:41:45 -05:00
|
|
|
|
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() {}
|
2019-02-13 01:05:50 -05:00
|
|
|
explicit TallyDerivative(pugi::xml_node node);
|
2019-01-26 12:10:18 -05:00
|
|
|
};
|
|
|
|
|
|
2019-02-10 21:45:54 -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);
|
|
|
|
|
|
2019-02-10 21:45:54 -05:00
|
|
|
//! Scale the given score by its logarithmic derivative
|
|
|
|
|
|
2020-04-23 09:56:14 -05:00
|
|
|
void apply_derivative_to_score(const Particle& p, int i_tally, int i_nuclide,
|
2019-02-12 17:10:25 -05:00
|
|
|
double atom_density, int score_bin, double& score);
|
2019-02-10 21:45:54 -05:00
|
|
|
|
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
|
2020-04-23 12:49:48 -05:00
|
|
|
void score_collision_derivative(Particle& p);
|
2019-02-07 10:05:43 -06:00
|
|
|
|
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
|
2020-04-23 12:49:48 -05:00
|
|
|
void score_track_derivative(Particle& p, double distance);
|
2019-02-07 10:05:43 -06:00
|
|
|
|
2019-01-26 12:10:18 -05:00
|
|
|
} // namespace openmc
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
// Global variables
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
namespace openmc {
|
2019-02-12 17:10:25 -05:00
|
|
|
|
|
|
|
|
namespace model {
|
|
|
|
|
extern std::unordered_map<int, int> tally_deriv_map;
|
2021-04-22 16:46:23 -04:00
|
|
|
extern vector<TallyDerivative> tally_derivs;
|
2019-02-12 17:10:25 -05:00
|
|
|
} // namespace model
|
|
|
|
|
|
|
|
|
|
} // namespace openmc
|
2019-01-26 12:10:18 -05:00
|
|
|
|
|
|
|
|
#endif // OPENMC_TALLIES_DERIVATIVE_H
|