|
| 1 | +#ifndef NJOY_DRYAD_FORMAT_ENDF_RESONANCES_LRF3_CREATECHANNELDATA |
| 2 | +#define NJOY_DRYAD_FORMAT_ENDF_RESONANCES_LRF3_CREATECHANNELDATA |
| 3 | + |
| 4 | +// system includes |
| 5 | +#include <algorithm> |
| 6 | +#include <vector> |
| 7 | + |
| 8 | +// other includes |
| 9 | +#include "tools/Log.hpp" |
| 10 | +#include "njoy/dryad/id/ReactionID.hpp" |
| 11 | +#include "njoy/dryad/id/ChannelID.hpp" |
| 12 | +#include "njoy/dryad/resonances/SpinGroup.hpp" |
| 13 | +#include "njoy/dryad/format/createVector.hpp" |
| 14 | +#include "njoy/dryad/format/endf/resonances/createChannelRadii.hpp" |
| 15 | +#include "ENDFtk/section/2/151.hpp" |
| 16 | + |
| 17 | +namespace njoy { |
| 18 | +namespace dryad { |
| 19 | +namespace format { |
| 20 | +namespace endf { |
| 21 | +namespace resonances { |
| 22 | +namespace lrf3 { |
| 23 | + |
| 24 | + inline dryad::resonances::ChannelQuantumNumbers |
| 25 | + retrieveQuantumNumber( unsigned int l, double j, |
| 26 | + std::vector< dryad::resonances::ChannelQuantumNumbers >& available ) { |
| 27 | + |
| 28 | + auto find = [l,j] ( auto&& numbers ) { |
| 29 | + |
| 30 | + return numbers.orbitalAngularMomentum() == l && |
| 31 | + numbers.totalAngularMomentum() == std::abs( j ); |
| 32 | + }; |
| 33 | + |
| 34 | + auto first = std::find_if( available.begin(), available.end(), find ); |
| 35 | + if ( first != available.end() ) { |
| 36 | + |
| 37 | + auto second = std::find_if( first, available.end(), find ); |
| 38 | + if ( second != available.end() ) { |
| 39 | + |
| 40 | + if ( j > 0 ) { |
| 41 | + |
| 42 | + first = second; |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + auto numbers = *first; |
| 47 | + available.erase( first ); |
| 48 | + return numbers; |
| 49 | + } |
| 50 | + else { |
| 51 | + |
| 52 | + throw std::runtime_error( "None of the expected spin groups has l = " |
| 53 | + + std::to_string( l ) + " and J = " |
| 54 | + + std::to_string( std::abs( j ) ) ); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @brief Create the channel data for Reich-Moore data for a given l value |
| 60 | + * |
| 61 | + * @param[in] projectile the projectile identifier |
| 62 | + * @param[in] target the target identifier |
| 63 | + * @param[in] incident the incident particle pair |
| 64 | + * @param[in] naps the channel radius option as given in the ENDF file |
| 65 | + * @param[in] nro the energy dependent scattering radius (if defined, given in fm) |
| 66 | + * @param[in] ap the l-dependent scattering radius (if defined, given in fm) |
| 67 | + * @param[in,out] available the quantum number combinations that are still available |
| 68 | + * @param[in] endfReichMooreLValue the parsed ENDF Reich-Moore l-value data |
| 69 | + */ |
| 70 | + inline auto createChannelData( |
| 71 | + const id::ParticleID& projectile, |
| 72 | + const id::ParticleID& target, |
| 73 | + const dryad::resonances::ParticlePair& incident, |
| 74 | + int naps, |
| 75 | + const std::optional< dryad::resonances::TabulatedRadius >& nro, |
| 76 | + double ap, |
| 77 | + std::vector< dryad::resonances::ChannelQuantumNumbers >& available, |
| 78 | + const ENDFtk::section::Type< 2, 151 >::ReichMooreLValue& endfReichMooreLValue ) { |
| 79 | + |
| 80 | + std::vector< dryad::resonances::SpinGroup::ChannelData > channel_data; |
| 81 | + |
| 82 | + unsigned int l = endfReichMooreLValue.orbitalMomentum(); |
| 83 | + double apl = endfReichMooreLValue.lDependentScatteringRadius() * constants::deca; |
| 84 | + double awri = endfReichMooreLValue.atomicWeightRatio(); |
| 85 | + |
| 86 | + // create the channel radii (check for l-dependent radius) |
| 87 | + dryad::resonances::ChannelRadii radii = createChannelRadii( naps, nro, apl != 0. ? apl : ap, awri ); |
| 88 | + |
| 89 | + // get all possible total angular momentum values |
| 90 | + std::vector< double > jvalues = createVector( endfReichMooreLValue.spinValues() ); |
| 91 | + std::sort( jvalues.begin(), jvalues.end() ); |
| 92 | + jvalues.erase( std::unique( jvalues.begin(), jvalues.end() ), jvalues.end() ); |
| 93 | + |
| 94 | + // lambda to calculate reduced width |
| 95 | + auto reduced_width = [] ( auto&& width, auto&& penetrability ) { |
| 96 | + |
| 97 | + int sign = width >= 0. ? +1 : -1; |
| 98 | + return sign * std::sqrt( std::abs( width ) / 2. / penetrability ); |
| 99 | + }; |
| 100 | + |
| 101 | + // go over each one to create channel data |
| 102 | + for ( double j : jvalues ) { |
| 103 | + |
| 104 | + // elastic channel |
| 105 | + id::ChannelID elastic_id( id::ReactionID( projectile, target, 2 ), |
| 106 | + retrieveQuantumNumber( l, j, available ) ); |
| 107 | + dryad::resonances::Channel elastic( elastic_id, incident, incident, 0., std::nullopt, radii ); |
| 108 | + |
| 109 | + // collect level energies and widths |
| 110 | + std::vector< double > energies; |
| 111 | + std::vector< double > elastic_widths; |
| 112 | + std::vector< double > capture_widths; |
| 113 | + std::vector< double > fission1_widths; |
| 114 | + std::vector< double > fission2_widths; |
| 115 | + |
| 116 | + // go over all resonances |
| 117 | + for ( unsigned int i = 0; i < endfReichMooreLValue.numberResonances(); ++i ) { |
| 118 | + |
| 119 | + if ( endfReichMooreLValue.spinValues()[i] == j ) { |
| 120 | + |
| 121 | + energies.emplace_back( endfReichMooreLValue.resonanceEnergies()[i] ); |
| 122 | + elastic_widths.emplace_back( reduced_width( endfReichMooreLValue.neutronWidths()[i], |
| 123 | + elastic.penetrability( energies.back() ) ) ); |
| 124 | + capture_widths.emplace_back( reduced_width( endfReichMooreLValue.gammaWidths()[i], 1. ) ); |
| 125 | + fission1_widths.emplace_back( reduced_width( endfReichMooreLValue.firstFissionWidths()[i], 1. ) ); |
| 126 | + fission2_widths.emplace_back( reduced_width( endfReichMooreLValue.secondFissionWidths()[i], 1. ) ); |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + // treat elastic |
| 131 | + channel_data.emplace_back( std::move( elastic ), dryad::resonances::ResonanceTable{ { elastic_id }, energies, std::move( elastic_widths ) } ); |
| 132 | + |
| 133 | + // treat capture |
| 134 | + dryad::resonances::ChannelQuantumNumbers other( l, 0, std::abs( j ), l%2 == 0 ? +1 : -1 ); |
| 135 | + id::ChannelID capture_id( id::ReactionID( projectile, target, 102 ), other ); |
| 136 | + dryad::resonances::ParticlePair capture_pair( { id::ParticleID::photon(), 0., 0., +1 }, |
| 137 | + { capture_id.reaction().residual().value(), 0., 0., +1 } ); |
| 138 | + dryad::resonances::Channel capture( capture_id, incident, capture_pair, 0., std::nullopt, radii ); |
| 139 | + channel_data.emplace_back( std::move( capture ), dryad::resonances::ResonanceTable{ { capture_id }, energies, std::move( capture_widths ) } ); |
| 140 | + |
| 141 | + // check for fission |
| 142 | + auto is_non_zero = [] ( auto&& value ) { return value != 0.; }; |
| 143 | + bool has_fission1 = std::any_of( fission1_widths.begin(), fission1_widths.end(), is_non_zero ); |
| 144 | + bool has_fission2 = std::any_of( fission2_widths.begin(), fission2_widths.end(), is_non_zero ); |
| 145 | + if ( has_fission1 && has_fission2 ) { |
| 146 | + |
| 147 | + id::ChannelID fission1_id( id::ReactionID( projectile, target, 18 ), other, 0 ); |
| 148 | + id::ChannelID fission2_id( id::ReactionID( projectile, target, 18 ), other, 1 ); |
| 149 | + dryad::resonances::Channel fission1( fission1_id, incident, std::nullopt, 0., std::nullopt, radii ); |
| 150 | + dryad::resonances::Channel fission2( fission2_id, incident, std::nullopt, 0., std::nullopt, radii ); |
| 151 | + channel_data.emplace_back( std::move( fission1 ), dryad::resonances::ResonanceTable{ { fission1_id }, energies, std::move( fission1_widths ) } ); |
| 152 | + channel_data.emplace_back( std::move( fission2 ), dryad::resonances::ResonanceTable{ { fission2_id }, energies, std::move( fission2_widths ) } ); |
| 153 | + |
| 154 | + } |
| 155 | + else if ( has_fission1 || has_fission2 ) { |
| 156 | + |
| 157 | + id::ChannelID fission_id( id::ReactionID( projectile, target, 18 ), other ); |
| 158 | + dryad::resonances::Channel fission( fission_id, incident, std::nullopt, 0., std::nullopt, radii ); |
| 159 | + if ( has_fission1 ) { |
| 160 | + |
| 161 | + channel_data.emplace_back( std::move( fission ), dryad::resonances::ResonanceTable{ { fission_id }, energies, std::move( fission1_widths ) } ); |
| 162 | + } |
| 163 | + else { |
| 164 | + |
| 165 | + channel_data.emplace_back( std::move( fission ), dryad::resonances::ResonanceTable{ { fission_id }, energies, std::move( fission2_widths ) } ); |
| 166 | + } |
| 167 | + } |
| 168 | + } |
| 169 | + |
| 170 | + return channel_data; |
| 171 | + } |
| 172 | + |
| 173 | +} // lrf3 namespace |
| 174 | +} // resonances namespace |
| 175 | +} // endf namespace |
| 176 | +} // format namespace |
| 177 | +} // dryad namespace |
| 178 | +} // njoy namespace |
| 179 | + |
| 180 | +#endif |
0 commit comments