Geant4  10.01.p03
G4Molecule.cc
Go to the documentation of this file.
1 // ********************************************************************
2 // * License and Disclaimer *
3 // * *
4 // * The Geant4 software is copyright of the Copyright Holders of *
5 // * the Geant4 Collaboration. It is provided under the terms and *
6 // * conditions of the Geant4 Software License, included in the file *
7 // * LICENSE and available at http://cern.ch/geant4/license . These *
8 // * include a list of copyright holders. *
9 // * *
10 // * Neither the authors of this software system, nor their employing *
11 // * institutes,nor the agencies providing financial support for this *
12 // * work make any representation or warranty, express or implied, *
13 // * regarding this software system or assume any liability for its *
14 // * use. Please see the license in the file LICENSE and URL above *
15 // * for the full disclaimer and the limitation of liability. *
16 // * *
17 // * This code implementation is the result of the scientific and *
18 // * technical work of the GEANT4 collaboration. *
19 // * By using, copying, modifying or distributing the software (or *
20 // * any work based on the software) you agree to acknowledge its *
21 // * use in resulting scientific publications, and indicate your *
22 // * acceptance of all terms of the Geant4 Software license. *
23 // ********************************************************************
24 //
25 // $Id: G4Molecule.cc 84858 2014-10-21 16:08:22Z gcosmo $
26 //
27 // ---------------------------------------------------------------------
28 // GEANT 4 class header file
29 //
30 // History: first implementation, based on G4DynamicParticle
31 // New dependency : G4VUserTrackInformation
32 //
33 // ---------------- G4Molecule ----------------
34 // first design&implementation by Alfonso Mantero, 7 Apr 2009
35 // New developments Alfonso Mantero & Mathieu Karamitros
36 // Oct/Nov 2009 Class Name changed to G4Molecule
37 // Removed dependency from G4DynamicParticle
38 // New constructors :
39 // copy constructor
40 // direct ionized/excited molecule
41 // New methods :
42 // Get : name,atoms' number,nb electrons,decayChannel
43 // PrintState //To get the electronic level and the
44 // corresponding name of the excitation
45 // Kinematic :
46 // BuildTrack,GetKineticEnergy,GetDiffusionVelocity
47 // Change the way dynCharge and eNb is calculated
48 // ---------------------------------------------------------------------
49 
50 #include "G4Molecule.hh"
52 #include "Randomize.hh"
53 #include "G4PhysicalConstants.hh"
54 #include "G4SystemOfUnits.hh"
55 #include "G4Track.hh"
56 #include "G4MoleculeCounter.hh"
57 
58 using namespace std;
59 
60 /*G4ThreadLocal*/G4double G4Molecule::fgTemperature = 310; // 310*kelvin;
61 // 37°C, used to shoot an energy
62 
64 
66 
68 {
69  return (G4Molecule*) (GetIT(track));
70 }
71 
73 {
74  return (G4Molecule*) (GetIT(track));
75 }
76 
78 {
79  return (G4Molecule*) (GetIT(track));
80 }
81 
82 void G4Molecule::Print() const
83 {
84  G4cout << "The user track information is a molecule" << G4endl;
85 }
86 
88  G4VUserTrackInformation("G4Molecule"), G4IT(right)
89 {
91 }
92 
94 {
95  if (&right == this) return *this;
97  return *this;
98 }
99 
101 {
103  {
104  return true;
105  }
106  return false;
107 }
108 
110 {
111  return !(*this == right);
112 }
113 
118 
120 {
122 }
123 
125 
129  G4VUserTrackInformation("G4Molecule"), G4IT()
131 {
133 }
134 
138 {
139  if (fpTrack != NULL)
140  {
142  {
144  *this, fpTrack->GetGlobalTime());
145  }
146  fpTrack = 0;
147  }
149 }
150 
154 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
156  G4VUserTrackInformation("G4Molecule"), G4IT()
158 {
161 }
162 
163 G4Molecule::G4Molecule(G4MoleculeDefinition* moleculeDefinition, int charge)
164 {
167  charge);
168 }
169 
174 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition,
176  G4int OrbitalToFree,
177  G4int OrbitalToFill) :
178  G4VUserTrackInformation("G4Molecule"), G4IT()
180 {
181  if (moleculeDefinition->GetGroundStateElectronOccupancy())
182  {
183  G4ElectronOccupancy dynElectronOccupancy(
184  *moleculeDefinition->GetGroundStateElectronOccupancy());
185 
186  if (OrbitalToFill != 0)
187  {
188  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
189  dynElectronOccupancy.AddElectron(OrbitalToFill - 1, 1);
190  // dynElectronOccupancy.DumpInfo(); // DEBUG
191  }
192 
193  if (OrbitalToFill == 0)
194  {
195  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
196  // dynElectronOccupancy.DumpInfo(); // DEBUG
197  }
198 
201  moleculeDefinition, dynElectronOccupancy);
202  }
203  else
204  {
206  G4Exception(
207  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
208  "G4int OrbitalToFree, G4int OrbitalToFill)",
209  "G4Molecule_wrong_usage_of_constructor",
211  "If you want to use this constructor, the molecule definition has to be "
212  "first defined with electron occupancies");
213  }
214 }
215 
222  G4int Level,
223  G4bool Excitation) :
224  G4VUserTrackInformation("G4Molecule"), G4IT()
225 {
226  if (moleculeDefinition->GetGroundStateElectronOccupancy())
227  {
228  G4ElectronOccupancy dynElectronOccupancy(
229  *moleculeDefinition->GetGroundStateElectronOccupancy());
230 
231  if (Excitation == true)
232  {
233  dynElectronOccupancy.RemoveElectron(Level, 1);
234  dynElectronOccupancy.AddElectron(5, 1);
235  // dynElectronOccupancy.DumpInfo(); // DEBUG
236  }
237 
238  if (Excitation == false)
239  {
240  dynElectronOccupancy.RemoveElectron(Level, 1);
241  // dynElectronOccupancy.DumpInfo(); // DEBUG
242  }
243 
246  moleculeDefinition, dynElectronOccupancy);
247  }
248  else
249  {
251  G4Exception(
252  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
253  "G4int OrbitalToFree, G4int OrbitalToFill)",
254  "G4Molecule_wrong_usage_of_constructor",
256  "If you want to use this constructor, the molecule definition has to be "
257  "first defined with electron occupancies");
258 
259  }
260 }
261 
263 {
267 }
268 
272 {
274  ExcitedLevel);
275 }
276 
280 {
282  IonizedLevel);
283 }
284 
286 {
288  number);
289 }
290 
292 {
294  number);
295 }
296 
297 void G4Molecule::MoveOneElectron(G4int orbitToFree, G4int orbitToFill)
298 {
300  orbitToFree, orbitToFill);
301 }
302 
304 {
306 }
307 
309 {
311 }
312 
314 {
316 }
317 
319 {
321 }
322 
324 {
326 }
327 
329  const G4ThreeVector& position)
330 {
331  if (fpTrack != 0)
332  {
333  G4Exception("G4Molecule::BuildTrack", "Molecule001", FatalErrorInArgument,
334  "A track was already assigned to this molecule");
335  }
336 
337  // Kinetic Values
338  // Set a random direction to the molecule
339  G4double costheta = (2 * G4UniformRand()-1);
340  G4double theta = acos(costheta);
341  G4double phi = 2 * pi * G4UniformRand();
342 
343  G4double xMomentum = cos(phi) * sin(theta);
344  G4double yMomentum = sin(theta) * sin(phi);
345  G4double zMomentum = costheta;
346 
347  G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
348  G4double KineticEnergy = GetKineticEnergy();
349 
350  G4DynamicParticle* dynamicParticle = new G4DynamicParticle(
351  fpMolecularConfiguration->GetDefinition(), MomentumDirection,
352  KineticEnergy);
353 
355  {
357  globalTime);
358  }
359 
360 
361  //Set the Track
362  fpTrack = new G4Track(dynamicParticle, globalTime, position);
364 
365  return fpTrack;
366 }
367 
369 {
371  // Ideal Gaz case
372  double v = GetDiffusionVelocity();
373  double E = (fpMolecularConfiguration->GetMass() / (c_squared)) * (v * v) / 2.;
375  return E;
376 }
377 
379 {
380  double moleculeMass = fpMolecularConfiguration->GetMass() / (c_squared);
381 
383  // Different possibilities
385  // Ideal Gaz case : Maxwell Boltzmann Distribution
386  // double sigma = k_Boltzmann * fgTemperature / mass;
387  // return G4RandGauss::shoot( 0, sigma );
389  // Ideal Gaz case : mean velocity from equipartition theorem
390  return sqrt(3 * k_Boltzmann * fgTemperature / moleculeMass);
392  // Using this approximation for liquid is wrong
393  // However the brownian process avoid taking
394  // care of energy consideration and plays only
395  // with positions
396 }
397 
398 // added - to be transformed in a "Decay method"
399 const vector<const G4MolecularDissociationChannel*>*
401 {
403 }
404 
406 {
408 }
409 
411 {
413 }
414 
416 {
417  fpMolecularConfiguration->SetDecayTime(dynDecayTime);
418 }
419 
421 {
423 }
424 
425 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
426 {
427  fpMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
428 }
429 
431 {
433 }
434 
436 {
438 }
439 
441 {
443 }
444 
446 {
448 }
449 
451 {
453 }
454 
456 {
458 }
459 
460 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
461 {
462  fpMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
463 }
464 
466 {
468 }
469 
471 {
473 }
474 
476 {
477  fgTemperature = temperature;
478 }
479 
481 {
482  return fgTemperature;
483 }
The pointer G4MolecularConfiguration will be shared by all the molecules having the same molecule def...
G4double GetDiffusionCoefficient() const
Returns the diffusion coefficient D.
void PrintState() const
Display the electronic state of the molecule.
G4int GetCharge() const
Returns the charge of molecule.
const G4String & GetName() const
Returns the name of the molecule.
void SetDiffusionCoefficient(G4double)
Sets the diffusion coefficient D of the molecule used in diffusion processes to calculate the mean sq...
Definition: G4Molecule.cc:460
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:400
G4bool operator!=(const G4Molecule &right) const
Definition: G4Molecule.cc:109
CLHEP::Hep3Vector G4ThreeVector
G4Molecule()
Default molecule builder.
Definition: G4Molecule.cc:128
virtual void AddAMoleculeAtTime(const G4Molecule &, G4double)
G4bool operator<(const G4Molecule &right) const
The two methods below are the most called of the simulation : compare molecules in the MoleculeStackM...
Definition: G4Molecule.cc:119
static G4Molecule * GetMolecule(const G4Track *)
Definition: G4Molecule.cc:77
G4double GetMass() const
Returns the total mass of the molecule.
Definition: G4Molecule.cc:445
void SetMass(G4double)
Set the total mass of the molecule.
Definition: G4Molecule.cc:440
const G4double pi
G4MolecularConfiguration * fpMolecularConfiguration
Definition: G4Molecule.hh:268
G4double GetDiffusionCoefficient() const
Returns the diffusion coefficient D.
Definition: G4Molecule.cc:465
static G4MoleculeCounter * GetMoleculeCounter()
G4double GetNbElectrons() const
Returns the number of electron.
Definition: G4Molecule.cc:318
G4double GetNbElectrons() const
Returns the number of electron.
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:470
const G4ElectronOccupancy * GetElectronOccupancy() const
Returns the object ElectronOccupancy describing the electronic configuration of the molecule...
#define G4ThreadLocal
Definition: tls.hh:89
virtual ~G4Molecule()
Definition: G4Molecule.cc:136
int G4int
Definition: G4Types.hh:78
static G4double GetGlobalTemperature()
Definition: G4Molecule.cc:480
const G4String & GetName() const
Returns the name of the molecule.
Definition: G4Molecule.cc:303
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
void MoveOneElectron(G4int, G4int)
Move one electron from an orbit to another.
Definition: G4Molecule.cc:297
#define position
Definition: xmlparse.cc:605
#define G4UniformRand()
Definition: Randomize.hh:93
G4GLOB_DLL std::ostream G4cout
G4MolecularConfiguration * IonizeMolecule(G4int)
Method used in Geant4-DNA to ionize water molecules.
void SetElectronOccupancy(const G4ElectronOccupancy *)
Will set up the correct molecularConfiguration given an electron configuration.
Definition: G4Molecule.cc:262
G4int GetAtomsNumber() const
Returns the nomber of atoms compouning the molecule.
Definition: G4Molecule.cc:313
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
Add n electrons to a given orbit.
G4int GetFakeParticleID() const
Definition: G4Molecule.cc:405
bool G4bool
Definition: G4Types.hh:79
G4Track * fpTrack
Definition: G4IT.hh:176
ITImp(G4Molecule) G4ThreadLocal G4Allocator< G4Molecule > *aMoleculeAllocator=0
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:67
void SetVanDerVaalsRadius(G4double)
The Van Der Valls Radius of the molecule.
Definition: G4Molecule.cc:425
G4MolecularConfiguration * MoveOneElectron(G4int, G4int)
Move one electron from an orbit to another.
void SetDiffusionCoefficient(G4double)
Sets the diffusion coefficient D of the molecule used in diffusion processes to calculate the mean sq...
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *)
G4Molecule & operator=(const G4Molecule &right)
Definition: G4Molecule.cc:93
G4double GetGlobalTime() const
void IonizeMolecule(G4int)
Method used in Geant4-DNA to ionize water molecules.
Definition: G4Molecule.cc:279
const G4MoleculeDefinition * GetDefinition() const
Get molecule definition.
Definition: G4Molecule.cc:455
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4Track * BuildTrack(G4double globalTime, const G4ThreeVector &Position)
Definition: G4Molecule.cc:328
G4double GetMass() const
Returns the total mass of the molecule.
const G4String & GetFormatedName() const
Returns the formated name of the molecule.
Definition: G4Molecule.cc:308
G4int GetCharge() const
Returns the charge of molecule.
Definition: G4Molecule.cc:435
const G4String & GetFormatedName() const
Returns the formated name of the molecule.
void SetMass(G4double)
Set the total mass of the molecule.
G4double GetKineticEnergy() const
Definition: G4Molecule.cc:368
void RemoveElectron(G4int, G4int number=1)
Remove n electrons to a given orbit.
Definition: G4Molecule.cc:291
void SetDecayTime(G4double)
Set the decay time of the molecule.
void SetVanDerVaalsRadius(G4double)
The Van Der Valls Radius of the molecule.
G4int GetAtomsNumber() const
Returns the nomber of atoms compouning the molecule.
G4DLLIMPORT G4ThreadLocal G4Allocator< G4Molecule > * aMoleculeAllocator
void PrintState() const
Show the electronic state of the molecule.
Definition: G4Molecule.cc:323
const G4MoleculeDefinition * GetDefinition() const
#define G4endl
Definition: G4ios.hh:61
G4double GetDiffusionVelocity() const
Definition: G4Molecule.cc:378
Class Description The dynamic molecule holds all the data that change for a molecule It has a pointer...
Definition: G4Molecule.hh:93
G4double GetDecayTime() const
Returns the decay time of the molecule.
double G4double
Definition: G4Types.hh:76
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
const G4ElectronOccupancy * GetElectronOccupancy() const
Returns the object ElectronOccupancy describing the electronic configuration of the molecule...
Definition: G4Molecule.cc:450
void SetUserInformation(G4VUserTrackInformation *aValue)
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
Remove n electrons to a given orbit.
G4double GetVanDerVaalsRadius() const
Definition: G4Molecule.cc:430
static void SetGlobalTemperature(G4double)
Definition: G4Molecule.cc:475
virtual void RemoveAMoleculeAtTime(const G4Molecule &, G4double)
G4double GetDecayTime() const
Returns the decay time of the molecule.
Definition: G4Molecule.cc:420
G4MolecularConfiguration * ExciteMolecule(G4int)
Method used in Geant4-DNA to excite water molecules.
{ Class description:
virtual void Print() const
Definition: G4IT.hh:104
void AddElectron(G4int orbit, G4int n=1)
Add n electrons to a given orbit.
Definition: G4Molecule.cc:285
G4bool operator==(const G4Molecule &right) const
Definition: G4Molecule.cc:100
void SetDecayTime(G4double)
Set the decay time of the molecule.
Definition: G4Molecule.cc:415
G4int RemoveElectron(G4int orbit, G4int number=1)
static double fgTemperature
Definition: G4Molecule.hh:270
void ExciteMolecule(G4int)
Method used in Geant4-DNA to excite water molecules.
Definition: G4Molecule.cc:271
G4int GetMoleculeID() const
Definition: G4Molecule.cc:410