Geant4  10.03
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 100802 2016-11-02 14:55:27Z 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 "G4VMoleculeCounter.hh"
57 
58 using namespace std;
59 
61 // 37°C, used to shoot an energy
62 
64 
66 
67 //______________________________________________________________________________
68 
70 {
71  return (G4Molecule*) (GetIT(track));
72 }
73 
74 //______________________________________________________________________________
75 
77 {
78  return (G4Molecule*) (GetIT(track));
79 }
80 
81 //______________________________________________________________________________
82 
84 {
85  return (G4Molecule*) (GetIT(track));
86 }
87 
88 //______________________________________________________________________________
89 
90 void G4Molecule::Print() const
91 {
92  G4cout << "The user track information is a molecule" << G4endl;
93 }
94 
95 //______________________________________________________________________________
96 
98  G4VUserTrackInformation("G4Molecule"), G4IT(right)
99 {
101 }
102 
103 //______________________________________________________________________________
104 
106 {
107  if (&right == this) return *this;
109  return *this;
110 }
111 
112 //______________________________________________________________________________
113 
115 {
117  {
118  return true;
119  }
120  return false;
121 }
122 
123 //______________________________________________________________________________
124 
126 {
127  return !(*this == right);
128 }
129 
130 //______________________________________________________________________________
137 {
139 }
140 
141 //______________________________________________________________________________
145  G4VUserTrackInformation("G4Molecule"), G4IT()
146 
147 {
149 }
150 
151 //______________________________________________________________________________
152 
154 {
155  if (fpTrack != NULL)
156  {
157  if (G4VMoleculeCounter::Instance()->InUse())
158  {
160  RemoveAMoleculeAtTime(fpMolecularConfiguration,
162  &(fpTrack->GetPosition()));
163  }
164  fpTrack = 0;
165  }
167 }
168 
169 //______________________________________________________________________________
173 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
175  G4VUserTrackInformation("G4Molecule"), G4IT()
177 {
180  GetOrCreateMolecularConfiguration(moleculeDefinition);
181 }
182 
183 //______________________________________________________________________________
184 
185 G4Molecule::G4Molecule(G4MoleculeDefinition* moleculeDefinition, int charge)
186 {
189  GetOrCreateMolecularConfiguration(moleculeDefinition,
190  charge);
191 }
192 
193 //______________________________________________________________________________
198 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition,
200  G4int OrbitalToFree,
201  G4int OrbitalToFill) :
202  G4VUserTrackInformation("G4Molecule"), G4IT()
204 {
205  if (moleculeDefinition->GetGroundStateElectronOccupancy())
206  {
207  G4ElectronOccupancy dynElectronOccupancy(
208  *moleculeDefinition->GetGroundStateElectronOccupancy());
209 
210  if (OrbitalToFill != 0)
211  {
212  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
213  dynElectronOccupancy.AddElectron(OrbitalToFill - 1, 1);
214  // dynElectronOccupancy.DumpInfo(); // DEBUG
215  }
216 
217  if (OrbitalToFill == 0)
218  {
219  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
220  // dynElectronOccupancy.DumpInfo(); // DEBUG
221  }
222 
225  moleculeDefinition, dynElectronOccupancy);
226  }
227  else
228  {
230  G4Exception(
231  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
232  "G4int OrbitalToFree, G4int OrbitalToFill)",
233  "G4Molecule_wrong_usage_of_constructor",
235  "If you want to use this constructor, the molecule definition has to be "
236  "first defined with electron occupancies");
237  }
238 }
239 
240 //______________________________________________________________________________
247  G4int Level,
248  G4bool Excitation) :
249  G4VUserTrackInformation("G4Molecule"), G4IT()
250 {
251  if (moleculeDefinition->GetGroundStateElectronOccupancy())
252  {
253  G4ElectronOccupancy dynElectronOccupancy(
254  *moleculeDefinition->GetGroundStateElectronOccupancy());
255 
256  if (Excitation == true)
257  {
258  dynElectronOccupancy.RemoveElectron(Level, 1);
259  dynElectronOccupancy.AddElectron(5, 1);
260  // dynElectronOccupancy.DumpInfo(); // DEBUG
261  }
262 
263  if (Excitation == false)
264  {
265  dynElectronOccupancy.RemoveElectron(Level, 1);
266  // dynElectronOccupancy.DumpInfo(); // DEBUG
267  }
268 
271  moleculeDefinition, dynElectronOccupancy);
272  }
273  else
274  {
276  G4Exception(
277  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
278  "G4int OrbitalToFree, G4int OrbitalToFill)",
279  "G4Molecule_wrong_usage_of_constructor",
281  "If you want to use this constructor, the molecule definition has to be "
282  "first defined with electron occupancies");
283 
284  }
285 }
286 
287 //______________________________________________________________________________
288 
290 {
291  fpMolecularConfiguration = molConf;
292 }
293 
294 //______________________________________________________________________________
295 
297 {
301 }
302 
303 //______________________________________________________________________________
304 
308 {
310  ExcitedLevel);
311 }
312 
313 //______________________________________________________________________________
314 
318 {
320  IonizedLevel);
321 }
322 
323 //______________________________________________________________________________
324 
326 {
328  number);
329 }
330 
331 //______________________________________________________________________________
332 
334 {
336  number);
337 }
338 
339 //______________________________________________________________________________
340 
341 void G4Molecule::MoveOneElectron(G4int orbitToFree, G4int orbitToFill)
342 {
344  orbitToFree, orbitToFill);
345 }
346 
347 //______________________________________________________________________________
348 
350 {
352 }
353 
354 //______________________________________________________________________________
355 
357 {
359 }
360 
361 //______________________________________________________________________________
362 
364 {
366 }
367 
368 //______________________________________________________________________________
369 
371 {
373 }
374 
375 //______________________________________________________________________________
376 
378 {
380 }
381 
382 //______________________________________________________________________________
383 
385  const G4ThreeVector& position)
386 {
387  if (fpTrack != 0){
388  G4Exception("G4Molecule::BuildTrack", "Molecule001", FatalErrorInArgument,
389  "A track was already assigned to this molecule");
390  }
391 
392  // Kinetic Values
393  // Set a random direction to the molecule
394  G4double costheta = (2 * G4UniformRand()-1);
395  G4double theta = acos(costheta);
396  G4double phi = 2 * pi * G4UniformRand();
397 
398  G4double xMomentum = cos(phi) * sin(theta);
399  G4double yMomentum = sin(theta) * sin(phi);
400  G4double zMomentum = costheta;
401 
402  G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
403  G4double KineticEnergy = GetKineticEnergy();
404 
405  G4DynamicParticle* dynamicParticle = new G4DynamicParticle(
406  fpMolecularConfiguration->GetDefinition(), MomentumDirection,
407  KineticEnergy);
408 
411  AddAMoleculeAtTime(fpMolecularConfiguration,
412  globalTime,
413  &(fpTrack->GetPosition()));
414  }
415 
416  //Set the Track
417  fpTrack = new G4Track(dynamicParticle, globalTime, position);
419 
420  return fpTrack;
421 }
422 
423 //______________________________________________________________________________
424 
426 {
428  // Ideal Gaz case
429  double v = GetDiffusionVelocity();
430  double E = (fpMolecularConfiguration->GetMass() / (c_squared)) * (v * v) / 2.;
432  return E;
433 }
434 
435 //______________________________________________________________________________
436 
438 {
439  double moleculeMass = fpMolecularConfiguration->GetMass() / (c_squared);
440 
442  // Different possibilities
444  // Ideal Gaz case : Maxwell Boltzmann Distribution
445  // double sigma = k_Boltzmann * fgTemperature / mass;
446  // return G4RandGauss::shoot( 0, sigma );
448  // Ideal Gaz case : mean velocity from equipartition theorem
449  return sqrt(3 * k_Boltzmann *
452  // Using this approximation for liquid is wrong
453  // However the brownian process avoid taking
454  // care of energy consideration and plays only
455  // with positions
456 }
457 
458 //______________________________________________________________________________
459 
460 // added - to be transformed in a "Decay method"
461 const vector<const G4MolecularDissociationChannel*>*
463 {
465 }
466 
467 //______________________________________________________________________________
468 
470 {
472 }
473 
474 //______________________________________________________________________________
475 
477 {
479 }
480 
481 //______________________________________________________________________________
482 
484 {
485  fpMolecularConfiguration->SetDecayTime(dynDecayTime);
486 }
487 
488 //______________________________________________________________________________
489 
491 {
493 }
494 
495 //______________________________________________________________________________
496 
497 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
498 {
499  fpMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
500 }
501 
502 //______________________________________________________________________________
503 
505 {
507 }
508 
509 //______________________________________________________________________________
510 
512 {
514 }
515 
516 //______________________________________________________________________________
517 
519 {
521 }
522 
523 //______________________________________________________________________________
524 
526 {
528 }
529 
530 //______________________________________________________________________________
531 
533 {
535 }
536 
537 //______________________________________________________________________________
538 
540 {
542 }
543 
544 //______________________________________________________________________________
545 
546 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
547 {
548  fpMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
549 }
550 
551 //______________________________________________________________________________
552 
554 {
556 }
557 
558 //______________________________________________________________________________
559 
561  double temperature) const
562 {
564  temperature);
565 }
566 
567 //______________________________________________________________________________
568 
570 {
572 }
573 
574 //______________________________________________________________________________
575 
576 //void G4Molecule::SetGlobalTemperature(G4double temperature)
577 //{
578 // fgTemperature = temperature;
579 //}
580 //
582 //
583 //G4double G4Molecule::GetGlobalTemperature()
584 //{
585 // return fgTemperature;
586 //}
587 
588 //______________________________________________________________________________
589 
591 {
593 }
594 
595 //______________________________________________________________________________
596 
597 void G4Molecule::SetLabel(const G4String& label)
598 {
600 }
601 
602 //______________________________________________________________________________
603 
605 {
606  // TODO check fpMolecularConfiguration already exists
607  // and new one as well
608  // TODO notify for stack change
612 
613  assert(fpMolecularConfiguration!=0);
614 }
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:546
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:462
G4bool operator!=(const G4Molecule &right) const
Definition: G4Molecule.cc:125
CLHEP::Hep3Vector G4ThreeVector
G4Molecule()
Default molecule builder.
Definition: G4Molecule.cc:144
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:136
static G4Molecule * GetMolecule(const G4Track *)
Definition: G4Molecule.cc:83
G4double GetMass() const
Returns the total mass of the molecule.
Definition: G4Molecule.cc:525
void SetMass(G4double)
Set the total mass of the molecule.
Definition: G4Molecule.cc:518
const G4ThreeVector & GetPosition() const
void SetLabel(const G4String &label)
Definition: G4Molecule.cc:597
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
G4MolecularConfiguration * fpMolecularConfiguration
Definition: G4Molecule.hh:290
G4double GetDiffusionCoefficient() const
Returns the diffusion coefficient D.
Definition: G4Molecule.cc:553
G4double GetNbElectrons() const
Returns the number of electron.
Definition: G4Molecule.cc:370
G4double GetNbElectrons() const
Returns the number of electron.
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:569
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:153
int G4int
Definition: G4Types.hh:78
void ChangeConfigurationToLabel(const G4String &label)
Definition: G4Molecule.cc:604
const G4String & GetName() const
Returns the name of the molecule.
Definition: G4Molecule.cc:349
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
void MoveOneElectron(G4int, G4int)
Move one electron from an orbit to another.
Definition: G4Molecule.cc:341
const G4String & GetLabel() const
Returns the label of the molecule configuration.
Definition: G4Molecule.cc:590
#define position
Definition: xmlparse.cc:622
#define G4UniformRand()
Definition: Randomize.hh:97
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:296
G4int GetAtomsNumber() const
Returns the nomber of atoms compouning the molecule.
Definition: G4Molecule.cc:363
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
Add n electrons to a given orbit.
G4int GetFakeParticleID() const
Definition: G4Molecule.cc:469
bool G4bool
Definition: G4Types.hh:79
G4Track * fpTrack
Definition: G4IT.hh:164
ITImp(G4Molecule) G4ThreadLocal G4Allocator< G4Molecule > *aMoleculeAllocator=0
G4ThreadLocal/G4double G4Molecule::fgTemperature = 310; // 310*kelvin;
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:69
void SetVanDerVaalsRadius(G4double)
The Van Der Valls Radius of the molecule.
Definition: G4Molecule.cc:497
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...
G4Molecule & operator=(const G4Molecule &right)
Definition: G4Molecule.cc:105
G4double GetGlobalTime() const
static G4VMoleculeCounter * Instance()
void IonizeMolecule(G4int)
Method used in Geant4-DNA to ionize water molecules.
Definition: G4Molecule.cc:317
static G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *)
const G4MoleculeDefinition * GetDefinition() const
Get molecule definition.
Definition: G4Molecule.cc:539
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetUserInformation(G4VUserTrackInformation *aValue) const
G4Track * BuildTrack(G4double globalTime, const G4ThreeVector &Position)
Definition: G4Molecule.cc:384
G4double GetMass() const
Returns the total mass of the molecule.
const G4String & GetFormatedName() const
Returns the formated name of the molecule.
Definition: G4Molecule.cc:356
G4int GetCharge() const
Returns the charge of molecule.
Definition: G4Molecule.cc:511
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:425
void RemoveElectron(G4int, G4int number=1)
Remove n electrons to a given orbit.
Definition: G4Molecule.cc:333
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:377
const G4MoleculeDefinition * GetDefinition() const
const G4String & GetLabel() const
#define G4endl
Definition: G4ios.hh:61
static constexpr double pi
Definition: G4SIunits.hh:75
G4double GetDiffusionVelocity() const
Definition: G4Molecule.cc:437
Class Description The dynamic molecule holds all the data that change for a molecule It has a pointer...
Definition: G4Molecule.hh:94
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:532
static G4bool InUse()
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
Remove n electrons to a given orbit.
G4double GetVanDerVaalsRadius() const
Definition: G4Molecule.cc:504
G4double GetDecayTime() const
Returns the decay time of the molecule.
Definition: G4Molecule.cc:490
G4MolecularConfiguration * ExciteMolecule(G4int)
Method used in Geant4-DNA to excite water molecules.
{ Class description:
virtual void Print() const
Definition: G4IT.hh:94
void AddElectron(G4int orbit, G4int n=1)
Add n electrons to a given orbit.
Definition: G4Molecule.cc:325
G4bool operator==(const G4Molecule &right) const
Definition: G4Molecule.cc:114
void SetDecayTime(G4double)
Set the decay time of the molecule.
Definition: G4Molecule.cc:483
G4int RemoveElectron(G4int orbit, G4int number=1)
void ExciteMolecule(G4int)
Method used in Geant4-DNA to excite water molecules.
Definition: G4Molecule.cc:307
G4int GetMoleculeID() const
Definition: G4Molecule.cc:476