Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ endif()
#===============================================================================

list(APPEND libopenmc_SOURCES
src/atomic_mass.cpp
src/bank.cpp
src/boundary_condition.cpp
src/bremsstrahlung.cpp
Expand Down
28 changes: 28 additions & 0 deletions include/openmc/atomic_mass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//==============================================================================
// atomic masses definitions
//==============================================================================

#ifndef OPENMC_ATOMIC_MASS_H
#define OPENMC_ATOMIC_MASS_H

#include <cstdint>
#include <unordered_map>

namespace openmc {

// Values here are from the Committee on Data for Science and Technology
// (CODATA) 2018 recommendation (https://physics.nist.gov/cuu/Constants/).

// Physical constants
constexpr double MASS_ELECTRON {5.48579909065e-4}; // mass of an electron in amu
constexpr double MASS_NEUTRON {1.00866491595}; // mass of a neutron in amu
constexpr double MASS_PROTON {1.007276466621}; // mass of a proton in amu
constexpr double MASS_DEUTRON {2.013553212745}; // mass of a deutron in amu
constexpr double MASS_HELION {3.014932247175}; // mass of a helion in amu
constexpr double MASS_ALPHA {4.001506179127}; // mass of an alpha in amu

extern std::unordered_map<int32_t, double> atomic_mass;

} // namespace openmc

#endif // OPENMC_ATOMIC_MASS_H
11 changes: 7 additions & 4 deletions include/openmc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <limits>

#include "openmc/array.h"
#include "openmc/atomic_mass.h"
#include "openmc/vector.h"
#include "openmc/version.h"

Expand Down Expand Up @@ -86,12 +87,12 @@ constexpr double INFTY {std::numeric_limits<double>::max()};
// (CODATA) 2018 recommendation (https://physics.nist.gov/cuu/Constants/).

// Physical constants
constexpr double MASS_NEUTRON {1.00866491595}; // mass of a neutron in amu
constexpr double AMU_EV {
9.314941024146563e8}; // atomic mass unit energy equivalent in eV/c^2
constexpr double MASS_NEUTRON_EV {
939.56542052e6}; // mass of a neutron in eV/c^2
constexpr double MASS_PROTON {1.007276466621}; // mass of a proton in amu
MASS_NEUTRON * AMU_EV}; // neutron mass energy equivalent in eV/c^2
constexpr double MASS_ELECTRON_EV {
0.51099895000e6}; // electron mass energy equivalent in eV/c^2
MASS_ELECTRON * AMU_EV}; // electron mass energy equivalent in eV/c^2
constexpr double FINE_STRUCTURE {
137.035999084}; // inverse fine structure constant
constexpr double PLANCK_C {
Expand All @@ -101,6 +102,8 @@ constexpr double C_LIGHT {2.99792458e10}; // speed of light in cm/s
constexpr double N_AVOGADRO {0.602214076}; // Avogadro's number in 10^24/mol
constexpr double K_BOLTZMANN {8.617333262e-5}; // Boltzmann constant in eV/K

static_assert(MASS_NEUTRON_EV == 939.56542052e6);

// Electron subshell labels
constexpr array<const char*, 39> SUBSHELLS = {"K", "L1", "L2", "L3", "M1", "M2",
"M3", "M4", "M5", "N1", "N2", "N3", "N4", "N5", "N6", "N7", "O1", "O2", "O3",
Expand Down
12 changes: 12 additions & 0 deletions include/openmc/particle_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <type_traits>

#include "openmc/constants.h"
#include "openmc/error.h"

namespace openmc {

Expand Down Expand Up @@ -61,6 +62,17 @@ class ParticleType {
//----------------------------------------------------------------------------
// Methods

// Get particle mass
double mass() const
{
int32_t p = std::abs(pdg_number_);
if (atomic_mass.count(p)) {
return atomic_mass[p];
} else {
fatal_error("Unknown mass for particle " + str());
}
}

// Convert to string representation
std::string str() const;

Expand Down
Loading
Loading