-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding fission neutron multiplicity and production
- Loading branch information
Showing
14 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef NJOY_NDITK_MULTIGROUP_FISSIONNEUTRONMULTIPLICITY | ||
#define NJOY_NDITK_MULTIGROUP_FISSIONNEUTRONMULTIPLICITY | ||
|
||
// system includes | ||
|
||
// other includes | ||
#include "tools/Log.hpp" | ||
#include "NDItk/base/RealListRecord.hpp" | ||
#include "NDItk/multigroup/FissionType.hpp" | ||
|
||
namespace njoy { | ||
namespace NDItk { | ||
namespace multigroup { | ||
|
||
/** | ||
* @brief A fission nubar record for multigroup neutron and photon data | ||
*/ | ||
class FissionNeutronMultiplicity : protected base::RealListRecord { | ||
|
||
/* fields */ | ||
|
||
/* auxiliary functions */ | ||
|
||
#include "NDItk/multigroup/FissionNeutronMultiplicity/src/verify.hpp" | ||
|
||
public: | ||
|
||
/* constructor */ | ||
|
||
#include "NDItk/multigroup/FissionNeutronMultiplicity/src/ctor.hpp" | ||
|
||
/* methods */ | ||
|
||
/** | ||
* @brief Return the fission type defined by this record | ||
*/ | ||
FissionType type() const { return this->key().fissionType().value(); } | ||
|
||
/** | ||
* @brief Return the number of groups defined by this record | ||
*/ | ||
unsigned int numberGroups() const { return this->size(); } | ||
|
||
using base::RealListRecord::keyword; | ||
using base::RealListRecord::values; | ||
using base::RealListRecord::size; | ||
using base::RealListRecord::empty; | ||
using base::RealListRecord::begin; | ||
using base::RealListRecord::end; | ||
using base::RealListRecord::print; | ||
|
||
#include "NDItk/multigroup/FissionNeutronMultiplicity/src/read.hpp" | ||
}; | ||
|
||
} // multigroup namespace | ||
} // NDItk namespace | ||
} // njoy namespace | ||
|
||
#endif |
16 changes: 16 additions & 0 deletions
16
src/NDItk/multigroup/FissionNeutronMultiplicity/src/ctor.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @brief Default constructor | ||
*/ | ||
FissionNeutronMultiplicity( FissionType type ) : RealListRecord( base::Keyword( "nu", type ) ) {} | ||
|
||
/** | ||
* @brief Constructor | ||
* | ||
* @param[in] weights the flux weights | ||
*/ | ||
FissionNeutronMultiplicity( FissionType type, | ||
std::vector< double > values ) : | ||
RealListRecord( base::Keyword( "nu", type ), std::move( values ) ) { | ||
|
||
verify( this->values() ); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/NDItk/multigroup/FissionNeutronMultiplicity/src/read.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @brief Read the record data | ||
* | ||
* This function overrides the base record read() function to enable | ||
* verification of the read data. | ||
* | ||
* @param[in,out] iter an iterator to the current position in the input | ||
* @param[in,out] end an iterator to the end of the input | ||
* @param[in,out] number the number of nu values | ||
*/ | ||
template< typename Iterator > | ||
void read( Iterator& iter, const Iterator& end, std::size_t number ) { | ||
|
||
base::RealListRecord::read( iter, end, number ); | ||
verify( this->values() ); | ||
}; |
18 changes: 18 additions & 0 deletions
18
src/NDItk/multigroup/FissionNeutronMultiplicity/src/verify.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @brief Verify the nu values | ||
* | ||
* The following verification tests are performed: | ||
* - there is at least one value | ||
* | ||
* @param[in] values the nu values to be verified | ||
*/ | ||
template < typename Range > | ||
static void verify( const Range& values ) { | ||
|
||
if ( values.size() < 1 ) { | ||
|
||
Log::error( "Expected at least one nu value, found {}", | ||
values.size() ); | ||
throw std::exception(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/NDItk/multigroup/FissionNeutronMultiplicity/test/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_cpp_test( multigroup.FissionNeutronMultiplicity FissionNeutronMultiplicity.test.cpp ) |
129 changes: 129 additions & 0 deletions
129
src/NDItk/multigroup/FissionNeutronMultiplicity/test/FissionNeutronMultiplicity.test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// include Catch2 | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <catch2/matchers/catch_matchers_floating_point.hpp> | ||
using Catch::Matchers::WithinRel; | ||
|
||
// what we are testing | ||
#include "NDItk/multigroup/FissionNeutronMultiplicity.hpp" | ||
|
||
// other includes | ||
|
||
// convenience typedefs | ||
using namespace njoy::NDItk; | ||
using FissionNeutronMultiplicity = multigroup::FissionNeutronMultiplicity; | ||
using FissionType = multigroup::FissionType; | ||
|
||
std::string chunk(); | ||
void verifyChunk( const FissionNeutronMultiplicity& ); | ||
std::string chunkWithInsufficientNumberValues(); | ||
|
||
SCENARIO( "FissionNeutronMultiplicity" ) { | ||
|
||
GIVEN( "valid data for a FissionNeutronMultiplicity instance" ) { | ||
|
||
std::string record = chunk(); | ||
|
||
WHEN( "the data is given explicitly" ) { | ||
|
||
std::vector< double > values = { 2., 2.1, 2.2, 2.3, 2.4, 5.0, 7.0 }; | ||
|
||
FissionNeutronMultiplicity chunk( FissionType::Prompt, std::move( values ) ); | ||
|
||
THEN( "a FissionNeutronMultiplicity can be constructed and members can " | ||
"be tested" ) { | ||
|
||
verifyChunk( chunk ); | ||
} // THEN | ||
|
||
THEN( "the record can be printed" ) { | ||
|
||
std::string buffer; | ||
auto output = std::back_inserter( buffer ); | ||
chunk.print( output ); | ||
|
||
CHECK( buffer == record ); | ||
} // THEN | ||
} // WHEN | ||
|
||
WHEN( "the data is read using iterators" ) { | ||
|
||
auto iter = record.begin() + 5; | ||
auto end = record.end(); | ||
|
||
FissionNeutronMultiplicity chunk( FissionType::Prompt ); | ||
chunk.read( iter, end, 7 ); | ||
|
||
THEN( "a FissionNeutronMultiplicity can be constructed and members can " | ||
"be tested" ) { | ||
|
||
verifyChunk( chunk ); | ||
} // THEN | ||
|
||
THEN( "the record can be printed" ) { | ||
|
||
std::string buffer; | ||
auto output = std::back_inserter( buffer ); | ||
chunk.print( output ); | ||
|
||
CHECK( buffer == record ); | ||
} // THEN | ||
} // WHEN | ||
} // GIVEN | ||
|
||
GIVEN( "invalid data for a FissionNeutronMultiplicity instance" ) { | ||
|
||
WHEN( "the number of weight values is insufficient" ) { | ||
|
||
THEN( "an exception is thrown" ) { | ||
|
||
std::vector< double > empty = {}; | ||
|
||
CHECK_THROWS( FissionNeutronMultiplicity( FissionType::Prompt, std::move( empty ) ) ); | ||
} // THEN | ||
} // WHEN | ||
|
||
WHEN( "reading the data of the record and the number of " | ||
"values is insufficient" ) { | ||
|
||
std::string record = chunkWithInsufficientNumberValues(); | ||
auto iter = record.begin() + 5; | ||
auto end = record.end(); | ||
FissionNeutronMultiplicity chunk( FissionType::Prompt ); | ||
|
||
THEN( "an exception is thrown" ) { | ||
|
||
CHECK_THROWS( chunk.read( iter, end, 0 ) ); | ||
} // THEN | ||
} // WHEN | ||
} // GIVEN | ||
} // SCENARIO | ||
|
||
std::string chunk() { | ||
|
||
return "nu_pr\n" | ||
" 2 2.1 2.2 2.3 2.4\n" | ||
" 5 7\n"; | ||
} | ||
|
||
void verifyChunk( const FissionNeutronMultiplicity& chunk ) { | ||
|
||
CHECK( "nu_pr" == chunk.keyword() ); | ||
CHECK_THAT( 2, WithinRel( chunk.values()[0] ) ); | ||
CHECK_THAT( 2.1, WithinRel( chunk.values()[1] ) ); | ||
CHECK_THAT( 2.2, WithinRel( chunk.values()[2] ) ); | ||
CHECK_THAT( 2.3, WithinRel( chunk.values()[3] ) ); | ||
CHECK_THAT( 2.4, WithinRel( chunk.values()[4] ) ); | ||
CHECK_THAT( 5, WithinRel( chunk.values()[5] ) ); | ||
CHECK_THAT( 7, WithinRel( chunk.values()[6] ) ); | ||
|
||
CHECK( false == chunk.empty() ); | ||
CHECK( 7 == chunk.size() ); | ||
|
||
CHECK( FissionType::Prompt == chunk.type() ); | ||
CHECK( 7 == chunk.numberGroups() ); | ||
} | ||
|
||
std::string chunkWithInsufficientNumberValues() { | ||
|
||
return "nu_pr\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef NJOY_NDITK_MULTIGROUP_FISSIONNEUTRONPRODUCTION | ||
#define NJOY_NDITK_MULTIGROUP_FISSIONNEUTRONPRODUCTION | ||
|
||
// system includes | ||
|
||
// other includes | ||
#include "tools/Log.hpp" | ||
#include "NDItk/base/RealListRecord.hpp" | ||
#include "NDItk/multigroup/FissionType.hpp" | ||
|
||
namespace njoy { | ||
namespace NDItk { | ||
namespace multigroup { | ||
|
||
/** | ||
* @brief A fission neutron production record for multigroup neutron and photon data | ||
*/ | ||
class FissionNeutronProduction : protected base::RealListRecord { | ||
|
||
/* fields */ | ||
|
||
/* auxiliary functions */ | ||
|
||
#include "NDItk/multigroup/FissionNeutronProduction/src/verify.hpp" | ||
|
||
public: | ||
|
||
/* constructor */ | ||
|
||
#include "NDItk/multigroup/FissionNeutronProduction/src/ctor.hpp" | ||
|
||
/* methods */ | ||
|
||
/** | ||
* @brief Return the fission type defined by this record | ||
*/ | ||
FissionType type() const { return this->key().fissionType().value(); } | ||
|
||
/** | ||
* @brief Return the number of groups defined by this record | ||
*/ | ||
unsigned int numberGroups() const { return this->size(); } | ||
|
||
using base::RealListRecord::keyword; | ||
using base::RealListRecord::values; | ||
using base::RealListRecord::size; | ||
using base::RealListRecord::empty; | ||
using base::RealListRecord::begin; | ||
using base::RealListRecord::end; | ||
using base::RealListRecord::print; | ||
|
||
#include "NDItk/multigroup/FissionNeutronProduction/src/read.hpp" | ||
}; | ||
|
||
} // multigroup namespace | ||
} // NDItk namespace | ||
} // njoy namespace | ||
|
||
#endif |
16 changes: 16 additions & 0 deletions
16
src/NDItk/multigroup/FissionNeutronProduction/src/ctor.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @brief Default constructor | ||
*/ | ||
FissionNeutronProduction( FissionType type ) : RealListRecord( base::Keyword( "nu_sig_f", type ) ) {} | ||
|
||
/** | ||
* @brief Constructor | ||
* | ||
* @param[in] weights the flux weights | ||
*/ | ||
FissionNeutronProduction( FissionType type, | ||
std::vector< double > values ) : | ||
RealListRecord( base::Keyword( "nu_sig_f", type ), std::move( values ) ) { | ||
|
||
verify( this->values() ); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/NDItk/multigroup/FissionNeutronProduction/src/read.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @brief Read the record data | ||
* | ||
* This function overrides the base record read() function to enable | ||
* verification of the read data. | ||
* | ||
* @param[in,out] iter an iterator to the current position in the input | ||
* @param[in,out] end an iterator to the end of the input | ||
* @param[in,out] number the number of nu values | ||
*/ | ||
template< typename Iterator > | ||
void read( Iterator& iter, const Iterator& end, std::size_t number ) { | ||
|
||
base::RealListRecord::read( iter, end, number ); | ||
verify( this->values() ); | ||
}; |
18 changes: 18 additions & 0 deletions
18
src/NDItk/multigroup/FissionNeutronProduction/src/verify.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @brief Verify the production values | ||
* | ||
* The following verification tests are performed: | ||
* - there is at least one value | ||
* | ||
* @param[in] values the production values to be verified | ||
*/ | ||
template < typename Range > | ||
static void verify( const Range& values ) { | ||
|
||
if ( values.size() < 1 ) { | ||
|
||
Log::error( "Expected at least one production value, found {}", | ||
values.size() ); | ||
throw std::exception(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/NDItk/multigroup/FissionNeutronProduction/test/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_cpp_test( multigroup.FissionNeutronProduction FissionNeutronProduction.test.cpp ) |
Oops, something went wrong.