Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4MolecularConfiguration.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// Author: Mathieu Karamitros
28
29// The code is developed in the framework of the ESA AO7146
30//
31// We would be very happy hearing from you, send us your feedback! :)
32//
33// In order for Geant4-DNA to be maintained and still open-source,
34// article citations are crucial.
35// If you use Geant4-DNA chemistry and you publish papers about your software,
36// in addition to the general paper on Geant4-DNA:
37//
38// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
39//
40// we would be very happy if you could please also cite the following
41// reference papers on chemistry:
42//
43// J. Comput. Phys. 274 (2014) 841-882
44// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
45
46#ifndef G4MolecularConfiguration_
47#define G4MolecularConfiguration_ 1
48
49#include <vector>
50#include <map>
51#include "G4Threading.hh"
53#include <cassert>
54#include <functional>
55
58class G4Material;
60
62{
64 const G4ElectronOccupancy& occ2) const
65 {
66 G4int totalOcc1 = occ1.GetTotalOccupancy();
67 G4int totalOcc2 = occ2.GetTotalOccupancy();
68 if (totalOcc1 != totalOcc2)
69 {
70 return totalOcc1 < totalOcc2;
71 }
72 else
73 {
74 G4int occupancy1 = -1;
75 G4int occupancy2 = -1;
76 const G4int sizeOrbit = occ1.GetSizeOfOrbit();
77 for (G4int i = 0; i < sizeOrbit; i++)
78 {
79 occupancy1 = occ1.GetOccupancy(i);
80 occupancy2 = occ2.GetOccupancy(i);
81
82 if (occupancy1 != occupancy2)
83 {
84 return occupancy1 < occupancy2;
85 }
86 }
87 }
88 return false;
89 }
90};
91
92/** The pointer G4MolecularConfiguration will be shared by all the
93 * molecules having the same molecule definition and the same
94 * electron occupancy
95 * BE CAREFUlL !!! : If you change the mass for instance of a OH^-,
96 * this will affect all the OH^- molecule diffusing around
97 */
99{
100public:
101
102 typedef std::function<double(const G4Material*,
103 double,
105
106 //____________________________________________________________________________
107 // Static methods
108
109 /////////////////////////////////////////////////
110 // CREATE FINALIZED SPECIES
111 // Get ground state electronic configuration
114
115 // Get for a given moleculeDefinition and a given electronic configuration,
116 // the molecular configuration
119 const G4ElectronOccupancy& eOcc);
120
121 // Get for a given moleculeDefinition and a given electronic configuration,
122 // the molecular configuration
125
126 /////////////////////////////////////////////////
127 // CREATE UNFINALIZED SPECIES
128 // Create ground state electronic configuration - to be finalized
130 CreateMolecularConfiguration(const G4String& userIdentifier,
132 bool& wasAlreadyCreated);
133
135 CreateMolecularConfiguration(const G4String& userIdentifier,
137 const G4String& label,
138 const G4ElectronOccupancy& eOcc,
139 bool& wasAlreadyCreated);
140
142 CreateMolecularConfiguration(const G4String& userIdentifier,
144 int charge,
145 const G4String& label,
146 bool& wasAlreadyCreated);
147
149 CreateMolecularConfiguration(const G4String& userIdentifier,
151 const G4String& label,
152 bool& wasAlreadyCreated);
153
154 /////////////////////////////////////////////////
155 // GET MOL CONF
156 //
159 const G4String& label);
160
162 GetMolecularConfiguration(int moleculeID);
163
165 GetMolecularConfiguration(const G4String& userID);
166
167 static int GetNumberOfSpecies();
168
169 static std::map<G4String, G4MolecularConfiguration*>& GetUserIDTable()
170 {
171 return GetManager()->GetUserIDTable();
172 }
173
174 // Release memory of the mol conf manager
175 static void DeleteManager();
176
177 static double DiffCoeffWater(double temperature_K);
178
180
181 //____________________________________________________________________________
182
183 const G4MoleculeDefinition* GetDefinition() const;
184
185 /** Returns the name of the molecule
186 */
187 const G4String& GetName() const;
188
189 /** Returns the formated name of the molecule
190 */
191 const G4String& GetFormatedName() const;
192
193 /** Returns the nomber of atoms compouning the molecule
194 */
195 G4int GetAtomsNumber() const;
196
197 /** Method used in Geant4-DNA to excite water molecules
198 */
200
201 /** Method used in Geant4-DNA to ionize water molecules
202 */
204
205 /** Add n electrons to a given orbit.
206 * Note : You can add as many electrons to a given orbit, the result
207 * may be unrealist.
208 */
209 G4MolecularConfiguration* AddElectron(G4int orbit, G4int n = 1) const;
210
211 /** Remove n electrons to a given orbit.
212 */
214
215 /** Move one electron from an orbit to another.
216 */
217 G4MolecularConfiguration* MoveOneElectron(G4int /*orbit*/, G4int /*orbit*/) const;
218
219 /** Returns the number of electron.
220 */
221 G4double GetNbElectrons() const;
222
223 /** Display the electronic state of the molecule.
224 */
225 void PrintState() const;
226
227 const std::vector<const G4MolecularDissociationChannel*>* GetDissociationChannels() const;
228
229 G4int GetFakeParticleID() const;
230
231 inline G4int GetMoleculeID() const;
232
233 /** Sets the diffusion coefficient D of the molecule used in diffusion
234 * processes to calculate the mean square jump distance between two
235 * changes of direction. In three dimension : <x^2> = 6 D t where t is
236 * the mean jump time between two changes of direction.
237 *
238 * Note : Diffusion Coefficient in one medium only
239 * For the time being, we will consider only one diffusion
240 * coefficient for the all simulation => diffusion in one medium only
241 * If the user needs to use the diffusion in different materials,
242 * she/he should contact the developers/maintainers of this package
243 */
245
246 /** Returns the diffusion coefficient D.
247 */
248 inline G4double GetDiffusionCoefficient() const;
249
251 double temperature) const;
252
253 /** Set the decay time of the molecule.
254 */
255 inline void SetDecayTime(G4double);
256
257 /** Returns the decay time of the molecule.
258 */
259 inline G4double GetDecayTime() const;
260
261 /** The Van Der Valls Radius of the molecule
262 */
263 inline void SetVanDerVaalsRadius(G4double);
264 inline G4double GetVanDerVaalsRadius() const;
265
266 /** Returns the object ElectronOccupancy describing the electronic
267 * configuration of the molecule.
268 */
269 inline const G4ElectronOccupancy* GetElectronOccupancy() const;
270
271 /** Returns the charge of molecule.
272 */
273 inline G4int GetCharge() const;
274
275 /** Set the total mass of the molecule.
276 */
277 inline void SetMass(G4double);
278
279 /** Returns the total mass of the molecule.
280 */
281 inline G4double GetMass() const;
282
283 /*
284 * Adds a label to the molecular configuration
285 * (Can be used for vibrational states for instance)
286 */
287 inline void SetLabel(const G4String&);
288
289 /*
290 * Returns the label assigned by the user
291 */
292 inline const G4String& GetLabel() const;
293
294 inline void Finalize();
295 static void FinalizeAll();
296 static void PrintAll(); //hoang added
297 inline void UnFinalize();
298 void SetUserID(const G4String& userID);//hoang moved it to public
299
300 inline const G4String& GetUserID() const;
301
302 static void SetGlobalTemperature(G4double);
304
305 //___________________________________________________________________________
306 // EXPERIMENTAL
307
308 static G4MolecularConfiguration* Load(std::istream&);
309
310 void Serialize(std::ostream&);
311 void Unserialize(std::istream&);
312 //___________________________________________________________________________
313
314
315protected:
317 const G4ElectronOccupancy&,
318 const G4String& label = "");
319
321 int charge);
322
324 const G4String& label,
325 int charge);
326
327 G4MolecularConfiguration(std::istream&);
328
332 G4MolecularConfiguration* ChangeConfiguration(const G4ElectronOccupancy& newElectronOccupancy) const;
334
335 void CheckElectronOccupancy(const char* line) const;
337
339 static void ScaleAllDiffusionCoefficientsOnWater(double temperature_K);
340
341public:
343 {
344 public:
346 fMoleculeCreationMutex()
347 {
348 fLastMoleculeID = -1;
349 }
351
353 {
354 return fLastMoleculeID+1;
355 }
356
357 //------------------------------------------------------------------------
358 // CALLED FROM CONSTRUCTORS
359 G4int Insert(const G4MoleculeDefinition* molDef,
360 const G4ElectronOccupancy& eOcc,
361 G4MolecularConfiguration* molConf);
362
363 G4int Insert(const G4MoleculeDefinition* molDef,
364 int charge,
365 G4MolecularConfiguration* molConf);
366
367 G4int Insert(const G4MoleculeDefinition* molDef,
368 const G4String& label,
369 G4MolecularConfiguration* molConf);
370
371 //------------------------------------------------------------------------
372 // CALLED WHEN USER ADD SPECIES
373 void AddUserID(const G4String& name,
374 G4MolecularConfiguration* molecule);
375
377
380 const G4ElectronOccupancy& eOcc);
381
384 const G4ElectronOccupancy& eOcc);
385
388 int charge);
389
392 const G4String& label);
393
395
397
400 const G4ElectronOccupancy& eOcc);
401
404 int charge);
405
407
409
410 const std::vector<G4MolecularConfiguration*>& GetAllSpecies()
411 {
412 return fMolConfPerID;
413 }
414
415 std::map<G4String, G4MolecularConfiguration*>& GetUserIDTable()
416 {
417 return fUserIDTable;
418 }
419
420 private:
421
422 //__________________________________________________________________________
423 typedef std::map<G4ElectronOccupancy,
425 comparator> ElectronOccupancyTable;
426 typedef std::map<const G4MoleculeDefinition*,
427 ElectronOccupancyTable > MolElectronConfTable;
428 MolElectronConfTable fElecOccTable;
429
430 //__________________________________________________________________________
431 typedef std::map<int,
432 G4MolecularConfiguration*> ChargeTable;
433 typedef std::map<const G4MoleculeDefinition*,
434 ChargeTable> MolChargeConfTable;
435 MolChargeConfTable fChargeTable;
436
437 //__________________________________________________________________________
438 typedef std::map<const G4String,
439 G4MolecularConfiguration*> LabelTable;
440 typedef std::map<const G4MoleculeDefinition*,
441 std::map<const G4String, G4MolecularConfiguration*> > MolLabelConfTable;
442 MolLabelConfTable fLabelTable;
443
444 //__________________________________________________________________________
445 typedef std::map<G4String, G4MolecularConfiguration*> UserIDTable;
446 UserIDTable fUserIDTable;
447
448 //__________________________________________________________________________
449 std::vector<G4MolecularConfiguration*> fMolConfPerID;
450 // Indexed by molecule ID
451
452 //__________________________________________________________________________
453 G4int fLastMoleculeID;
454 G4Mutex fMoleculeCreationMutex;
455 };
456
457protected:
460
463
464 mutable G4String* fLabel;
465
473 /*mutable*/ G4String fName;
476
478 static /*G4ThreadLocal*/double fgTemperature;
479
480 static double ReturnDefaultDiffCoeff(const G4Material*,
481 double,
483 molConf);
484};
485
487{
488 return fMoleculeDefinition;
489}
490
492{
493 return fElectronOccupancy;
494}
495
497{
499 fDynDiffusionCoefficient = dynDiffusionCoefficient;
500}
501
503{
505}
506
508{
510 fDynDecayTime = dynDecayTime;
511}
512
514{
515 return fDynDecayTime;
516}
517
519{
521 fDynVanDerVaalsRadius = dynVanDerVaalsRadius;
522}
523
525{
527}
528
530{
531 return fDynCharge;
532}
533
535{
537 fDynMass = aMass;
538}
539
541{
542 return fDynMass;
543}
544
546{
547 return fMoleculeID;
548}
549
551{
552 assert(fLabel == 0 || *fLabel == "");
553 if(fLabel == 0)
554 {
555 fLabel = new G4String(label);
556 }
557 else
558 {
559 *fLabel = label;
560 }
562}
563
565{
566 if(fLabel == 0)
567 fLabel = new G4String();
568
569 return (*fLabel);
570}
571
573{
575 fIsFinalized = true;
576}
577
579{
580 return fUserIdentifier;
581}
582
584(const G4DiffCoeffParam& para)
585{
586 fDiffParam = para;
587}
588
589inline G4double
591 double temperature) const
592{
593 return fDiffParam(material, temperature, this);
594}
595
597{
598 fIsFinalized = false;
599}
600
601#endif
std::mutex G4Mutex
Definition: G4Threading.hh:81
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4int GetTotalOccupancy() const
G4int GetOccupancy(G4int orbit) const
const G4ElectronOccupancy * FindCommonElectronOccupancy(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
G4int Insert(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc, G4MolecularConfiguration *molConf)
const std::vector< G4MolecularConfiguration * > & GetAllSpecies()
void RecordNewlyLabeledConfiguration(G4MolecularConfiguration *molConf)
G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
std::map< G4String, G4MolecularConfiguration * > & GetUserIDTable()
G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
void AddUserID(const G4String &name, G4MolecularConfiguration *molecule)
static G4MolecularConfiguration * Load(std::istream &)
void SetUserID(const G4String &userID)
static G4MolecularConfigurationManager * GetManager()
const G4String & GetName() const
const G4ElectronOccupancy * fElectronOccupancy
G4MolecularConfiguration * IonizeMolecule(G4int) const
const G4String & GetLabel() const
G4MolecularConfiguration * ChangeConfiguration(const G4ElectronOccupancy &newElectronOccupancy) const
G4MolecularConfiguration & operator=(G4MolecularConfiguration &right)
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1) const
const G4MoleculeDefinition * GetDefinition() const
std::function< double(const G4Material *, double, const G4MolecularConfiguration *)> G4DiffCoeffParam
static void ScaleAllDiffusionCoefficientsOnWater(double temperature_K)
static std::map< G4String, G4MolecularConfiguration * > & GetUserIDTable()
G4MolecularConfiguration * MoveOneElectron(G4int, G4int) const
G4MolecularConfiguration(const G4MolecularConfiguration &)
static double ReturnDefaultDiffCoeff(const G4Material *, double, const G4MolecularConfiguration *molConf)
const G4MoleculeDefinition * fMoleculeDefinition
void AddDiffCoeffParameterization(const G4DiffCoeffParam &)
static void SetGlobalTemperature(G4double)
static G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *)
const G4ElectronOccupancy * GetElectronOccupancy() const
void CheckElectronOccupancy(const char *line) const
const std::vector< const G4MolecularDissociationChannel * > * GetDissociationChannels() const
const G4String & GetFormatedName() const
static G4MolecularConfigurationManager * fgManager
const G4String & GetUserID() const
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
G4MolecularConfiguration * ExciteMolecule(G4int) const
static double DiffCoeffWater(double temperature_K)
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1) const
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)
bool operator()(const G4ElectronOccupancy &occ1, const G4ElectronOccupancy &occ2) const