Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding GENDF Capabilities to ENDFtk #73

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removed placeholder parse-gendf. Added testing for GendfTape and upda…
…ted GendfSection.test.
  • Loading branch information
nathangibson14 committed May 29, 2020
commit b2939c130b6eaea51ca9d160afff34207932e6d3
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -771,7 +771,7 @@ target_sources( ENDFtk INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/File/src/parse.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/Section/src/ctor.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/Section/src/findEnd.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/Section/src/parse.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/Section/src/parse-endf.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/Tape/src/createMap.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/Tape/src/materialNumber.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ENDFtk/syntaxTree/Tape/src/ctor.hpp"
3 changes: 2 additions & 1 deletion src/ENDFtk/syntaxTree/Section.hpp
Original file line number Diff line number Diff line change
@@ -58,8 +58,9 @@ class Section< BufferIterator, GENDFTag >

/* methods */

// TODO: Add parse function once required classes are implemented.
// this file implements the parse() function
#include "ENDFtk/syntaxTree/Section/src/parse-gendf.hpp"
// #include "ENDFtk/syntaxTree/Section/src/parse-gendf.hpp"

using Base::MT;
using Base::sectionNumber;
23 changes: 0 additions & 23 deletions src/ENDFtk/syntaxTree/Section/src/parse-gendf.hpp

This file was deleted.

171 changes: 109 additions & 62 deletions src/ENDFtk/syntaxTree/Section/test/GendfSection.test.cpp
Original file line number Diff line number Diff line change
@@ -3,22 +3,16 @@
#include "catch.hpp"
#include "ENDFtk.hpp"

std::string baseSection();
std::string mfd3mt2();
std::string validSEND();
std::string invalidSEND();

using namespace njoy::ENDFtk;

/*
* Note: this was lifted from Section.test.cpp.
* The ENDF Section given below is not a valid
* GENDF section, and so it needs to be updated
* when parsing is implemented.
*/
SCENARIO( "Creating a syntax tree of a GENDF Section" ){
GIVEN( "A string representation of a Section" ){
WHEN( "a valid SEND record ends the Section" ){
std::string sectionString = baseSection() + validSEND();
std::string sectionString = mfd3mt2() + validSEND();
auto position = sectionString.begin();
auto start = sectionString.begin();
auto end = sectionString.end();
@@ -31,7 +25,7 @@ SCENARIO( "Creating a syntax tree of a GENDF Section" ){
const auto& csectionTree = sectionTree;

THEN( "the entire stream is read" ){
REQUIRE( 36 == lineNumber );
REQUIRE( 90 == lineNumber );
}

AND_THEN( "the buffer iterators are populated correctly "){
@@ -44,10 +38,10 @@ SCENARIO( "Creating a syntax tree of a GENDF Section" ){
AND_THEN( "the file/section number or MF/MT is populated correctly" ){
REQUIRE( 3 == sectionTree.MF() );
REQUIRE( 3 == sectionTree.fileNumber() );
REQUIRE( 1 == sectionTree.MT() );
REQUIRE( 1 == sectionTree.sectionNumber() );
REQUIRE( 1 == csectionTree.MT() );
REQUIRE( 1 == csectionTree.sectionNumber() );
REQUIRE( 2 == sectionTree.MT() );
REQUIRE( 2 == sectionTree.sectionNumber() );
REQUIRE( 2 == csectionTree.MT() );
REQUIRE( 2 == csectionTree.sectionNumber() );
}

AND_THEN( "the first record of the section is a head record" ){
@@ -56,22 +50,20 @@ SCENARIO( "Creating a syntax tree of a GENDF Section" ){
long lineNumber = 0;

HeadRecord head( start, end, lineNumber );
REQUIRE( head.ZA() == 1.001E3 );
REQUIRE( head.AWR() == 9.991673E-1 );
REQUIRE( head.L1() == 0 );
REQUIRE( head.L2() == 0 );
REQUIRE( head.ZA() == 9.2235E4 );
REQUIRE( head.AWR() == 0.0 );
REQUIRE( head.L1() == 1 );
REQUIRE( head.L2() == 1 );
REQUIRE( head.N1() == 0 );
REQUIRE( head.N2() == 0 );
REQUIRE( head.N2() == 44 );
}

AND_THEN( "it can be parsed") {
auto parsec = sectionTree.parse<3>();
REQUIRE( parsec.confirm() == 0 );
}
// TODO: Add test of parse function.

} // WHEN

WHEN( "an invalid (MT!=0) SEND record ends the Section" ){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job testing failure conditions. Are there others that also need to be tested?

std::string sectionString = baseSection() + invalidSEND();
std::string sectionString = mfd3mt2() + invalidSEND();
THEN( "an exception is thrown" ){
auto begin = sectionString.begin();
auto start = sectionString.begin();
@@ -86,7 +78,7 @@ SCENARIO( "Creating a syntax tree of a GENDF Section" ){

WHEN( "a Section that is too short (no SEND record)" ){
THEN( "an exception is thrown" ){
std::string sectionString = baseSection();
std::string sectionString = mfd3mt2();
auto begin = sectionString.begin();
auto start = sectionString.begin();
auto end = sectionString.end();
@@ -99,51 +91,106 @@ SCENARIO( "Creating a syntax tree of a GENDF Section" ){
} // GIVEN
} // SCENARIO

std::string baseSection(){

std::string mfd3mt2() {
return
" 1.001000+3 9.991673-1 0 0 0 0 125 3 1\n"
" 0.000000+0 0.000000+0 0 0 2 96 125 3 1\n"
" 30 5 96 2 125 3 1\n"
" 1.000000-5 3.713628+1 2.000000-5 3.224498+1 5.000000-5 2.790478+1 125 3 1\n"
" 1.000000-4 2.571732+1 2.000000-4 2.417056+1 5.000000-4 2.279806+1 125 3 1\n"
" 1.000000-3 2.210633+1 2.000000-3 2.161720+1 5.000000-3 2.118318+1 125 3 1\n"
" 1.000000-2 2.096443+1 2.530000-2 2.076834+1 5.000000-2 2.067250+1 125 3 1\n"
" 1.000000-1 2.060332+1 2.000000-1 2.055439+1 5.000000-1 2.051095+1 125 3 1\n"
" 1.000000+0 2.048901+1 2.000000+0 2.047341+1 5.000000+0 2.045928+1 125 3 1\n"
" 1.000000+1 2.045169+1 2.000000+1 2.044545+1 5.000000+1 2.043707+1 125 3 1\n"
" 1.000000+2 2.042815+1 2.000000+2 2.041317+1 5.000000+2 2.037161+1 125 3 1\n"
" 1.000000+3 2.030435+1 2.000000+3 2.017221+1 4.000000+3 1.991433+1 125 3 1\n"
" 6.000000+3 1.966407+1 8.000000+3 1.942096+1 1.000000+4 1.918468+1 125 3 1\n"
" 1.500000+4 1.862195+1 2.000000+4 1.809600+1 4.000000+4 1.629575+1 125 3 1\n"
" 6.000000+4 1.486744+1 8.000000+4 1.370595+1 1.000000+5 1.274239+1 125 3 1\n"
" 1.500000+5 1.092347+1 2.000000+5 9.643237+0 3.000000+5 7.951994+0 125 3 1\n"
" 4.000000+5 6.876451+0 5.000000+5 6.125481+0 6.000000+5 5.566913+0 125 3 1\n"
" 7.000000+5 5.132043+0 8.000000+5 4.781603+0 9.000000+5 4.491504+0 125 3 1\n"
" 1.000000+6 4.246138+0 1.200000+6 3.850489+0 1.400000+6 3.541783+0 125 3 1\n"
" 1.600000+6 3.291349+0 1.800000+6 3.082224+0 2.000000+6 2.903682+0 125 3 1\n"
" 2.200000+6 2.748580+0 2.400000+6 2.611955+0 2.600000+6 2.490235+0 125 3 1\n"
" 2.800000+6 2.380773+0 3.000000+6 2.281558+0 3.200000+6 2.191030+0 125 3 1\n"
" 3.400000+6 2.107954+0 3.600000+6 2.031337+0 3.800000+6 1.960371+0 125 3 1\n"
" 4.000000+6 1.894386+0 4.200000+6 1.832823+0 4.400000+6 1.775213+0 125 3 1\n"
" 4.600000+6 1.721153+0 4.800000+6 1.670299+0 5.000000+6 1.622354+0 125 3 1\n"
" 5.500000+6 1.513587+0 6.000000+6 1.418191+0 6.500000+6 1.333743+0 125 3 1\n"
" 7.000000+6 1.258400+0 7.500000+6 1.190730+0 8.000000+6 1.129596+0 125 3 1\n"
" 8.500000+6 1.074084+0 9.000000+6 1.023447+0 9.500000+6 9.770666-1 125 3 1\n"
" 1.000000+7 9.344290-1 1.050000+7 8.950999-1 1.100000+7 8.587108-1 125 3 1\n"
" 1.150000+7 8.249463-1 1.200000+7 7.935351-1 1.250000+7 7.642418-1 125 3 1\n"
" 1.300000+7 7.368615-1 1.350000+7 7.112148-1 1.400000+7 6.871439-1 125 3 1\n"
" 1.450000+7 6.645095-1 1.500000+7 6.431880-1 1.550000+7 6.230693-1 125 3 1\n"
" 1.600000+7 6.040552-1 1.650000+7 5.860577-1 1.700000+7 5.689977-1 125 3 1\n"
" 1.750000+7 5.528040-1 1.800000+7 5.374121-1 1.850000+7 5.227637-1 125 3 1\n"
" 1.900000+7 5.088059-1 1.950000+7 4.954905-1 2.000000+7 4.827735-1 125 3 1\n";
" 9.223500+4 0.000000+0 1 1 0 449228 3 2 1\n"
" 2.936000+2 0.000000+0 2 1 2 19228 3 2 2\n"
" 8.864840+4 1.469141+1 9228 3 2 3\n"
" 2.936000+2 0.000000+0 2 1 2 29228 3 2 4\n"
" 4.076628+5 1.430320+1 9228 3 2 5\n"
" 2.936000+2 0.000000+0 2 1 2 39228 3 2 6\n"
" 3.325475+5 1.422934+1 9228 3 2 7\n"
" 2.936000+2 0.000000+0 2 1 2 49228 3 2 8\n"
" 2.704187+6 1.415084+1 9228 3 2 9\n"
" 2.936000+2 0.000000+0 2 1 2 59228 3 2 10\n"
" 9.182484+5 1.409805+1 9228 3 2 11\n"
" 2.936000+2 0.000000+0 2 1 2 69228 3 2 12\n"
" 1.831983+6 1.406694+1 9228 3 2 13\n"
" 2.936000+2 0.000000+0 2 1 2 79228 3 2 14\n"
" 1.611269+6 1.402843+1 9228 3 2 15\n"
" 2.936000+2 0.000000+0 2 1 2 89228 3 2 16\n"
" 2.150369+6 1.397806+1 9228 3 2 17\n"
" 2.936000+2 0.000000+0 2 1 2 99228 3 2 18\n"
" 1.677811+6 1.389651+1 9228 3 2 19\n"
" 2.936000+2 0.000000+0 2 1 2 109228 3 2 20\n"
" 9.702871+5 1.378522+1 9228 3 2 21\n"
" 2.936000+2 0.000000+0 2 1 2 119228 3 2 22\n"
" 3.285728+5 1.362093+1 9228 3 2 23\n"
" 2.936000+2 0.000000+0 2 1 2 129228 3 2 24\n"
" 1.348773+5 1.352095+1 9228 3 2 25\n"
" 2.936000+2 0.000000+0 2 1 2 139228 3 2 26\n"
" 1.208261+5 1.348035+1 9228 3 2 27\n"
" 2.936000+2 0.000000+0 2 1 2 149228 3 2 28\n"
" 1.094424+5 1.347708+1 9228 3 2 29\n"
" 2.936000+2 0.000000+0 2 1 2 159228 3 2 30\n"
" 1.921488+5 1.352816+1 9228 3 2 31\n"
" 2.936000+2 0.000000+0 2 1 2 169228 3 2 32\n"
" 8.537350+4 1.355762+1 9228 3 2 33\n"
" 2.936000+2 0.000000+0 2 1 2 179228 3 2 34\n"
" 7.955453+4 1.353933+1 9228 3 2 35\n"
" 2.936000+2 0.000000+0 2 1 2 189228 3 2 36\n"
" 7.448245+4 1.350431+1 9228 3 2 37\n"
" 2.936000+2 0.000000+0 2 1 2 199228 3 2 38\n"
" 5.152778+5 1.330950+1 9228 3 2 39\n"
" 2.936000+2 0.000000+0 2 1 2 209228 3 2 40\n"
" 5.421450+5 1.289614+1 9228 3 2 41\n"
" 2.936000+2 0.000000+0 2 1 2 219228 3 2 42\n"
" 6.582378+5 1.263968+1 9228 3 2 43\n"
" 2.936000+2 0.000000+0 2 1 2 229228 3 2 44\n"
" 6.085370+5 1.195173+1 9228 3 2 45\n"
" 2.936000+2 0.000000+0 2 1 2 239228 3 2 46\n"
" 5.304027+5 1.137018+1 9228 3 2 47\n"
" 2.936000+2 0.000000+0 2 1 2 249228 3 2 48\n"
" 2.698745+5 1.075633+1 9228 3 2 49\n"
" 2.936000+2 0.000000+0 2 1 2 259228 3 2 50\n"
" 3.469132+5 1.070006+1 9228 3 2 51\n"
" 2.936000+2 0.000000+0 2 1 2 269228 3 2 52\n"
" 2.436662+5 1.161760+1 9228 3 2 53\n"
" 2.936000+2 0.000000+0 2 1 2 279228 3 2 54\n"
" 1.269261+6 1.149129+1 9228 3 2 55\n"
" 2.936000+2 0.000000+0 2 1 2 289228 3 2 56\n"
" 1.389867+6 1.140790+1 9228 3 2 57\n"
" 2.936000+2 0.000000+0 2 1 2 299228 3 2 58\n"
" 1.966742+6 1.152955+1 9228 3 2 59\n"
" 2.936000+2 0.000000+0 2 1 2 309228 3 2 60\n"
" 1.958830+6 1.215428+1 9228 3 2 61\n"
" 2.936000+2 0.000000+0 2 1 2 319228 3 2 62\n"
" 2.003216+6 1.195243+1 9228 3 2 63\n"
" 2.936000+2 0.000000+0 2 1 2 329228 3 2 64\n"
" 4.448512+5 1.144792+1 9228 3 2 65\n"
" 2.936000+2 0.000000+0 2 1 2 339228 3 2 66\n"
" 1.600971+6 1.069586+1 9228 3 2 67\n"
" 2.936000+2 0.000000+0 2 1 2 349228 3 2 68\n"
" 1.653127+6 8.151080+0 9228 3 2 69\n"
" 2.936000+2 0.000000+0 2 1 2 359228 3 2 70\n"
" 1.607887+6 5.004643+0 9228 3 2 71\n"
" 2.936000+2 0.000000+0 2 1 2 369228 3 2 72\n"
" 1.044185+6 3.748074+0 9228 3 2 73\n"
" 2.936000+2 0.000000+0 2 1 2 379228 3 2 74\n"
" 5.807999+5 3.589833+0 9228 3 2 75\n"
" 2.936000+2 0.000000+0 2 1 2 389228 3 2 76\n"
" 4.118760+5 3.848525+0 9228 3 2 77\n"
" 2.936000+2 0.000000+0 2 1 2 399228 3 2 78\n"
" 7.543025+4 4.091297+0 9228 3 2 79\n"
" 2.936000+2 0.000000+0 2 1 2 409228 3 2 80\n"
" 2.347697+5 4.284081+0 9228 3 2 81\n"
" 2.936000+2 0.000000+0 2 1 2 419228 3 2 82\n"
" 3.334087+5 4.525173+0 9228 3 2 83\n"
" 2.936000+2 0.000000+0 2 1 2 429228 3 2 84\n"
" 8.667041+4 4.115439+0 9228 3 2 85\n"
" 2.936000+2 0.000000+0 2 1 2 439228 3 2 86\n"
" 3.704342+4 3.442857+0 9228 3 2 87\n"
" 2.936000+2 0.000000+0 2 1 2 449228 3 2 88\n"
" 1.292703+5 2.786681+0 9228 3 2 89\n";
}

std::string validSEND(){
return
" 125 3 0\n";
" 9228 3 0\n";
}

std::string invalidSEND(){
return
" 125 3 1\n";
" 9228 3 1\n";
}
20 changes: 19 additions & 1 deletion src/ENDFtk/syntaxTree/Tape/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -15,4 +15,22 @@ file( GLOB resources "resources/*" )
foreach( resource ${resources})
file( COPY "${resource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" )
endforeach()
add_test( NAME ENDFtk.syntaxTree.Tape COMMAND ENDFtk.syntaxTree.Tape.test )
add_test( NAME ENDFtk.syntaxTree.Tape COMMAND ENDFtk.syntaxTree.Tape.test )

add_executable( ENDFtk.syntaxTree.GendfTape.test GendfTape.test.cpp )
target_compile_options( ENDFtk.syntaxTree.GendfTape.test PRIVATE ${${PREFIX}_common_flags}
$<$<BOOL:${strict}>:${${PREFIX}_strict_flags}>$<$<CONFIG:DEBUG>:
${${PREFIX}_DEBUG_flags}
$<$<BOOL:${coverage}>:${${PREFIX}_coverage_flags}>>
$<$<CONFIG:RELEASE>:
${${PREFIX}_RELEASE_flags}
$<$<BOOL:${link_time_optimization}>:${${PREFIX}_link_time_optimization_flags}>
$<$<BOOL:${nonportable_optimization}>:${${PREFIX}_nonportable_optimization_flags}>>

${CXX_appended_flags} ${ENDFtk_appended_flags} )
target_link_libraries( ENDFtk.syntaxTree.GendfTape.test PUBLIC ENDFtk )
file( GLOB resources "resources/*" )
foreach( resource ${resources})
file( COPY "${resource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" )
endforeach()
add_test( NAME ENDFtk.syntaxTree.GendfTape COMMAND ENDFtk.syntaxTree.GendfTape.test )