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

Applications | User Support | Publications | Collaboration