Skip to content

Commit 140836c

Browse files
committed
Merge branch 'feature/constants' into 'develop'
Feature/constants See merge request njoy/dryad!80
2 parents d733b48 + a0676b3 commit 140836c

14 files changed

+51
-17
lines changed

python/stubs/dryad/resonances.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Channel:
9797
"""
9898
def sommerfeld_parameter(self, energy: float) -> float:
9999
"""
100-
Calcualte the Sommerfeld parameter for the channel at a given energy
100+
Calculate the Sommerfeld parameter for the channel at a given energy
101101
102102
The Sommerfeld parameter eta is an energy dependent quantity defined as
103103
follows:

src/dryad/constants.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ namespace constants {
2323
// CODATA 2022 - vacuum electric permittivity in F / m = Coulomb^2 kg^−1 m^−3 s^2
2424
constexpr double epsilon0 = 8.8541878188e-12;
2525

26+
// SI prefixes
27+
constexpr double giga = 1e+9;
28+
constexpr double mega = 1e+6;
29+
constexpr double kilo = 1e+3;
30+
constexpr double hecto = 1e+2;
31+
constexpr double deca = 1e+1;
32+
constexpr double deci = 1e-1;
33+
constexpr double centi = 1e-2;
34+
constexpr double mili = 1e-3;
35+
constexpr double micro = 1e-6;
36+
constexpr double nano = 1e-9;
37+
constexpr double pico = 1e-12;
38+
constexpr double femto = 1e-15;
39+
2640
} // constants namespace
2741
} // dryad namespace
2842
} // njoy namespace

src/dryad/format/ace/createTabulatedAverageEnergy.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// other includes
88
#include "tools/Log.hpp"
9+
#include "dryad/constants.hpp"
910
#include "dryad/format/createVector.hpp"
1011
#include "dryad/TabulatedAverageEnergy.hpp"
1112
#include "ACEtk/electroatomic/ExcitationBlock.hpp"
@@ -29,14 +30,18 @@ namespace ace {
2930

3031
auto convertEnergy = [] ( auto&& energy ) {
3132

32-
return energy * 1e+6;
33+
return energy * constants::mega;
34+
};
35+
auto convertEnergyDifference = [] ( auto&& left, auto&& right ) {
36+
37+
return ( left - right ) * constants::mega;
3338
};
3439

3540
Log::info( "Reading average energy data" );
3641
auto energies = createVector( block.energies() );
3742
auto values = createVector( block.excitationEnergyLoss() );
3843
std::transform( energies.begin(), energies.end(), values.begin(), values.begin(),
39-
[] ( auto&& left, auto&& right ) { return ( left - right ) * 1e+6; } );
44+
convertEnergyDifference );
4045
std::transform( energies.begin(), energies.end(), energies.begin(), convertEnergy );
4146
std::vector< std::size_t > boundaries = { energies.size() - 1 };
4247
std::vector< InterpolationType > interpolants = { InterpolationType::LinearLinear };
@@ -64,14 +69,18 @@ namespace ace {
6469

6570
auto convertEnergy = [] ( auto&& energy ) {
6671

67-
return energy * 1e+6;
72+
return energy * constants::mega;
73+
};
74+
auto convertEnergyDifference = [] ( auto&& left, auto&& right ) {
75+
76+
return ( left - right ) * constants::mega;
6877
};
6978

7079
Log::info( "Reading average energy data" );
7180
auto energies = createVector( block.energies() );
7281
auto values = createVector( block.energyAfterBremsstrahlung() );
7382
std::transform( energies.begin(), energies.end(), values.begin(), values.begin(),
74-
[] ( auto&& left, auto&& right ) { return ( left - right ) * 1e+6; } );
83+
convertEnergyDifference );
7584
std::transform( energies.begin(), energies.end(), energies.begin(), convertEnergy );
7685
std::vector< std::size_t > boundaries = { energies.size() - 1 };
7786
std::vector< InterpolationType > interpolants = { InterpolationType::LinearLinear };

