Geant4_10
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 {
85  fpMolecularConfiguration = right . fpMolecularConfiguration;
86 }
87 
89 {
90  if (&right==this) return *this;
91  fpMolecularConfiguration = right . fpMolecularConfiguration;
92  return *this;
93 }
94 
96 {
97  if(fpMolecularConfiguration==right.fpMolecularConfiguration)
98  {
99  return true;
100  }
101  return false;
102 }
103 
105 {
106  return !(*this == right);
107 }
108 
113 
115 {
116  return fpMolecularConfiguration < right.fpMolecularConfiguration ;
117 }
118 
120 
122 G4Molecule::G4Molecule() : G4VUserTrackInformation("G4Molecule"), G4IT()
125 {
126  fpMolecularConfiguration = 0 ;
127 }
128 
132 {
133  if(fpTrack!=NULL)
134  {
136  {
139  }
140  fpTrack = 0;
141  }
142  fpMolecularConfiguration = 0;
143 }
144 
148 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
150  G4VUserTrackInformation("G4Molecule"), G4IT()
152 {
153  fpMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition);
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 {
211  fpMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(fpMolecularConfiguration->GetDefinition(), *occ);
212 }
213 
217 {
218  fpMolecularConfiguration = fpMolecularConfiguration->ExciteMolecule(ExcitedLevel);
219 }
220 
224 {
225  fpMolecularConfiguration = fpMolecularConfiguration->IonizeMolecule(IonizedLevel);
226 }
227 
229 {
230  fpMolecularConfiguration = fpMolecularConfiguration->AddElectron(orbit,number);
231 }
232 
234 {
235  fpMolecularConfiguration = fpMolecularConfiguration->RemoveElectron(orbit,number);
236 }
237 
238 void G4Molecule::MoveOneElectron(G4int orbitToFree,G4int orbitToFill)
239 {
240  fpMolecularConfiguration = fpMolecularConfiguration->MoveOneElectron(orbitToFree,orbitToFill);
241 }
242 
244 {
245  return fpMolecularConfiguration->GetName();
246 }
247 
249 {
250  return fpMolecularConfiguration->GetAtomsNumber();
251 }
252 
254 {
255  return fpMolecularConfiguration->GetNbElectrons();
256 }
257 
259 {
260  fpMolecularConfiguration->PrintState();
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 
284  G4DynamicParticle* dynamicParticle = new G4DynamicParticle(fpMolecularConfiguration->GetDefinition(),
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 {
331  return fpMolecularConfiguration->GetDecayChannel();
332 }
333 
335 {
336  return fpMolecularConfiguration->GetMoleculeID();
337 }
338 
340 {
341  fpMolecularConfiguration->SetDecayTime(dynDecayTime);
342 }
343 
345 {
346  return fpMolecularConfiguration->GetDecayTime();
347 }
348 
349 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
350 {
351  fpMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
352 }
353 
355 {
356  return fpMolecularConfiguration->GetVanDerVaalsRadius();
357 }
358 
360 {
361  return fpMolecularConfiguration->GetCharge() ;
362 }
363 
365 {
366  fpMolecularConfiguration->SetMass(aMass);
367 }
368 
370 {
371  return fpMolecularConfiguration->GetMass();
372 }
373 
375 {
376  return fpMolecularConfiguration->GetElectronOccupancy();
377 }
378 
380 {
381  return fpMolecularConfiguration->GetDefinition();
382 }
383 
384 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
385 {
386  fpMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
387 }
388 
390 {
391  return fpMolecularConfiguration->GetDiffusionCoefficient();
392 }
393 
395 {
396  return fpMolecularConfiguration ;
397 }
398 
400 {
401  fgTemperature = temperature;
402 }
403 
405 {
406  return fgTemperature;
407 }
Definition: G4IT.hh:82
const G4String & GetName() const
void SetDiffusionCoefficient(G4double)
Definition: G4Molecule.cc:384
G4bool operator!=(const G4Molecule &right) const
Definition: G4Molecule.cc:104
virtual void AddAMoleculeAtTime(const G4Molecule &, G4double)
G4bool operator<(const G4Molecule &right) const
Definition: G4Molecule.cc:114
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &electronOccupancy)
G4double GetMass() const
Definition: G4Molecule.cc:369
void SetMass(G4double)
Definition: G4Molecule.cc:364
G4double GetDiffusionCoefficient() const
Definition: G4Molecule.cc:389
static G4MoleculeCounter * GetMoleculeCounter()
G4double GetNbElectrons() const
Definition: G4Molecule.cc:253
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:329
G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:394
const G4ElectronOccupancy * GetElectronOccupancy() const
#define G4ThreadLocal
Definition: tls.hh:52
const G4ThreeVector const G4double const
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
G4Molecule(const G4Molecule &)
Definition: G4Molecule.cc:82
const G4String & GetName() const
Definition: G4Molecule.cc:243
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:48
void MoveOneElectron(G4int, G4int)
Definition: G4Molecule.cc:238
#define G4UniformRand()
Definition: Randomize.hh:87
G4GLOB_DLL std::ostream G4cout
float k_Boltzmann
Definition: hepunit.py:299
G4MolecularConfiguration * IonizeMolecule(G4int)
void SetElectronOccupancy(const G4ElectronOccupancy *)
Definition: G4Molecule.cc:209
G4int GetAtomsNumber() const
Definition: G4Molecule.cc:248
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
bool G4bool
Definition: G4Types.hh:79
G4Track * fpTrack
Definition: G4IT.hh:144
void SetVanDerVaalsRadius(G4double)
Definition: G4Molecule.cc:349
G4MolecularConfiguration * MoveOneElectron(G4int, G4int)
G4Molecule & operator=(const G4Molecule &right)
Definition: G4Molecule.cc:88
G4double GetGlobalTime() const
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:67
void IonizeMolecule(G4int)
Definition: G4Molecule.cc:223
tuple v
Definition: test.py:18
const G4MoleculeDefinition * GetDefinition() const
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
G4int GetCharge() const
Definition: G4Molecule.cc:359
G4double GetKineticEnergy() const
Definition: G4Molecule.cc:298
void RemoveElectron(G4int, G4int number=1)
Definition: G4Molecule.cc:233
G4DLLIMPORT G4ThreadLocal G4Allocator< G4Molecule > * aMoleculeAllocator
Definition: G4Molecule.cc:65
void PrintState() const
Definition: G4Molecule.cc:258
const G4MoleculeDefinition * GetDefinition() const
#define G4endl
Definition: G4ios.hh:61
G4double GetDiffusionVelocity() const
Definition: G4Molecule.cc:308
void Print() const
Definition: G4Molecule.cc:77
double G4double
Definition: G4Types.hh:76
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
const G4ElectronOccupancy * GetElectronOccupancy() const
Definition: G4Molecule.cc:374
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
G4double GetVanDerVaalsRadius() const
Definition: G4Molecule.cc:354
static void SetGlobalTemperature(G4double)
Definition: G4Molecule.cc:399
virtual void RemoveAMoleculeAtTime(const G4Molecule &, G4double)
G4double GetDecayTime() const
Definition: G4Molecule.cc:344
G4MolecularConfiguration * ExciteMolecule(G4int)
void AddElectron(G4int orbit, G4int n=1)
Definition: G4Molecule.cc:228
#define ITImp(T)
Definition: G4ITType.hh:127
G4bool operator==(const G4Molecule &right) const
Definition: G4Molecule.cc:95
void SetDecayTime(G4double)
Definition: G4Molecule.cc:339
G4int RemoveElectron(G4int orbit, G4int number=1)
void ExciteMolecule(G4int)
Definition: G4Molecule.cc:216
G4int GetMoleculeID() const
Definition: G4Molecule.cc:334