Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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"
54#include "G4SystemOfUnits.hh"
55#include "G4Track.hh"
56#include "G4MoleculeCounter.hh"
57
58using namespace std;
59
60double G4Molecule::fgTemperature = 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
77void 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
111////////////////////////////////////////////////////////////////////////
112/// The two methods below are the most called of the simulation :
113/// compare molecules in the MoleculeStackManager or in
114/// the InteractionTable
115
117{
118 return fMolecularConfiguration < right.fMolecularConfiguration ;
119}
120////////////////////////////////////////////////////////////////////////
121void G4Molecule::Init()
122{
123 fMolecularConfiguration = 0 ;
124 fDynamicParticle = 0;
125}
126
127////////////////////////////////////////////////////////////////////////
128/** Default molecule builder
129 */
130//////////////////////////
132 //////////////////////////
133{
134 Init();
135}
136
137//////////////////////////
139//////////////////////////
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
156/** Build a molecule at ground state according to a given
157 * G4MoleculeDefinition that can be obtained from G4GenericMoleculeManager
158 */
159//////////////////////////
161 G4VUserTrackInformation("G4Molecule"), G4IT()
162 //////////////////////////
163{
164 Init();
165 fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition);
166}
167
168/** Build a molecule at a specific excitation/ionisation state according
169 * to a ground state that can be obtained from G4GenericMoleculeManager.
170 * Put 0 in the second option if this is a ionisation.
171 */
172//////////////////////////
173G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, G4int OrbitalToFree, G4int OrbitalToFill):
174 G4VUserTrackInformation("G4Molecule"), G4IT()
175 //////////////////////////
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
197/** Specific builder for water molecules to be used in Geant4-DNA,
198 * the last option Excitation is true if the molecule is excited, is
199 * false is the molecule is ionized.
200 */
201
202G4Molecule::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
230/** Method used in Geant4-DNA to excite water molecules
231 */
233{
234 fMolecularConfiguration = fMolecularConfiguration->ExciteMolecule(ExcitedLevel);
235}
236
237/** Method used in Geant4-DNA to ionize water molecules
238 */
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
254void 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
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{
316 ////
317 // Ideal Gaz case
318 double v = GetDiffusionVelocity();
319 double E = (fMolecularConfiguration->GetMass()/(c_squared))*(v*v)/2.;
320 ////
321 return E;
322}
323
325{
326 double moleculeMass = fMolecularConfiguration->GetMass()/(c_squared);
327
328 ////
329 // Different possibilities
330 ////
331 // Ideal Gaz case : Maxwell Boltzmann Distribution
332 // double sigma = k_Boltzmann * fgTemperature / mass;
333 // return G4RandGauss::shoot( 0, sigma );
334 ////
335 // Ideal Gaz case : mean velocity from equipartition theorem
336 return sqrt(3*k_Boltzmann*fgTemperature/moleculeMass);
337 ////
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"
345const 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
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
401{
402 fMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
403}
404
406{
407 return fMolecularConfiguration->GetDiffusionCoefficient();
408}
@ FatalErrorInArgument
#define ITImp(T)
Definition: G4ITType.hh:120
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:48
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:67
G4DLLIMPORT G4Allocator< G4Molecule > aMoleculeAllocator
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:53
G4int AddElectron(G4int orbit, G4int number=1)
G4int RemoveElectron(G4int orbit, G4int number=1)
Definition: G4IT.hh:83
virtual void Print() const
Definition: G4IT.hh:92
G4Track * fpTrack
Definition: G4IT.hh:144
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannel() const
const G4String & GetName() const
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &electronOccupancy)
const G4MoleculeDefinition * GetDefinition() const
G4MolecularConfiguration * MoveOneElectron(G4int, G4int)
G4MolecularConfiguration * IonizeMolecule(G4int)
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
const G4ElectronOccupancy * GetElectronOccupancy() const
G4MolecularConfiguration * ExciteMolecule(G4int)
virtual void AddAMoleculeAtTime(const G4Molecule &, G4double)
static G4MoleculeCounter * GetMoleculeCounter()
virtual void RemoveAMoleculeAtTime(const G4Molecule &, G4double)
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
void IonizeMolecule(G4int)
Definition: G4Molecule.cc:239
G4int GetCharge() const
Definition: G4Molecule.cc:375
void RemoveElectron(G4int, G4int number=1)
Definition: G4Molecule.cc:249
void AddElectron(G4int orbit, G4int n=1)
Definition: G4Molecule.cc:244
virtual ~G4Molecule()
Definition: G4Molecule.cc:138
G4bool operator<(const G4Molecule &right) const
Definition: G4Molecule.cc:116
G4double GetVanDerVaalsRadius() const
Definition: G4Molecule.cc:370
void SetElectronOccupancy(const G4ElectronOccupancy *)
Definition: G4Molecule.cc:225
void MoveOneElectron(G4int, G4int)
Definition: G4Molecule.cc:254
G4double GetMass() const
Definition: G4Molecule.cc:385
G4int GetMoleculeID() const
Definition: G4Molecule.cc:350
G4double GetKineticEnergy() const
Definition: G4Molecule.cc:314
G4Molecule(const G4Molecule &)
Definition: G4Molecule.cc:82
G4int GetAtomsNumber() const
Definition: G4Molecule.cc:264
G4bool operator==(const G4Molecule &right) const
Definition: G4Molecule.cc:97
void SetMass(G4double)
Definition: G4Molecule.cc:380
void SetVanDerVaalsRadius(G4double)
Definition: G4Molecule.cc:365
G4double GetDiffusionVelocity() const
Definition: G4Molecule.cc:324
void PrintState() const
Definition: G4Molecule.cc:274
void SetDecayTime(G4double)
Definition: G4Molecule.cc:355
const G4String & GetName() const
Definition: G4Molecule.cc:259
G4Track * BuildTrack(G4double globalTime, const G4ThreeVector &Position)
Definition: G4Molecule.cc:279
void ExciteMolecule(G4int)
Definition: G4Molecule.cc:232
G4bool operator!=(const G4Molecule &right) const
Definition: G4Molecule.cc:106
void SetDiffusionCoefficient(G4double)
Definition: G4Molecule.cc:400
const G4ElectronOccupancy * GetElectronOccupancy() const
Definition: G4Molecule.cc:390
G4Molecule & operator=(const G4Molecule &right)
Definition: G4Molecule.cc:89
const G4MoleculeDefinition * GetDefinition() const
Definition: G4Molecule.cc:395
G4double GetDiffusionCoefficient() const
Definition: G4Molecule.cc:405
G4double GetDecayTime() const
Definition: G4Molecule.cc:360
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:345
G4double GetNbElectrons() const
Definition: G4Molecule.cc:269
G4double GetGlobalTime() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41