Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI_settings.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include "GIDI.hpp"
11
12namespace GIDI {
13
14namespace Transporting {
15
16/*! \class Settings
17 * This class is used to instruct deterministic methods and the Monte Carlo API MCGIDI on what data are being requested.
18*/
19
20/* *********************************************************************************************************//**
21 * @param a_projectileID [in] The PoPs id for the projectile.
22 * @param a_delayedNeutrons [in] Flag indicating whether or not delayed neutron data are to be include in the requested data.
23 ***********************************************************************************************************/
24
25Settings::Settings( std::string const &a_projectileID, DelayedNeutrons a_delayedNeutrons ) :
26 m_projectileID( a_projectileID ),
27 m_delayedNeutrons( a_delayedNeutrons ),
28 m_nuclearPlusCoulombInterferenceOnly( false ),
29 m_throwOnError( true ),
30 m_zeroDepositionIfAllProductsTracked( true ) {
31
32}
33
34/* *********************************************************************************************************//**
35 ***********************************************************************************************************/
36
40
41/* *********************************************************************************************************//**
42 * Returns a Vector of 0.0's of the proper length for the projectile's multi-group data.
43 *
44 * @param a_particles [in] The list of particles to be transported.
45 * @param a_collapse [in] If true, the length of the returned vector is for the collapsed multi-group, otherwise, it is for the uncollapsed multi-group.
46 *
47 * @return The Vector of 0.0.
48 ***********************************************************************************************************/
49
50Vector Settings::multiGroupZeroVector( Particles const &a_particles, bool a_collapse ) const {
51
52 Particle const *projectile( a_particles.particle( projectileID( ) ) );
53
54 std::size_t n1 = projectile->fineMultiGroup( ).numberOfGroups( );
55 if( a_collapse ) n1 = projectile->numberOfGroups( );
56
57 Vector vector( n1 );
58 return( vector );
59}
60
61/* *********************************************************************************************************//**
62 * Returns a Matrix of 0.0's of the proper length for the projectile's and product's multi-group data.
63 *
64 * @param a_particles [in] The list of particles to be transported.
65 * @param a_pid [in] The PoPs index for the product.
66 * @param a_collapse [in] If true, the length of the returned vector is for the collapsed multi-group, otherwise, it is for the uncollapsed multi-group.
67 *
68 * @return The Matrix of 0.0.
69 ***********************************************************************************************************/
70
71Matrix Settings::multiGroupZeroMatrix( Particles const &a_particles, std::string const &a_pid, bool a_collapse ) const {
72
73 Particle const *projectile( a_particles.particle( projectileID( ) ) );
74 Particle const *product( a_particles.particle( a_pid ) );
75
76 std::size_t n1 = projectile->fineMultiGroup( ).numberOfGroups( );
77 std::size_t n2 = product->fineMultiGroup( ).numberOfGroups( );
78 if( a_collapse ) {
79 n1 = projectile->numberOfGroups( );
80 n2 = product->numberOfGroups( );
81 }
82
83 Matrix matrix( n1, n2 );
84 return( matrix );
85}
86
87#if 0
88/* *********************************************************************************************************//**
89 * Prints the contents of *this* to std::cout. Mainly used for debugging.
90 ***********************************************************************************************************/
91
92void Settings::print( ) const {
93
94 std::cout << "setting info:" << std::endl;
95 std::cout << " transport mode = " << m_mode << std::endl;
96
97 std::cout << " delayed neutrons ";
98 if( m_delayedNeutrons ) {
99 std::cout << "on" << std::endl; }
100 else {
101 std::cout << "off" << std::endl;
102 }
103
104 std::cout << " throw on error ";
105 if( m_throwOnError ) {
106 std::cout << "on" << std::endl; }
107 else {
108 std::cout << "off" << std::endl;
109 }
110}
111#endif
112
113/*! \class MG
114 * This class is used to instruct deterministic methods on what data are being requested.
115*/
116
117/* *********************************************************************************************************//**
118 * @param a_projectileID [in] The PoPs index for the projectile.
119 * @param a_mode [in] Specifies the type of data to use or retrieve for transport codes.
120 * @param a_delayedNeutrons [in] Flag indicating whether or not delayed neutron data are to be include in the requested data.
121 ***********************************************************************************************************/
122
123MG::MG( std::string const &a_projectileID, Mode a_mode, DelayedNeutrons a_delayedNeutrons ) :
124 Settings( a_projectileID, a_delayedNeutrons ),
125 m_mode( a_mode ),
126 m_useMultiGroupSummedData( true ) {
127
128}
129
130/* *********************************************************************************************************//**
131 * Searches the suite *a_suite* for the form style specified by *m_mode* and matching one in *a_temperatureInfo*.
132 * This only works for multi-group data (i.e., multiGroup or multiGroupWithSnElasticUpScatter type data).
133 * If *a_label* is not an empty string, then it is used as the label for the form to return and *a_temperatureInfo* is ignored.
134 *
135 * @param a_smr [Out] If errors are not to be thrown, then the error is reported via this instance.
136 * @param a_suite [in] The suite to search for the requested form.
137 * @param a_temperatureInfo [in] Specifies the temperature and labels use to lookup the requested data.
138 * @param a_dataType [in] The type of data being required. Only used if data not found.
139 * @param a_label [in] The not an empty string, this is used as the label for the form to return.
140 ***********************************************************************************************************/
141
142Form const *MG::form( LUPI::StatusMessageReporting &a_smr, GIDI::Suite const &a_suite, Styles::TemperatureInfo const &a_temperatureInfo,
143 std::string a_dataType, std::string const &a_label ) const {
144
145 std::string label;
146
147 if( a_label != "" ) {
148 label = a_label; }
149 else if( m_mode == Mode::multiGroup ) {
150 label = a_temperatureInfo.heatedMultiGroup( ); }
151 else if( m_mode == Mode::multiGroupWithSnElasticUpScatter ) {
152 label = a_temperatureInfo.SnElasticUpScatter( );
153 }
154
155 Suite::const_iterator iter = a_suite.find( label, true );
156 if( ( iter == a_suite.end( ) ) && ( a_label == "" ) ) {
157 if( m_mode == Mode::multiGroupWithSnElasticUpScatter ) iter = a_suite.find( a_temperatureInfo.heatedMultiGroup( ), true );
158 }
159
160 if( iter == a_suite.end( ) ) {
161 std::string sourceInfo( a_suite.toXLink( ) );
162 ProtareSingle const *rootProtareSingle = static_cast<ProtareSingle const *>( a_suite.root( ) );
163 sourceInfo += " for protare " + rootProtareSingle->projectile( ).ID( ) + " + " + rootProtareSingle->target( ).ID( )
164 + " for " + rootProtareSingle->evaluation( ) + ".";
165
166 if( throwOnError( ) ) {
167 throw Exception( "ERROR from GIDI::MG::form: label '" + label + "' not found in suite '" + sourceInfo ); }
168 else {
169 std::string warning( "data for " + a_dataType + " not found with label '" + label + "' in suite " + sourceInfo );
170 smr_setReportError2p( a_smr.smr( ), 0, 0, warning.c_str( ) );
171 }
172 return( nullptr );
173 }
174
175 return( *iter );
176}
177
178}
179
180}
std::string const & ID() const
Definition GIDI.hpp:760
std::string const & evaluation(LUPI_maybeUnused std::size_t a_index=0) const
Definition GIDI.hpp:4786
ParticleInfo const & target() const
Definition GIDI.hpp:4543
ParticleInfo const & projectile() const
Definition GIDI.hpp:4541
std::string const & heatedMultiGroup() const
Definition GIDI.hpp:3434
std::string const & SnElasticUpScatter() const
Definition GIDI.hpp:3435
iterator find(std::string const &a_label, bool a_convertLazyParsingHelperForm=false)
iterator end()
Definition GIDI.hpp:2596
Forms::const_iterator const_iterator
Definition GIDI.hpp:2593
Form const * form(LUPI::StatusMessageReporting &a_smr, GIDI::Suite const &a_suite, Styles::TemperatureInfo const &a_temperatureInfo, std::string a_dataType, std::string const &a_label="") const
MG(std::string const &a_projectileID, Mode a_mode, DelayedNeutrons a_delayedNeutrons)
std::size_t numberOfGroups() const
Definition GIDI.hpp:3500
MultiGroup fineMultiGroup() const
Definition GIDI.hpp:3669
std::size_t numberOfGroups() const
Definition GIDI.hpp:3667
Particle const * particle(std::string const &a_particleID) const
Vector multiGroupZeroVector(Particles const &a_particles, bool a_collapse=true) const
Matrix multiGroupZeroMatrix(Particles const &a_particles, std::string const &a_particleID, bool a_collapse=true) const
std::string const & projectileID() const
Definition GIDI.hpp:3725
Settings(std::string const &a_projectileID, DelayedNeutrons a_delayedNeutrons)
Ancestry * root()
std::string toXLink() const
statusMessageReporting * smr()
Definition LUPI.hpp:112
Definition GIDI.hpp:32
#define smr_setReportError2p(smr, libraryID, code, fmt)