Geant4  10.00.p02
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 74551 2013-10-14 12:59:14Z 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 
77 void G4Molecule::Print() const
78 {
79  G4cout<<"The user track information is a molecule"<<G4endl;
80 }
81 
83  G4VUserTrackInformation("G4Molecule"), G4IT(right)
84 {
86 }
87 
89 {
90  if (&right==this) return *this;
92  return *this;
93 }
94 
96 {
98  {
99  return true;
100  }
101  return false;
102 }
103 
105 {
106  return !(*this == right);
107 }
108 
113 
115 {
117 }
118 
120 
125 {
127 }
128 
132 {
133  if(fpTrack!=NULL)
134  {
136  {
139  }
140  fpTrack = 0;
141  }
143 }
144 
148 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
150  G4VUserTrackInformation("G4Molecule"), G4IT()
152 {
154 }
155 
160 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, G4int OrbitalToFree, G4int OrbitalToFill):
162  G4VUserTrackInformation("G4Molecule"), G4IT()
164 {
165  G4ElectronOccupancy dynElectronOccupancy (*moleculeDefinition->GetGroundStateElectronOccupancy());
166 
167  if (OrbitalToFill != 0)
168  {
169  dynElectronOccupancy.RemoveElectron(OrbitalToFree-1,1);
170  dynElectronOccupancy.AddElectron(OrbitalToFill-1,1);
171  // dynElectronOccupancy.DumpInfo(); // DEBUG
172  }
173 
174  if (OrbitalToFill == 0)
175  {
176  dynElectronOccupancy.RemoveElectron(OrbitalToFree-1,1);
177  // dynElectronOccupancy.DumpInfo(); // DEBUG
178  }
179 
180  fpMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition, dynElectronOccupancy);
181 }
182 
188 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, G4int Level, G4bool Excitation):
189  G4VUserTrackInformation("G4Molecule"), G4IT()
190 {
191  G4ElectronOccupancy dynElectronOccupancy (*moleculeDefinition->GetGroundStateElectronOccupancy());
192 
193  if (Excitation == true)
194  {
195  dynElectronOccupancy.RemoveElectron(Level,1);
196  dynElectronOccupancy.AddElectron(5,1);
197  // dynElectronOccupancy.DumpInfo(); // DEBUG
198  }
199 
200  if (Excitation == false)
201  {
202  dynElectronOccupancy.RemoveElectron(Level,1);
203  // dynElectronOccupancy.DumpInfo(); // DEBUG
204  }
205 
206  fpMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition, dynElectronOccupancy);
207 }
208 
210 {
212 }
213 
217 {
219 }
220 
224 {
226 }
227 
229 {
231 }
232 
234 {
236 }
237 
238 void G4Molecule::MoveOneElectron(G4int orbitToFree,G4int orbitToFill)
239 {
241 }
242 
244 {
246 }
247 
249 {
251 }
252 
254 {
256 }
257 
259 {
261 }
262 
263 G4Track * G4Molecule::BuildTrack(G4double globalTime, const G4ThreeVector& Position)
264 {
265  if(fpTrack != 0)
266  {
267  G4Exception("G4Molecule::BuildTrack","Molecule001",
268  FatalErrorInArgument,"A track was already assigned to this molecule");
269  }
270 
271  // Kinetic Values
272  // Set a random direction to the molecule
273  G4double costheta = (2*G4UniformRand()-1);
274  G4double theta = acos (costheta);
275  G4double phi = 2*pi*G4UniformRand();
276 
277  G4double xMomentum = cos(phi)* sin(theta);
278  G4double yMomentum = sin(theta)*sin(phi);
279  G4double zMomentum = costheta;
280 
281  G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
282  G4double KineticEnergy = GetKineticEnergy();
283 
285  MomentumDirection,
286  KineticEnergy);
287 
290 
291  //Set the Track
292  fpTrack = new G4Track(dynamicParticle, globalTime, Position);
293  fpTrack -> SetUserInformation (this);
294 
295  return fpTrack;
296 }
297 
299 {
301  // Ideal Gaz case
302  double v = GetDiffusionVelocity();
303  double E = (fpMolecularConfiguration->GetMass()/(c_squared))*(v*v)/2.;
305  return E;
306 }
307 
309 {
310  double moleculeMass = fpMolecularConfiguration->GetMass()/(c_squared);
311 
313  // Different possibilities
315  // Ideal Gaz case : Maxwell Boltzmann Distribution
316  // double sigma = k_Boltzmann * fgTemperature / mass;
317  // return G4RandGauss::shoot( 0, sigma );
319  // Ideal Gaz case : mean velocity from equipartition theorem
320  return sqrt(3*k_Boltzmann*fgTemperature/moleculeMass);
322  // Using this approximation for liquid is wrong
323  // However the brownian process avoid taking
324  // care of energy consideration and plays only
325  // with positions
326 }
327 
328 // added - to be transformed in a "Decay method"
329 const vector <const G4MolecularDecayChannel*>* G4Molecule::GetDecayChannel() const
330 {
332 }
333 
335 {
337 }
338 
340 {
341  fpMolecularConfiguration->SetDecayTime(dynDecayTime);
342 }
343 
345 {
347 }
348 
349 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
350 {
351  fpMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
352 }
353 
355 {
357 }
358 
360 {
362 }
363 
365 {
367 }
368 
370 {
372 }
373 
375 {
377 }
378 
380 {
382 }
383 
384 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
385 {
386  fpMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
387 }
388 
390 {
392 }
393 
395 {
396  return fpMolecularConfiguration ;
397 }
398 
400 {
401  fgTemperature = temperature;
402 }
403 
405 {
406  return fgTemperature;
407 }
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.
G4IT is a interface which allows the inheriting object :
Definition: G4IT.hh:82
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:384
G4bool operator!=(const G4Molecule &right) const
Definition: G4Molecule.cc:104
CLHEP::Hep3Vector G4ThreeVector
G4Molecule()
Default molecule builder.
Definition: G4Molecule.cc:123
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:114
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &electronOccupancy)
G4double GetMass() const
Returns the total mass of the molecule.
Definition: G4Molecule.cc:369
void SetMass(G4double)
Set the total mass of the molecule.
Definition: G4Molecule.cc:364
const G4double pi
G4MolecularConfiguration * fpMolecularConfiguration
Definition: G4Molecule.hh:239
G4double GetDiffusionCoefficient() const
Returns the diffusion coefficient D.
Definition: G4Molecule.cc:389
static G4MoleculeCounter * GetMoleculeCounter()
G4double GetNbElectrons() const
Returns the number of electron.
Definition: G4Molecule.cc:253
G4double GetNbElectrons() const
Returns the number of electron.
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:329
G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:394
const G4ElectronOccupancy * GetElectronOccupancy() const
Returns the object ElectronOccupancy describing the electronic configuration of the molecule...
#define G4ThreadLocal
Definition: tls.hh:52
virtual ~G4Molecule()
Definition: G4Molecule.cc:130
int G4int
Definition: G4Types.hh:78
static G4double GetGlobalTemperature()
Definition: G4Molecule.cc:404
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannel() const
const G4String & GetName() const
Returns the name of the molecule.
Definition: G4Molecule.cc:243
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:48
void MoveOneElectron(G4int, G4int)
Move one electron from an orbit to another.
Definition: G4Molecule.cc:238
#define G4UniformRand()
Definition: Randomize.hh:87
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:209
G4int GetAtomsNumber() const
Returns the nomber of atoms compouning the molecule.
Definition: G4Molecule.cc:248
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
Add n electrons to a given orbit.
bool G4bool
Definition: G4Types.hh:79
G4Track * fpTrack
Definition: G4IT.hh:144
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:349
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:88
G4double GetGlobalTime() const
void IonizeMolecule(G4int)
Method used in Geant4-DNA to ionize water molecules.
Definition: G4Molecule.cc:223
const G4MoleculeDefinition * GetDefinition() const
Get molecule definition.
Definition: G4Molecule.cc:379
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:263
G4double GetMass() const
Returns the total mass of the molecule.
G4int GetCharge() const
Returns the charge of molecule.
Definition: G4Molecule.cc:359
void SetMass(G4double)
Set the total mass of the molecule.
G4double GetKineticEnergy() const
Definition: G4Molecule.cc:298
void RemoveElectron(G4int, G4int number=1)
Remove n electrons to a given orbit.
Definition: G4Molecule.cc:233
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:258
const G4MoleculeDefinition * GetDefinition() const
#define G4endl
Definition: G4ios.hh:61
G4double GetDiffusionVelocity() const
Definition: G4Molecule.cc:308
Class Description The dynamic molecule holds all the data that change for a molecule It has a pointer...
Definition: G4Molecule.hh:76
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:374
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
Remove n electrons to a given orbit.
G4double GetVanDerVaalsRadius() const
Definition: G4Molecule.cc:354
static void SetGlobalTemperature(G4double)
Definition: G4Molecule.cc:399
virtual void RemoveAMoleculeAtTime(const G4Molecule &, G4double)
G4double GetDecayTime() const
Returns the decay time of the molecule.
Definition: G4Molecule.cc:344
G4MolecularConfiguration * ExciteMolecule(G4int)
Method used in Geant4-DNA to excite water molecules.
virtual void Print() const
Definition: G4IT.hh:92
void AddElectron(G4int orbit, G4int n=1)
Add n electrons to a given orbit.
Definition: G4Molecule.cc:228
G4bool operator==(const G4Molecule &right) const
Definition: G4Molecule.cc:95
void SetDecayTime(G4double)
Set the decay time of the molecule.
Definition: G4Molecule.cc:339
G4int RemoveElectron(G4int orbit, G4int number=1)
static double fgTemperature
Definition: G4Molecule.hh:241
void ExciteMolecule(G4int)
Method used in Geant4-DNA to excite water molecules.
Definition: G4Molecule.cc:216
G4int GetMoleculeID() const
Definition: G4Molecule.cc:334