src/dryad/format/ace/createTabulatedEnergyDistributionFunction.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// other includes
88
#include "tools/Log.hpp"
9+
#include "dryad/constants.hpp"
910
#include "dryad/format/createVector.hpp"
1011
#include "dryad/TabulatedEnergyDistributionFunction.hpp"
1112
#include "ACEtk/electroatomic/TabulatedEnergyDistribution.hpp"
@@ -28,7 +29,7 @@ namespace ace {
2829

2930
auto convertEnergy = [] ( auto&& energy ) {
3031

31-
return energy * 1e+6;
32+
return energy * constants::mega;
3233
};
3334

3435
auto energies = createVector( distribution.outgoingEnergies() );

src/dryad/format/ace/electroatomic/createTabulatedCrossSections.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// other includes
88
#include "tools/Log.hpp"
9+
#include "dryad/constants.hpp"
910
#include "dryad/format/createVector.hpp"
1011
#include "dryad/TabulatedCrossSection.hpp"
1112
#include "ACEtk/PhotoatomicTable.hpp"
@@ -28,7 +29,7 @@ namespace electroatomic {
2829

2930
auto convertEnergy = [] ( auto&& energy ) {
3031

31-
return energy * 1e+6;
32+
return energy * constants::mega;
3233
};
3334

3435
if ( table.electronPhotonRelaxationFormat() > 0 ) {

src/dryad/format/ace/photoatomic/createTabulatedCrossSections.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// other includes
88
#include "tools/Log.hpp"
9+
#include "dryad/constants.hpp"
910
#include "dryad/format/createVector.hpp"
1011
#include "dryad/TabulatedCrossSection.hpp"
1112
#include "ACEtk/PhotoatomicTable.hpp"
@@ -30,7 +31,7 @@ namespace photoatomic {
3031
// is exactly 0 (in which case it is zero)
3132
auto convertEnergy = [] ( auto&& energy ) {
3233

33-
return energy == 0. ? energy : std::exp( energy ) * 1e+6;
34+
return energy == 0. ? energy : std::exp( energy ) * constants::mega;
3435
};
3536
auto convertValue = [] ( auto&& value ) {
3637

src/dryad/format/endf/resonances/createTabulatedRadius.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// other includes
88
#include "tools/Log.hpp"
9+
#include "dryad/constants.hpp"
910
#include "dryad/format/createVector.hpp"
1011
#include "dryad/format/endf/createBoundaries.hpp"
1112
#include "dryad/format/endf/createInterpolants.hpp"
@@ -27,11 +28,13 @@ namespace resonances {
2728

2829
try {
2930

31+
// ENDF gives a radius in 1e-12 cm, dryad stores it in fm
32+
3033
Log::info( "Reading energy dependent scattering radius" );
3134
auto energies = createVector( radius.energies() );
3235
auto values = createVector( radius.radii() );
3336
std::transform( values.begin(), values.end(), values.begin(),
34-
[] ( auto&& value ) { return value * 10.; } );
37+
[] ( auto&& value ) { return value * constants::deca; } );
3538
auto boundaries = createBoundaries( radius.boundaries() );
3639
auto interpolants = createInterpolants( radius.interpolants() );
3740
return dryad::resonances::TabulatedRadius(

src/dryad/format/gnds/convertCrossSections.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// other includes
99
#include "tools/Log.hpp"
10+
#include "dryad/constants.hpp"
1011

1112
namespace njoy {
1213
namespace dryad {
@@ -23,7 +24,7 @@ namespace gnds {
2324
if ( unit == "Mb" ) {
2425

2526
std::for_each( xs.begin(), xs.end(),
26-
[] ( double& xs ) { xs *= 1e+6; } );
27+
[] ( double& xs ) { xs *= constants::mega; } );
2728
}
2829
else {
2930

src/dryad/format/gnds/convertEnergies.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// other includes
99
#include "tools/Log.hpp"
10+
#include "dryad/constants.hpp"
1011

1112
namespace njoy {
1213
namespace dryad {
@@ -23,7 +24,7 @@ namespace gnds {
2324
if ( unit == "MeV" ) {
2425

2526
std::for_each( energies.begin(), energies.end(),
26-
[] ( double& energy ) { energy *= 1e+6; } );
27+
[] ( double& energy ) { energy *= constants::mega; } );
2728
}
2829
else {
2930

src/dryad/format/gnds/convertEnergy.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// other includes
88
#include "tools/Log.hpp"
9+
#include "dryad/constants.hpp"
910

1011
namespace njoy {
1112
namespace dryad {
@@ -21,7 +22,7 @@ namespace gnds {
2122

2223
if ( unit == "MeV" ) {
2324

24-
energy *= 1e+6;
25+
energy *= constants::mega;
2526
}
2627
else {
2728

0 commit comments

Comments
 (0)