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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 9.0.p2)


  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 // $Id: G4NistManager.cc,v 1.9 2007/05/02 10:48:52 vnivanch Exp $
                                                   >>  27 // GEANT4 tag $Name: geant4-09-00-patch-01 $
                                                   >>  28 //
 26 // -------------------------------------------     29 // -------------------------------------------------------------------
 27 //                                                 30 //
 28 // GEANT4 Class file                               31 // GEANT4 Class file
 29 //                                                 32 //
 30 //                                                 33 //
 31 // File name:     G4NistManager                    34 // File name:     G4NistManager
 32 //                                                 35 //
 33 // Author:        Vladimir Ivanchenko              36 // Author:        Vladimir Ivanchenko
 34 //                                                 37 //
 35 // Creation date: 23.12.2004                       38 // Creation date: 23.12.2004
 36 //                                                 39 //
                                                   >>  40 // Modifications:
                                                   >>  41 // 27.02.06 V.Ivanchneko add ConstructNewGasMaterial
                                                   >>  42 // 18.04.06 V.Ivanchneko add combined creation of materials (NIST + user)
                                                   >>  43 // 11.05.06 V.Ivanchneko add warning flag to FindMaterial method
 37 //                                                 44 //
 38 // -------------------------------------------     45 // -------------------------------------------------------------------
 39 //                                                 46 //
 40 // Class Description:                              47 // Class Description:
 41 //                                                 48 //
 42 // Element data from the NIST DB on Atomic Wei     49 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
 43 // http://physics.nist.gov/PhysRefData/Composi     50 // http://physics.nist.gov/PhysRefData/Compositions/index.html
                                                   >>  51 //
                                                   >>  52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 44                                                    54 
 45 #include "G4NistManager.hh"                        55 #include "G4NistManager.hh"
 46 #include "G4AutoLock.hh"                       <<  56 
                                                   >>  57 #include "G4NistMaterialBuilder.hh"
 47 #include "G4NistMessenger.hh"                      58 #include "G4NistMessenger.hh"
 48                                                    59 
                                                   >>  60 G4NistManager* G4NistManager::instance = 0;
                                                   >>  61 
                                                   >>  62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
 49                                                    63 
 50 namespace                                      <<  64 G4NistManager* G4NistManager::Instance()
 51 {                                                  65 {
 52 G4Mutex nistManagerMutex = G4MUTEX_INITIALIZER <<  66   if (instance == 0) {
                                                   >>  67     static G4NistManager manager;
                                                   >>  68     instance = &manager;
                                                   >>  69   }
                                                   >>  70   return instance;
 53 }                                                  71 }
 54                                                    72 
 55 //....oooOO0OOooo........oooOO0OOooo........oo <<  73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 56                                                    74 
 57 G4NistManager* G4NistManager::Instance()       <<  75 G4NistManager::G4NistManager()
 58 {                                                  76 {
 59   static G4NistManager manager;                <<  77   nElements  = 0;
 60   return &manager;                             <<  78   nMaterials = 0;
                                                   >>  79   verbose    = 0;
                                                   >>  80 
                                                   >>  81   elmBuilder = new G4NistElementBuilder(verbose);
                                                   >>  82   matBuilder = new G4NistMaterialBuilder(this,elmBuilder,verbose);
                                                   >>  83   
                                                   >>  84   messenger  = new G4NistMessenger(this);  
 61 }                                                  85 }
 62                                                    86 
 63 //....oooOO0OOooo........oooOO0OOooo........oo     87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 64                                                    88 
 65 G4NistManager::~G4NistManager()                    89 G4NistManager::~G4NistManager()
 66 {                                                  90 {
                                                   >>  91   for (size_t i=0; i<nMaterials; i++) {
                                                   >>  92     if( materials[i] ) delete materials[i];
                                                   >>  93   }
                                                   >>  94   for (size_t j=0; j<nElements; j++) {
                                                   >>  95     if( elements[j] ) delete elements[j];
                                                   >>  96   }
                                                   >>  97   
 67   delete messenger;                                98   delete messenger;
 68   delete matBuilder;                               99   delete matBuilder;
 69   delete elmBuilder;                              100   delete elmBuilder;
 70   delete fICRU90;                              << 101   
 71 }                                                 102 }
 72                                                   103 
 73 //....oooOO0OOooo........oooOO0OOooo........oo    104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 74                                                   105 
 75 G4Material* G4NistManager::BuildMaterialWithNe << 106 void G4NistManager::RegisterElement(G4Element* elm)
 76   const G4String& basename, G4double density,  << 
 77 {                                                 107 {
 78   G4Material* bmat = FindOrBuildMaterial(name) << 108   if(elm) {
 79   if (bmat != nullptr) {                       << 109     elements.push_back(elm);
 80     G4cout << "G4NistManager::BuildMaterialWit << 110     nElements++;
 81     G4cout << " New material <" << name << ">  << 
 82            << " with the same name already exi << 
 83     G4Exception("G4NistManager::BuildMaterialW << 
 84       "Wrong material name");                  << 
 85     return nullptr;                            << 
 86   }                                            << 
 87   bmat = FindOrBuildMaterial(basename);        << 
 88   if (bmat == nullptr) {                       << 
 89     G4cout << "G4NistManager::BuildMaterialWit << 
 90     G4cout << " New material <" << name << ">  << 
 91     G4cout << " base material <" << basename < << 
 92     G4Exception("G4NistManager::BuildMaterialW << 
 93       "Wrong material name");                  << 
 94     return nullptr;                            << 
 95   }                                            << 
 96   G4double dens = density;                     << 
 97   G4double temp = temperature;                 << 
 98   G4double pres = pressure;                    << 
 99   if (dens == 0.0) {                           << 
100     dens = bmat->GetDensity();                 << 
101     temp = bmat->GetTemperature();             << 
102     pres = bmat->GetPressure();                << 
103   }                                               111   }
104   auto mat = new G4Material(name, dens, bmat,  << 
105   return mat;                                  << 
106 }                                                 112 }
107                                                   113 
108 //....oooOO0OOooo........oooOO0OOooo........oo    114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109                                                   115 
110 void G4NistManager::PrintElement(const G4Strin << 116 void G4NistManager::DeRegisterElement(G4Element* elm)
111 {                                                 117 {
112   if (symbol == "all") {                       << 118   for(size_t i=0; i<nElements; i++) {
113     elmBuilder->PrintElement(0);               << 119     if(elm == elements[i]) {
114   }                                            << 120       elements[i] = 0;
115   else {                                       << 121       return;
116     elmBuilder->PrintElement(elmBuilder->GetZ( << 122     }
117   }                                               123   }
118 }                                                 124 }
119                                                   125 
120 //....oooOO0OOooo........oooOO0OOooo........oo    126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121                                                   127 
122 void G4NistManager::PrintG4Element(const G4Str << 128 void G4NistManager::PrintElement(const G4String& symbol)
                                                   >> 129 {
                                                   >> 130   if (symbol == "all") elmBuilder->PrintElement(0);
                                                   >> 131   else                 elmBuilder->PrintElement(elmBuilder->GetZ(symbol));
                                                   >> 132 }
                                                   >> 133 
                                                   >> 134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 135 
                                                   >> 136 void G4NistManager::PrintElement(G4int Z)
123 {                                                 137 {
124   for (auto const & elm : *G4Element::GetEleme << 138   elmBuilder->PrintElement(Z);
125     if (name == elm->GetName() || "all" == nam << 139 }
126       G4cout << *elm << G4endl;                << 140 
                                                   >> 141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 142 
                                                   >> 143 void G4NistManager::PrintG4Element(const G4String& name)
                                                   >> 144 {
                                                   >> 145  for (size_t i=0; i<nElements; i++) {
                                                   >> 146   if ((name==(elements[i])->GetName()) || (name==(elements[i])->GetSymbol())) {
                                                   >> 147      G4cout << *(elements[i]) << G4endl;
                                                   >> 148      return;
127     }                                             149     }
128   }                                               150   }
129 }                                                 151 }
130                                                   152 
131 //....oooOO0OOooo........oooOO0OOooo........oo    153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132                                                   154 
133 void G4NistManager::PrintG4Material(const G4St << 155 void G4NistManager::RegisterMaterial(G4Material* mat)
134 {                                                 156 {
135   for (auto const & mat : *G4Material::GetMate << 157   if(mat) {
136     if (name == mat->GetName() || "all" == nam << 158     materials.push_back(mat);
137       G4cout << *mat << G4endl;                << 159     nMaterials++;
138     }                                          << 
139   }                                               160   }
140 }                                                 161 }
141                                                   162 
142 //....oooOO0OOooo........oooOO0OOooo........oo    163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143                                                   164 
144 void G4NistManager::SetVerbose(G4int val)      << 165 void G4NistManager::DeRegisterMaterial(G4Material* mat)
145 {                                                 166 {
146   verbose = val;                               << 167   for (size_t i=0; i<nMaterials; i++) {
147   elmBuilder->SetVerbose(val);                 << 168     if (mat == materials[i]) { materials[i] = 0; return; }
148   matBuilder->SetVerbose(val);                 << 169   }
149 }                                                 170 }
150                                                   171 
151 //....oooOO0OOooo........oooOO0OOooo........oo    172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152                                                   173 
153 G4NistManager::G4NistManager()                 << 174 G4Material* G4NistManager::FindOrBuildMaterial(const G4String& name,
                                                   >> 175                  G4bool isotopes,
                                                   >> 176                  G4bool warning)
154 {                                                 177 {
155   nElements = 0;                               << 178   if (verbose>1) G4cout << "G4NistManager::FindMaterial " << name 
156   nMaterials = 0;                              << 179                         << G4endl;
157   verbose = 0;                                 << 
158                                                   180 
159   theMaterialTable = G4Material::GetMaterialTa << 181   // search the material in the list of user 
160   theElementTable = G4Element::GetElementTable << 182   G4Material* mat =  G4Material::GetMaterial(name, warning);
161   theIsotopeTable = G4Isotope::GetIsotopeTable << 
162                                                   183 
163   elmBuilder = new G4NistElementBuilder(verbos << 184   if (!mat) mat = matBuilder->FindOrBuildMaterial(name, isotopes, warning);  
164   matBuilder = new G4NistMaterialBuilder(elmBu << 185   return mat;
                                                   >> 186 }
                                                   >> 187 
                                                   >> 188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165                                                   189 
166   messenger = new G4NistMessenger(this);       << 190 G4Material* G4NistManager::ConstructNewMaterial(
167   g4pow = G4Pow::GetInstance();                << 191                                       const G4String& name,
                                                   >> 192                                       const std::vector<G4String>& elm,
                                                   >> 193                                       const std::vector<G4int>& nbAtoms,
                                                   >> 194               G4double dens, G4bool isotopes)
                                                   >> 195 {
                                                   >> 196   return matBuilder->ConstructNewMaterial(name,elm,nbAtoms,dens,isotopes);
                                                   >> 197 }
168                                                   198 
169   // compute frequently used values for mean a << 199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170   for (G4int j = 1; j < 101; ++j) {            << 200 
171     G4double A = elmBuilder->GetAtomicMassAmu( << 201 G4Material* G4NistManager::ConstructNewMaterial(
172     POWERA27[j] = std::pow(A, 0.27);           << 202                                       const G4String& name,
173     LOGAZ[j] = std::log(A);                    << 203                                       const std::vector<G4String>& elm,
174   }                                            << 204                                       const std::vector<G4double>& w,
175   POWERA27[0] = 1.0;                           << 205               G4double dens, G4bool isotopes)
176   LOGAZ[0] = 0.0;                              << 206 {
177   fICRU90 = nullptr;                           << 207   return matBuilder->ConstructNewMaterial(name,elm,w,dens,isotopes);
178 }                                                 208 }
179                                                   209 
180 //....oooOO0OOooo........oooOO0OOooo........oo    210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
181                                                   211 
182 G4ICRU90StoppingData* G4NistManager::GetICRU90 << 212 G4Material* G4NistManager::ConstructNewGasMaterial(
                                                   >> 213               const G4String& name,
                                                   >> 214                                       const G4String& nameNist,
                                                   >> 215               G4double temp, G4double pres, 
                                                   >> 216               G4bool isotopes)
183 {                                                 217 {
184   if (fICRU90 == nullptr) {                    << 218   return matBuilder->ConstructNewGasMaterial(name,nameNist,
185     G4AutoLock l(&nistManagerMutex);           << 219                temp,pres,isotopes);
186     if (fICRU90 == nullptr) {                  << 
187       fICRU90 = new G4ICRU90StoppingData();    << 
188     }                                          << 
189     l.unlock();                                << 
190   }                                            << 
191   return fICRU90;                              << 
192 }                                                 220 }
193                                                   221 
194 //....oooOO0OOooo........oooOO0OOooo........oo    222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195                                                   223 
196 void G4NistManager::SetDensityEffectCalculator << 224 void G4NistManager::ListMaterials(const G4String& list)
197 {                                                 225 {
198   if (mname == "all") {                        << 226   matBuilder->ListMaterials(list);
199     for (auto mat : materials) {               << 227 }
200       SetDensityEffectCalculatorFlag(mat, val) << 228 
                                                   >> 229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 230 
                                                   >> 231 void G4NistManager::PrintG4Material(const G4String& name)
                                                   >> 232 {
                                                   >> 233   for (size_t i=0; i<nMaterials; i++) {
                                                   >> 234     if (name == (materials[i])->GetName()) {
                                                   >> 235       G4cout << *(materials[i]) << G4endl;
                                                   >> 236       return;
201     }                                             237     }
202   }                                               238   }
203   else {                                       << 239   // search the material in the list of user 
204     G4Material* mat = FindMaterial(mname);     << 240   G4Material* mat =  G4Material::GetMaterial(name, true);
205     SetDensityEffectCalculatorFlag(mat, val);  << 241   if(mat) G4cout << *mat << G4endl;
206   }                                            << 
207 }                                                 242 }
208                                                   243 
209 //....oooOO0OOooo........oooOO0OOooo........oo    244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210                                                   245 
211 void G4NistManager::SetDensityEffectCalculator << 246 void G4NistManager::SetVerbose(G4int val)
212 {                                                 247 {
213   if (mat != nullptr) {                        << 248   verbose = val;
214     mat->ComputeDensityEffectOnFly(val);       << 249   elmBuilder->SetVerbose(val);
215   }                                            << 250   matBuilder->SetVerbose(val);
216 }                                                 251 }
                                                   >> 252 
                                                   >> 253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 254 
                                                   >> 255 const std::vector<G4String>& G4NistManager::GetNistMaterialNames() const
                                                   >> 256 {
                                                   >> 257   return matBuilder->GetMaterialNames();
                                                   >> 258 }
                                                   >> 259 
                                                   >> 260 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217                                                   261