Geant4-11
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
99{
100public:
101
102 typedef std::function<double(const G4Material*,
103 double,
105
106 //____________________________________________________________________________
107 // Static methods
108
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
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
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
187 const G4String& GetName() const;
188
191 const G4String& GetFormatedName() const;
192
195 G4int GetAtomsNumber() const;
196
200
204
210
214
217 G4MolecularConfiguration* MoveOneElectron(G4int /*orbit*/, G4int /*orbit*/) const;
218
221 G4double GetNbElectrons() const;
222
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
245
248 inline G4double GetDiffusionCoefficient() const;
249
251 double temperature) const;
252
255 inline void SetDecayTime(G4double);
256
259 inline G4double GetDecayTime() const;
260
263 inline void SetVanDerVaalsRadius(G4double);
264 inline G4double GetVanDerVaalsRadius() const;
265
269 inline const G4ElectronOccupancy* GetElectronOccupancy() const;
270
273 inline G4int GetCharge() const;
274
277 inline void SetMass(G4double);
278
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
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 void SetUserID(const G4String& userID);
335
337 static void ScaleAllDiffusionCoefficientsOnWater(double temperature_K);
338
339public:
341 {
342 public:
345 {
346 fLastMoleculeID = -1;
347 }
349
351 {
352 return fLastMoleculeID+1;
353 }
354
355 //------------------------------------------------------------------------
356 // CALLED FROM CONSTRUCTORS
357 G4int Insert(const G4MoleculeDefinition* molDef,
358 const G4ElectronOccupancy& eOcc,
359 G4MolecularConfiguration* molConf);
360
361 G4int Insert(const G4MoleculeDefinition* molDef,
362 int charge,
363 G4MolecularConfiguration* molConf);
364
365 G4int Insert(const G4MoleculeDefinition* molDef,
366 const G4String& label,
367 G4MolecularConfiguration* molConf);
368
369 //------------------------------------------------------------------------
370 // CALLED WHEN USER ADD SPECIES
371 void AddUserID(const G4String& name,
372 G4MolecularConfiguration* molecule);
373
375
378 const G4ElectronOccupancy& eOcc);
379
382 const G4ElectronOccupancy& eOcc);
383
386 int charge);
387
390 const G4String& label);
391
393
395
398 const G4ElectronOccupancy& eOcc);
399
402 int charge);
403
405
407
408 const std::vector<G4MolecularConfiguration*>& GetAllSpecies()
409 {
410 return fMolConfPerID;
411 }
412
413 std::map<G4String, G4MolecularConfiguration*>& GetUserIDTable()
414 {
415 return fUserIDTable;
416 }
417
418 private:
419
420 //__________________________________________________________________________
424 typedef std::map<const G4MoleculeDefinition*,
427
428 //__________________________________________________________________________
429 typedef std::map<int,
431 typedef std::map<const G4MoleculeDefinition*,
434
435 //__________________________________________________________________________
436 typedef std::map<const G4String,
438 typedef std::map<const G4MoleculeDefinition*,
439 std::map<const G4String, G4MolecularConfiguration*> > MolLabelConfTable;
441
442 //__________________________________________________________________________
443 typedef std::map<G4String, G4MolecularConfiguration*> UserIDTable;
445
446 //__________________________________________________________________________
447 std::vector<G4MolecularConfiguration*> fMolConfPerID;
448 // Indexed by molecule ID
449
450 //__________________________________________________________________________
453 };
454
455protected:
458
461
462 mutable G4String* fLabel;
463
471 /*mutable*/ G4String fName;
474
476 static /*G4ThreadLocal*/double fgTemperature;
477
478 static double ReturnDefaultDiffCoeff(const G4Material*,
479 double,
481 molConf);
482};
483
485{
486 return fMoleculeDefinition;
487}
488
490{
491 return fElectronOccupancy;
492}
493
495{
497 fDynDiffusionCoefficient = dynDiffusionCoefficient;
498}
499
501{
503}
504
506{
508 fDynDecayTime = dynDecayTime;
509}
510
512{
513 return fDynDecayTime;
514}
515
517{
519 fDynVanDerVaalsRadius = dynVanDerVaalsRadius;
520}
521
523{
525}
526
528{
529 return fDynCharge;
530}
531
533{
535 fDynMass = aMass;
536}
537
539{
540 return fDynMass;
541}
542
544{
545 return fMoleculeID;
546}
547
549{
550 assert(fLabel == 0 || *fLabel == "");
551 if(fLabel == 0)
552 {
553 fLabel = new G4String(label);
554 }
555 else
556 {
557 *fLabel = label;
558 }
560}
561
563{
564 if(fLabel == 0)
565 fLabel = new G4String();
566
567 return (*fLabel);
568}
569
571{
573 fIsFinalized = true;
574}
575
577{
578 return fUserIdentifier;
579}
580
582(const G4DiffCoeffParam& para)
583{
584 fDiffParam = para;
585}
586
587inline G4double
589 double temperature) const
590{
591 return fDiffParam(material, temperature, this);
592}
593
594#endif
G4double(* function)(G4double)
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
std::map< const G4MoleculeDefinition *, ChargeTable > MolChargeConfTable
const G4ElectronOccupancy * FindCommonElectronOccupancy(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
G4int Insert(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc, G4MolecularConfiguration *molConf)
std::map< const G4MoleculeDefinition *, std::map< const G4String, G4MolecularConfiguration * > > MolLabelConfTable
const std::vector< G4MolecularConfiguration * > & GetAllSpecies()
std::map< const G4String, G4MolecularConfiguration * > LabelTable
void RecordNewlyLabeledConfiguration(G4MolecularConfiguration *molConf)
G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
std::map< G4String, G4MolecularConfiguration * > UserIDTable
std::map< G4String, G4MolecularConfiguration * > & GetUserIDTable()
G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
std::map< const G4MoleculeDefinition *, ElectronOccupancyTable > MolElectronConfTable
std::map< G4ElectronOccupancy, G4MolecularConfiguration *, comparator > ElectronOccupancyTable
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
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
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)
const char * name(G4int ptype)
string material
Definition: eplot.py:19
bool operator()(const G4ElectronOccupancy &occ1, const G4ElectronOccupancy &occ2) const