Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
73 G4int occupancy1 = -1;
74 G4int occupancy2 = -1;
75 const G4int sizeOrbit = occ1.GetSizeOfOrbit();
76 for (G4int i = 0; i < sizeOrbit; i++)
77 {
78 occupancy1 = occ1.GetOccupancy(i);
79 occupancy2 = occ2.GetOccupancy(i);
80
81 if (occupancy1 != occupancy2)
82 {
83 return occupancy1 < occupancy2;
84 }
85 }
86
87 return false;
88 }
89};
90
91/** The pointer G4MolecularConfiguration will be shared by all the
92 * molecules having the same molecule definition and the same
93 * electron occupancy
94 * BE CAREFUlL !!! : If you change the mass for instance of a OH^-,
95 * this will affect all the OH^- molecule diffusing around
96 */
98{
99public:
100
101 using G4DiffCoeffParam = std::function<double (const G4Material *, double, const G4MolecularConfiguration *)>;
102
103 //____________________________________________________________________________
104 // Static methods
105
106 /////////////////////////////////////////////////
107 // CREATE FINALIZED SPECIES
108 // Get ground state electronic configuration
111
112 // Get for a given moleculeDefinition and a given electronic configuration,
113 // the molecular configuration
116 const G4ElectronOccupancy& eOcc);
117
118 // Get for a given moleculeDefinition and a given electronic configuration,
119 // the molecular configuration
122
123 /////////////////////////////////////////////////
124 // CREATE UNFINALIZED SPECIES
125 // Create ground state electronic configuration - to be finalized
127 CreateMolecularConfiguration(const G4String& userIdentifier,
129 bool& wasAlreadyCreated);
130
132 CreateMolecularConfiguration(const G4String& userIdentifier,
134 const G4String& label,
135 const G4ElectronOccupancy& eOcc,
136 bool& wasAlreadyCreated);
137
139 CreateMolecularConfiguration(const G4String& userIdentifier,
141 int charge,
142 const G4String& label,
143 bool& wasAlreadyCreated);
144
146 CreateMolecularConfiguration(const G4String& userIdentifier,
148 const G4String& label,
149 bool& wasAlreadyCreated);
150
151 /////////////////////////////////////////////////
152 // GET MOL CONF
153 //
156 const G4String& label);
157
159 GetMolecularConfiguration(int moleculeID);
160
162 GetMolecularConfiguration(const G4String& userID);
163
164 static int GetNumberOfSpecies();
165
166 static std::map<G4String, G4MolecularConfiguration*>& GetUserIDTable()
167 {
168 return GetManager()->GetUserIDTable();
169 }
170
171 // Release memory of the mol conf manager
172 static void DeleteManager();
173
174 static double DiffCoeffWater(double temperature_K);
175
177
178 //____________________________________________________________________________
179
180 const G4MoleculeDefinition* GetDefinition() const;
181
182 /** Returns the name of the molecule
183 */
184 const G4String& GetName() const;
185
186 /** Returns the formated name of the molecule
187 */
188 const G4String& GetFormatedName() const;
189
190 /** Returns the nomber of atoms compouning the molecule
191 */
192 G4int GetAtomsNumber() const;
193
194 /** Method used in Geant4-DNA to excite water molecules
195 */
197
198 /** Method used in Geant4-DNA to ionize water molecules
199 */
201
202 /** Add n electrons to a given orbit.
203 * Note : You can add as many electrons to a given orbit, the result
204 * may be unrealist.
205 */
206 G4MolecularConfiguration* AddElectron(G4int orbit, G4int n = 1) const;
207
208 /** Remove n electrons to a given orbit.
209 */
211
212 /** Move one electron from an orbit to another.
213 */
214 G4MolecularConfiguration* MoveOneElectron(G4int /*orbit*/, G4int /*orbit*/) const;
215
216 /** Returns the number of electron.
217 */
218 G4double GetNbElectrons() const;
219
220 /** Display the electronic state of the molecule.
221 */
222 void PrintState() const;
223
224 const std::vector<const G4MolecularDissociationChannel*>* GetDissociationChannels() const;
225
226 G4int GetFakeParticleID() const;
227
228 inline G4int GetMoleculeID() const;
229
230 /** Sets the diffusion coefficient D of the molecule used in diffusion
231 * processes to calculate the mean square jump distance between two
232 * changes of direction. In three dimension : <x^2> = 6 D t where t is
233 * the mean jump time between two changes of direction.
234 *
235 * Note : Diffusion Coefficient in one medium only
236 * For the time being, we will consider only one diffusion
237 * coefficient for the all simulation => diffusion in one medium only
238 * If the user needs to use the diffusion in different materials,
239 * she/he should contact the developers/maintainers of this package
240 */
242
243 /** Returns the diffusion coefficient D.
244 */
245 inline G4double GetDiffusionCoefficient() const;
246
248 double temperature) const;
249
250 /** Set the decay time of the molecule.
251 */
252 inline void SetDecayTime(G4double);
253
254 /** Returns the decay time of the molecule.
255 */
256 inline G4double GetDecayTime() const;
257
258 /** The Van Der Valls Radius of the molecule
259 */
260 inline void SetVanDerVaalsRadius(G4double);
261 inline G4double GetVanDerVaalsRadius() const;
262
263 /** Returns the object ElectronOccupancy describing the electronic
264 * configuration of the molecule.
265 */
266 inline const G4ElectronOccupancy* GetElectronOccupancy() const;
267
268 /** Returns the charge of molecule.
269 */
270 inline G4int GetCharge() const;
271
272 /** Set the total mass of the molecule.
273 */
274 inline void SetMass(G4double);
275
276 /** Returns the total mass of the molecule.
277 */
278 inline G4double GetMass() const;
279
280 /*
281 * Adds a label to the molecular configuration
282 * (Can be used for vibrational states for instance)
283 */
284 inline void SetLabel(const G4String&);
285
286 /*
287 * Returns the label assigned by the user
288 */
289 inline const G4String& GetLabel() const;
290
291 inline void Finalize();
292 static void FinalizeAll();
293 static void PrintAll(); //hoang added
294 inline void UnFinalize();
295 void SetUserID(const G4String& userID);//hoang moved it to public
296
297 inline const G4String& GetUserID() const;
298
299 static void SetGlobalTemperature(G4double);
301
302 //___________________________________________________________________________
303 // EXPERIMENTAL
304
305 static G4MolecularConfiguration* Load(std::istream&);
306
307 void Serialize(std::ostream&);
308 void Unserialize(std::istream&);
309 //___________________________________________________________________________
310
311
312protected:
314 const G4ElectronOccupancy&,
315 const G4String& label = "");
316
318 int charge);
319
321 const G4String& label,
322 int charge);
323
324 G4MolecularConfiguration(std::istream&);
325
329 G4MolecularConfiguration* ChangeConfiguration(const G4ElectronOccupancy& newElectronOccupancy) const;
331
332 void CheckElectronOccupancy(const char* line) const;
334
336 static void ScaleAllDiffusionCoefficientsOnWater(double temperature_K);
337
338public:
340 {
341 public:
343 {
344 fLastMoleculeID = -1;
345 }
347
349 {
350 return fLastMoleculeID+1;
351 }
352
353 //------------------------------------------------------------------------
354 // CALLED FROM CONSTRUCTORS
355 G4int Insert(const G4MoleculeDefinition* molDef,
356 const G4ElectronOccupancy& eOcc,
357 G4MolecularConfiguration* molConf);
358
359 G4int Insert(const G4MoleculeDefinition* molDef,
360 int charge,
361 G4MolecularConfiguration* molConf);
362
363 G4int Insert(const G4MoleculeDefinition* molDef,
364 const G4String& label,
365 G4MolecularConfiguration* molConf);
366
367 //------------------------------------------------------------------------
368 // CALLED WHEN USER ADD SPECIES
369 void AddUserID(const G4String& name,
370 G4MolecularConfiguration* molecule);
371
373
376 const G4ElectronOccupancy& eOcc);
377
380 const G4ElectronOccupancy& eOcc);
381
384 int charge);
385
388 const G4String& label);
389
391
393
396 const G4ElectronOccupancy& eOcc);
397
400 int charge);
401
403
405
406 const std::vector<G4MolecularConfiguration*>& GetAllSpecies()
407 {
408 return fMolConfPerID;
409 }
410
411 std::map<G4String, G4MolecularConfiguration*>& GetUserIDTable()
412 {
413 return fUserIDTable;
414 }
415
416 private:
417
418 //__________________________________________________________________________
419 using ElectronOccupancyTable = std::map<G4ElectronOccupancy, G4MolecularConfiguration *, comparator>;
420 using MolElectronConfTable = std::map<const G4MoleculeDefinition *, ElectronOccupancyTable>;
421 MolElectronConfTable fElecOccTable;
422
423 //__________________________________________________________________________
424 using ChargeTable = std::map<int, G4MolecularConfiguration *>;
425 using MolChargeConfTable = std::map<const G4MoleculeDefinition *, ChargeTable>;
426 MolChargeConfTable fChargeTable;
427
428 //__________________________________________________________________________
429 using LabelTable = std::map<const G4String, G4MolecularConfiguration *>;
430 using MolLabelConfTable = std::map<const G4MoleculeDefinition *, std::map<const G4String, G4MolecularConfiguration *>>;
431 MolLabelConfTable fLabelTable;
432
433 //__________________________________________________________________________
434 using UserIDTable = std::map<G4String, G4MolecularConfiguration *>;
435 UserIDTable fUserIDTable;
436
437 //__________________________________________________________________________
438 std::vector<G4MolecularConfiguration*> fMolConfPerID;
439 // Indexed by molecule ID
440
441 //__________________________________________________________________________
442 G4int fLastMoleculeID;
443 G4Mutex fMoleculeCreationMutex;
444 };
445
446protected:
449
452
453 mutable G4String* fLabel;
454
462 /*mutable*/ G4String fName;
465
467 static /*G4ThreadLocal*/double fgTemperature;
468
469 static double ReturnDefaultDiffCoeff(const G4Material*,
470 double,
472 molConf);
473};
474
479
484
486{
488 fDynDiffusionCoefficient = dynDiffusionCoefficient;
489}
490
495
497{
499 fDynDecayTime = dynDecayTime;
500}
501
506
508{
510 fDynVanDerVaalsRadius = dynVanDerVaalsRadius;
511}
512
517
519{
520 return fDynCharge;
521}
522
524{
526 fDynMass = aMass;
527}
528
530{
531 return fDynMass;
532}
533
535{
536 return fMoleculeID;
537}
538
540{
541 assert(fLabel == 0 || *fLabel == "");
542 if(fLabel == nullptr)
543 {
544 fLabel = new G4String(label);
545 }
546 else
547 {
548 *fLabel = label;
549 }
551}
552
554{
555 if(fLabel == nullptr)
556 fLabel = new G4String();
557
558 return (*fLabel);
559}
560
566
568{
569 return fUserIdentifier;
570}
571
577
578inline G4double
580 double temperature) const
581{
582 return fDiffParam(material, temperature, this);
583}
584
586{
587 fIsFinalized = false;
588}
589
590#endif
std::mutex G4Mutex
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
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
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
G4MolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &, const G4String &label="")
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
std::function< double(const G4Material *, double, const G4MolecularConfiguration *)> G4DiffCoeffParam
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)
bool operator()(const G4ElectronOccupancy &occ1, const G4ElectronOccupancy &occ2) const