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.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /materials/src/G4NistManager.cc (Version 11.3.0) and /materials/src/G4NistManager.cc (Version 11.2.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25                                                    25 
 26 // -------------------------------------------     26 // -------------------------------------------------------------------
 27 //                                                 27 //
 28 // GEANT4 Class file                               28 // GEANT4 Class file
 29 //                                                 29 //
 30 //                                                 30 //
 31 // File name:     G4NistManager                    31 // File name:     G4NistManager
 32 //                                                 32 //
 33 // Author:        Vladimir Ivanchenko              33 // Author:        Vladimir Ivanchenko
 34 //                                                 34 //
 35 // Creation date: 23.12.2004                       35 // Creation date: 23.12.2004
 36 //                                                 36 //
 37 //                                                 37 //
 38 // -------------------------------------------     38 // -------------------------------------------------------------------
 39 //                                                 39 //
 40 // Class Description:                              40 // Class Description:
 41 //                                                 41 //
 42 // Element data from the NIST DB on Atomic Wei     42 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
 43 // http://physics.nist.gov/PhysRefData/Composi     43 // http://physics.nist.gov/PhysRefData/Compositions/index.html
 44                                                    44 
 45 #include "G4NistManager.hh"                        45 #include "G4NistManager.hh"
 46 #include "G4AutoLock.hh"                           46 #include "G4AutoLock.hh"
                                                   >>  47 #include "G4Isotope.hh"
 47 #include "G4NistMessenger.hh"                      48 #include "G4NistMessenger.hh"
 48                                                    49 
                                                   >>  50 G4NistManager* G4NistManager::instance = nullptr;
 49                                                    51 
 50 namespace                                          52 namespace
 51 {                                                  53 {
 52 G4Mutex nistManagerMutex = G4MUTEX_INITIALIZER     54 G4Mutex nistManagerMutex = G4MUTEX_INITIALIZER;
 53 }                                                  55 }
 54                                                    56 
 55 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
 56                                                    58 
 57 G4NistManager* G4NistManager::Instance()           59 G4NistManager* G4NistManager::Instance()
 58 {                                                  60 {
 59   static G4NistManager manager;                <<  61   if (instance == nullptr) {
 60   return &manager;                             <<  62     G4AutoLock l(&nistManagerMutex);
                                                   >>  63     if (instance == nullptr) {
                                                   >>  64       static G4NistManager manager;
                                                   >>  65       instance = &manager;
                                                   >>  66     }
                                                   >>  67     l.unlock();
                                                   >>  68   }
                                                   >>  69   return instance;
 61 }                                                  70 }
 62                                                    71 
 63 //....oooOO0OOooo........oooOO0OOooo........oo     72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 64                                                    73 
 65 G4NistManager::~G4NistManager()                    74 G4NistManager::~G4NistManager()
 66 {                                                  75 {
                                                   >>  76   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
                                                   >>  77   for (auto const & mat : *theMaterialTable) { delete mat; }
                                                   >>  78   const G4ElementTable* theElementTable = G4Element::GetElementTable();
                                                   >>  79   for (auto const & elm : *theElementTable) { delete elm; }
                                                   >>  80   const G4IsotopeTable* theIsotopeTable = G4Isotope::GetIsotopeTable();
                                                   >>  81   for (auto const & iso : *theIsotopeTable) { delete iso; }
                                                   >>  82 
 67   delete messenger;                                83   delete messenger;
 68   delete matBuilder;                               84   delete matBuilder;
 69   delete elmBuilder;                               85   delete elmBuilder;
 70   delete fICRU90;                                  86   delete fICRU90;
 71 }                                                  87 }
 72                                                    88 
 73 //....oooOO0OOooo........oooOO0OOooo........oo     89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 74                                                    90 
 75 G4Material* G4NistManager::BuildMaterialWithNe     91 G4Material* G4NistManager::BuildMaterialWithNewDensity(const G4String& name,
 76   const G4String& basename, G4double density,      92   const G4String& basename, G4double density, G4double temperature, G4double pressure)
 77 {                                                  93 {
 78   G4Material* bmat = FindOrBuildMaterial(name)     94   G4Material* bmat = FindOrBuildMaterial(name);
 79   if (bmat != nullptr) {                           95   if (bmat != nullptr) {
 80     G4cout << "G4NistManager::BuildMaterialWit     96     G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
 81     G4cout << " New material <" << name << ">      97     G4cout << " New material <" << name << "> cannot be built because material"
 82            << " with the same name already exi     98            << " with the same name already exists." << G4endl;
 83     G4Exception("G4NistManager::BuildMaterialW     99     G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat101", FatalException,
 84       "Wrong material name");                     100       "Wrong material name");
 85     return nullptr;                               101     return nullptr;
 86   }                                               102   }
 87   bmat = FindOrBuildMaterial(basename);           103   bmat = FindOrBuildMaterial(basename);
 88   if (bmat == nullptr) {                          104   if (bmat == nullptr) {
 89     G4cout << "G4NistManager::BuildMaterialWit    105     G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
 90     G4cout << " New material <" << name << ">     106     G4cout << " New material <" << name << "> cannot be built because " << G4endl;
 91     G4cout << " base material <" << basename <    107     G4cout << " base material <" << basename << "> does not exist." << G4endl;
 92     G4Exception("G4NistManager::BuildMaterialW    108     G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat102", FatalException,
 93       "Wrong material name");                     109       "Wrong material name");
 94     return nullptr;                               110     return nullptr;
 95   }                                               111   }
 96   G4double dens = density;                        112   G4double dens = density;
 97   G4double temp = temperature;                    113   G4double temp = temperature;
 98   G4double pres = pressure;                       114   G4double pres = pressure;
 99   if (dens == 0.0) {                              115   if (dens == 0.0) {
100     dens = bmat->GetDensity();                    116     dens = bmat->GetDensity();
101     temp = bmat->GetTemperature();                117     temp = bmat->GetTemperature();
102     pres = bmat->GetPressure();                   118     pres = bmat->GetPressure();
103   }                                               119   }
104   auto mat = new G4Material(name, dens, bmat,     120   auto mat = new G4Material(name, dens, bmat, bmat->GetState(), temp, pres);
105   return mat;                                     121   return mat;
106 }                                                 122 }
107                                                   123 
108 //....oooOO0OOooo........oooOO0OOooo........oo    124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109                                                   125 
110 void G4NistManager::PrintElement(const G4Strin    126 void G4NistManager::PrintElement(const G4String& symbol) const
111 {                                                 127 {
112   if (symbol == "all") {                          128   if (symbol == "all") {
113     elmBuilder->PrintElement(0);                  129     elmBuilder->PrintElement(0);
114   }                                               130   }
115   else {                                          131   else {
116     elmBuilder->PrintElement(elmBuilder->GetZ(    132     elmBuilder->PrintElement(elmBuilder->GetZ(symbol));
117   }                                               133   }
118 }                                                 134 }
119                                                   135 
120 //....oooOO0OOooo........oooOO0OOooo........oo    136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121                                                   137 
122 void G4NistManager::PrintG4Element(const G4Str    138 void G4NistManager::PrintG4Element(const G4String& name) const
123 {                                                 139 {
124   for (auto const & elm : *G4Element::GetEleme    140   for (auto const & elm : *G4Element::GetElementTable()) {
125     if (name == elm->GetName() || "all" == nam    141     if (name == elm->GetName() || "all" == name) {
126       G4cout << *elm << G4endl;                   142       G4cout << *elm << G4endl;
127     }                                             143     }
128   }                                               144   }
129 }                                                 145 }
130                                                   146 
131 //....oooOO0OOooo........oooOO0OOooo........oo    147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132                                                   148 
133 void G4NistManager::PrintG4Material(const G4St    149 void G4NistManager::PrintG4Material(const G4String& name) const
134 {                                                 150 {
135   for (auto const & mat : *G4Material::GetMate    151   for (auto const & mat : *G4Material::GetMaterialTable()) {
136     if (name == mat->GetName() || "all" == nam    152     if (name == mat->GetName() || "all" == name) {
137       G4cout << *mat << G4endl;                   153       G4cout << *mat << G4endl;
138     }                                             154     }
139   }                                               155   }
140 }                                                 156 }
141                                                   157 
142 //....oooOO0OOooo........oooOO0OOooo........oo    158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143                                                   159 
144 void G4NistManager::SetVerbose(G4int val)         160 void G4NistManager::SetVerbose(G4int val)
145 {                                                 161 {
146   verbose = val;                                  162   verbose = val;
147   elmBuilder->SetVerbose(val);                    163   elmBuilder->SetVerbose(val);
148   matBuilder->SetVerbose(val);                    164   matBuilder->SetVerbose(val);
149 }                                                 165 }
150                                                   166 
151 //....oooOO0OOooo........oooOO0OOooo........oo    167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152                                                   168 
153 G4NistManager::G4NistManager()                    169 G4NistManager::G4NistManager()
154 {                                                 170 {
155   nElements = 0;                                  171   nElements = 0;
156   nMaterials = 0;                                 172   nMaterials = 0;
157   verbose = 0;                                    173   verbose = 0;
158                                                << 
159   theMaterialTable = G4Material::GetMaterialTa << 
160   theElementTable = G4Element::GetElementTable << 
161   theIsotopeTable = G4Isotope::GetIsotopeTable << 
162                                                   174 
163   elmBuilder = new G4NistElementBuilder(verbos    175   elmBuilder = new G4NistElementBuilder(verbose);
164   matBuilder = new G4NistMaterialBuilder(elmBu    176   matBuilder = new G4NistMaterialBuilder(elmBuilder, verbose);
165                                                   177 
166   messenger = new G4NistMessenger(this);          178   messenger = new G4NistMessenger(this);
167   g4pow = G4Pow::GetInstance();                   179   g4pow = G4Pow::GetInstance();
168                                                   180 
169   // compute frequently used values for mean a    181   // compute frequently used values for mean atomic numbers
170   for (G4int j = 1; j < 101; ++j) {               182   for (G4int j = 1; j < 101; ++j) {
171     G4double A = elmBuilder->GetAtomicMassAmu(    183     G4double A = elmBuilder->GetAtomicMassAmu(j);
172     POWERA27[j] = std::pow(A, 0.27);              184     POWERA27[j] = std::pow(A, 0.27);
173     LOGAZ[j] = std::log(A);                       185     LOGAZ[j] = std::log(A);
174   }                                               186   }
175   POWERA27[0] = 1.0;                              187   POWERA27[0] = 1.0;
176   LOGAZ[0] = 0.0;                                 188   LOGAZ[0] = 0.0;
177   fICRU90 = nullptr;                              189   fICRU90 = nullptr;
178 }                                                 190 }
179                                                   191 
180 //....oooOO0OOooo........oooOO0OOooo........oo    192 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
181                                                   193 
182 G4ICRU90StoppingData* G4NistManager::GetICRU90    194 G4ICRU90StoppingData* G4NistManager::GetICRU90StoppingData()
183 {                                                 195 {
184   if (fICRU90 == nullptr) {                       196   if (fICRU90 == nullptr) {
185     G4AutoLock l(&nistManagerMutex);              197     G4AutoLock l(&nistManagerMutex);
186     if (fICRU90 == nullptr) {                     198     if (fICRU90 == nullptr) {
187       fICRU90 = new G4ICRU90StoppingData();       199       fICRU90 = new G4ICRU90StoppingData();
188     }                                             200     }
189     l.unlock();                                   201     l.unlock();
190   }                                               202   }
191   return fICRU90;                                 203   return fICRU90;
192 }                                                 204 }
193                                                   205 
194 //....oooOO0OOooo........oooOO0OOooo........oo    206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195                                                   207 
196 void G4NistManager::SetDensityEffectCalculator    208 void G4NistManager::SetDensityEffectCalculatorFlag(const G4String& mname, G4bool val)
197 {                                                 209 {
198   if (mname == "all") {                           210   if (mname == "all") {
199     for (auto mat : materials) {                  211     for (auto mat : materials) {
200       SetDensityEffectCalculatorFlag(mat, val)    212       SetDensityEffectCalculatorFlag(mat, val);
201     }                                             213     }
202   }                                               214   }
203   else {                                          215   else {
204     G4Material* mat = FindMaterial(mname);        216     G4Material* mat = FindMaterial(mname);
205     SetDensityEffectCalculatorFlag(mat, val);     217     SetDensityEffectCalculatorFlag(mat, val);
206   }                                               218   }
207 }                                                 219 }
208                                                   220 
209 //....oooOO0OOooo........oooOO0OOooo........oo    221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210                                                   222 
211 void G4NistManager::SetDensityEffectCalculator    223 void G4NistManager::SetDensityEffectCalculatorFlag(G4Material* mat, G4bool val)
212 {                                                 224 {
213   if (mat != nullptr) {                           225   if (mat != nullptr) {
214     mat->ComputeDensityEffectOnFly(val);          226     mat->ComputeDensityEffectOnFly(val);
215   }                                               227   }
216 }                                                 228 }
217                                                   229