Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 64057 2012-10-30 15:04:49Z 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 double G4Molecule::fgTemperature = 310*kelvin;
61 // 37°C, used to shoot an energy
62 
64 
65 G4Allocator<G4Molecule> aMoleculeAllocator;
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  Init();
86  fMolecularConfiguration = right . fMolecularConfiguration;
87 }
88 
90 {
91  if (&right==this) return *this;
92  Init();
93  fMolecularConfiguration = right . fMolecularConfiguration;
94  return *this;
95 }
96 
98 {
99  if(fMolecularConfiguration==right.fMolecularConfiguration)
100  {
101  return true;
102  }
103  return false;
104 }
105 
107 {
108  return !(*this == right);
109 }
110 
115 
117 {
118  return fMolecularConfiguration < right.fMolecularConfiguration ;
119 }
121 void G4Molecule::Init()
122 {
123  fMolecularConfiguration = 0 ;
124  fDynamicParticle = 0;
125 }
126 
128 
133 {
134  Init();
135 }
136 
140 {
141  if(fpTrack!=NULL)
142  {
144  {
147  }
148  fpTrack = 0;
149  }
150  fMolecularConfiguration = 0;
151  fDynamicParticle = 0;
152  // DEBUG
153  // G4cout<<"Molecule killed"<<G4endl;
154 }
155 
159 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
161  G4VUserTrackInformation("G4Molecule"), G4IT()
163 {
164  Init();
165  fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition);
166 }
167 
172 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, G4int OrbitalToFree, G4int OrbitalToFill):
174  G4VUserTrackInformation("G4Molecule"), G4IT()
176 {
177  Init();
178 
179  G4ElectronOccupancy dynElectronOccupancy (*moleculeDefinition->GetGroundStateElectronOccupancy());
180 
181  if (OrbitalToFill != 0)
182  {
183  dynElectronOccupancy.RemoveElectron(OrbitalToFree-1,1);
184  dynElectronOccupancy.AddElectron(OrbitalToFill-1,1);
185  // dynElectronOccupancy.DumpInfo(); // DEBUG
186  }
187 
188  if (OrbitalToFill == 0)
189  {
190  dynElectronOccupancy.RemoveElectron(OrbitalToFree-1,1);
191  // dynElectronOccupancy.DumpInfo(); // DEBUG
192  }
193 
194  fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition, dynElectronOccupancy);
195 }
196 
202 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, G4int Level, G4bool Excitation):
203  G4VUserTrackInformation("G4Molecule"), G4IT()
204 {
205  Init();
206 
207  G4ElectronOccupancy dynElectronOccupancy (*moleculeDefinition->GetGroundStateElectronOccupancy());
208 
209  if (Excitation == true)
210  {
211  dynElectronOccupancy.RemoveElectron(Level,1);
212  dynElectronOccupancy.AddElectron(5,1);
213  // dynElectronOccupancy.DumpInfo(); // DEBUG
214  }
215 
216  if (Excitation == false)
217  {
218  dynElectronOccupancy.RemoveElectron(Level,1);
219  // dynElectronOccupancy.DumpInfo(); // DEBUG
220  }
221 
222  fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition, dynElectronOccupancy);
223 }
224 
226 {
227  fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(fMolecularConfiguration->GetDefinition(), *occ);
228 }
229 
233 {
234  fMolecularConfiguration = fMolecularConfiguration->ExciteMolecule(ExcitedLevel);
235 }
236 
240 {
241  fMolecularConfiguration = fMolecularConfiguration->IonizeMolecule(IonizedLevel);
242 }
243 
245 {
246  fMolecularConfiguration = fMolecularConfiguration->AddElectron(orbit,number);
247 }
248 
250 {
251  fMolecularConfiguration = fMolecularConfiguration->RemoveElectron(orbit,number);
252 }
253 
254 void G4Molecule::MoveOneElectron(G4int orbitToFree,G4int orbitToFill)
255 {
256  fMolecularConfiguration = fMolecularConfiguration->MoveOneElectron(orbitToFree,orbitToFill);
257 }
258 
260 {
261  return fMolecularConfiguration->GetName();
262 }
263 
265 {
266  return fMolecularConfiguration->GetAtomsNumber();
267 }
268 
270 {
271  return fMolecularConfiguration->GetNbElectrons();
272 }
273 
275 {
276  fMolecularConfiguration->PrintState();
277 }
278 
279 G4Track * G4Molecule::BuildTrack(G4double globalTime, const G4ThreeVector& Position)
280 {
281  if(fpTrack != 0)
282  {
283  G4Exception("G4Molecule::BuildTrack","Molecule001",
284  FatalErrorInArgument,"A track was already assigned to this molecule");
285  }
286 
287  // Kinetic Values
288  // Set a random direction to the molecule
289  G4double costheta = (2*G4UniformRand()-1);
290  G4double theta = acos (costheta);
291  G4double phi = 2*pi*G4UniformRand();
292 
293  G4double xMomentum = cos(phi)* sin(theta);
294  G4double yMomentum = sin(theta)*sin(phi);
295  G4double zMomentum = costheta;
296 
297  G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
298  G4double KineticEnergy = GetKineticEnergy();
299  // G4cout << " **** KineticEnergy : " << KineticEnergy << G4endl;
300  fDynamicParticle = new G4DynamicParticle(fMolecularConfiguration->GetDefinition(),
301  MomentumDirection,
302  KineticEnergy);
303 
306 
307  //Set the Track
308  fpTrack = new G4Track(fDynamicParticle, globalTime, Position);
309  fpTrack -> SetUserInformation (this);
310 
311  return fpTrack;
312 }
313 
315 {
317  // Ideal Gaz case
318  double v = GetDiffusionVelocity();
319  double E = (fMolecularConfiguration->GetMass()/(c_squared))*(v*v)/2.;
321  return E;
322 }
323 
325 {
326  double moleculeMass = fMolecularConfiguration->GetMass()/(c_squared);
327 
329  // Different possibilities
331  // Ideal Gaz case : Maxwell Boltzmann Distribution
332  // double sigma = k_Boltzmann * fgTemperature / mass;
333  // return G4RandGauss::shoot( 0, sigma );
335  // Ideal Gaz case : mean velocity from equipartition theorem
336  return sqrt(3*k_Boltzmann*fgTemperature/moleculeMass);
338  // Using this approximation for liquid is wrong
339  // However the brownian process avoid taking
340  // care of energy consideration and plays only
341  // with positions
342 }
343 
344 // added - to be transformed in a "Decay method"
345 const vector <const G4MolecularDecayChannel*>* G4Molecule::GetDecayChannel() const
346 {
347  return fMolecularConfiguration->GetDecayChannel();
348 }
349 
351 {
352  return fMolecularConfiguration->GetMoleculeID();
353 }
354 
356 {
357  fMolecularConfiguration->SetDecayTime(dynDecayTime);
358 }
359 
361 {
362  return fMolecularConfiguration->GetDecayTime();
363 }
364 
365 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
366 {
367  fMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
368 }
369 
371 {
372  return fMolecularConfiguration->GetVanDerVaalsRadius();
373 }
374 
376 {
377  return fMolecularConfiguration->GetCharge() ;
378 }
379 
381 {
382  fMolecularConfiguration->SetMass(aMass);
383 }
384 
386 {
387  return fMolecularConfiguration->GetMass();
388 }
389 
391 {
392  return fMolecularConfiguration->GetElectronOccupancy();
393 }
394 
396 {
397  return fMolecularConfiguration->GetDefinition();
398 }
399 
400 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
401 {
402  fMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
403 }
404 
406 {
407  return fMolecularConfiguration->GetDiffusionCoefficient();
408 }