Geant4 Cross Reference |
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 // ------------------------------------------------------------------- 28 // 29 // GEANT4 Class header file 30 // 31 // 32 // File name: G4NeutronGeneralProcess 33 // 34 // Author: Vladimir Ivanchenko 35 // 36 // Creation date: 08.08.2022 37 // 38 // Modifications: 39 // 40 // Class Description: 41 // 42 // It is the neutron super process 43 44 // ------------------------------------------------------------------- 45 // 46 47 #ifndef G4NeutronGeneralProcess_h 48 #define G4NeutronGeneralProcess_h 1 49 50 #include "G4HadronicProcess.hh" 51 #include "globals.hh" 52 #include "G4HadDataHandler.hh" 53 #include <vector> 54 55 class G4Step; 56 class G4Track; 57 class G4ParticleDefinition; 58 class G4VParticleChange; 59 class G4VCrossSectionDataSet; 60 class G4CrossSectionDataStore; 61 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 63 64 class G4NeutronGeneralProcess : public G4HadronicProcess 65 { 66 public: 67 68 explicit G4NeutronGeneralProcess(const G4String& pname="NeutronGeneralProc"); 69 70 ~G4NeutronGeneralProcess() override; 71 72 G4bool IsApplicable(const G4ParticleDefinition&) override; 73 74 void ProcessDescription(std::ostream& outFile) const override; 75 76 // Initialise for build of tables 77 void PreparePhysicsTable(const G4ParticleDefinition&) override; 78 79 // Build physics table during initialisation 80 void BuildPhysicsTable(const G4ParticleDefinition&) override; 81 82 // Store internal tables after initialisation 83 G4bool StorePhysicsTable(const G4ParticleDefinition* part, 84 const G4String& directory, G4bool ascii) override; 85 86 // Called before tracking of each new G4Track 87 void StartTracking(G4Track*) override; 88 89 // implementation of virtual method, specific for G4NeutronGeneralProcess 90 G4double PostStepGetPhysicalInteractionLength( 91 const G4Track& track, 92 G4double previousStepSize, 93 G4ForceCondition* condition) override; 94 95 // implementation of virtual method, specific for G4NeutronGeneralProcess 96 G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&) override; 97 98 const G4VProcess* GetCreatorProcess() const override; 99 100 // Temporary method 101 const G4String& GetSubProcessName() const; 102 103 // Temporary method 104 G4int GetSubProcessSubType() const; 105 106 void SetInelasticProcess(G4HadronicProcess*); 107 void SetElasticProcess(G4HadronicProcess*); 108 void SetCaptureProcess(G4HadronicProcess*); 109 110 // access methods to cross sections and processes 111 G4VCrossSectionDataSet* GetXSection(G4int type); 112 G4HadronicProcess* GetHadronicProcess(G4int type); 113 114 inline const G4VProcess* GetSelectedProcess() const; 115 116 inline void SetTimeLimit(G4double val); 117 118 inline void SetMinEnergyLimit(G4double val); 119 120 // hide copy constructor and assignment operator 121 G4NeutronGeneralProcess(G4NeutronGeneralProcess &) = delete; 122 G4NeutronGeneralProcess & operator= 123 (const G4NeutronGeneralProcess &right) = delete; 124 125 protected: 126 127 G4double GetMeanFreePath(const G4Track& track, G4double previousStepSize, 128 G4ForceCondition* condition) override; 129 130 inline G4double ComputeGeneralLambda(size_t idxe, size_t idxt); 131 132 inline G4double GetProbability(size_t idxt); 133 134 inline void SelectedProcess(const G4Step& step, G4HadronicProcess* ptr, 135 G4CrossSectionDataStore*); 136 137 private: 138 139 // partial cross section 140 G4double ComputeCrossSection(G4VCrossSectionDataSet*, const G4Material*, 141 G4double kinEnergy, G4double loge); 142 143 G4VCrossSectionDataSet* InitialisationXS(G4HadronicProcess*); 144 145 // total cross section 146 inline void CurrentCrossSection(const G4Track&); 147 148 static G4HadDataHandler* theHandler; 149 static const size_t nTables = 5; 150 static G4String nameT[nTables]; 151 152 G4HadronicProcess* fInelasticP = nullptr; 153 G4HadronicProcess* fElasticP = nullptr; 154 G4HadronicProcess* fCaptureP = nullptr; 155 G4HadronicProcess* fSelectedProc = nullptr; 156 157 G4VCrossSectionDataSet* fInelasticXS = nullptr; 158 G4VCrossSectionDataSet* fElasticXS = nullptr; 159 G4VCrossSectionDataSet* fCaptureXS = nullptr; 160 161 G4CrossSectionDataStore* fXSSInelastic = nullptr; 162 G4CrossSectionDataStore* fXSSElastic = nullptr; 163 G4CrossSectionDataStore* fXSSCapture = nullptr; 164 G4CrossSectionDataStore* fCurrentXSS = nullptr; 165 166 const G4ParticleDefinition* fNeutron; 167 const G4Material* fCurrMat = nullptr; 168 169 G4double fMinEnergy; 170 G4double fMiddleEnergy; 171 G4double fMaxEnergy; 172 G4double fTimeLimit; 173 G4double fXSFactorInel = 1.0; 174 G4double fXSFactorEl = 1.0; 175 G4double fCurrE = 0.0; 176 G4double fCurrLogE = 0.0; 177 G4double fLambda = 0.0; 178 179 // number of bins per decade 180 std::size_t nLowE = 100; 181 std::size_t nHighE = 10; 182 183 std::size_t idxEnergy = 0; 184 std::size_t matIndex = 0; 185 186 G4bool isMaster = true; 187 std::vector<G4double> fXsec; 188 }; 189 190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 191 192 inline G4double 193 G4NeutronGeneralProcess::ComputeGeneralLambda(std::size_t idxe, std::size_t idxt) 194 { 195 idxEnergy = idxe; 196 return theHandler->GetVector(idxt, matIndex) 197 ->LogVectorValue(fCurrE, fCurrLogE); 198 } 199 200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 201 202 inline G4double G4NeutronGeneralProcess::GetProbability(std::size_t idxt) 203 { 204 return theHandler->GetVector(idxt, matIndex) 205 ->LogVectorValue(fCurrE, fCurrLogE); 206 } 207 208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 209 210 inline void 211 G4NeutronGeneralProcess::SelectedProcess(const G4Step& step, 212 G4HadronicProcess* ptr, 213 G4CrossSectionDataStore* xs) 214 215 { 216 fSelectedProc = ptr; 217 fCurrentXSS = xs; 218 step.GetPostStepPoint()->SetProcessDefinedStep(ptr); 219 } 220 221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 222 223 inline const G4VProcess* G4NeutronGeneralProcess::GetSelectedProcess() const 224 { 225 return fSelectedProc; 226 } 227 228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 229 230 inline void G4NeutronGeneralProcess::CurrentCrossSection(const G4Track& track) 231 { 232 G4double energy = track.GetKineticEnergy(); 233 const G4Material* mat = track.GetMaterial(); 234 if(mat != fCurrMat || energy != fCurrE) { 235 fCurrMat = mat; 236 matIndex = mat->GetIndex(); 237 fCurrE = energy; 238 fCurrLogE = track.GetDynamicParticle()->GetLogKineticEnergy(); 239 fLambda = (energy <= fMiddleEnergy) ? ComputeGeneralLambda(0, 0) 240 : ComputeGeneralLambda(1, 3); 241 currentInteractionLength = 1.0/fLambda; 242 } 243 } 244 245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 246 247 inline void G4NeutronGeneralProcess::SetTimeLimit(G4double val) 248 { 249 fTimeLimit = val; 250 } 251 252 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 253 254 inline void G4NeutronGeneralProcess::SetMinEnergyLimit(G4double val) 255 { 256 fMinEnergy = val; 257 } 258 259 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 260 261 #endif 262