[819] | 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 | // neutron_hp -- source file |
---|
| 27 | // J.P. Wellisch, Nov-1996 |
---|
| 28 | // A prototype of the low energy neutron transport model. |
---|
| 29 | // |
---|
| 30 | // 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi) |
---|
| 31 | // |
---|
| 32 | #include "G4NeutronHPChannelList.hh" |
---|
| 33 | #include "G4Element.hh" |
---|
| 34 | #include "G4HadFinalState.hh" |
---|
| 35 | #include "G4HadProjectile.hh" |
---|
| 36 | #include "G4NeutronHPFinalState.hh" |
---|
| 37 | |
---|
| 38 | G4int G4NeutronHPChannelList::trycounter = 0; |
---|
| 39 | |
---|
| 40 | G4NeutronHPChannelList::G4NeutronHPChannelList(G4int n) |
---|
| 41 | { |
---|
| 42 | nChannels = n; |
---|
| 43 | theChannels = new G4NeutronHPChannel * [n]; |
---|
| 44 | allChannelsCreated = false; |
---|
| 45 | theInitCount = 0; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | G4NeutronHPChannelList::G4NeutronHPChannelList() |
---|
| 49 | { |
---|
| 50 | nChannels = 0; |
---|
| 51 | theChannels = 0; |
---|
| 52 | allChannelsCreated = false; |
---|
| 53 | theInitCount = 0; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | G4NeutronHPChannelList::~G4NeutronHPChannelList() |
---|
| 57 | { |
---|
| 58 | if(theChannels!=0) |
---|
| 59 | { |
---|
| 60 | for(G4int i=0;i<nChannels; i++) |
---|
| 61 | { |
---|
| 62 | delete theChannels[i]; |
---|
| 63 | } |
---|
| 64 | delete [] theChannels; |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | #include "G4NeutronHPThermalBoost.hh" |
---|
| 69 | G4HadFinalState * G4NeutronHPChannelList::ApplyYourself(const G4Element * , const G4HadProjectile & aTrack) |
---|
| 70 | { |
---|
| 71 | G4NeutronHPThermalBoost aThermalE; |
---|
| 72 | G4int i, ii; |
---|
| 73 | // decide on the isotope |
---|
| 74 | G4int numberOfIsos(0); |
---|
| 75 | for(ii=0; ii<nChannels; ii++) |
---|
| 76 | { |
---|
| 77 | numberOfIsos = theChannels[ii]->GetNiso(); |
---|
| 78 | if(numberOfIsos!=0) break; |
---|
| 79 | } |
---|
| 80 | G4double * running= new G4double [numberOfIsos]; |
---|
| 81 | running[0] = 0; |
---|
| 82 | for(i=0;i<numberOfIsos; i++) |
---|
| 83 | { |
---|
| 84 | if(i!=0) running[i] = running[i-1]; |
---|
| 85 | for(ii=0; ii<nChannels; ii++) |
---|
| 86 | { |
---|
| 87 | if(theChannels[ii]->HasAnyData(i)) |
---|
| 88 | { |
---|
| 89 | running[i] +=theChannels[ii]->GetWeightedXsec(aThermalE.GetThermalEnergy(aTrack, |
---|
| 90 | theChannels[ii]->GetN(i), |
---|
| 91 | theChannels[ii]->GetZ(i), |
---|
| 92 | aTrack.GetMaterial()->GetTemperature()), |
---|
| 93 | i); |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | G4int isotope=nChannels-1; |
---|
| 98 | G4double random=G4UniformRand(); |
---|
| 99 | for(i=0;i<numberOfIsos; i++) |
---|
| 100 | { |
---|
| 101 | isotope = i; |
---|
| 102 | //if(random<running[i]/running[numberOfIsos-1]) break; |
---|
| 103 | if(running[numberOfIsos-1] != 0) if(random<running[i]/running[numberOfIsos-1]) break; |
---|
| 104 | } |
---|
| 105 | delete [] running; |
---|
| 106 | |
---|
| 107 | // decide on the channel |
---|
| 108 | running = new G4double[nChannels]; |
---|
| 109 | running[0]=0; |
---|
| 110 | for(i=0; i<nChannels; i++) |
---|
| 111 | { |
---|
| 112 | if(i!=0) running[i] = running[i-1]; |
---|
| 113 | if(theChannels[i]->HasAnyData(isotope)) |
---|
| 114 | { |
---|
| 115 | running[i] += theChannels[i]->GetFSCrossSection(aThermalE.GetThermalEnergy(aTrack, |
---|
| 116 | theChannels[i]->GetN(isotope), |
---|
| 117 | theChannels[i]->GetZ(isotope), |
---|
| 118 | aTrack.GetMaterial()->GetTemperature()), |
---|
| 119 | isotope); |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | G4int lChan=0; |
---|
| 123 | random=G4UniformRand(); |
---|
| 124 | for(i=0; i<nChannels; i++) |
---|
| 125 | { |
---|
| 126 | lChan = i; |
---|
| 127 | if(running[nChannels-1] != 0) if(random<running[i]/running[nChannels-1]) break; |
---|
| 128 | } |
---|
| 129 | delete [] running; |
---|
| 130 | return theChannels[lChan]->ApplyYourself(aTrack, isotope); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | void G4NeutronHPChannelList::Init(G4Element * anElement, const G4String & dirName) |
---|
| 134 | { |
---|
| 135 | theDir = dirName; |
---|
| 136 | // G4cout << theDir << G4endl; |
---|
| 137 | theElement = anElement; |
---|
| 138 | // G4cout << theElement << G4endl; |
---|
| 139 | ; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | void G4NeutronHPChannelList::Register(G4NeutronHPFinalState * theFS, |
---|
| 143 | const G4String & aName) |
---|
| 144 | { |
---|
| 145 | G4bool result; |
---|
| 146 | if(!allChannelsCreated) |
---|
| 147 | { |
---|
| 148 | if(nChannels!=0) |
---|
| 149 | { |
---|
| 150 | G4NeutronHPChannel ** theBuffer = new G4NeutronHPChannel * [nChannels+1]; |
---|
| 151 | G4int i; |
---|
| 152 | for(i=0; i<nChannels; i++) |
---|
| 153 | { |
---|
| 154 | theBuffer[i] = theChannels[i]; |
---|
| 155 | } |
---|
| 156 | delete [] theChannels; |
---|
| 157 | theChannels = theBuffer; |
---|
| 158 | } |
---|
| 159 | else |
---|
| 160 | { |
---|
| 161 | theChannels = new G4NeutronHPChannel * [nChannels+1]; |
---|
| 162 | } |
---|
| 163 | G4String name; |
---|
| 164 | name = aName+"/"; |
---|
| 165 | theChannels[nChannels] = new G4NeutronHPChannel; |
---|
| 166 | theChannels[nChannels]->Init(theElement, theDir, name); |
---|
| 167 | nChannels++; |
---|
| 168 | } |
---|
| 169 | result = theChannels[theInitCount]->Register(theFS); |
---|
| 170 | theInitCount++; |
---|
| 171 | } |
---|