Geant4  10.02.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 93883 2015-11-03 08:25:04Z 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 
61 // 37°C, used to shoot an energy
62 
64 
66 
67 //______________________________________________________________________________
68 
69 G4Molecule* GetMolecule(const G4Track& track)
70 {
71  return (G4Molecule*) (GetIT(track));
72 }
73 
74 //______________________________________________________________________________
75 
76 G4Molecule* GetMolecule(const G4Track* track)
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  {
158  {
160  fpMolecularConfiguration, fpTrack->GetGlobalTime());
161  }
162  fpTrack = 0;
163  }
165 }
166 
167 //______________________________________________________________________________
171 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
173  G4VUserTrackInformation("G4Molecule"), G4IT()
175 {
178 }
179 
180 //______________________________________________________________________________
181 
182 G4Molecule::G4Molecule(G4MoleculeDefinition* moleculeDefinition, int charge)
183 {
186  charge);
187 }
188 
189 //______________________________________________________________________________
194 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition,
196  G4int OrbitalToFree,
197  G4int OrbitalToFill) :
198  G4VUserTrackInformation("G4Molecule"), G4IT()
200 {
201  if (moleculeDefinition->GetGroundStateElectronOccupancy())
202  {
203  G4ElectronOccupancy dynElectronOccupancy(
204  *moleculeDefinition->GetGroundStateElectronOccupancy());
205 
206  if (OrbitalToFill != 0)
207  {
208  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
209  dynElectronOccupancy.AddElectron(OrbitalToFill - 1, 1);
210  // dynElectronOccupancy.DumpInfo(); // DEBUG
211  }
212 
213  if (OrbitalToFill == 0)
214  {
215  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
216  // dynElectronOccupancy.DumpInfo(); // DEBUG
217  }
218 
221  moleculeDefinition, dynElectronOccupancy);
222  }
223  else
224  {
226  G4Exception(
227  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
228  "G4int OrbitalToFree, G4int OrbitalToFill)",
229  "G4Molecule_wrong_usage_of_constructor",
231  "If you want to use this constructor, the molecule definition has to be "
232  "first defined with electron occupancies");
233  }
234 }
235 
236 //______________________________________________________________________________
243  G4int Level,
244  G4bool Excitation) :
245  G4VUserTrackInformation("G4Molecule"), G4IT()
246 {
247  if (moleculeDefinition->GetGroundStateElectronOccupancy())
248  {
249  G4ElectronOccupancy dynElectronOccupancy(
250  *moleculeDefinition->GetGroundStateElectronOccupancy());
251 
252  if (Excitation == true)
253  {
254  dynElectronOccupancy.RemoveElectron(Level, 1);
255  dynElectronOccupancy.AddElectron(5, 1);
256  // dynElectronOccupancy.DumpInfo(); // DEBUG
257  }
258 
259  if (Excitation == false)
260  {
261  dynElectronOccupancy.RemoveElectron(Level, 1);
262  // dynElectronOccupancy.DumpInfo(); // DEBUG
263  }
264 
267  moleculeDefinition, dynElectronOccupancy);
268  }
269  else
270  {
272  G4Exception(
273  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
274  "G4int OrbitalToFree, G4int OrbitalToFill)",
275  "G4Molecule_wrong_usage_of_constructor",
277  "If you want to use this constructor, the molecule definition has to be "
278  "first defined with electron occupancies");
279 
280  }
281 }
282 
283 //______________________________________________________________________________
284 
286 {
287  fpMolecularConfiguration = molConf;
288 }
289 
290 //______________________________________________________________________________
291 
293 {
297 }
298 
299 //______________________________________________________________________________
300 
304 {
306  ExcitedLevel);
307 }
308 
309 //______________________________________________________________________________
310 
314 {
316  IonizedLevel);
317 }
318 
319 //______________________________________________________________________________
320 
322 {
324  number);
325 }
326 
327 //______________________________________________________________________________
328 
330 {
332  number);
333 }
334 
335 //______________________________________________________________________________
336 
337 void G4Molecule::MoveOneElectron(G4int orbitToFree, G4int orbitToFill)
338 {
340  orbitToFree, orbitToFill);
341 }
342 
343 //______________________________________________________________________________
344 
346 {
348 }
349 
350 //______________________________________________________________________________
351 
353 {
355 }
356 
357 //______________________________________________________________________________
358 
360 {
362 }
363 
364 //______________________________________________________________________________
365 
367 {
369 }
370 
371 //______________________________________________________________________________
372 
374 {
376 }
377 
378 //______________________________________________________________________________
379 
380 G4Track * G4Molecule::BuildTrack(G4double globalTime,
381  const G4ThreeVector& position)
382 {
383  if (fpTrack != 0)
384  {
385  G4Exception("G4Molecule::BuildTrack", "Molecule001", FatalErrorInArgument,
386  "A track was already assigned to this molecule");
387  }
388 
389  // Kinetic Values
390  // Set a random direction to the molecule
391  G4double costheta = (2 * G4UniformRand()-1);
392  G4double theta = acos(costheta);
393  G4double phi = 2 * pi * G4UniformRand();
394 
395  G4double xMomentum = cos(phi) * sin(theta);
396  G4double yMomentum = sin(theta) * sin(phi);
397  G4double zMomentum = costheta;
398 
399  G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
400  G4double KineticEnergy = GetKineticEnergy();
401 
402  G4DynamicParticle* dynamicParticle = new G4DynamicParticle(
403  fpMolecularConfiguration->GetDefinition(), MomentumDirection,
404  KineticEnergy);
405 
407  {
409  globalTime);
410  }
411 
412  //Set the Track
413  fpTrack = new G4Track(dynamicParticle, globalTime, position);
414  fpTrack->SetUserInformation(this);
415 
416  return fpTrack;
417 }
418 
419 //______________________________________________________________________________
420 
422 {
424  // Ideal Gaz case
425  double v = GetDiffusionVelocity();
426  double E = (fpMolecularConfiguration->GetMass() / (c_squared)) * (v * v) / 2.;
428  return E;
429 }
430 
431 //______________________________________________________________________________
432 
434 {
435  double moleculeMass = fpMolecularConfiguration->GetMass() / (c_squared);
436 
438  // Different possibilities
440  // Ideal Gaz case : Maxwell Boltzmann Distribution
441  // double sigma = k_Boltzmann * fgTemperature / mass;
442  // return G4RandGauss::shoot( 0, sigma );
444  // Ideal Gaz case : mean velocity from equipartition theorem
445  return sqrt(3 * k_Boltzmann *
448  // Using this approximation for liquid is wrong
449  // However the brownian process avoid taking
450  // care of energy consideration and plays only
451  // with positions
452 }
453 
454 //______________________________________________________________________________
455 
456 // added - to be transformed in a "Decay method"
457 const vector<const G4MolecularDissociationChannel*>*
459 {
461 }
462 
463 //______________________________________________________________________________
464 
466 {
468 }
469 
470 //______________________________________________________________________________
471 
473 {
475 }
476 
477 //______________________________________________________________________________
478 
480 {
481  fpMolecularConfiguration->SetDecayTime(dynDecayTime);
482 }
483 
484 //______________________________________________________________________________
485 
487 {
489 }
490 
491 //______________________________________________________________________________
492 
493 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
494 {
495  fpMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
496 }
497 
498 //______________________________________________________________________________
499 
501 {
503 }
504 
505 //______________________________________________________________________________
506 
508 {
510 }
511 
512 //______________________________________________________________________________
513 
515 {
517 }
518 
519 //______________________________________________________________________________
520 
522 {
524 }
525 
526 //______________________________________________________________________________
527 
529 {
531 }
532 
533 //______________________________________________________________________________
534 
536 {
538 }
539 
540 //______________________________________________________________________________
541 
542 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
543 {
544  fpMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
545 }
546 
547 //______________________________________________________________________________
548 
550 {
552 }
553 
554 //______________________________________________________________________________
555 
557  double temperature) const
558 {
560  temperature);
561 }
562 
563 //______________________________________________________________________________
564 
566 {
568 }
569 
570 //______________________________________________________________________________
571 
572 //void G4Molecule::SetGlobalTemperature(G4double temperature)
573 //{
574 // fgTemperature = temperature;
575 //}
576 //
578 //
579 //G4double G4Molecule::GetGlobalTemperature()
580 //{
581 // return fgTemperature;
582 //}
583 
584 //______________________________________________________________________________
585 
587 {
589 }
590 
591 //______________________________________________________________________________
592 
593 void G4Molecule::SetLabel(const G4String& label)
594 {
596 }
597 
598 //______________________________________________________________________________
599 
601 {
602  // TODO check fpMolecularConfiguration already exists
603  // and new one as well
604  // TODO notify for stack change
608 
609  assert(fpMolecularConfiguration!=0);
610 }
void SetDiffusionCoefficient(G4double)
Definition: G4Molecule.cc:542
float c_squared
Definition: hepunit.py:258
const G4String & GetName() const
G4int GetCharge() const
Definition: G4Molecule.cc:507
G4IT()
Definition: G4IT.cc:63
static G4Molecule * GetMolecule(const G4Track *)
Definition: G4Molecule.cc:83
void SetMass(G4double)
Definition: G4Molecule.cc:514
void SetLabel(const G4String &label)
Definition: G4Molecule.cc:593
void PrintState() const
Definition: G4Molecule.cc:373
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
const G4String & GetLabel() const
Definition: G4Molecule.cc:586
const G4MoleculeDefinition * GetDefinition() const
G4double GetNbElectrons() const
Definition: G4Molecule.cc:366
G4MolecularConfiguration * fpMolecularConfiguration
Definition: G4Molecule.hh:290
static G4MoleculeCounter * GetMoleculeCounter()
virtual void RemoveAMoleculeAtTime(G4MolecularConfiguration *, G4double time, int number=1)
#define G4ThreadLocal
Definition: tls.hh:89
const G4ElectronOccupancy * GetElectronOccupancy() const
virtual ~G4Molecule()
Definition: G4Molecule.cc:153
int G4int
Definition: G4Types.hh:78
const G4ElectronOccupancy * GetElectronOccupancy() const
Definition: G4Molecule.cc:528
void ChangeConfigurationToLabel(const G4String &label)
Definition: G4Molecule.cc:600
Float_t mat
G4int GetAtomsNumber() const
Definition: G4Molecule.cc:359
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
const G4MoleculeDefinition * GetDefinition() const
Definition: G4Molecule.cc:535
G4int GetMoleculeID() const
Definition: G4Molecule.cc:472
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:458
void MoveOneElectron(G4int, G4int)
Definition: G4Molecule.cc:337
G4bool operator<(const G4Molecule &right) const
Definition: G4Molecule.cc:136
const G4String & GetLabel() const
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
Definition: G4Molecule.cc:345
static G4bool InUse()
float k_Boltzmann
Definition: hepunit.py:299
G4MolecularConfiguration * IonizeMolecule(G4int)
void SetElectronOccupancy(const G4ElectronOccupancy *)
Definition: G4Molecule.cc:292
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
G4double GetDecayTime() const
Definition: G4Molecule.cc:486
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;
G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:565
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:69
void SetVanDerVaalsRadius(G4double)
Definition: G4Molecule.cc:493
G4MolecularConfiguration * MoveOneElectron(G4int, G4int)
virtual void AddAMoleculeAtTime(G4MolecularConfiguration *, G4double time, int number=1)
G4double GetKineticEnergy() const
Definition: G4Molecule.cc:421
G4Molecule & operator=(const G4Molecule &right)
Definition: G4Molecule.cc:105
void IonizeMolecule(G4int)
Definition: G4Molecule.cc:313
G4int GetFakeParticleID() const
Definition: G4Molecule.cc:465
static G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *)
G4double GetMass() const
Definition: G4Molecule.cc:521
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:380
virtual void Print() const
Definition: G4IT.hh:94
G4double GetDiffusionVelocity() const
Definition: G4Molecule.cc:433
static const double pi
Definition: G4SIunits.hh:74
G4bool operator!=(const G4Molecule &right) const
Definition: G4Molecule.cc:125
void RemoveElectron(G4int, G4int number=1)
Definition: G4Molecule.cc:329
G4DLLIMPORT G4ThreadLocal G4Allocator< G4Molecule > * aMoleculeAllocator
G4bool operator==(const G4Molecule &right) const
Definition: G4Molecule.cc:114
#define G4endl
Definition: G4ios.hh:61
const G4String & GetFormatedName() const
const G4String & GetFormatedName() const
Definition: G4Molecule.cc:352
G4double GetVanDerVaalsRadius() const
Definition: G4Molecule.cc:500
double G4double
Definition: G4Types.hh:76
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
G4MolecularConfiguration * ExciteMolecule(G4int)
{ Class description:
void AddElectron(G4int orbit, G4int n=1)
Definition: G4Molecule.cc:321
G4double GetDiffusionCoefficient() const
Definition: G4Molecule.cc:549
void SetDecayTime(G4double)
Definition: G4Molecule.cc:479
G4int RemoveElectron(G4int orbit, G4int number=1)
void ExciteMolecule(G4int)
Definition: G4Molecule.cc:303