Geant4 Cross Reference |
1 // ******************************************* 1 // ******************************************************************** 2 // * License and Disclaimer 2 // * License and Disclaimer * 3 // * 3 // * * 4 // * The Geant4 software is copyright of th 4 // * The Geant4 software is copyright of the Copyright Holders of * 5 // * the Geant4 Collaboration. It is provided 5 // * the Geant4 Collaboration. It is provided under the terms and * 6 // * conditions of the Geant4 Software License 6 // * conditions of the Geant4 Software License, included in the file * 7 // * LICENSE and available at http://cern.ch/ 7 // * LICENSE and available at http://cern.ch/geant4/license . These * 8 // * include a list of copyright holders. 8 // * include a list of copyright holders. * 9 // * 9 // * * 10 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 11 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 12 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 13 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 14 // * use. Please see the license in the file 14 // * use. Please see the license in the file LICENSE and URL above * 15 // * for the full disclaimer and the limitatio 15 // * for the full disclaimer and the limitation of liability. * 16 // * 16 // * * 17 // * This code implementation is the result 17 // * This code implementation is the result of the scientific and * 18 // * technical work of the GEANT4 collaboratio 18 // * technical work of the GEANT4 collaboration. * 19 // * By using, copying, modifying or distri 19 // * By using, copying, modifying or distributing the software (or * 20 // * any work based on the software) you ag 20 // * any work based on the software) you agree to acknowledge its * 21 // * use in resulting scientific publicati 21 // * use in resulting scientific publications, and indicate your * 22 // * acceptance of all terms of the Geant4 Sof 22 // * acceptance of all terms of the Geant4 Software license. * 23 // ******************************************* 23 // ******************************************************************** 24 // 24 // 25 // 25 // 26 // ------------------------------------------- 26 // --------------------------------------------------------------------- 27 // GEANT 4 class header file 27 // GEANT 4 class header file 28 // 28 // 29 // History: first implementation, based on G4 29 // History: first implementation, based on G4DynamicParticle 30 // New dependency : G4VUserTrackInfo 30 // New dependency : G4VUserTrackInformation 31 // 31 // 32 // ---------------- G4Molecule --------- 32 // ---------------- G4Molecule ---------------- 33 // first design&implementation by Alfonso 33 // first design&implementation by Alfonso Mantero, 7 Apr 2009 34 // New developments Alfonso Mantero & Mat 34 // New developments Alfonso Mantero & Mathieu Karamitros 35 // Oct/Nov 2009 Class Name changed to G4M 35 // Oct/Nov 2009 Class Name changed to G4Molecule 36 // Removed dependency from G 36 // Removed dependency from G4DynamicParticle 37 // New constructors : 37 // New constructors : 38 // copy constructor 38 // copy constructor 39 // direct ionized/excited m 39 // direct ionized/excited molecule 40 // New methods : 40 // New methods : 41 // Get : name,atoms' number 41 // Get : name,atoms' number,nb electrons,decayChannel 42 // PrintState //To get the 42 // PrintState //To get the electronic level and the 43 // correspondi 43 // corresponding name of the excitation 44 // Kinematic : 44 // Kinematic : 45 // BuildTrack,GetKineticEne 45 // BuildTrack,GetKineticEnergy,GetDiffusionVelocity 46 // Change the way dynCharge 46 // Change the way dynCharge and eNb is calculated 47 // ------------------------------------------- 47 // --------------------------------------------------------------------- 48 48 49 #include "G4Molecule.hh" 49 #include "G4Molecule.hh" 50 #include "G4MolecularConfiguration.hh" 50 #include "G4MolecularConfiguration.hh" 51 #include "Randomize.hh" 51 #include "Randomize.hh" 52 #include "G4PhysicalConstants.hh" 52 #include "G4PhysicalConstants.hh" 53 #include "G4SystemOfUnits.hh" 53 #include "G4SystemOfUnits.hh" 54 #include "G4Track.hh" 54 #include "G4Track.hh" 55 #include "G4VMoleculeCounter.hh" 55 #include "G4VMoleculeCounter.hh" 56 56 57 using namespace std; 57 using namespace std; 58 58 >> 59 ///*G4ThreadLocal*/G4double G4Molecule::fgTemperature = 310; // 310*kelvin; >> 60 // 37°C, used to shoot an energy >> 61 >> 62 ITImp(G4Molecule) >> 63 59 G4Allocator<G4Molecule>*& aMoleculeAllocator() 64 G4Allocator<G4Molecule>*& aMoleculeAllocator() 60 { 65 { 61 G4ThreadLocalStatic G4Allocator<G4Molecule 66 G4ThreadLocalStatic G4Allocator<G4Molecule>* _instance = nullptr; 62 return _instance; 67 return _instance; 63 } 68 } 64 69 65 //____________________________________________ 70 //______________________________________________________________________________ 66 71 67 template<> 72 template<> 68 G4KDNode<G4Molecule>::~G4KDNode() { << 73 G4KDNode<G4Molecule>::~G4KDNode(){ 69 fPoint->SetNode(nullptr); << 74 fPoint->SetNode(nullptr); 70 } 75 } 71 76 72 //____________________________________________ 77 //______________________________________________________________________________ 73 78 74 G4Molecule* GetMolecule(const G4Track& track) 79 G4Molecule* GetMolecule(const G4Track& track) 75 { 80 { 76 return (G4Molecule*)(GetIT(track)); << 81 return (G4Molecule*) (GetIT(track)); 77 } 82 } 78 83 79 //____________________________________________ 84 //______________________________________________________________________________ 80 85 81 G4Molecule* GetMolecule(const G4Track* track) 86 G4Molecule* GetMolecule(const G4Track* track) 82 { 87 { 83 return (G4Molecule*)(GetIT(track)); << 88 return (G4Molecule*) (GetIT(track)); 84 } 89 } 85 90 86 //____________________________________________ 91 //______________________________________________________________________________ 87 92 88 G4Molecule* G4Molecule::GetMolecule(const G4Tr 93 G4Molecule* G4Molecule::GetMolecule(const G4Track* track) 89 { 94 { 90 return (G4Molecule*)(GetIT(track)); << 95 return (G4Molecule*) (GetIT(track)); 91 } 96 } 92 97 93 //____________________________________________ 98 //______________________________________________________________________________ 94 99 95 void G4Molecule::Print() const 100 void G4Molecule::Print() const 96 { 101 { 97 G4cout << "The user track information is a << 102 G4cout << "The user track information is a molecule" << G4endl; 98 } 103 } 99 104 100 //____________________________________________ 105 //______________________________________________________________________________ 101 106 102 G4Molecule::G4Molecule(const G4Molecule& right << 107 G4Molecule::G4Molecule(const G4Molecule& right) : 103 : G4VUserTrackInformation("G4Molecule") << 108 G4VUserTrackInformation("G4Molecule"), G4IT(right) 104 , G4IT(right) << 105 { 109 { 106 fpMolecularConfiguration = right.fpMolecul << 110 fpMolecularConfiguration = right.fpMolecularConfiguration; 107 } 111 } 108 112 109 //____________________________________________ 113 //______________________________________________________________________________ 110 114 111 G4Molecule& G4Molecule::operator=(const G4Mole 115 G4Molecule& G4Molecule::operator=(const G4Molecule& right) 112 { 116 { 113 if (&right == this) return *this; << 117 if (&right == this) return *this; 114 fpMolecularConfiguration = right.fpMolecul << 118 fpMolecularConfiguration = right.fpMolecularConfiguration; 115 return *this; << 119 return *this; 116 } 120 } 117 121 118 //____________________________________________ 122 //______________________________________________________________________________ 119 123 120 G4bool G4Molecule::operator==(const G4Molecule 124 G4bool G4Molecule::operator==(const G4Molecule& right) const 121 { 125 { 122 return fpMolecularConfiguration == right.f << 126 if (fpMolecularConfiguration == right.fpMolecularConfiguration) >> 127 { >> 128 return true; >> 129 } >> 130 return false; 123 } 131 } 124 132 125 //____________________________________________ 133 //______________________________________________________________________________ 126 134 127 G4bool G4Molecule::operator!=(const G4Molecule 135 G4bool G4Molecule::operator!=(const G4Molecule& right) const 128 { 136 { 129 return !(*this == right); << 137 return !(*this == right); 130 } 138 } 131 139 132 //____________________________________________ 140 //______________________________________________________________________________ 133 /** The two methods below are the most called 141 /** The two methods below are the most called of the simulation : 134 * compare molecules in the MoleculeStackMana 142 * compare molecules in the MoleculeStackManager or in 135 * the InteractionTable 143 * the InteractionTable 136 */ 144 */ 137 145 138 G4bool G4Molecule::operator<(const G4Molecule& 146 G4bool G4Molecule::operator<(const G4Molecule& right) const 139 { 147 { 140 return fpMolecularConfiguration < right.fp << 148 return fpMolecularConfiguration < right.fpMolecularConfiguration; 141 } 149 } 142 150 143 //____________________________________________ 151 //______________________________________________________________________________ >> 152 /** Default molecule builder >> 153 */ >> 154 G4Molecule::G4Molecule() : >> 155 G4VUserTrackInformation("G4Molecule"), G4IT() 144 156 145 G4Molecule::G4Molecule() << 146 : G4VUserTrackInformation("G4Molecule") << 147 { 157 { 148 fpMolecularConfiguration = nullptr; << 158 fpMolecularConfiguration = 0; 149 } 159 } 150 160 151 //____________________________________________ 161 //______________________________________________________________________________ 152 162 153 G4Molecule::~G4Molecule() 163 G4Molecule::~G4Molecule() 154 { 164 { 155 if (fpTrack != nullptr) << 165 if (fpTrack != nullptr) >> 166 { >> 167 if (G4VMoleculeCounter::Instance()->InUse()) 156 { 168 { 157 if (G4VMoleculeCounter::Instance()->In << 169 G4VMoleculeCounter::Instance()-> 158 { << 170 RemoveAMoleculeAtTime(fpMolecularConfiguration, 159 G4VMoleculeCounter::Instance()-> << 171 fpTrack->GetGlobalTime(), 160 RemoveAMoleculeAtTime(fpMolecu << 172 &(fpTrack->GetPosition())); 161 fpTrack- << 162 &(fpTrac << 163 } << 164 fpTrack = nullptr; << 165 } 173 } 166 fpMolecularConfiguration = nullptr; << 174 fpTrack = nullptr; >> 175 } >> 176 fpMolecularConfiguration = nullptr; 167 } 177 } 168 178 169 //____________________________________________ 179 //______________________________________________________________________________ 170 /** Build a molecule at ground state according 180 /** Build a molecule at ground state according to a given 171 * G4MoleculeDefinition that can be obtained 181 * G4MoleculeDefinition that can be obtained from G4GenericMoleculeManager 172 */ 182 */ 173 G4Molecule::G4Molecule(G4MoleculeDefinition* p << 183 ////////////////////////// 174 : G4VUserTrackInformation("G4Molecule") << 184 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) : >> 185 G4VUserTrackInformation("G4Molecule"), G4IT() >> 186 ////////////////////////// 175 { 187 { 176 fpMolecularConfiguration = G4MolecularConf << 188 fpMolecularConfiguration = >> 189 G4MolecularConfiguration:: >> 190 GetOrCreateMolecularConfiguration(moleculeDefinition); 177 } 191 } 178 192 179 //____________________________________________ 193 //______________________________________________________________________________ 180 194 181 G4Molecule::G4Molecule(G4MoleculeDefinition* p << 195 G4Molecule::G4Molecule(G4MoleculeDefinition* moleculeDefinition, int charge) 182 { 196 { 183 fpMolecularConfiguration = G4MolecularConf << 197 fpMolecularConfiguration = 184 << 198 G4MolecularConfiguration:: >> 199 GetOrCreateMolecularConfiguration(moleculeDefinition, >> 200 charge); 185 } 201 } 186 202 187 //____________________________________________ 203 //______________________________________________________________________________ 188 /** Build a molecule at a specific excitation/ 204 /** Build a molecule at a specific excitation/ionisation state according 189 * to a ground state that can be obtained fro 205 * to a ground state that can be obtained from G4GenericMoleculeManager. 190 * Put 0 in the second option if this is a io 206 * Put 0 in the second option if this is a ionisation. 191 */ 207 */ 192 G4Molecule::G4Molecule(G4MoleculeDefinition* p << 208 ////////////////////////// >> 209 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, 193 G4int OrbitalToFree, 210 G4int OrbitalToFree, 194 G4int OrbitalToFill) << 211 G4int OrbitalToFill) : 195 : G4VUserTrackInformation("G4Molecule") << 212 G4VUserTrackInformation("G4Molecule"), G4IT() 196 { << 213 ////////////////////////// 197 if (pMoleculeDefinition->GetGroundStateEle << 214 { 198 { << 215 if (moleculeDefinition->GetGroundStateElectronOccupancy()) 199 G4ElectronOccupancy dynElectronOccupan << 216 { >> 217 G4ElectronOccupancy dynElectronOccupancy( >> 218 *moleculeDefinition->GetGroundStateElectronOccupancy()); 200 219 201 if (OrbitalToFill != 0) << 220 if (OrbitalToFill != 0) 202 { << 221 { 203 dynElectronOccupancy.RemoveElectro << 222 dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1); 204 dynElectronOccupancy.AddElectron(O << 223 dynElectronOccupancy.AddElectron(OrbitalToFill - 1, 1); 205 // dynElectronOccupancy.DumpInfo() << 224 // dynElectronOccupancy.DumpInfo(); // DEBUG 206 } << 207 << 208 if (OrbitalToFill == 0) << 209 { << 210 dynElectronOccupancy.RemoveElectro << 211 // dynElectronOccupancy.DumpInfo() << 212 } << 213 << 214 fpMolecularConfiguration = << 215 G4MolecularConfiguration::GetOrCre << 216 pMoleculeDefinition, dynElectr << 217 } 225 } 218 else << 226 >> 227 if (OrbitalToFill == 0) 219 { 228 { 220 fpMolecularConfiguration = nullptr; << 229 dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1); 221 G4Exception( << 230 // dynElectronOccupancy.DumpInfo(); // DEBUG 222 "G4Molecule::G4Molecule(G4Molecule << 223 "G4int OrbitalToFree, G4int Orbita << 224 "G4Molecule_wrong_usage_of_constru << 225 FatalErrorInArgument, << 226 "If you want to use this construct << 227 "first defined with electron occup << 228 } 231 } >> 232 >> 233 fpMolecularConfiguration = >> 234 G4MolecularConfiguration::GetOrCreateMolecularConfiguration( >> 235 moleculeDefinition, dynElectronOccupancy); >> 236 } >> 237 else >> 238 { >> 239 fpMolecularConfiguration = 0; >> 240 G4Exception( >> 241 "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, " >> 242 "G4int OrbitalToFree, G4int OrbitalToFill)", >> 243 "G4Molecule_wrong_usage_of_constructor", >> 244 FatalErrorInArgument, >> 245 "If you want to use this constructor, the molecule definition has to be " >> 246 "first defined with electron occupancies"); >> 247 } 229 } 248 } 230 249 231 //____________________________________________ 250 //______________________________________________________________________________ 232 /** Specific builder for water molecules to be 251 /** Specific builder for water molecules to be used in Geant4-DNA, 233 * the last option Excitation is true if the m 252 * the last option Excitation is true if the molecule is excited, is 234 * false is the molecule is ionized. 253 * false is the molecule is ionized. 235 */ 254 */ 236 G4Molecule::G4Molecule(G4MoleculeDefinition* p << 237 G4int level, << 238 G4bool excitation) << 239 : G4VUserTrackInformation("G4Molecule") << 240 { << 241 if (pMoleculeDefinition->GetGroundStateEle << 242 { << 243 G4ElectronOccupancy dynElectronOccupan << 244 255 245 if (excitation) << 256 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, 246 { << 257 G4int Level, 247 dynElectronOccupancy.RemoveElectro << 258 G4bool Excitation) : 248 dynElectronOccupancy.AddElectron(5 << 259 G4VUserTrackInformation("G4Molecule"), G4IT() 249 // dynElectronOccupancy.DumpInfo() << 260 { 250 } << 261 if (moleculeDefinition->GetGroundStateElectronOccupancy()) 251 else << 262 { 252 { << 263 G4ElectronOccupancy dynElectronOccupancy( 253 dynElectronOccupancy.RemoveElectro << 264 *moleculeDefinition->GetGroundStateElectronOccupancy()); 254 // dynElectronOccupancy.DumpInfo() << 255 } << 256 265 257 fpMolecularConfiguration = G4Molecular << 266 if (Excitation == true) 258 dynElectronOccupancy); << 267 { >> 268 dynElectronOccupancy.RemoveElectron(Level, 1); >> 269 dynElectronOccupancy.AddElectron(5, 1); >> 270 // dynElectronOccupancy.DumpInfo(); // DEBUG 259 } 271 } 260 else << 272 >> 273 if (Excitation == false) 261 { 274 { 262 fpMolecularConfiguration = nullptr; << 275 dynElectronOccupancy.RemoveElectron(Level, 1); 263 G4Exception( << 276 // dynElectronOccupancy.DumpInfo(); // DEBUG 264 "G4Molecule::G4Molecule(G4Molecule << 265 "G4int OrbitalToFree, G4int Orbita << 266 "G4Molecule_wrong_usage_of_constru << 267 FatalErrorInArgument, << 268 "If you want to use this construct << 269 "first defined with electron occup << 270 } 277 } >> 278 >> 279 fpMolecularConfiguration = >> 280 G4MolecularConfiguration::GetOrCreateMolecularConfiguration( >> 281 moleculeDefinition, dynElectronOccupancy); >> 282 } >> 283 else >> 284 { >> 285 fpMolecularConfiguration = 0; >> 286 G4Exception( >> 287 "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, " >> 288 "G4int OrbitalToFree, G4int OrbitalToFill)", >> 289 "G4Molecule_wrong_usage_of_constructor", >> 290 FatalErrorInArgument, >> 291 "If you want to use this constructor, the molecule definition has to be " >> 292 "first defined with electron occupancies"); >> 293 >> 294 } 271 } 295 } 272 296 273 //____________________________________________ 297 //______________________________________________________________________________ 274 298 275 G4Molecule::G4Molecule(const G4MolecularConfig << 299 G4Molecule::G4Molecule(G4MolecularConfiguration* molConf) 276 { 300 { 277 fpMolecularConfiguration = pMolecularConfi << 301 fpMolecularConfiguration = molConf; 278 } 302 } 279 303 280 //____________________________________________ 304 //______________________________________________________________________________ 281 305 282 void G4Molecule::SetElectronOccupancy(const G4 << 306 void G4Molecule::SetElectronOccupancy(const G4ElectronOccupancy* occ) 283 { 307 { 284 fpMolecularConfiguration = << 308 fpMolecularConfiguration = 285 G4MolecularConfiguration::GetOrCreateM << 309 G4MolecularConfiguration::GetOrCreateMolecularConfiguration( 286 << 310 fpMolecularConfiguration->GetDefinition(), *occ); 287 } 311 } 288 312 289 //____________________________________________ 313 //______________________________________________________________________________ 290 314 291 void G4Molecule::ExciteMolecule(G4int excitati << 315 /** Method used in Geant4-DNA to excite water molecules >> 316 */ >> 317 void G4Molecule::ExciteMolecule(G4int ExcitedLevel) 292 { 318 { 293 fpMolecularConfiguration = fpMolecularConf << 319 fpMolecularConfiguration = fpMolecularConfiguration->ExciteMolecule( >> 320 ExcitedLevel); 294 } 321 } 295 322 296 //____________________________________________ 323 //______________________________________________________________________________ 297 324 298 void G4Molecule::IonizeMolecule(G4int ionizati << 325 /** Method used in Geant4-DNA to ionize water molecules >> 326 */ >> 327 void G4Molecule::IonizeMolecule(G4int IonizedLevel) 299 { 328 { 300 fpMolecularConfiguration = fpMolecularConf << 329 fpMolecularConfiguration = fpMolecularConfiguration->IonizeMolecule( >> 330 IonizedLevel); 301 } 331 } 302 332 303 //____________________________________________ 333 //______________________________________________________________________________ 304 334 305 void G4Molecule::AddElectron(G4int orbit, G4in 335 void G4Molecule::AddElectron(G4int orbit, G4int number) 306 { 336 { 307 fpMolecularConfiguration = fpMolecularConf << 337 fpMolecularConfiguration = fpMolecularConfiguration->AddElectron(orbit, >> 338 number); 308 } 339 } 309 340 310 //____________________________________________ 341 //______________________________________________________________________________ 311 342 312 void G4Molecule::RemoveElectron(G4int orbit, G 343 void G4Molecule::RemoveElectron(G4int orbit, G4int number) 313 { 344 { 314 fpMolecularConfiguration = << 345 fpMolecularConfiguration = fpMolecularConfiguration->RemoveElectron(orbit, 315 fpMolecularConfiguration->RemoveElectr << 346 number); 316 } 347 } 317 348 318 //____________________________________________ 349 //______________________________________________________________________________ 319 350 320 void G4Molecule::MoveOneElectron(G4int orbitTo 351 void G4Molecule::MoveOneElectron(G4int orbitToFree, G4int orbitToFill) 321 { 352 { 322 fpMolecularConfiguration = << 353 fpMolecularConfiguration = fpMolecularConfiguration->MoveOneElectron( 323 fpMolecularConfiguration->MoveOneElect << 354 orbitToFree, orbitToFill); 324 } 355 } 325 356 326 //____________________________________________ 357 //______________________________________________________________________________ 327 358 328 const G4String& G4Molecule::GetName() const 359 const G4String& G4Molecule::GetName() const 329 { 360 { 330 return fpMolecularConfiguration->GetName() << 361 return fpMolecularConfiguration->GetName(); 331 } 362 } 332 363 333 //____________________________________________ 364 //______________________________________________________________________________ 334 365 335 const G4String& G4Molecule::GetFormatedName() 366 const G4String& G4Molecule::GetFormatedName() const 336 { 367 { 337 return fpMolecularConfiguration->GetFormat << 368 return fpMolecularConfiguration->GetFormatedName(); 338 } 369 } 339 370 340 //____________________________________________ 371 //______________________________________________________________________________ 341 372 342 G4int G4Molecule::GetAtomsNumber() const 373 G4int G4Molecule::GetAtomsNumber() const 343 { 374 { 344 return fpMolecularConfiguration->GetAtomsN << 375 return fpMolecularConfiguration->GetAtomsNumber(); 345 } 376 } 346 377 347 //____________________________________________ 378 //______________________________________________________________________________ 348 379 349 G4double G4Molecule::GetNbElectrons() const 380 G4double G4Molecule::GetNbElectrons() const 350 { 381 { 351 return fpMolecularConfiguration->GetNbElec << 382 return fpMolecularConfiguration->GetNbElectrons(); 352 } 383 } 353 384 354 //____________________________________________ 385 //______________________________________________________________________________ 355 386 356 void G4Molecule::PrintState() const 387 void G4Molecule::PrintState() const 357 { 388 { 358 fpMolecularConfiguration->PrintState(); << 389 fpMolecularConfiguration->PrintState(); 359 } 390 } 360 391 361 //____________________________________________ 392 //______________________________________________________________________________ 362 393 363 G4Track* G4Molecule::BuildTrack(G4double globa << 394 G4Track * G4Molecule::BuildTrack(G4double globalTime, 364 const G4Three 395 const G4ThreeVector& position) 365 { 396 { 366 if (fpTrack != nullptr) << 397 if (fpTrack != 0){ 367 { << 398 G4Exception("G4Molecule::BuildTrack", "Molecule001", FatalErrorInArgument, 368 G4Exception("G4Molecule::BuildTrack", << 399 "A track was already assigned to this molecule"); 369 "A track was already assig << 400 } 370 } << 401 371 << 402 // Kinetic Values 372 // Kinetic Values << 403 // Set a random direction to the molecule 373 // Set a random direction to the molecule << 404 G4double costheta = (2 * G4UniformRand()-1); 374 G4double costheta = (2 * G4UniformRand() - << 405 G4double theta = acos(costheta); 375 G4double theta = acos(costheta); << 406 G4double phi = 2 * pi * G4UniformRand(); 376 G4double phi = 2 * pi * G4UniformRand(); << 407 377 << 408 G4double xMomentum = cos(phi) * sin(theta); 378 G4double xMomentum = cos(phi) * sin(theta) << 409 G4double yMomentum = sin(theta) * sin(phi); 379 G4double yMomentum = sin(theta) * sin(phi) << 410 G4double zMomentum = costheta; 380 G4double zMomentum = costheta; << 411 381 << 412 G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum); 382 G4ThreeVector MomentumDirection(xMomentum, << 413 G4double KineticEnergy = GetKineticEnergy(); 383 G4double KineticEnergy = GetKineticEnergy( << 414 384 << 415 G4DynamicParticle* dynamicParticle = new G4DynamicParticle( 385 auto dynamicParticle = new G4DynamicParti << 416 fpMolecularConfiguration->GetDefinition(), MomentumDirection, 386 fpMolecularConfiguration->GetDefinitio << 417 KineticEnergy); 387 KineticEnergy); << 418 388 << 419 if (G4VMoleculeCounter::InUse()){ 389 if (G4VMoleculeCounter::Instance()->InUse( << 420 G4VMoleculeCounter::Instance()-> 390 { << 421 AddAMoleculeAtTime(fpMolecularConfiguration, 391 G4VMoleculeCounter::Instance()-> << 422 globalTime, 392 AddAMoleculeAtTime(fpMolecularConf << 423 &(fpTrack->GetPosition())); 393 globalTime, << 424 } 394 &(fpTrack->GetP << 425 395 } << 426 //Set the Track 396 << 427 fpTrack = new G4Track(dynamicParticle, globalTime, position); 397 //Set the Track << 428 fpTrack->SetUserInformation(this); 398 fpTrack = new G4Track(dynamicParticle, glo << 399 fpTrack->SetUserInformation(this); << 400 429 401 return fpTrack; << 430 return fpTrack; 402 } 431 } 403 432 404 //____________________________________________ 433 //______________________________________________________________________________ 405 434 406 G4double G4Molecule::GetKineticEnergy() const 435 G4double G4Molecule::GetKineticEnergy() const 407 { 436 { 408 //// << 437 //// 409 // Ideal Gaz case << 438 // Ideal Gaz case 410 double v = GetDiffusionVelocity(); << 439 double v = GetDiffusionVelocity(); 411 double E = (fpMolecularConfiguration->GetM << 440 double E = (fpMolecularConfiguration->GetMass() / (c_squared)) * (v * v) / 2.; 412 //// << 441 //// 413 return E; << 442 return E; 414 } 443 } 415 444 416 //____________________________________________ 445 //______________________________________________________________________________ 417 446 418 G4double G4Molecule::GetDiffusionVelocity() co 447 G4double G4Molecule::GetDiffusionVelocity() const 419 { 448 { 420 double moleculeMass = fpMolecularConfigura << 449 double moleculeMass = fpMolecularConfiguration->GetMass() / (c_squared); 421 450 422 //// << 451 //// 423 // Different possibilities << 452 // Different possibilities 424 //// << 453 //// 425 // Ideal Gaz case : Maxwell Boltzmann Dist << 454 // Ideal Gaz case : Maxwell Boltzmann Distribution 426 // double sigma = k_Boltzmann * fgTempe << 455 // double sigma = k_Boltzmann * fgTemperature / mass; 427 // return G4RandGauss::shoot( 0, sigma << 456 // return G4RandGauss::shoot( 0, sigma ); 428 //// << 457 //// 429 // Ideal Gaz case : mean velocity from equ << 458 // Ideal Gaz case : mean velocity from equipartition theorem 430 return sqrt(3 * k_Boltzmann * << 459 return sqrt(3 * k_Boltzmann * 431 G4MolecularConfiguration::GetG << 460 G4MolecularConfiguration::GetGlobalTemperature()/ moleculeMass); 432 //// << 461 //// 433 // Using this approximation for liquid is << 462 // Using this approximation for liquid is wrong 434 // However the brownian process avoid taki << 463 // However the brownian process avoid taking 435 // care of energy consideration and plays << 464 // care of energy consideration and plays only 436 // with positions << 465 // with positions 437 } 466 } 438 467 439 //____________________________________________ 468 //______________________________________________________________________________ 440 469 441 // added - to be transformed in a "Decay metho 470 // added - to be transformed in a "Decay method" 442 const vector<const G4MolecularDissociationChan 471 const vector<const G4MolecularDissociationChannel*>* 443 G4Molecule::GetDissociationChannels() const << 472 G4Molecule::GetDecayChannel() const 444 { 473 { 445 return fpMolecularConfiguration->GetDissoc << 474 return fpMolecularConfiguration->GetDecayChannel(); 446 } 475 } 447 476 448 //____________________________________________ 477 //______________________________________________________________________________ 449 478 450 G4int G4Molecule::GetFakeParticleID() const 479 G4int G4Molecule::GetFakeParticleID() const 451 { 480 { 452 return fpMolecularConfiguration->GetFakePa << 481 return fpMolecularConfiguration->GetFakeParticleID(); 453 } 482 } 454 483 455 //____________________________________________ 484 //______________________________________________________________________________ 456 485 457 G4int G4Molecule::GetMoleculeID() const 486 G4int G4Molecule::GetMoleculeID() const 458 { 487 { 459 return fpMolecularConfiguration->GetMolecu << 488 return fpMolecularConfiguration->GetMoleculeID(); >> 489 } >> 490 >> 491 //______________________________________________________________________________ >> 492 >> 493 void G4Molecule::SetDecayTime(G4double dynDecayTime) >> 494 { >> 495 fpMolecularConfiguration->SetDecayTime(dynDecayTime); 460 } 496 } 461 497 462 //____________________________________________ 498 //______________________________________________________________________________ 463 499 464 G4double G4Molecule::GetDecayTime() const 500 G4double G4Molecule::GetDecayTime() const 465 { 501 { 466 return fpMolecularConfiguration->GetDecayT << 502 return fpMolecularConfiguration->GetDecayTime(); >> 503 } >> 504 >> 505 //______________________________________________________________________________ >> 506 >> 507 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius) >> 508 { >> 509 fpMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius); 467 } 510 } 468 511 469 //____________________________________________ 512 //______________________________________________________________________________ 470 513 471 G4double G4Molecule::GetVanDerVaalsRadius() co 514 G4double G4Molecule::GetVanDerVaalsRadius() const 472 { 515 { 473 return fpMolecularConfiguration->GetVanDer << 516 return fpMolecularConfiguration->GetVanDerVaalsRadius(); 474 } 517 } 475 518 476 //____________________________________________ 519 //______________________________________________________________________________ 477 520 478 G4int G4Molecule::GetCharge() const 521 G4int G4Molecule::GetCharge() const 479 { 522 { 480 return fpMolecularConfiguration->GetCharge << 523 return fpMolecularConfiguration->GetCharge(); >> 524 } >> 525 >> 526 //______________________________________________________________________________ >> 527 >> 528 void G4Molecule::SetMass(G4double aMass) >> 529 { >> 530 fpMolecularConfiguration->SetMass(aMass); 481 } 531 } 482 532 483 //____________________________________________ 533 //______________________________________________________________________________ 484 534 485 G4double G4Molecule::GetMass() const 535 G4double G4Molecule::GetMass() const 486 { 536 { 487 return fpMolecularConfiguration->GetMass() << 537 return fpMolecularConfiguration->GetMass(); 488 } 538 } 489 539 490 //____________________________________________ 540 //______________________________________________________________________________ 491 541 492 const G4ElectronOccupancy* G4Molecule::GetElec 542 const G4ElectronOccupancy* G4Molecule::GetElectronOccupancy() const 493 { 543 { 494 return fpMolecularConfiguration->GetElectr << 544 return fpMolecularConfiguration->GetElectronOccupancy(); 495 } 545 } 496 546 497 //____________________________________________ 547 //______________________________________________________________________________ 498 548 499 const G4MoleculeDefinition* G4Molecule::GetDef 549 const G4MoleculeDefinition* G4Molecule::GetDefinition() const 500 { 550 { 501 return fpMolecularConfiguration->GetDefini << 551 return fpMolecularConfiguration->GetDefinition(); >> 552 } >> 553 >> 554 //______________________________________________________________________________ >> 555 >> 556 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient) >> 557 { >> 558 fpMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient); 502 } 559 } 503 560 504 //____________________________________________ 561 //______________________________________________________________________________ 505 562 506 G4double G4Molecule::GetDiffusionCoefficient() 563 G4double G4Molecule::GetDiffusionCoefficient() const 507 { 564 { 508 return fpMolecularConfiguration->GetDiffus << 565 return fpMolecularConfiguration->GetDiffusionCoefficient(); 509 } 566 } 510 567 511 //____________________________________________ 568 //______________________________________________________________________________ 512 569 513 G4double G4Molecule::GetDiffusionCoefficient(c << 570 G4double G4Molecule::GetDiffusionCoefficient(const G4Material* mat, 514 d 571 double temperature) const 515 { 572 { 516 return fpMolecularConfiguration->GetDiffus << 573 return fpMolecularConfiguration->GetDiffusionCoefficient(mat, 517 << 574 temperature); 518 } 575 } 519 576 520 //____________________________________________ 577 //______________________________________________________________________________ 521 578 522 const G4MolecularConfiguration* G4Molecule::Ge << 579 G4MolecularConfiguration* G4Molecule::GetMolecularConfiguration() const 523 { 580 { 524 return fpMolecularConfiguration; << 581 return fpMolecularConfiguration; 525 } 582 } 526 583 527 //____________________________________________ 584 //______________________________________________________________________________ 528 585 >> 586 //void G4Molecule::SetGlobalTemperature(G4double temperature) >> 587 //{ >> 588 // fgTemperature = temperature; >> 589 //} >> 590 // >> 591 ////______________________________________________________________________________ >> 592 // >> 593 //G4double G4Molecule::GetGlobalTemperature() >> 594 //{ >> 595 // return fgTemperature; >> 596 //} >> 597 >> 598 //______________________________________________________________________________ >> 599 529 const G4String& G4Molecule::GetLabel() const 600 const G4String& G4Molecule::GetLabel() const 530 { 601 { 531 return fpMolecularConfiguration->GetLabel( << 602 return fpMolecularConfiguration->GetLabel(); >> 603 } >> 604 >> 605 //______________________________________________________________________________ >> 606 >> 607 void G4Molecule::SetLabel(const G4String& label) >> 608 { >> 609 fpMolecularConfiguration->SetLabel(label); 532 } 610 } 533 611 534 //____________________________________________ 612 //______________________________________________________________________________ 535 613 536 void G4Molecule::ChangeConfigurationToLabel(co 614 void G4Molecule::ChangeConfigurationToLabel(const G4String& label) 537 { 615 { 538 // TODO check fpMolecularConfiguration alr << 616 // TODO check fpMolecularConfiguration already exists 539 // and new one as well << 617 // and new one as well 540 // TODO notify for stack change << 618 // TODO notify for stack change 541 fpMolecularConfiguration = G4MolecularConf << 619 fpMolecularConfiguration = 542 fpMolecularConfiguration->GetDefinitio << 620 G4MolecularConfiguration::GetMolecularConfiguration( >> 621 fpMolecularConfiguration->GetDefinition(), label); 543 622 544 assert(fpMolecularConfiguration != nullptr << 623 assert(fpMolecularConfiguration!=0); 545 } 624 } 546 625