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