Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // ------------------------------------------- 26 // ------------------------------------------------------------- 27 // GEANT4 FF_Neutron_HP 27 // GEANT4 FF_Neutron_HP 28 // 28 // 29 // Command line options: 29 // Command line options: 30 // -i ARG : run in batch mode from s 30 // -i ARG : run in batch mode from script file ARG 31 // -o ARG : write output to file ARG 31 // -o ARG : write output to file ARG 32 // (defaults to FF_Neutron_ 32 // (defaults to FF_Neutron_HP.out) 33 // -n ARG : multithreading with ARG 33 // -n ARG : multithreading with ARG number of threads 34 // (only works if Geant4 wa 34 // (only works if Geant4 was compiled with 35 // multithreading enables) 35 // multithreading enables) 36 // 36 // 37 // =============== Begin Documentation Commen 37 // =============== Begin Documentation Comments =============== 38 //! 38 //! 39 //! \file FissionFragment.cc 39 //! \file FissionFragment.cc 40 //! \author B. Wendt (brycen.linn.wendt@ce 40 //! \author B. Wendt (brycen.linn.wendt@cern.ch) 41 //! \date June 06, 2014 41 //! \date June 06, 2014 42 //! 42 //! 43 //! \brief Main program of the FissionFra 43 //! \brief Main program of the FissionFragment example 44 //! 44 //! 45 //! \details Application demonstrating the 45 //! \details Application demonstrating the Fission Fragment model as used 46 //! within the neutron_hp mode 46 //! within the neutron_hp model. It demostrates the capability 47 //! for fission product contai 47 //! for fission product containment by the cladding in a water 48 //! moderated sub-critical ass 48 //! moderated sub-critical assembly. 49 //! It could also be further exten 49 //! It could also be further extended to calculate the effective 50 //! multiplication factor of t 50 //! multiplication factor of the subcritical assembly for 51 //! various loading schemes. 51 //! various loading schemes. 52 //! 52 //! 53 // ================ End Documentation Comment 53 // ================ End Documentation Comments ================ 54 // 54 // 55 // Modified: 55 // Modified: 56 // 56 // 57 // 05-08-20 << 58 // Replaced deprecated HP environmental varia << 59 // 23-06-14 57 // 23-06-14 BWendt 60 // Added check for NeutronHP fission generato 58 // Added check for NeutronHP fission generator environment variable 61 // 59 // 62 // ------------------------------------------- 60 // ------------------------------------------------------------- 63 61 64 #include "FFActionInitialization.hh" << 62 #include "globals.hh" 65 #include "FFDetectorConstruction.hh" << 63 66 #include "QGSP_BIC_HP.hh" << 64 #ifdef G4MULTITHREADED >> 65 #include "G4MTRunManager.hh" >> 66 #else >> 67 #include "G4RunManager.hh" >> 68 #endif // G4MULTITHREADED 67 69 68 #include "G4ParticleHPManager.hh" << 69 #include "G4RunManagerFactory.hh" << 70 #include "G4UIExecutive.hh" << 71 #include "G4UImanager.hh" 70 #include "G4UImanager.hh" 72 #include "G4VisExecutive.hh" << 71 #include "QGSP_BIC_HP.hh" 73 #include "Randomize.hh" 72 #include "Randomize.hh" 74 #include "globals.hh" << 73 >> 74 #include "FFDetectorConstruction.hh" >> 75 #include "FFActionInitialization.hh" >> 76 >> 77 #include "G4VisExecutive.hh" >> 78 #include "G4UIExecutive.hh" >> 79 75 80 76 // Entry point 81 // Entry point 77 //....oooOO0OOooo........oooOO0OOooo........oo 82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 78 int main(int argc, char* argv[]) 83 int main(int argc, char* argv[]) 79 { 84 { 80 int result; << 85 int result; 81 unsigned int numberOfThreads = 1; << 86 unsigned int numberOfThreads = 1; 82 << 87 83 G4String scriptFileName = ""; << 88 G4String scriptFileName = ""; 84 G4String outputFileName = "FF_Neutron_HP.out << 89 G4String outputFileName = "FF_Neutron_HP.out"; 85 G4UImanager* UIManager = NULL; << 90 G4UImanager* UIManager = NULL; 86 << 91 87 // Activate production of fission fragments << 92 char makeFissionFragments[] = "G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS"; 88 G4ParticleHPManager::GetInstance()->SetProdu << 93 char useWendtFission[] = "G4NEUTRON_HP_USE_WENDT_FISSION_MODEL"; 89 << 94 90 char Force[] = "G4FORCENUMBEROFTHREADS"; << 95 char Force[] = "G4FORCENUMBEROFTHREADS"; 91 if (std::getenv(Force) != NULL) { << 96 if(std::getenv(Force) != NULL) { 92 char doNotForce[] = "G4FORCENUMBEROFTHREAD << 97 char doNotForce[]="G4FORCENUMBEROFTHREADS=1"; 93 putenv(doNotForce); << 98 putenv(doNotForce); 94 } << 99 } 95 << 100 96 // Indicate the example is starting << 101 // Indicate the example is starting 97 G4cout << "#### Starting: " << argv[0] << << 102 G4cout << "#### Starting: " << argv[0] << " ####" << G4endl; 98 << 103 99 // Parse the command line arguments, if any << 104 // Verify that NeutronHP is going to create fission fragments 100 for (int i = 1; i < argc; i += 2) { << 105 // Throw and error if it isn't. 101 // Ensure that this is actually a command << 106 if(std::getenv(makeFissionFragments) == NULL) 102 if (argv[i][0] != '-') { << 107 { 103 G4cerr << G4endl << "!!!!" << G4endl; << 108 G4cerr << G4endl << "!!!!" << G4endl; 104 G4cerr << "!!!! Error in argument " << i << 109 G4cerr << "!!!! Error in example" << argv[0] << G4endl; 105 G4cerr << "!!!! A command-line option wa << 110 G4cerr << "!!!! The \"" << makeFissionFragments << "\" " 106 << G4endl; << 111 "environment variable is not set!" << G4endl; 107 G4cerr << "!!!! " << argv[0] << " will n << 112 G4cerr << "!!!! Please set it in order to use this example." << G4endl; 108 G4cerr << "!!!!" << G4endl << G4endl; << 113 G4cerr << "!!!!" << G4endl << G4endl; 109 << 114 110 return EXIT_FAILURE; << 115 return EXIT_FAILURE; 111 } << 116 } 112 << 117 113 // Ensure that the command-line option has << 118 // We are trying to use the Wendt fission model in Neutron_HP 114 if (!(i + 1 < argc)) { << 119 // Warn the user if the appropriate environment variable is not set up 115 G4cerr << G4endl << "!!!!" << G4endl; << 120 if(std::getenv(useWendtFission) == NULL) 116 G4cerr << "!!!! Error in argument " << i << 121 { 117 G4cerr << "!!!! An argument was expected << 118 G4cerr << "!!!! Ensure that a space is u << 119 "option and argument" << 120 << G4endl; << 121 G4cerr << "!!!! " << argv[0] << " will n << 122 G4cerr << "!!!!" << G4endl << G4endl; << 123 << 124 return EXIT_FAILURE; << 125 } << 126 << 127 switch (argv[i][1]) { << 128 case 'i': << 129 scriptFileName = "/control/execute "; << 130 scriptFileName.append(argv[i + 1]); << 131 break; << 132 << 133 case 'o': << 134 outputFileName = argv[i + 1]; << 135 break; << 136 << 137 case 'n': << 138 result = sscanf(argv[i + 1], "%u", &nu << 139 if (result != 1) { << 140 G4cerr << G4endl << "!!!!" << G4endl << 141 G4cerr << "!!!! Error in argument " << 142 G4cerr << "!!!! An positive number w << 143 << G4endl; << 144 G4cerr << "!!!! " << argv[0] << " wi << 145 G4cerr << "!!!!" << G4endl << G4endl << 146 << 147 return EXIT_FAILURE; << 148 } << 149 break; << 150 << 151 default: << 152 G4cout << G4endl << "!!!!" << G4endl; 122 G4cout << G4endl << "!!!!" << G4endl; 153 G4cout << "!!!! Warning for command " << 123 G4cout << "!!!! Warning in example" << argv[0] << G4endl; 154 G4cout << "!!!! \"" << argv[i] << "\" << 124 G4cout << "!!!! The \"" << useWendtFission << "\" " 155 G4cout << "!!!! " << argv[0] << " will << 125 "environment variable is not set!" << G4endl; 156 << "\"" << G4endl; << 126 G4cout << "!!!! Please set it if you wish to use this fission model, " >> 127 "otherwise the default fission model will be used" << G4endl; 157 G4cout << "!!!!" << G4endl << G4endl; 128 G4cout << "!!!!" << G4endl << G4endl; 158 } 129 } 159 } << 130 >> 131 // Parse the command line arguments, if any >> 132 for(int i = 1; >> 133 i < argc; >> 134 i += 2) >> 135 { >> 136 // Ensure that this is actually a command >> 137 if(argv[i][0] != '-') >> 138 { >> 139 G4cerr << G4endl << "!!!!" << G4endl; >> 140 G4cerr << "!!!! Error in argument " << i + 1 << G4endl; >> 141 G4cerr << "!!!! A command-line option was expected, but \"" >> 142 << argv[i] << "\" was found" << G4endl; >> 143 G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl; >> 144 G4cerr << "!!!!" << G4endl << G4endl; >> 145 >> 146 return EXIT_FAILURE; >> 147 } >> 148 >> 149 // Ensure that the command-line option has an associated argument >> 150 if(!(i + 1 < argc)) >> 151 { >> 152 G4cerr << G4endl << "!!!!" << G4endl; >> 153 G4cerr << "!!!! Error in argument " << i + 2 << G4endl; >> 154 G4cerr << "!!!! An argument was expected, but \"" << argv[i + 1] >> 155 << "\" was found" << G4endl; >> 156 G4cerr << "!!!! Ensure that a space is used to separate the " >> 157 "option and argument" << G4endl; >> 158 G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl; >> 159 G4cerr << "!!!!" << G4endl << G4endl; >> 160 >> 161 return EXIT_FAILURE; >> 162 } >> 163 >> 164 switch(argv[i][1]) >> 165 { >> 166 case 'i': >> 167 scriptFileName = "/control/execute "; >> 168 scriptFileName.append(argv[i + 1]); >> 169 break; >> 170 >> 171 case 'o': >> 172 outputFileName = argv[i + 1]; >> 173 break; >> 174 >> 175 case 'n': >> 176 result = sscanf(argv[i + 1], >> 177 "%u", >> 178 &numberOfThreads); >> 179 if(result != 1) >> 180 { >> 181 G4cerr << G4endl << "!!!!" << G4endl; >> 182 G4cerr << "!!!! Error in argument " << i + 2 << G4endl; >> 183 G4cerr << "!!!! An positive number was expected, but \"" >> 184 << argv[i + 1] << "\" was found" << G4endl; >> 185 G4cerr << "!!!! " << argv[0] << " will now terminate" >> 186 << G4endl; >> 187 G4cerr << "!!!!" << G4endl << G4endl; >> 188 >> 189 return EXIT_FAILURE; >> 190 } >> 191 break; >> 192 >> 193 default: >> 194 G4cout << G4endl << "!!!!" << G4endl; >> 195 G4cout << "!!!! Warning for command " << i + 1 << G4endl; >> 196 G4cout << "!!!! \"" << argv[i] << "\" is not a valid command" >> 197 << G4endl; >> 198 G4cout << "!!!! " << argv[0] << " will ignore \"" << argv[i] >> 199 << "\" and \"" << argv[i + 1] << "\"" << G4endl; >> 200 G4cout << "!!!!" << G4endl << G4endl; >> 201 } >> 202 } >> 203 >> 204 // Instantiate G4UIExecutive if interactive mode >> 205 G4UIExecutive* ui = nullptr; >> 206 if (scriptFileName.length() == 0) { >> 207 ui = new G4UIExecutive(argc, argv); >> 208 } 160 209 161 // Instantiate G4UIExecutive if interactive << 210 // Set the Random engine 162 G4UIExecutive* ui = nullptr; << 211 // A seed of 62737819 produced a maximum number of 67 events on the 163 if (scriptFileName.length() == 0) { << 212 // author's system before timing out the nightly test 164 ui = new G4UIExecutive(argc, argv); << 213 const G4long seed = 62737819; 165 } << 166 << 167 // Set the Random engine << 168 // A seed of 62737819 produced a maximum num << 169 // author's system before timing out the nig << 170 const G4long seed = 62737819; << 171 #ifndef NDEBUG 214 #ifndef NDEBUG 172 G4cout << "MT RNG Seed: " << seed << G4endl; << 215 G4cout << "MT RNG Seed: " << seed << G4endl; 173 #endif // NDEBUG << 216 #endif // NDEBUG 174 G4Random::setTheEngine(new CLHEP::MTwistEngi << 217 G4Random::setTheEngine(new CLHEP::MTwistEngine(seed)); 175 << 218 176 // Initialize the multithreaded run manager << 219 // The 'runManger' type must be declared here at initialization to provide for 177 auto* runManager = G4RunManagerFactory::Crea << 220 // 'SetNumberOfThreads()' method required for multithreading 178 runManager->SetNumberOfThreads(numberOfThrea << 221 #ifdef G4MULTITHREADED 179 G4cout << " Threads requested: " << nu << 222 // Initialize the multithreaded run manager 180 G4cout << " Threads started: " << ru << 223 G4MTRunManager* const runManager = new G4MTRunManager(); 181 << 224 runManager->SetNumberOfThreads(numberOfThreads); 182 // Set mandatory initialization classes << 225 183 runManager->SetUserInitialization(new FFDete << 226 G4cout << "Multithreading enabled" << G4endl; 184 runManager->SetUserInitialization(new QGSP_B << 227 G4cout << " Threads requested: " << numberOfThreads << G4endl; 185 runManager->SetUserInitialization(new FFActi << 228 G4cout << " Threads started: " << runManager->GetNumberOfThreads() 186 << 229 << G4endl; 187 // Initialize the Geant4 kernel << 230 #else 188 runManager->Initialize(); << 231 // Multithreading not available 189 << 232 G4RunManager* const runManager = new G4RunManager(); 190 // Initialize visualization << 233 #endif // G4MULTITHREADED 191 G4VisManager* visManager = new G4VisExecutiv << 234 192 visManager->Initialize(); << 235 // Set mandatory initialization classes 193 << 236 runManager->SetUserInitialization(new FFDetectorConstruction()); 194 // Get the pointer to the User Interface man << 237 runManager->SetUserInitialization(new QGSP_BIC_HP()); 195 UIManager = G4UImanager::GetUIpointer(); << 238 runManager->SetUserInitialization(new FFActionInitialization()); 196 << 239 197 if (!ui) { << 240 // Initialize the Geant4 kernel 198 // Batch mode << 241 runManager->Initialize(); 199 UIManager->ApplyCommand(scriptFileName); << 242 200 } << 243 // Initialize visualization 201 else { << 244 G4VisManager* visManager = new G4VisExecutive(); 202 // Interactive mode << 245 visManager->Initialize(); 203 ui->SessionStart(); << 246 204 delete ui; << 247 // Get the pointer to the User Interface manager 205 } << 248 UIManager = G4UImanager::GetUIpointer(); 206 << 249 207 // Job termination << 250 if(!ui) 208 // Free the store: user actions, physics_lis << 251 { 209 // owned and deleted by the run manager, so << 252 // Batch mode 210 // in the main() program ! << 253 UIManager->ApplyCommand(scriptFileName); 211 delete visManager; << 254 } else 212 delete runManager; << 255 { >> 256 // Interactive mode >> 257 ui->SessionStart(); >> 258 delete ui; >> 259 } 213 260 214 return 0; << 261 // Job termination >> 262 // Free the store: user actions, physics_list and detector_description are >> 263 // owned and deleted by the run manager, so they should not be deleted >> 264 // in the main() program ! >> 265 delete visManager; >> 266 delete runManager; >> 267 >> 268 return 0; 215 } 269 } >> 270 >> 271 216 272