Skip to content

Commit

Permalink
adding fission neutron spectra vector and matrix records
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Jun 5, 2024
1 parent 0332067 commit 466dbaf
Show file tree
Hide file tree
Showing 12 changed files with 362 additions and 27 deletions.
14 changes: 14 additions & 0 deletions src/NDItk/MultigroupTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "NDItk/multigroup/AverageFissionEnergyRelease.hpp"
#include "NDItk/multigroup/FissionNeutronMultiplicity.hpp"
#include "NDItk/multigroup/FissionNeutronProduction.hpp"
#include "NDItk/multigroup/FissionNeutronSpectrumVector.hpp"
#include "NDItk/multigroup/FissionNeutronSpectrumMatrix.hpp"
#include "NDItk/multigroup/OutgoingParticleTypes.hpp"
#include "NDItk/multigroup/OutgoingParticleTransportData.hpp"
#include "NDItk/multigroup/HeatingNumbers.hpp"
Expand Down Expand Up @@ -42,6 +44,12 @@ class MultigroupTable {
multigroup::FissionNeutronMultiplicity nubar_prompt_;
multigroup::FissionNeutronMultiplicity nubar_delayed_;
multigroup::FissionNeutronMultiplicity nubar_total_;
multigroup::FissionNeutronSpectrumVector chi_vector_prompt_;
multigroup::FissionNeutronSpectrumVector chi_vector_delayed_;
multigroup::FissionNeutronSpectrumVector chi_vector_total_;
multigroup::FissionNeutronSpectrumMatrix chi_matrix_prompt_;
multigroup::FissionNeutronSpectrumMatrix chi_matrix_delayed_;
multigroup::FissionNeutronSpectrumMatrix chi_matrix_total_;
multigroup::HeatingNumbers primary_heating_;
multigroup::Kerma primary_kerma_;
depletion::ReactionMultiplicities product_multiplicities_all_;
Expand Down Expand Up @@ -286,6 +294,12 @@ class MultigroupTable {
this->nubar_prompt_.print( iter );
this->nubar_delayed_.print( iter );
this->nubar_total_.print( iter );
this->chi_vector_prompt_.print( iter );
this->chi_vector_delayed_.print( iter );
this->chi_vector_total_.print( iter );
this->chi_matrix_prompt_.print( iter );
this->chi_matrix_delayed_.print( iter );
this->chi_matrix_total_.print( iter );
this->primary_heating_.print( iter );
this->primary_kerma_.print( iter );
this->product_multiplicities_all_.print( iter );
Expand Down
6 changes: 6 additions & 0 deletions src/NDItk/MultigroupTable/src/ctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ MultigroupTable() :
nubar_prompt_( multigroup::FissionType::Prompt ),
nubar_delayed_( multigroup::FissionType::Delayed ),
nubar_total_( multigroup::FissionType::Total ),
chi_vector_prompt_( multigroup::FissionType::Prompt ),
chi_vector_delayed_( multigroup::FissionType::Delayed ),
chi_vector_total_( multigroup::FissionType::Total ),
chi_matrix_prompt_( multigroup::FissionType::Prompt ),
chi_matrix_delayed_( multigroup::FissionType::Delayed ),
chi_matrix_total_( multigroup::FissionType::Total ),
primary_heating_(), primary_kerma_(),
product_multiplicities_all_( depletion::ReactionMultiplicityType::All ),
product_multiplicities_few_( depletion::ReactionMultiplicityType::Few ),
Expand Down
90 changes: 87 additions & 3 deletions src/NDItk/MultigroupTable/src/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void read( Iterator& iter, const Iterator& end ) {

readRecord( this->release_, iter, end );
}
// prompt fission neutorn multiplicity
// prompt fission neutron multiplicity
else if ( keyword == this->nubar_prompt_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {
Expand All @@ -137,7 +137,7 @@ void read( Iterator& iter, const Iterator& end ) {
throw std::exception();
}
}
// delayed fission neutorn multiplicity
// delayed fission neutron multiplicity
else if ( keyword == this->nubar_delayed_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {
Expand All @@ -151,7 +151,7 @@ void read( Iterator& iter, const Iterator& end ) {
throw std::exception();
}
}
// total fission neutorn multiplicity
// total fission neutron multiplicity
else if ( keyword == this->nubar_total_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {
Expand All @@ -165,6 +165,90 @@ void read( Iterator& iter, const Iterator& end ) {
throw std::exception();
}
}
// prompt fission neutron spectrum vector
else if ( keyword == this->chi_vector_prompt_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {

readRecord( this->chi_vector_prompt_, iter, end, this->metadata_.numberGroups().value() );
}
else {

Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
// delayed fission neutron spectrum vector
else if ( keyword == this->chi_vector_delayed_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {

readRecord( this->chi_vector_delayed_, iter, end, this->metadata_.numberGroups().value() );
}
else {

Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
// total fission neutron spectrum vector
else if ( keyword == this->chi_vector_total_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {

readRecord( this->chi_vector_total_, iter, end, this->metadata_.numberGroups().value() );
}
else {

Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
// prompt fission neutron spectrum matrix
else if ( keyword == this->chi_matrix_prompt_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {

readRecord( this->chi_matrix_prompt_, iter, end, this->metadata_.numberGroups().value() );
}
else {

Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
// delayed fission neutron spectrum matrix
else if ( keyword == this->chi_matrix_delayed_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {

readRecord( this->chi_matrix_delayed_, iter, end, this->metadata_.numberGroups().value() );
}
else {

Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
// total fission neutron spectrum matrix
else if ( keyword == this->chi_matrix_total_.keyword() ) {

if ( this->metadata_.numberGroups().has_value() ) {

readRecord( this->chi_matrix_total_, iter, end, this->metadata_.numberGroups().value() );
}
else {

Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
// primary and outgoing heating keyword
else if ( keyword.find( this->primary_heating_.keyword() ) == 0 ) {

Expand Down
51 changes: 27 additions & 24 deletions src/NDItk/MultigroupTable/src/verify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,35 @@ void verify() {
}

// secondary particles
const auto types = this->metadata().numberOutgoingParticles().value();
if ( types > 0 ) {
if ( this->metadata().numberOutgoingParticles().has_value() ) {

if ( ( this->outgoingParticleTypes().numberOutgoingParticles() != types ) ||
( ! this->outgoingParticleTransportData().empty() && this->outgoingParticleTransportData().numberOutgoingParticles() != types ) ||
( this->outgoing_structure_.size() && this->outgoing_structure_.size() != types ) ||
( this->outgoing_production_.size() && this->outgoing_production_.size() != types ) ||
( this->outgoing_heating_.size() && this->outgoing_heating_.size() != types ) ||
( this->outgoing_kerma_.size() && this->outgoing_kerma_.size() != types ) ) {
const auto types = this->metadata().numberOutgoingParticles().value();
if ( types > 0 ) {

Log::error( "Found inconsistent number of outgoing particle types across the table" );
Log::info( "Number of outgoing particles in the metadata: {}",
this->metadata().numberOutgoingParticles().value() );
Log::info( "Number of types in the outgoing particle types: {}",
this->outgoingParticleTypes().numberOutgoingParticles() );
Log::info( "Number of types in the outgoing transport data: {}",
this->outgoingParticleTransportData().numberOutgoingParticles() );
Log::info( "Number of types in the outgoing group structures: {}",
this->outgoing_structure_.size() );
Log::info( "Number of types in the outgoing production matrices: {}",
this->outgoing_production_.size() );
Log::info( "Number of types in the outgoing heating numbers: {}",
this->outgoing_heating_.size() );
Log::info( "Number of types in the outgoing kerma values: {}",
this->outgoing_kerma_.size() );
throw std::exception();
if ( ( this->outgoingParticleTypes().numberOutgoingParticles() != types ) ||
( ! this->outgoingParticleTransportData().empty() && this->outgoingParticleTransportData().numberOutgoingParticles() != types ) ||
( this->outgoing_structure_.size() && this->outgoing_structure_.size() != types ) ||
( this->outgoing_production_.size() && this->outgoing_production_.size() != types ) ||
( this->outgoing_heating_.size() && this->outgoing_heating_.size() != types ) ||
( this->outgoing_kerma_.size() && this->outgoing_kerma_.size() != types ) ) {

Log::error( "Found inconsistent number of outgoing particle types across the table" );
Log::info( "Number of outgoing particles in the metadata: {}",
this->metadata().numberOutgoingParticles().value() );
Log::info( "Number of types in the outgoing particle types: {}",
this->outgoingParticleTypes().numberOutgoingParticles() );
Log::info( "Number of types in the outgoing transport data: {}",
this->outgoingParticleTransportData().numberOutgoingParticles() );
Log::info( "Number of types in the outgoing group structures: {}",
this->outgoing_structure_.size() );
Log::info( "Number of types in the outgoing production matrices: {}",
this->outgoing_production_.size() );
Log::info( "Number of types in the outgoing heating numbers: {}",
this->outgoing_heating_.size() );
Log::info( "Number of types in the outgoing kerma values: {}",
this->outgoing_kerma_.size() );
throw std::exception();
}
}
}
};
59 changes: 59 additions & 0 deletions src/NDItk/multigroup/FissionNeutronSpectrumMatrix.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef NJOY_NDITK_MULTIGROUP_FISSIONNEUTRONSPECTRUMMATRIX
#define NJOY_NDITK_MULTIGROUP_FISSIONNEUTRONSPECTRUMMATRIX

// 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 spectrum matrix record for multigroup neutron and photon data
*/
class FissionNeutronSpectrumMatrix : protected base::RealListRecord {

/* fields */

/* auxiliary functions */

#include "NDItk/multigroup/FissionNeutronSpectrumMatrix/src/verify.hpp"

public:

/* constructor */

#include "NDItk/multigroup/FissionNeutronSpectrumMatrix/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 std::sqrt( 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/FissionNeutronSpectrumMatrix/src/read.hpp"
};

} // multigroup namespace
} // NDItk namespace
} // njoy namespace

#endif
21 changes: 21 additions & 0 deletions src/NDItk/multigroup/FissionNeutronSpectrumMatrix/src/ctor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @brief Default constructor
*/
FissionNeutronSpectrumMatrix() : RealListRecord( base::Keyword( "chi_mat" ) ) {}

/**
* @brief Default constructor
*/
FissionNeutronSpectrumMatrix( FissionType type ) : RealListRecord( base::Keyword( "chi_mat", type ) ) {}

/**
* @brief Constructor
*
* @param[in] values the fission neutron spectrum matrix values
*/
FissionNeutronSpectrumMatrix( FissionType type,
std::vector< double > values ) :
RealListRecord( base::Keyword( "chi_mat", type ), std::move( values ) ) {

verify( this->values() );
}
16 changes: 16 additions & 0 deletions src/NDItk/multigroup/FissionNeutronSpectrumMatrix/src/read.hpp
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 groups
*/
template< typename Iterator >
void read( Iterator& iter, const Iterator& end, std::size_t number ) {

base::RealListRecord::read( iter, end, number * number );
verify( this->values() );
};
18 changes: 18 additions & 0 deletions src/NDItk/multigroup/FissionNeutronSpectrumMatrix/src/verify.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @brief Verify the fission neutron spectrum vector 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 fission neutron spectrum matrix value, found {}",
values.size() );
throw std::exception();
}
}
Loading

0 comments on commit 466dbaf

Please sign in to comment.