Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4Molecule.cc
이 파일의 문서화 페이지로 가기
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 110873 2018-06-22 13:11:22Z 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  G4ThreadLocalStatic G4Allocator<G4Molecule>* _instance = nullptr;
68  return _instance;
69 }
70 
71 //______________________________________________________________________________
72 
73 template<>
75  fPoint->SetNode(nullptr);
76 }
77 
78 //______________________________________________________________________________
79 
81 {
82  return (G4Molecule*) (GetIT(track));
83 }
84 
85 //______________________________________________________________________________
86 
88 {
89  return (G4Molecule*) (GetIT(track));
90 }
91 
92 //______________________________________________________________________________
93 
95 {
96  return (G4Molecule*) (GetIT(track));
97 }
98 
99 //______________________________________________________________________________
100 
101 void G4Molecule::Print() const
102 {
103  G4cout << "The user track information is a molecule" << G4endl;
104 }
105 
106 //______________________________________________________________________________
107 
109  G4VUserTrackInformation("G4Molecule"), G4IT(right)
110 {
112 }
113 
114 //______________________________________________________________________________
115 
117 {
118  if (&right == this) return *this;
120  return *this;
121 }
122 
123 //______________________________________________________________________________
124 
126 {
128  {
129  return true;
130  }
131  return false;
132 }
133 
134 //______________________________________________________________________________
135 
137 {
138  return !(*this == right);
139 }
140 
141 //______________________________________________________________________________
148 {
150 }
151 
152 //______________________________________________________________________________
156  G4VUserTrackInformation("G4Molecule"), G4IT()
157 
158 {
160 }
161 
162 //______________________________________________________________________________
163 
165 {
166  if (fpTrack != nullptr)
167  {
168  if (G4VMoleculeCounter::Instance()->InUse())
169  {
171  RemoveAMoleculeAtTime(fpMolecularConfiguration,
173  &(fpTrack->GetPosition()));
174  }
175  fpTrack = nullptr;
176  }
177  fpMolecularConfiguration = nullptr;
178 }
179 
180 //______________________________________________________________________________
184 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
186  G4VUserTrackInformation("G4Molecule"), G4IT()
188 {
191  GetOrCreateMolecularConfiguration(moleculeDefinition);
192 }
193 
194 //______________________________________________________________________________
195 
196 G4Molecule::G4Molecule(G4MoleculeDefinition* moleculeDefinition, int charge)
197 {
200  GetOrCreateMolecularConfiguration(moleculeDefinition,
201  charge);
202 }
203 
204 //______________________________________________________________________________
209 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition,
211  G4int OrbitalToFree,
212  G4int OrbitalToFill) :
213  G4VUserTrackInformation("G4Molecule"), G4IT()
215 {
216  if (moleculeDefinition->GetGroundStateElectronOccupancy())
217  {
218  G4ElectronOccupancy dynElectronOccupancy(
219  *moleculeDefinition->GetGroundStateElectronOccupancy());
220 
221  if (OrbitalToFill != 0)
222  {
223  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
224  dynElectronOccupancy.AddElectron(OrbitalToFill - 1, 1);
225  // dynElectronOccupancy.DumpInfo(); // DEBUG
226  }
227 
228  if (OrbitalToFill == 0)
229  {
230  dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
231  // dynElectronOccupancy.DumpInfo(); // DEBUG
232  }
233 
236  moleculeDefinition, dynElectronOccupancy);
237  }
238  else
239  {
241  G4Exception(
242  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
243  "G4int OrbitalToFree, G4int OrbitalToFill)",
244  "G4Molecule_wrong_usage_of_constructor",
246  "If you want to use this constructor, the molecule definition has to be "
247  "first defined with electron occupancies");
248  }
249 }
250 
251 //______________________________________________________________________________
258  G4int Level,
259  G4bool Excitation) :
260  G4VUserTrackInformation("G4Molecule"), G4IT()
261 {
262  if (moleculeDefinition->GetGroundStateElectronOccupancy())
263  {
264  G4ElectronOccupancy dynElectronOccupancy(
265  *moleculeDefinition->GetGroundStateElectronOccupancy());
266 
267  if (Excitation == true)
268  {
269  dynElectronOccupancy.RemoveElectron(Level, 1);
270  dynElectronOccupancy.AddElectron(5, 1);
271  // dynElectronOccupancy.DumpInfo(); // DEBUG
272  }
273 
274  if (Excitation == false)
275  {
276  dynElectronOccupancy.RemoveElectron(Level, 1);
277  // dynElectronOccupancy.DumpInfo(); // DEBUG
278  }
279 
282  moleculeDefinition, dynElectronOccupancy);
283  }
284  else
285  {
287  G4Exception(
288  "G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, "
289  "G4int OrbitalToFree, G4int OrbitalToFill)",
290  "G4Molecule_wrong_usage_of_constructor",
292  "If you want to use this constructor, the molecule definition has to be "
293  "first defined with electron occupancies");
294 
295  }
296 }
297 
298 //______________________________________________________________________________
299 
301 {
302  fpMolecularConfiguration = molConf;
303 }
304 
305 //______________________________________________________________________________
306 
308 {
312 }
313 
314 //______________________________________________________________________________
315 
319 {
321  ExcitedLevel);
322 }
323 
324 //______________________________________________________________________________
325 
329 {
331  IonizedLevel);
332 }
333 
334 //______________________________________________________________________________
335 
337 {
339  number);
340 }
341 
342 //______________________________________________________________________________
343 
345 {
347  number);
348 }
349 
350 //______________________________________________________________________________
351 
352 void G4Molecule::MoveOneElectron(G4int orbitToFree, G4int orbitToFill)
353 {
355  orbitToFree, orbitToFill);
356 }
357 
358 //______________________________________________________________________________
359 
361 {
363 }
364 
365 //______________________________________________________________________________
366 
368 {
370 }
371 
372 //______________________________________________________________________________
373 
375 {
377 }
378 
379 //______________________________________________________________________________
380 
382 {
384 }
385 
386 //______________________________________________________________________________
387 
389 {
391 }
392 
393 //______________________________________________________________________________
394 
396  const G4ThreeVector& position)
397 {
398  if (fpTrack != 0){
399  G4Exception("G4Molecule::BuildTrack", "Molecule001", FatalErrorInArgument,
400  "A track was already assigned to this molecule");
401  }
402 
403  // Kinetic Values
404  // Set a random direction to the molecule
405  G4double costheta = (2 * G4UniformRand()-1);
406  G4double theta = acos(costheta);
407  G4double phi = 2 * pi * G4UniformRand();
408 
409  G4double xMomentum = cos(phi) * sin(theta);
410  G4double yMomentum = sin(theta) * sin(phi);
411  G4double zMomentum = costheta;
412 
413  G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
414  G4double KineticEnergy = GetKineticEnergy();
415 
416  G4DynamicParticle* dynamicParticle = new G4DynamicParticle(
417  fpMolecularConfiguration->GetDefinition(), MomentumDirection,
418  KineticEnergy);
419 
422  AddAMoleculeAtTime(fpMolecularConfiguration,
423  globalTime,
424  &(fpTrack->GetPosition()));
425  }
426 
427  //Set the Track
428  fpTrack = new G4Track(dynamicParticle, globalTime, position);
430 
431  return fpTrack;
432 }
433 
434 //______________________________________________________________________________
435 
437 {
439  // Ideal Gaz case
440  double v = GetDiffusionVelocity();
441  double E = (fpMolecularConfiguration->GetMass() / (c_squared)) * (v * v) / 2.;
443  return E;
444 }
445 
446 //______________________________________________________________________________
447 
449 {
450  double moleculeMass = fpMolecularConfiguration->GetMass() / (c_squared);
451 
453  // Different possibilities
455  // Ideal Gaz case : Maxwell Boltzmann Distribution
456  // double sigma = k_Boltzmann * fgTemperature / mass;
457  // return G4RandGauss::shoot( 0, sigma );
459  // Ideal Gaz case : mean velocity from equipartition theorem
460  return sqrt(3 * k_Boltzmann *
463  // Using this approximation for liquid is wrong
464  // However the brownian process avoid taking
465  // care of energy consideration and plays only
466  // with positions
467 }
468 
469 //______________________________________________________________________________
470 
471 // added - to be transformed in a "Decay method"
472 const vector<const G4MolecularDissociationChannel*>*
474 {
476 }
477 
478 //______________________________________________________________________________
479 
481 {
483 }
484 
485 //______________________________________________________________________________
486 
488 {
490 }
491 
492 //______________________________________________________________________________
493 
495 {
496  fpMolecularConfiguration->SetDecayTime(dynDecayTime);
497 }
498 
499 //______________________________________________________________________________
500 
502 {
504 }
505 
506 //______________________________________________________________________________
507 
508 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
509 {
510  fpMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
511 }
512 
513 //______________________________________________________________________________
514 
516 {
518 }
519 
520 //______________________________________________________________________________
521 
523 {
525 }
526 
527 //______________________________________________________________________________
528 
530 {
532 }
533 
534 //______________________________________________________________________________
535 
537 {
539 }
540 
541 //______________________________________________________________________________
542 
544 {
546 }
547 
548 //______________________________________________________________________________
549 
551 {
553 }
554 
555 //______________________________________________________________________________
556 
557 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
558 {
559  fpMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
560 }
561 
562 //______________________________________________________________________________
563 
565 {
567 }
568 
569 //______________________________________________________________________________
570 
572  double temperature) const
573 {
575  temperature);
576 }
577 
578 //______________________________________________________________________________
579 
581 {
583 }
584 
585 //______________________________________________________________________________
586 
587 //void G4Molecule::SetGlobalTemperature(G4double temperature)
588 //{
589 // fgTemperature = temperature;
590 //}
591 //
593 //
594 //G4double G4Molecule::GetGlobalTemperature()
595 //{
596 // return fgTemperature;
597 //}
598 
599 //______________________________________________________________________________
600 
602 {
604 }
605 
606 //______________________________________________________________________________
607 
608 void G4Molecule::SetLabel(const G4String& label)
609 {
611 }
612 
613 //______________________________________________________________________________
614 
616 {
617  // TODO check fpMolecularConfiguration already exists
618  // and new one as well
619  // TODO notify for stack change
623 
624  assert(fpMolecularConfiguration!=0);
625 }
void RemoveElectron(G4int, G4int number=1)
Definition: G4Molecule.cc:344
void SetVanDerVaalsRadius(G4double)
Definition: G4Molecule.cc:508
const G4MoleculeDefinition * GetDefinition() const
void SetLabel(const G4String &label)
Definition: G4Molecule.cc:608
const G4String & GetLabel() const
G4DLLIMPORT G4Allocator< G4Molecule > *& aMoleculeAllocator()
G4ThreadLocal/G4double G4Molecule::fgTemperature = 310; // 310*kelvin;
Definition: G4Molecule.cc:65
G4Track * fpTrack
Definition: G4IT.hh:168
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
static G4bool InUse()
static G4Molecule * GetMolecule(const G4Track *)
Definition: G4Molecule.cc:94
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
Definition: G4Molecule.cc:360
static G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *)
void ExciteMolecule(G4int)
Definition: G4Molecule.cc:318
void MoveOneElectron(G4int, G4int)
Definition: G4Molecule.cc:352
virtual ~G4KDNode()
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
#define G4ThreadLocalStatic
Definition: tls.hh:68
virtual ~G4Molecule()
Definition: G4Molecule.cc:164
const G4String & GetFormatedName() const
G4double GetVanDerVaalsRadius() const
Definition: G4Molecule.cc:515
static constexpr double c_squared
G4MolecularConfiguration * MoveOneElectron(G4int, G4int)
G4int GetCharge() const
Definition: G4Molecule.cc:522
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
#define ITImp(T)
Definition: G4ITType.hh:136
G4double GetDecayTime() const
Definition: G4Molecule.cc:501
G4double GetKineticEnergy() const
Definition: G4Molecule.cc:436
G4int GetFakeParticleID() const
Definition: G4Molecule.cc:480
G4int GetAtomsNumber() const
Definition: G4Molecule.cc:374
G4bool operator==(const G4Molecule &right) const
Definition: G4Molecule.cc:125
void SetDecayTime(G4double)
Definition: G4Molecule.cc:494
#define G4UniformRand()
Definition: Randomize.hh:53
G4double GetGlobalTime() const
const G4MoleculeDefinition * GetDefinition() const
Definition: G4Molecule.cc:550
void AddElectron(G4int orbit, G4int n=1)
Definition: G4Molecule.cc:336
const G4ThreeVector & GetPosition() const
void SetDiffusionCoefficient(G4double)
Definition: G4Molecule.cc:557
Float_t mat
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
G4double GetMass() const
Definition: G4Molecule.cc:536
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:80
G4MolecularConfiguration * IonizeMolecule(G4int)
const G4String & GetLabel() const
Definition: G4Molecule.cc:601
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:473
void ChangeConfigurationToLabel(const G4String &label)
Definition: G4Molecule.cc:615
const G4ElectronOccupancy * GetElectronOccupancy() const
G4double GetDiffusionCoefficient() const
Definition: G4Molecule.cc:564
int G4int
Definition: G4Types.hh:78
G4Molecule & operator=(const G4Molecule &right)
Definition: G4Molecule.cc:116
G4bool operator!=(const G4Molecule &right) const
Definition: G4Molecule.cc:136
G4double GetNbElectrons() const
Definition: G4Molecule.cc:381
G4int RemoveElectron(G4int orbit, G4int number=1)
G4MolecularConfiguration * fpMolecularConfiguration
Definition: G4Molecule.hh:294
static constexpr double k_Boltzmann
void SetElectronOccupancy(const G4ElectronOccupancy *)
Definition: G4Molecule.cc:307
G4MolecularConfiguration * ExciteMolecule(G4int)
void IonizeMolecule(G4int)
Definition: G4Molecule.cc:328
G4GLOB_DLL std::ostream G4cout
G4int GetMoleculeID() const
Definition: G4Molecule.cc:487
Definition: G4IT.hh:88
static constexpr double pi
Definition: G4SIunits.hh:75
void Print() const
Definition: G4Molecule.cc:101
G4bool operator<(const G4Molecule &right) const
Definition: G4Molecule.cc:147
const G4String & GetFormatedName() const
Definition: G4Molecule.cc:367
G4Track * BuildTrack(G4double globalTime, const G4ThreeVector &Position)
Definition: G4Molecule.cc:395
void SetMass(G4double)
Definition: G4Molecule.cc:529
const G4String & GetName() const
void PrintState() const
Definition: G4Molecule.cc:388
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
void SetUserInformation(G4VUserTrackInformation *aValue) const
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
G4double GetDiffusionVelocity() const
Definition: G4Molecule.cc:448
G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:580
static G4VMoleculeCounter * Instance()
const G4ElectronOccupancy * GetElectronOccupancy() const
Definition: G4Molecule.cc:543