File tree Expand file tree Collapse file tree 7 files changed +124
-6
lines changed Expand file tree Collapse file tree 7 files changed +124
-6
lines changed Original file line number Diff line number Diff line change
1
+ #ifndef NJOY_DRYAD_INTERACTIONTYPE
2
+ #define NJOY_DRYAD_INTERACTIONTYPE
3
+
4
+ // system includes
5
+
6
+ // other includes
7
+
8
+ namespace njoy {
9
+ namespace dryad {
10
+
11
+ enum class InteractionType : short {
12
+
13
+ Atomic = 1 ,
14
+ Nuclear = 2
15
+ };
16
+
17
+ } // dryad namespace
18
+ } // njoy namespace
19
+
20
+ #endif
Original file line number Diff line number Diff line change 6
6
7
7
// other includes
8
8
#include " dryad/type-aliases.hpp"
9
+ #include " dryad/InteractionType.hpp"
9
10
#include " dryad/ParticleID.hpp"
10
11
#include " dryad/Reaction.hpp"
11
12
@@ -22,6 +23,8 @@ namespace dryad {
22
23
ParticleID projectile_id_;
23
24
ParticleID target_id_;
24
25
26
+ InteractionType interaction_;
27
+
25
28
std::vector< Reaction > reactions_;
26
29
27
30
bool linearised_;
Original file line number Diff line number Diff line change
1
+ #ifndef NJOY_DRYAD_FORMAT_ENDF_CREATEINTERACTIONTYPE
2
+ #define NJOY_DRYAD_FORMAT_ENDF_CREATEINTERACTIONTYPE
3
+
4
+ // system includes
5
+ #include < vector>
6
+
7
+ // other includes
8
+ #include " tools/Log.hpp"
9
+ #include " dryad/InteractionType.hpp"
10
+
11
+ namespace njoy {
12
+ namespace dryad {
13
+ namespace format {
14
+ namespace endf {
15
+
16
+ /* *
17
+ * @brief Create the interaction type
18
+ */
19
+ InteractionType createInteractionType ( int sublibrary ) {
20
+
21
+ switch ( sublibrary ) {
22
+
23
+ case 0 : return InteractionType::Nuclear;
24
+ case 3 : return InteractionType::Atomic;
25
+ case 10 : return InteractionType::Nuclear;
26
+ case 113 : return InteractionType::Atomic;
27
+ case 10010 : return InteractionType::Nuclear;
28
+ case 10020 : return InteractionType::Nuclear;
29
+ case 10030 : return InteractionType::Nuclear;
30
+ case 20030 : return InteractionType::Nuclear;
31
+ case 20040 : return InteractionType::Nuclear;
32
+ default : {
33
+
34
+ Log::error ( " ENDF sublibrary {} does not define projectile-target data" ,
35
+ sublibrary );
36
+ throw std::exception ();
37
+ }
38
+ }
39
+ }
40
+
41
+ } // endf namespace
42
+ } // format namespace
43
+ } // dryad namespace
44
+ } // njoy namespace
45
+
46
+ #endif
Original file line number Diff line number Diff line change @@ -21,9 +21,9 @@ namespace endf {
21
21
switch ( sublibrary ) {
22
22
23
23
case 0 : return ParticleID ( " g" );
24
- case 3 : return ParticleID ( " photoatomic " );
24
+ case 3 : return ParticleID ( " g " );
25
25
case 10 : return ParticleID ( " n" );
26
- case 113 : return ParticleID ( " e" );
26
+ case 113 : return ParticleID ( " e- " );
27
27
case 10010 : return ParticleID ( " p" );
28
28
case 10020 : return ParticleID ( " d" );
29
29
case 10030 : return ParticleID ( " t" );
Original file line number Diff line number Diff line change 1
- add_cpp_test( format.endf.createBoundaries createBoundaries.test .cpp )
2
- add_cpp_test( format.endf.createInterpolant createInterpolant.test .cpp )
3
- add_cpp_test( format.endf.createInterpolants createInterpolants.test .cpp )
4
- add_cpp_test( format.endf.createParticleID createParticleID.test .cpp )
1
+ add_cpp_test( format.endf.createBoundaries createBoundaries.test .cpp )
2
+ add_cpp_test( format.endf.createInterpolant createInterpolant.test .cpp )
3
+ add_cpp_test( format.endf.createInterpolants createInterpolants.test .cpp )
4
+ add_cpp_test( format.endf.createParticleID createParticleID.test .cpp )
5
+ add_cpp_test( format.endf.createInteractionType createInteractionType.test .cpp )
5
6
6
7
add_cpp_test( format.endf.createTabulatedCrossSection createTabulatedCrossSection.test .cpp )
7
8
add_cpp_test( format.endf.createReaction createReaction.test .cpp )
Original file line number Diff line number Diff line change
1
+ // include Catch2
2
+ #include < catch2/catch_test_macros.hpp>
3
+ #include < catch2/matchers/catch_matchers_floating_point.hpp>
4
+ using Catch::Matchers::WithinRel;
5
+
6
+ // what we are testing
7
+ #include " dryad/format/endf/createInteractionType.hpp"
8
+
9
+ // other includes
10
+
11
+ // convenience typedefs
12
+ using namespace njoy ::dryad;
13
+
14
+ SCENARIO ( " createInteractionType" ) {
15
+
16
+ GIVEN ( " ENDF sublibrary values" ) {
17
+
18
+ WHEN ( " a single sublibrary value is given" ) {
19
+
20
+ THEN ( " it can be converted" ) {
21
+
22
+ CHECK ( InteractionType::Nuclear == format::endf::createInteractionType ( 0 ) );
23
+ CHECK ( InteractionType::Atomic == format::endf::createInteractionType ( 3 ) );
24
+ CHECK ( InteractionType::Nuclear == format::endf::createInteractionType ( 10 ) );
25
+ CHECK ( InteractionType::Atomic == format::endf::createInteractionType ( 113 ) );
26
+ CHECK ( InteractionType::Nuclear == format::endf::createInteractionType ( 10010 ) );
27
+ CHECK ( InteractionType::Nuclear == format::endf::createInteractionType ( 10020 ) );
28
+ CHECK ( InteractionType::Nuclear == format::endf::createInteractionType ( 10030 ) );
29
+ CHECK ( InteractionType::Nuclear == format::endf::createInteractionType ( 20030 ) );
30
+ CHECK ( InteractionType::Nuclear == format::endf::createInteractionType ( 20040 ) );
31
+ } // THEN
32
+
33
+ THEN ( " an exception is thrown for an unknown or unsupported sublibrary type" ) {
34
+
35
+ CHECK_THROWS ( format::endf::createInteractionType ( 1 ) );
36
+ CHECK_THROWS ( format::endf::createInteractionType ( 40090 ) );
37
+ } // THEN
38
+ } // WHEN
39
+ } // GIVEN
40
+ } // SCENARIO
Original file line number Diff line number Diff line change @@ -19,7 +19,15 @@ SCENARIO( "createParticleID" ) {
19
19
20
20
THEN ( " it can be converted" ) {
21
21
22
+ CHECK ( ParticleID ( " g" ) == format::endf::createParticleID ( 0 ) );
23
+ CHECK ( ParticleID ( " g" ) == format::endf::createParticleID ( 3 ) );
22
24
CHECK ( ParticleID ( " n" ) == format::endf::createParticleID ( 10 ) );
25
+ CHECK ( ParticleID ( " e-" ) == format::endf::createParticleID ( 113 ) );
26
+ CHECK ( ParticleID ( " p" ) == format::endf::createParticleID ( 10010 ) );
27
+ CHECK ( ParticleID ( " d" ) == format::endf::createParticleID ( 10020 ) );
28
+ CHECK ( ParticleID ( " t" ) == format::endf::createParticleID ( 10030 ) );
29
+ CHECK ( ParticleID ( " he3" ) == format::endf::createParticleID ( 20030 ) );
30
+ CHECK ( ParticleID ( " a" ) == format::endf::createParticleID ( 20040 ) );
23
31
} // THEN
24
32
25
33
THEN ( " an exception is thrown for an unknown or unsupported sublibrary type" ) {
You can’t perform that action at this time.
0 commit comments