Skip to content

Commit 04890a2

Browse files
committed
Merge branch 'feature/resonances-part5' into 'develop'
Feature/resonances part5 See merge request njoy/dryad!78
2 parents e2c4ae7 + e8dd652 commit 04890a2

33 files changed

+1731
-59
lines changed

cmake/unit_testing.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ add_cpp_test( id.LevelID id/Leve
5050
add_cpp_test( id.ParticleID id/ParticleID.test.cpp )
5151
add_cpp_test( id.ReactionType id/ReactionType.test.cpp )
5252
add_cpp_test( id.ReactionID id/ReactionID.test.cpp )
53+
add_cpp_test( id.ChannelID id/ChannelID.test.cpp )
5354

55+
add_cpp_test( resonances.Particle resonances/Particle.test.cpp )
56+
add_cpp_test( resonances.ParticlePair resonances/ParticlePair.test.cpp )
5457
add_cpp_test( resonances.TabulatedRadius resonances/TabulatedRadius.test.cpp )
5558
add_cpp_test( resonances.ChannelRadii resonances/ChannelRadii.test.cpp )
5659
add_cpp_test( resonances.ChannelQuantumNumbers resonances/ChannelQuantumNumbers.test.cpp )

cmake/unit_testing_python.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_python_test( id.LevelID id/Test_dryad_id_LevelI
3232
add_python_test( id.ParticleID id/Test_dryad_id_ParticleID.py )
3333
add_python_test( id.ReactionType id/Test_dryad_id_ReactionType.py )
3434
add_python_test( id.ReactionID id/Test_dryad_id_ReactionID.py )
35+
add_python_test( id.ChannelID id/Test_dryad_id_ChannelID.py )
3536

3637
add_python_test( atomic.RadiativeTransitionData atomic/Test_dryad_atomic_RadiativeTransitionData.py )
3738
add_python_test( atomic.NonRadiativeTransitionData atomic/Test_dryad_atomic_NonRadiativeTransitionData.py )
@@ -45,6 +46,8 @@ add_python_test( covariance.ProductMultiplicityMetadata covariance/Test
4546
add_python_test( covariance.ProductMultiplicityCovarianceMatrix covariance/Test_dryad_covariance_ProductMultiplicityCovarianceMatrix.py )
4647
add_python_test( covariance.LinearCombinationCovariance covariance/Test_dryad_covariance_LinearCombinationCovariance.py )
4748

49+
add_python_test( resonances.Particle resonances/Test_dryad_resonances_Particle.py )
50+
add_python_test( resonances.ParticlePair resonances/Test_dryad_resonances_ParticlePair.py )
4851
add_python_test( resonances.ChannelQuantumNumbers resonances/Test_dryad_resonances_ChannelQuantumNumbers.py )
4952
add_python_test( resonances.TabulatedRadius resonances/Test_dryad_resonances_TabulatedRadius.py )
5053
add_python_test( resonances.ChannelRadii resonances/Test_dryad_resonances_ChannelRadii.py )

python/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ if(dryad.python)
1212
${CMAKE_CURRENT_SOURCE_DIR}/src/id/ParticleID.python.cpp
1313
${CMAKE_CURRENT_SOURCE_DIR}/src/id/ReactionType.python.cpp
1414
${CMAKE_CURRENT_SOURCE_DIR}/src/id/ReactionID.python.cpp
15+
${CMAKE_CURRENT_SOURCE_DIR}/src/id/ChannelID.python.cpp
1516
${CMAKE_CURRENT_SOURCE_DIR}/src/atomic.python.cpp
1617
${CMAKE_CURRENT_SOURCE_DIR}/src/atomic/TransitionType.python.cpp
1718
${CMAKE_CURRENT_SOURCE_DIR}/src/atomic/RadiativeTransitionData.python.cpp
1819
${CMAKE_CURRENT_SOURCE_DIR}/src/atomic/NonRadiativeTransitionData.python.cpp
1920
${CMAKE_CURRENT_SOURCE_DIR}/src/atomic/ElectronSubshellConfiguration.python.cpp
2021
${CMAKE_CURRENT_SOURCE_DIR}/src/resonances.python.cpp
2122
${CMAKE_CURRENT_SOURCE_DIR}/src/resonances/ResonanceParameters.python.cpp
23+
${CMAKE_CURRENT_SOURCE_DIR}/src/resonances/Particle.python.cpp
24+
${CMAKE_CURRENT_SOURCE_DIR}/src/resonances/ParticlePair.python.cpp
2225
${CMAKE_CURRENT_SOURCE_DIR}/src/resonances/ChannelQuantumNumbers.python.cpp
2326
${CMAKE_CURRENT_SOURCE_DIR}/src/resonances/TabulatedRadius.python.cpp
2427
${CMAKE_CURRENT_SOURCE_DIR}/src/resonances/ChannelRadii.python.cpp

python/src/id.python.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace id {
1717
void wrapParticleID( python::module& );
1818
void wrapReactionType( python::module& );
1919
void wrapReactionID( python::module& );
20+
void wrapChannelID( python::module& );
2021
}
2122

2223
void wrapID( python::module& module ) {
@@ -35,4 +36,5 @@ void wrapID( python::module& module ) {
3536
id::wrapParticleID( submodule );
3637
id::wrapReactionType( submodule );
3738
id::wrapReactionID( submodule );
39+
id::wrapChannelID( submodule );
3840
}

python/src/id/ChannelID.python.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
#include <pybind11/operators.h>
5+
6+
// local includes
7+
#include "definitions.hpp"
8+
#include "dryad/id/ChannelID.hpp"
9+
10+
// namespace aliases
11+
namespace python = pybind11;
12+
13+
namespace id {
14+
15+
void wrapChannelID( python::module& module ) {
16+
17+
// type aliases
18+
using Component = njoy::dryad::id::ChannelID;
19+
using ReactionID = njoy::dryad::id::ReactionID;
20+
using ChannelQuantumNumbers = njoy::dryad::resonances::ChannelQuantumNumbers;
21+
22+
// wrap views created by this component
23+
24+
// create the component
25+
python::class_< Component > component(
26+
27+
module,
28+
"ChannelID",
29+
"The channel identifier, with associated reaction and quantum numbers"
30+
);
31+
32+
// wrap the component
33+
component
34+
.def(
35+
36+
python::init< const ReactionID&, const ChannelQuantumNumbers&,
37+
const std::optional< std::size_t >& >(),
38+
python::arg( "reaction" ), python::arg( "quantum_numbers" ),
39+
python::arg( "partial" ) = std::nullopt,
40+
"Initialise the channel identifier\n\n"
41+
"Arguments:\n"
42+
" self the channel identifier\n"
43+
" reaction the reaction\n"
44+
" numbers the channel quantum numbers\n"
45+
" partial the optional partial index"
46+
)
47+
.def(
48+
49+
python::init< const std::string& >(),
50+
python::arg( "symbol" ),
51+
"Initialise the channel identifier\n\n"
52+
"Arguments:\n"
53+
" self the channel identifier\n"
54+
" symbol the channel symbol"
55+
)
56+
.def(
57+
58+
python::init< const Component& >(),
59+
python::arg( "instance" ),
60+
"Initialise a copy\n\n"
61+
"Arguments:\n"
62+
" instance the instance to be copied\n"
63+
)
64+
.def_property_readonly(
65+
66+
"reaction",
67+
&Component::reaction,
68+
"The reaction"
69+
)
70+
.def_property_readonly(
71+
72+
"quantum_numbers",
73+
&Component::quantumNumbers,
74+
"The quantum numbers"
75+
)
76+
.def_property_readonly(
77+
78+
"partial",
79+
&Component::partial,
80+
"The partial number (if defined)"
81+
)
82+
.def_property_readonly(
83+
84+
"symbol",
85+
&Component::symbol,
86+
"The channel identifier's symbol"
87+
)
88+
.def(
89+
90+
"__hash__",
91+
[] ( const Component& self ) { return std::hash< Component >{}( self ); },
92+
"Hash function"
93+
);
94+
95+
// add standard comparison definitions
96+
addStandardComparisonDefinitions< Component >( component );
97+
98+
// add standard print definitions
99+
addStandardPrintDefinitions< Component >( component );
100+
}
101+
102+
} // namespace id

python/src/resonances.python.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace python = pybind11;
1010
namespace resonances {
1111

1212
// declarations - components
13+
void wrapParticle( python::module& );
14+
void wrapParticlePair( python::module& );
1315
void wrapChannelQuantumNumbers( python::module& );
1416
void wrapTabulatedRadius( python::module& );
1517
void wrapChannelRadii( python::module& );
@@ -32,6 +34,8 @@ void wrapResonances( python::module& module ) {
3234
);
3335

3436
// components
37+
resonances::wrapParticle( submodule );
38+
resonances::wrapParticlePair( submodule );
3539
resonances::wrapChannelQuantumNumbers( submodule );
3640
resonances::wrapTabulatedRadius( submodule );
3741
resonances::wrapChannelRadii( submodule );

python/src/resonances/ChannelQuantumNumbers.python.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ void wrapChannelQuantumNumbers( python::module& module ) {
117117
" l the orbital angular momentum\n"
118118
" s the channel spin"
119119

120-
)
121-
;
120+
);
122121

123122
// add standard comparison definitions
124123
addStandardComparisonDefinitions< Component >( component );
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
#include "definitions.hpp"
7+
#include "dryad/resonances/Particle.hpp"
8+
9+
// namespace aliases
10+
namespace python = pybind11;
11+
12+
namespace resonances {
13+
14+
void wrapParticle( python::module& module ) {
15+
16+
// type aliases
17+
using Component = njoy::dryad::resonances::Particle;
18+
using ParticleID = njoy::dryad::id::ParticleID;
19+
20+
// wrap views created by this component
21+
22+
// create the component
23+
python::class_< Component > component(
24+
25+
module,
26+
"Particle",
27+
"Particle information for resonance reconstruction\n\n"
28+
"The Particle class contains specific information for a particle as used\n"
29+
"during resonance reconstruction. The Particle has an atomic mass, an\n"
30+
"electrical charge, a spin and a parity (either + or -).\n\n"
31+
"These variables are used to calculate quantities like the wave number k."
32+
);
33+
34+
// wrap the component
35+
component
36+
.def(
37+
38+
python::init< ParticleID, double, double, short >(),
39+
python::arg( "id" ), python::arg( "mass" ),
40+
python::arg( "spin" ), python::arg( "parity" ),
41+
"Initialise the particle information\n\n"
42+
"Arguments:\n"
43+
" self the particle information\n"
44+
" mass the atomic mass\n"
45+
" spin the channel spin\n"
46+
" parity the parity"
47+
)
48+
.def(
49+
50+
python::init< const Component& >(),
51+
python::arg( "instance" ),
52+
"Initialise a copy\n\n"
53+
"Arguments:\n"
54+
" instance the instance to be copied\n"
55+
)
56+
.def_property_readonly(
57+
58+
"identifier",
59+
&Component::identifier,
60+
"The particle identifier"
61+
)
62+
.def_property_readonly(
63+
64+
"mass",
65+
&Component::mass,
66+
"The atomic mass of the particle (in atomic mass units)"
67+
)
68+
.def_property_readonly(
69+
70+
"charge",
71+
&Component::charge,
72+
"The electrical charge of the particle (in units of the "
73+
"elementary charge)"
74+
)
75+
.def_property_readonly(
76+
77+
"spin",
78+
&Component::spin,
79+
"The particle spin"
80+
)
81+
.def_property_readonly(
82+
83+
"parity",
84+
&Component::parity,
85+
"The parity"
86+
);
87+
88+
// add standard comparison definitions
89+
addStandardEqualityComparisonDefinitions< Component >( component );
90+
}
91+
92+
} // resonances namespace
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
#include "definitions.hpp"
7+
#include "dryad/resonances/ParticlePair.hpp"
8+
9+
// namespace aliases
10+
namespace python = pybind11;
11+
12+
namespace resonances {
13+
14+
void wrapParticlePair( python::module& module ) {
15+
16+
// type aliases
17+
using Component = njoy::dryad::resonances::ParticlePair;
18+
using Particle = njoy::dryad::resonances::Particle;
19+
20+
// wrap views created by this component
21+
22+
// create the component
23+
python::class_< Component > component(
24+
25+
module,
26+
"ParticlePair",
27+
"Particle information for resonance reconstruction\n\n"
28+
"A ParticlePair represents the two particles involved in a entrance or exit\n"
29+
"reaction channel (we assume that the reaction is a two-body reaction). The\n"
30+
"pair consists of a \"small\" incident or outgoing particle (e.g. a neutron,\n"
31+
"photon, alpha, etc.) and a \"larger\" target or residual nucleus (e.g. H1,\n"
32+
"He4, U235, etc.).\n\n"
33+
"The ParticlePair class gives us access to information related to the\n"
34+
"pair of particles such as the mass ratio and the reduced mass."
35+
);
36+
37+
// wrap the component
38+
component
39+
.def(
40+
41+
python::init< Particle, Particle >(),
42+
python::arg( "particle" ), python::arg( "residual" ),
43+
"Initialise the particle pair information\n\n"
44+
"Arguments:\n"
45+
" self the particle pair information\n"
46+
" particle the light particle\n"
47+
" residual the heavy residual"
48+
)
49+
.def(
50+
51+
python::init< const Component& >(),
52+
python::arg( "instance" ),
53+
"Initialise a copy\n\n"
54+
"Arguments:\n"
55+
" instance the instance to be copied\n"
56+
)
57+
.def_property_readonly(
58+
59+
"particle",
60+
&Component::particle,
61+
"The light particle in the particle pair"
62+
)
63+
.def_property_readonly(
64+
65+
"residual",
66+
&Component::residual,
67+
"The heavy residual in the particle pair"
68+
)
69+
.def_property_readonly(
70+
71+
"reduced_mass",
72+
&Component::reducedMass,
73+
"The reduced mass of the particle pair (in atomic mass units)\n\n"
74+
"The reduced mass mu of the two particles is defined as follows:\n"
75+
" mu = ma * mb / ( ma + mb )\n"
76+
"in which ma and mb are the atomic mass values of the particles in the\n"
77+
"particle pair."
78+
)
79+
.def_property_readonly(
80+
81+
"mass_ratio",
82+
&Component::massRatio,
83+
"The mass ratio of the particle pair (dimensionless)\n\n"
84+
"The mass ratio of the two particles is defined as follows:\n"
85+
" ratio = mb / ( ma + mb )\n"
86+
"in which ma and mb are the atomic mass values of the particles\n"
87+
"in the particle pair."
88+
);
89+
90+
// add standard comparison definitions
91+
addStandardEqualityComparisonDefinitions< Component >( component );
92+
}
93+
94+
} // resonances namespace

0 commit comments

Comments
 (0)