Skip to content

Commit 1684476

Browse files
committed
Merge branch 'feature/rm-backgrounds-part3' into 'develop'
Feature/rm backgrounds part3 See merge request njoy/dryad!136
2 parents de188d4 + 19ecc12 commit 1684476

File tree

15 files changed

+1229
-24
lines changed

15 files changed

+1229
-24
lines changed

cmake/dependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ shacl_FetchContent_Declare( tools
2121

2222
shacl_FetchContent_Declare( scion
2323
GIT_REPOSITORY ../../njoy/scion
24-
GIT_TAG 278592f6d0a96271b997871b2ad61ba0b6ec6733 # NOT A RELEASED VERSION - CHANGE ME!
24+
GIT_TAG 6cf4be58060dcb1b23243c60f01b35f6b45a6c29 # NOT A RELEASED VERSION - CHANGE ME!
2525
)
2626

2727
shacl_FetchContent_Declare( ACEtk

python/src/dryad/resonances/Channel.python.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void wrapChannel( python::module& module ) {
2020
using ParticlePair = njoy::dryad::resonances::ParticlePair;
2121
using ChannelRadii = njoy::dryad::resonances::ChannelRadii;
2222
using Kinematics = njoy::dryad::resonances::Kinematics;
23+
using Background = njoy::dryad::resonances::Channel::Background;
2324
using Penetrability = njoy::dryad::resonances::Channel::Penetrability;
2425
using ShiftFactor = njoy::dryad::resonances::Channel::ShiftFactor;
2526
using PhaseShift = njoy::dryad::resonances::Channel::PhaseShift;
@@ -46,16 +47,17 @@ void wrapChannel( python::module& module ) {
4647
std::optional< double >,
4748
ChannelRadii,
4849
Kinematics,
50+
std::optional< Background >,
4951
Penetrability,
5052
ShiftFactor,
5153
PhaseShift,
5254
PhaseShiftDifference >(),
5355
python::arg( "identifier" ), python::arg( "incident" ),
5456
python::arg( "outgoing" ), python::arg( "q_value" ),
5557
python::arg( "boundary" ), python::arg( "radii" ),
56-
python::arg( "kinematics" ), python::arg( "penetrability" ),
57-
python::arg( "shift_factor" ), python::arg( "phase_shift" ),
58-
python::arg( "phase_shift_difference" ),
58+
python::arg( "kinematics" ), python::arg( "background" ),
59+
python::arg( "penetrability" ), python::arg( "shift_factor" ),
60+
python::arg( "phase_shift" ), python::arg( "phase_shift_difference" ),
5961
"Initialise the channel\n\n"
6062
"Arguments:\n"
6163
" self the channel\n"
@@ -81,11 +83,13 @@ void wrapChannel( python::module& module ) {
8183
double,
8284
std::optional< double >,
8385
ChannelRadii,
84-
Kinematics >(),
86+
Kinematics,
87+
std::optional< Background > >(),
8588
python::arg( "identifier" ), python::arg( "incident" ),
8689
python::arg( "outgoing" ), python::arg( "qValue" ),
8790
python::arg( "boundary" ), python::arg( "radii" ),
8891
python::arg( "kinematics" ) = Kinematics::NonRelativistic,
92+
python::arg( "background" ) = std::nullopt,
8993
"Initialise the channel\n\n"
9094
"Arguments:\n"
9195
" self the channel\n"
@@ -148,6 +152,12 @@ void wrapChannel( python::module& module ) {
148152
&Component::boundaryCondition,
149153
"The boundary condition value (if defined)"
150154
)
155+
.def_property_readonly(
156+
157+
"background",
158+
&Component::background,
159+
"The background function (if defined)"
160+
)
151161
.def_property_readonly(
152162

153163
"channel_radii",

python/stubs/njoy/dryad/resonances.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Channel:
6666
def __eq__(self, arg0: Channel) -> bool:
6767
...
6868
@typing.overload
69-
def __init__(self, identifier: njoy.dryad.id.ChannelID, incident: ParticlePair, outgoing: ParticlePair | None, q_value: float, boundary: float | None, radii: ChannelRadii, kinematics: Kinematics, penetrability: float | HardSpherePenetrability | CoulombPenetrability | TabulatedWaveFunction, shift_factor: float | HardSphereShiftFactor | CoulombShiftFactor | TabulatedWaveFunction, phase_shift: float | HardSpherePhaseShift | CoulombPhaseShift | TabulatedWaveFunction, phase_shift_difference: float | CoulombPhaseShiftDifference) -> None:
69+
def __init__(self, identifier: njoy.dryad.id.ChannelID, incident: ParticlePair, outgoing: ParticlePair | None, q_value: float, boundary: float | None, radii: ChannelRadii, kinematics: Kinematics, background: FrohnerBackground | SammyBackground | TabulatedBackground | None, penetrability: float | HardSpherePenetrability | CoulombPenetrability | TabulatedWaveFunction, shift_factor: float | HardSphereShiftFactor | CoulombShiftFactor | TabulatedWaveFunction, phase_shift: float | HardSpherePhaseShift | CoulombPhaseShift | TabulatedWaveFunction, phase_shift_difference: float | CoulombPhaseShiftDifference) -> None:
7070
"""
7171
Initialise the channel
7272
@@ -87,7 +87,7 @@ class Channel:
8787
phase_shift_difference the phase shift difference of the channel
8888
"""
8989
@typing.overload
90-
def __init__(self, identifier: njoy.dryad.id.ChannelID, incident: ParticlePair, outgoing: ParticlePair | None, qValue: float, boundary: float | None, radii: ChannelRadii, kinematics: Kinematics = ...) -> None:
90+
def __init__(self, identifier: njoy.dryad.id.ChannelID, incident: ParticlePair, outgoing: ParticlePair | None, qValue: float, boundary: float | None, radii: ChannelRadii, kinematics: Kinematics = ..., background: FrohnerBackground | SammyBackground | TabulatedBackground | None = None) -> None:
9191
"""
9292
Initialise the channel
9393
@@ -176,6 +176,11 @@ class Channel:
176176
energy the energy (given in eV)
177177
"""
178178
@property
179+
def background(self) -> FrohnerBackground | SammyBackground | TabulatedBackground | None:
180+
"""
181+
The background function (if defined)
182+
"""
183+
@property
179184
def boundary_condition(self) -> float | None:
180185
"""
181186
The boundary condition value (if defined)

src/njoy/dryad/format/endf/resonances/lrf7/createChannelData.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ namespace lrf7 {
4343

4444
// get the channels
4545
auto channels = lrf7::createChannels( projectile, target, boundary_condition,
46-
kinematics, endfPairs, endfSpinGroup.channels() );
46+
kinematics, endfPairs, endfSpinGroup.channels(),
47+
endfSpinGroup.background() );
4748

4849
// go over all channels
4950
for ( unsigned int i = 0; i < channels.size(); ++i ) {

src/njoy/dryad/format/endf/resonances/lrf7/createChannels.hpp

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "njoy/dryad/resonances/Channel.hpp"
1111
#include "njoy/dryad/format/createVector.hpp"
1212
#include "njoy/dryad/format/endf/resonances/lrf7/createParticlePairs.hpp"
13+
#include "njoy/dryad/format/endf/resonances/lrf7/createFrohnerBackground.hpp"
14+
#include "njoy/dryad/format/endf/resonances/lrf7/createSammyBackground.hpp"
15+
#include "njoy/dryad/format/endf/resonances/lrf7/createTabulatedBackground.hpp"
1316
#include "ENDFtk/section/2/151.hpp"
1417

1518
namespace njoy {
@@ -35,7 +38,8 @@ namespace lrf7 {
3538
const dryad::resonances::BoundaryCondition& boundary_condition,
3639
const dryad::resonances::Kinematics& kinematics,
3740
const ENDFtk::section::Type< 2, 151 >::RMatrixLimited::ParticlePairs& endfPairs,
38-
const ENDFtk::section::Type< 2, 151 >::RMatrixLimited::ResonanceChannels& endfChannels ) {
41+
const ENDFtk::section::Type< 2, 151 >::RMatrixLimited::ResonanceChannels& endfChannels,
42+
const ENDFtk::section::Type< 2, 151 >::RMatrixLimited::BackgroundChannels& endfBackground ) {
3943

4044
std::vector< dryad::resonances::Channel > channels;
4145

@@ -114,6 +118,41 @@ namespace lrf7 {
114118
dryad::resonances::ChannelRadii radii( endfChannels.trueChannelRadii()[i] * constants::deca,
115119
endfChannels.effectiveChannelRadii()[i] * constants::deca );
116120

121+
using Background = dryad::resonances::Channel::Background;
122+
std::optional< Background > background = std::nullopt;
123+
if ( endfBackground.KBK() > 0 ) {
124+
125+
if ( endfBackground.backgroundRMatrices()[i].has_value() ) {
126+
127+
using NoBackgroundRMatrix = ENDFtk::section::Type< 2, 151 >::RMatrixLimited::NoBackgroundRMatrix;
128+
using TabulatedBackgroundRMatrix = ENDFtk::section::Type< 2, 151 >::RMatrixLimited::TabulatedBackgroundRMatrix;
129+
using SammyBackgroundRMatrix = ENDFtk::section::Type< 2, 151 >::RMatrixLimited::SammyBackgroundRMatrix;
130+
using FrohnerBackgroundRMatrix = ENDFtk::section::Type< 2, 151 >::RMatrixLimited::FrohnerBackgroundRMatrix;
131+
132+
auto getBackground = tools::overload{
133+
134+
[&] ( const NoBackgroundRMatrix& ) -> std::optional< Background > {
135+
136+
return std::nullopt;
137+
},
138+
[&] ( const FrohnerBackgroundRMatrix& data ) -> std::optional< Background > {
139+
140+
return createFrohnerBackground( data );
141+
},
142+
[&] ( const SammyBackgroundRMatrix& data ) -> std::optional< Background > {
143+
144+
return createSammyBackground( data );
145+
},
146+
[&] ( const TabulatedBackgroundRMatrix& data ) -> std::optional< Background > {
147+
148+
return createTabulatedBackground( data );
149+
}
150+
};
151+
152+
background = std::visit( getBackground, endfBackground.backgroundRMatrices()[i].value() );
153+
}
154+
}
155+
117156
channels.emplace_back( id::ChannelID( id::ReactionID( projectile, target, endfPairs.MT()[index] ),
118157
dryad::resonances::ChannelQuantumNumbers( endfChannels.orbitalMomentumValues()[i],
119158
endfChannels.channelSpinValues()[i],
@@ -124,7 +163,8 @@ namespace lrf7 {
124163
qvalues[index],
125164
std::move( boundary ),
126165
std::move( radii ),
127-
kinematics );
166+
kinematics,
167+
std::move( background ) );
128168
}
129169

130170
return channels;

src/njoy/dryad/format/endf/resonances/lrf7/createFrohnerBackground.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef NJOY_DRYAD_FORMAT_ENDF_CREATETABULATEDBACKGROUND
2-
#define NJOY_DRYAD_FORMAT_ENDF_CREATETABULATEDBACKGROUND
1+
#ifndef NJOY_DRYAD_FORMAT_ENDF_CREATEFROHNERBACKGROUND
2+
#define NJOY_DRYAD_FORMAT_ENDF_CREATEFROHNERBACKGROUND
33

44
// system includes
55
#include <vector>

src/njoy/dryad/format/endf/resonances/lrf7/createSammyBackground.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef NJOY_DRYAD_FORMAT_ENDF_CREATETABULATEDBACKGROUND
2-
#define NJOY_DRYAD_FORMAT_ENDF_CREATETABULATEDBACKGROUND
1+
#ifndef NJOY_DRYAD_FORMAT_ENDF_CREATESAMMYBACKGROUND
2+
#define NJOY_DRYAD_FORMAT_ENDF_CREATESAMMYBACKGROUND
33

44
// system includes
55
#include <vector>

src/njoy/dryad/resonances/Channel.hpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "njoy/dryad/resonances/CoulombPhaseShift.hpp"
2424
#include "njoy/dryad/resonances/CoulombPhaseShiftDifference.hpp"
2525
#include "njoy/dryad/resonances/TabulatedWaveFunction.hpp"
26+
#include "njoy/dryad/resonances/FrohnerBackground.hpp"
27+
#include "njoy/dryad/resonances/SammyBackground.hpp"
28+
#include "njoy/dryad/resonances/TabulatedBackground.hpp"
2629

2730
namespace njoy {
2831
namespace dryad {
@@ -38,6 +41,9 @@ namespace resonances {
3841

3942
/* type aliases */
4043

44+
using Background = std::variant< FrohnerBackground,
45+
SammyBackground,
46+
TabulatedBackground >;
4147
using WaveNumber = std::variant< NonRelativisticWaveNumber,
4248
RelativisticWaveNumber >;
4349
using Penetrability = std::variant< double,
@@ -64,6 +70,7 @@ namespace resonances {
6470
std::optional< ParticlePair > outgoing_pair_;
6571
double q_;
6672
std::optional< double > boundary_condition_;
73+
std::optional< Background > background_;
6774

6875
ChannelRadii radii_;
6976
WaveNumber wave_number_;
@@ -143,6 +150,14 @@ namespace resonances {
143150
return this->boundary_condition_;
144151
}
145152

153+
/**
154+
* @brief Return the background function (if defined)
155+
*/
156+
const std::optional< Background >& background() const {
157+
158+
return this->background_;
159+
}
160+
146161
/**
147162
* @brief Return the channel radii
148163
*/
@@ -382,10 +397,12 @@ namespace resonances {
382397

383398
return std::tie( left.identifier(), left.incidentParticlePair(),
384399
left.outgoingParticlePair(), left.q_,
385-
left.boundaryCondition(), left.channelRadii() ) ==
400+
left.boundaryCondition(), left.channelRadii(),
401+
left.background() ) ==
386402
std::tie( right.identifier(), right.incidentParticlePair(),
387403
right.outgoingParticlePair(), right.q_,
388-
right.boundaryCondition(), right.channelRadii() );
404+
right.boundaryCondition(), right.channelRadii(),
405+
right.background() );
389406
}
390407

391408
/**

src/njoy/dryad/resonances/Channel/src/ctor.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Channel( id::ChannelID identifier,
3333
std::optional< double > boundary,
3434
ChannelRadii radii,
3535
Kinematics kinematics,
36+
std::optional< Background > background,
3637
Penetrability penetrability,
3738
ShiftFactor shiftFactor,
3839
PhaseShift phaseShift,
@@ -42,6 +43,7 @@ Channel( id::ChannelID identifier,
4243
outgoing_pair_( std::move( outgoing ) ),
4344
q_( qValue ),
4445
boundary_condition_( std::move( boundary ) ),
46+
background_( std::move( background ) ),
4547
radii_( std::move( radii ) ),
4648
wave_number_( selectWaveNumber( kinematics ) ),
4749
penetrability_( std::move( penetrability ) ),
@@ -70,11 +72,13 @@ Channel( id::ChannelID identifier,
7072
double qValue,
7173
std::optional< double > boundary,
7274
ChannelRadii radii,
73-
Kinematics kinematics = Kinematics::NonRelativistic ) :
75+
Kinematics kinematics = Kinematics::NonRelativistic,
76+
std::optional< Background > background = std::nullopt ) :
7477
Channel( std::move( identifier ), std::move( incident ),
7578
std::move( outgoing ), qValue,
7679
std::move( boundary ), std::move( radii ),
7780
std::move( kinematics ),
81+
std::move( background ),
7882
selectPenetrabilityFunction( identifier.quantumNumbers().orbitalAngularMomentum(),
7983
outgoing ),
8084
selectShiftFactorFunction( identifier.quantumNumbers().orbitalAngularMomentum(),

src/njoy/dryad/resonances/calculator/ReichMoore.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ namespace calculator {
272272
this->r_matrix_( c, cprime ) += gg / std::complex< double >( delta, -Gamma );
273273
}
274274

275+
// add background if one is defined
276+
if ( channels[c].background().has_value() ) {
277+
278+
this->r_matrix_( c, c ) += std::visit( [&] ( auto&& background ) -> std::complex< double >
279+
{ return background( energy ); },
280+
channels[c].background().value() );
281+
}
282+
275283
// the r matrix is symmetrical
276284
if ( cprime > c ) {
277285

0 commit comments

Comments
 (0)