Geant4 Cross Reference |
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 // >> 27 // $Id: G4Material.cc,v 1.42 2008/08/13 16:06:42 vnivanch Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02 $ >> 29 // >> 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 31 // 26 // 26-06-96, Code uses operators (+=, *=, ++, 32 // 26-06-96, Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban 27 // 10-07-96, new data members added by L.Urban 33 // 10-07-96, new data members added by L.Urban 28 // 12-12-96, new data memberfFreeElecDensitys << 34 // 12-12-96, new data members added by L.Urban 29 // 20-01-97, aesthetic rearrangement. RadLengt 35 // 20-01-97, aesthetic rearrangement. RadLength calculation modified. 30 // Data members Zeff and Aeff REMOVE 36 // Data members Zeff and Aeff REMOVED (i.e. passed to the Elements). 31 // (local definition of Zeff in Dens 37 // (local definition of Zeff in DensityEffect and FluctModel...) 32 // Vacuum defined as a G4State. Mixt << 38 // Vacuum defined as a G4State. Mixture flag removed, M.Maire. 33 // 29-01-97, State=Vacuum automatically set de 39 // 29-01-97, State=Vacuum automatically set density=0 in the contructors. 34 // Subsequent protections have been << 40 // Subsequent protections have been put in the calculation of 35 // MeanExcEnergy, ShellCorrectionVec 41 // MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire. 36 // 11-02-97, ComputeDensityEffect() rearranged 42 // 11-02-97, ComputeDensityEffect() rearranged, M.Maire. 37 // 20-03-97, corrected initialization of point 43 // 20-03-97, corrected initialization of pointers, M.Maire. 38 // 28-05-98, the kState=kVacuum has been remov 44 // 28-05-98, the kState=kVacuum has been removed. 39 // automatic check for a minimal den << 45 // automatic check for a minimal density, M.Maire 40 // 12-06-98, new method AddMaterial() allowing << 46 // 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire 41 // 09-07-98, ionisation parameters removed fro 47 // 09-07-98, ionisation parameters removed from the class, M.Maire 42 // 05-10-98, change names: NumDensity -> NbOfA 48 // 05-10-98, change names: NumDensity -> NbOfAtomsPerVolume 43 // 18-11-98, new interface to SandiaTable 49 // 18-11-98, new interface to SandiaTable 44 // 19-01-99 enlarge tolerance on test of cohe 50 // 19-01-99 enlarge tolerance on test of coherence of gas conditions 45 // 19-07-99, Constructors with chemicalFormula 51 // 19-07-99, Constructors with chemicalFormula added by V.Ivanchenko 46 // 16-01-01, Nuclear interaction length, M.Mai 52 // 16-01-01, Nuclear interaction length, M.Maire 47 // 12-03-01, G4bool fImplicitElement; 53 // 12-03-01, G4bool fImplicitElement; 48 // copy constructor and assignement 54 // copy constructor and assignement operator revised (mma) 49 // 03-05-01, flux.precision(prec) at begin/end 55 // 03-05-01, flux.precision(prec) at begin/end of operator<< 50 // 17-07-01, migration to STL. M. Verderi. 56 // 17-07-01, migration to STL. M. Verderi. 51 // 14-09-01, Suppression of the data member fI 57 // 14-09-01, Suppression of the data member fIndexInTable 52 // 26-02-02, fIndexInTable renewed 58 // 26-02-02, fIndexInTable renewed 53 // 16-04-02, G4Exception put in constructor wi 59 // 16-04-02, G4Exception put in constructor with chemical formula 54 // 06-05-02, remove the check of the ideal gas 60 // 06-05-02, remove the check of the ideal gas state equation 55 // 06-08-02, remove constructors with chemical 61 // 06-08-02, remove constructors with chemical formula (mma) 56 // 22-01-04, proper STL handling of theElement 62 // 22-01-04, proper STL handling of theElementVector (Hisaya) 57 // 30-03-05, warning in GetMaterial(materialNa << 63 // 30-03-05, warning in GetMaterial(materialName) 58 // 09-03-06, minor change of printout (V.Ivanc << 64 // 09-03-06, minor change of printout (V.Ivanchenko) 59 // 10-01-07, compute fAtomVector in the case o << 65 // 10-01-07, compute fAtomVector in the case of mass fraction (V.Ivanchenko) 60 // 27-07-07, improve destructor (V.Ivanchenko) << 66 // 27-07-07, improve destructor (V.Ivanchenko) 61 // 18-10-07, moved definition of mat index to << 67 // 18-10-07, move definition of material index to InitialisePointers (V.Ivanchenko) 62 // 13-08-08, do not use fixed size arrays (V.I << 68 // 13-08-08, do not use fixed size arrays (V.Ivanchenko) 63 // 26-10-11, new scheme for G4Exception (mma) << 69 // 64 // 13-04-12, map<G4Material*,G4double> fMatCom << 65 // 21-04-12, fMassOfMolecule, computed for Ato << 66 70 67 #include "G4Material.hh" << 71 // >> 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 73 69 #include "G4ApplicationState.hh" << 74 #include "G4Material.hh" 70 #include "G4AtomicShells.hh" << 71 #include "G4ExtendedMaterial.hh" << 72 #include "G4Pow.hh" << 73 #include "G4NistManager.hh" << 74 #include "G4PhysicalConstants.hh" << 75 #include "G4StateManager.hh" << 76 #include "G4SystemOfUnits.hh" << 77 #include "G4UnitsTable.hh" 75 #include "G4UnitsTable.hh" 78 << 79 #include <iomanip> 76 #include <iomanip> 80 77 >> 78 >> 79 G4MaterialTable G4Material::theMaterialTable; >> 80 81 //....oooOO0OOooo........oooOO0OOooo........oo 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 82 82 83 // Constructor to create a material from scrat 83 // Constructor to create a material from scratch 84 84 85 G4Material::G4Material(const G4String& name, G << 85 G4Material::G4Material(const G4String& name, G4double z, 86 G4State state, G4double temp, G4double press << 86 G4double a, G4double density, 87 : fName(name) << 87 G4State state, G4double temp, G4double pressure) >> 88 : fName(name) 88 { 89 { 89 InitializePointers(); 90 InitializePointers(); 90 << 91 91 if (density < universe_mean_density) { << 92 if (density < universe_mean_density) 92 G4cout << " G4Material WARNING:" << 93 { G4cerr << "--- Warning from G4Material::G4Material()" 93 << " define a material with density << 94 << " define a material with density=0 is not allowed. \n" 94 << " The material " << name << " wi << 95 << " The material " << name << " will be constructed with the" 95 << " default minimal density: " << << 96 << " default minimal density: " << universe_mean_density/(g/cm3) 96 << G4endl; << 97 << "g/cm3" << G4endl; 97 density = universe_mean_density; << 98 density = universe_mean_density; 98 } << 99 } 99 << 100 100 fDensity = density; << 101 fDensity = density; 101 fState = state; << 102 fState = state; 102 fTemp = temp; << 103 fTemp = temp; 103 fPressure = pressure; 104 fPressure = pressure; >> 105 fChemicalFormula = " "; 104 106 105 // Initialize theElementVector allocating on 107 // Initialize theElementVector allocating one 106 // element corresponding to this material 108 // element corresponding to this material 107 fNbComponents = fNumberOfElements = 1; << 109 maxNbComponents = fNumberOfComponents = fNumberOfElements = 1; 108 theElementVector = new G4ElementVector(); << 110 fArrayLength = maxNbComponents; 109 << 111 fImplicitElement = true; 110 // take element from DB << 112 theElementVector = new G4ElementVector(); 111 G4NistManager* nist = G4NistManager::Instanc << 113 theElementVector->push_back( new G4Element(name, " ", z, a)); 112 G4int iz = G4lrint(z); << 114 fMassFractionVector = new G4double[1]; 113 auto elm = nist->FindOrBuildElement(iz); << 115 fMassFractionVector[0] = 1. ; 114 if (elm == nullptr) { << 116 115 elm = new G4Element("ELM_" + name, name, z << 117 (*theElementVector)[0] -> increaseCountUse(); 116 } << 118 117 theElementVector->push_back(elm); << 119 if (fState == kStateUndefined) 118 << 120 { 119 fMassFractionVector = new G4double[1]; << 121 if (fDensity > kGasThreshold) fState = kStateSolid; 120 fMassFractionVector[0] = 1.; << 122 else fState = kStateGas; 121 fMassOfMolecule = a / CLHEP::Avogadro; << 122 << 123 if (fState == kStateUndefined) { << 124 if (fDensity > kGasThreshold) { << 125 fState = kStateSolid; << 126 } << 127 else { << 128 fState = kStateGas; << 129 } 123 } 130 } << 131 124 132 ComputeDerivedQuantities(); 125 ComputeDerivedQuantities(); 133 } 126 } 134 127 135 //....oooOO0OOooo........oooOO0OOooo........oo 128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 136 129 137 // Constructor to create a material from a Lis 130 // Constructor to create a material from a List of constituents 138 // (elements and/or materials) added with Add 131 // (elements and/or materials) added with AddElement or AddMaterial 139 132 140 G4Material::G4Material(const G4String& name, G << 133 G4Material::G4Material(const G4String& name, G4double density, 141 G4double temp, G4double pressure) << 134 G4int nComponents, 142 : fName(name) << 135 G4State state, G4double temp, G4double pressure) >> 136 : fName(name) 143 { 137 { 144 InitializePointers(); 138 InitializePointers(); 145 << 139 146 if (density < universe_mean_density) { << 140 if (density < universe_mean_density) 147 G4cout << "--- Warning from G4Material::G4 << 141 {G4cerr << "--- Warning from G4Material::G4Material()" 148 << " define a material with density << 142 << " define a material with density=0 is not allowed. \n" 149 << " The material " << name << " wi << 143 << " The material " << name << " will be constructed with the" 150 << " default minimal density: " << << 144 << " default minimal density: " << universe_mean_density/(g/cm3) 151 << G4endl; << 145 << "g/cm3" << G4endl; 152 density = universe_mean_density; << 146 density = universe_mean_density; 153 } << 147 } 154 << 148 155 fDensity = density; << 149 fDensity = density; 156 fState = state; << 150 fState = state; 157 fTemp = temp; << 151 fTemp = temp; 158 fPressure = pressure; 152 fPressure = pressure; 159 << 153 fChemicalFormula = " "; 160 fNbComponents = nComponents; << 154 161 fMassFraction = true; << 155 maxNbComponents = nComponents; 162 << 156 fArrayLength = maxNbComponents; 163 if (fState == kStateUndefined) { << 157 fNumberOfComponents = fNumberOfElements = 0; 164 if (fDensity > kGasThreshold) { << 158 fImplicitElement = false; 165 fState = kStateSolid; << 159 theElementVector = new G4ElementVector(); 166 } << 160 theElementVector->reserve(maxNbComponents); 167 else { << 161 168 fState = kStateGas; << 162 if (fState == kStateUndefined) >> 163 { >> 164 if (fDensity > kGasThreshold) fState = kStateSolid; >> 165 else fState = kStateGas; 169 } 166 } 170 } << 171 } 167 } 172 168 173 //....oooOO0OOooo........oooOO0OOooo........oo 169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 174 170 175 // Constructor to create a material from base << 171 // Fake default constructor - sets only member data and allocates memory >> 172 // for usage restricted to object persistency 176 173 177 G4Material::G4Material(const G4String& name, G << 174 G4Material::G4Material(__void__&) 178 G4State state, G4double temp, G4double press << 175 : fNumberOfComponents(0), fNumberOfElements(0), theElementVector(0), 179 : fName(name) << 176 fImplicitElement(false), fMassFractionVector(0), fAtomsVector(0), >> 177 fMaterialPropertiesTable(0), fIndexInTable(0), >> 178 VecNbOfAtomsPerVolume(0), fIonisation(0), fSandiaTable(0) 180 { 179 { 181 InitializePointers(); << 182 << 183 if (density < universe_mean_density) { << 184 G4cout << "--- Warning from G4Material::G4 << 185 << " define a material with density << 186 << " The material " << name << " wi << 187 << " default minimal density: " << << 188 << G4endl; << 189 density = universe_mean_density; << 190 } << 191 << 192 fDensity = density; << 193 fState = state; << 194 fTemp = temp; << 195 fPressure = pressure; << 196 << 197 fBaseMaterial = bmat; << 198 auto ptr = bmat; << 199 if (nullptr != ptr) { << 200 while (true) { << 201 ptr = ptr->GetBaseMaterial(); << 202 if (nullptr == ptr) { << 203 break; << 204 } << 205 fBaseMaterial = ptr; << 206 } << 207 } << 208 << 209 fChemicalFormula = fBaseMaterial->GetChemica << 210 fMassOfMolecule = fBaseMaterial->GetMassOfMo << 211 << 212 fNumberOfElements = (G4int)fBaseMaterial->Ge << 213 fNbComponents = fNumberOfElements; << 214 << 215 CopyPointersOfBaseMaterial(); << 216 } 180 } 217 181 218 //....oooOO0OOooo........oooOO0OOooo........oo 182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 219 183 220 G4Material::~G4Material() << 184 // AddElement -- composition by atom count 221 { << 222 if (fBaseMaterial == nullptr) { << 223 delete theElementVector; << 224 delete fSandiaTable; << 225 delete[] fMassFractionVector; << 226 delete[] fAtomsVector; << 227 } << 228 delete fIonisation; << 229 delete[] fVecNbOfAtomsPerVolume; << 230 185 231 // Remove this material from the MaterialTab << 186 void G4Material::AddElement(G4Element* element, G4int nAtoms) 232 // << 187 { 233 (*GetMaterialTable())[fIndexInTable] = nullp << 188 // initialization 234 } << 189 if ( fNumberOfElements == 0 ) { 235 << 190 fAtomsVector = new G4int [fArrayLength]; 236 //....oooOO0OOooo........oooOO0OOooo........oo << 191 fMassFractionVector = new G4double[fArrayLength]; 237 << 238 void G4Material::InitializePointers() << 239 { << 240 fBaseMaterial = nullptr; << 241 fMaterialPropertiesTable = nullptr; << 242 theElementVector = nullptr; << 243 fAtomsVector = nullptr; << 244 fMassFractionVector = nullptr; << 245 fVecNbOfAtomsPerVolume = nullptr; << 246 << 247 fIonisation = nullptr; << 248 fSandiaTable = nullptr; << 249 << 250 fDensity = fFreeElecDensity = fTemp = fPress << 251 fTotNbOfAtomsPerVolume = 0.0; << 252 fTotNbOfElectPerVolume = 0.0; << 253 fRadlen = fNuclInterLen = fMassOfMolecule = << 254 << 255 fState = kStateUndefined; << 256 fNumberOfElements = fNbComponents = fIdxComp << 257 fMassFraction = true; << 258 fChemicalFormula = ""; << 259 << 260 // Store in the static Table of Materials << 261 fIndexInTable = GetMaterialTable()->size(); << 262 for (std::size_t i = 0; i < fIndexInTable; + << 263 if ((*GetMaterialTable())[i]->GetName() == << 264 G4cout << "G4Material WARNING: duplicate << 265 break; << 266 } << 267 } 192 } 268 GetMaterialTable()->push_back(this); << 269 } << 270 << 271 //....oooOO0OOooo........oooOO0OOooo........oo << 272 193 273 void G4Material::ComputeDerivedQuantities() << 194 // filling ... 274 { << 195 if ( G4int(fNumberOfElements) < maxNbComponents ) { 275 // Header routine to compute various propert << 196 theElementVector->push_back(element); 276 // << 197 fAtomsVector [fNumberOfElements] = nAtoms; 277 // Number of atoms per volume (per element), << 198 fNumberOfComponents = ++fNumberOfElements; 278 G4double Zi, Ai; << 199 element->increaseCountUse(); 279 fTotNbOfAtomsPerVolume = 0.; << 200 } else { 280 delete[] fVecNbOfAtomsPerVolume; << 201 G4cerr << "G4Material::AddElement ERROR for " << fName << " nElement= " 281 fVecNbOfAtomsPerVolume = new G4double[fNumbe << 202 << fNumberOfElements << G4endl; 282 fTotNbOfElectPerVolume = 0.; << 203 G4Exception 283 fFreeElecDensity = 0.; << 204 ("ERROR!!! - Attempt to add more than the declared number of elements."); 284 const G4double elecTh = 15. * CLHEP::eV; // << 285 for (G4int i = 0; i < fNumberOfElements; ++i << 286 Zi = (*theElementVector)[i]->GetZ(); << 287 Ai = (*theElementVector)[i]->GetA(); << 288 fVecNbOfAtomsPerVolume[i] = Avogadro * fDe << 289 fTotNbOfAtomsPerVolume += fVecNbOfAtomsPer << 290 fTotNbOfElectPerVolume += fVecNbOfAtomsPer << 291 if (fState != kStateGas) { << 292 fFreeElecDensity += << 293 fVecNbOfAtomsPerVolume[i] * G4AtomicSh << 294 } << 295 } 205 } >> 206 // filled. >> 207 if ( G4int(fNumberOfElements) == maxNbComponents ) { >> 208 // compute proportion by mass >> 209 size_t i=0; >> 210 G4double Zmol(0.), Amol(0.); >> 211 for (i=0;i<fNumberOfElements;i++) { >> 212 Zmol += fAtomsVector[i]*(*theElementVector)[i]->GetZ(); >> 213 Amol += fAtomsVector[i]*(*theElementVector)[i]->GetA(); >> 214 } >> 215 for (i=0;i<fNumberOfElements;i++) { >> 216 fMassFractionVector[i] = fAtomsVector[i] >> 217 *(*theElementVector)[i]->GetA()/Amol; >> 218 } 296 219 297 ComputeRadiationLength(); << 220 ComputeDerivedQuantities(); 298 ComputeNuclearInterLength(); << 299 << 300 if (fIonisation == nullptr) { << 301 fIonisation = new G4IonisParamMat(this); << 302 } << 303 if (fSandiaTable == nullptr) { << 304 fSandiaTable = new G4SandiaTable(this); << 305 } 221 } 306 } 222 } 307 223 308 //....oooOO0OOooo........oooOO0OOooo........oo 224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 309 225 310 void G4Material::CopyPointersOfBaseMaterial() << 226 // AddElement -- composition by fraction of mass 311 { << 312 G4double factor = fDensity / fBaseMaterial-> << 313 fTotNbOfAtomsPerVolume = factor * fBaseMater << 314 fTotNbOfElectPerVolume = factor * fBaseMater << 315 fFreeElecDensity = factor * fBaseMaterial->G << 316 << 317 if (fState == kStateUndefined) { << 318 fState = fBaseMaterial->GetState(); << 319 } << 320 << 321 theElementVector = const_cast<G4ElementVecto << 322 fMassFractionVector = const_cast<G4double*>( << 323 fAtomsVector = const_cast<G4int*>(fBaseMater << 324 << 325 const G4double* v = fBaseMaterial->GetVecNbO << 326 delete[] fVecNbOfAtomsPerVolume; << 327 fVecNbOfAtomsPerVolume = new G4double[fNumbe << 328 for (G4int i = 0; i < fNumberOfElements; ++i << 329 fVecNbOfAtomsPerVolume[i] = factor * v[i]; << 330 } << 331 fRadlen = fBaseMaterial->GetRadlen() / facto << 332 fNuclInterLen = fBaseMaterial->GetNuclearInt << 333 227 334 if (fIonisation == nullptr) { << 228 void G4Material::AddElement(G4Element* element, G4double fraction) 335 fIonisation = new G4IonisParamMat(this); << 336 } << 337 fIonisation->SetMeanExcitationEnergy(fBaseMa << 338 if (fBaseMaterial->GetIonisation()->GetDensi << 339 ComputeDensityEffectOnFly(true); << 340 } << 341 << 342 fSandiaTable = fBaseMaterial->GetSandiaTable << 343 fMaterialPropertiesTable = fBaseMaterial->Ge << 344 } << 345 << 346 //....oooOO0OOooo........oooOO0OOooo........oo << 347 << 348 void G4Material::AddElementByNumberOfAtoms(con << 349 { 229 { 350 // perform checks consistency << 230 // initialization 351 if (0 == fIdxComponent) { << 231 if (fNumberOfComponents == 0) { 352 fMassFraction = false; << 232 fMassFractionVector = new G4double[fArrayLength]; 353 fAtoms = new std::vector<G4int>; << 233 fAtomsVector = new G4int [fArrayLength]; 354 fElm = new std::vector<const G4Element*>; << 355 } << 356 if (fIdxComponent >= fNbComponents) { << 357 G4ExceptionDescription ed; << 358 ed << "For material " << fName << " and ad << 359 << " with Natoms=" << nAtoms << 360 << " wrong attempt to add more than the << 361 << " >= " << fNbComponents; << 362 G4Exception("G4Material::AddElementByNumbe << 363 } << 364 if (fMassFraction) { << 365 G4ExceptionDescription ed; << 366 ed << "For material " << fName << " and ad << 367 << " with Natoms=" << nAtoms << " probl << 368 << "addition of elements by mass fracti << 369 G4Exception("G4Material::AddElementByNumbe << 370 } << 371 if (0 >= nAtoms) { << 372 G4ExceptionDescription ed; << 373 ed << "For material " << fName << " and ad << 374 << " with Natoms=" << nAtoms << " probl << 375 G4Exception("G4Material::AddElementByNumbe << 376 } 234 } 377 235 378 // filling << 236 // filling ... 379 G4bool isAdded = false; << 237 if (G4int(fNumberOfComponents) < maxNbComponents) { 380 if (! fElm->empty()) { << 238 size_t el = 0; 381 for (G4int i = 0; i < fNumberOfElements; + << 239 while ((el<fNumberOfElements)&&(element!=(*theElementVector)[el])) el++; 382 if (elm == (*fElm)[i]) { << 240 if (el<fNumberOfElements) fMassFractionVector[el] += fraction; 383 (*fAtoms)[i] += nAtoms; << 241 else { 384 isAdded = true; << 242 theElementVector->push_back(element); 385 break; << 243 fMassFractionVector[el] = fraction; >> 244 fNumberOfElements++; >> 245 element->increaseCountUse(); 386 } 246 } 387 } << 247 fNumberOfComponents++; 388 } << 248 } else { 389 if (! isAdded) { << 249 G4cerr << "G4Material::AddElement ERROR for " << fName << " nElement= " 390 fElm->push_back(elm); << 250 << fNumberOfElements << G4endl; 391 fAtoms->push_back(nAtoms); << 251 G4Exception 392 ++fNumberOfElements; << 252 ("ERROR!!! - Attempt to add more than the declared number of components."); 393 } << 253 } 394 ++fIdxComponent; << 254 395 << 255 // filled. 396 // is filled - complete composition of atoms << 256 if (G4int(fNumberOfComponents) == maxNbComponents) { 397 if (fIdxComponent == fNbComponents) { << 257 398 theElementVector = new G4ElementVector(); << 258 size_t i=0; 399 theElementVector->reserve(fNumberOfElement << 259 G4double Zmol(0.), Amol(0.); 400 fAtomsVector = new G4int[fNumberOfElements << 260 // check sum of weights -- OK? 401 fMassFractionVector = new G4double[fNumber << 261 G4double wtSum(0.0); 402 << 262 for (i=0;i<fNumberOfElements;i++) { 403 G4double Amol = 0.; << 263 wtSum += fMassFractionVector[i]; 404 for (G4int i = 0; i < fNumberOfElements; + << 264 Zmol += fMassFractionVector[i]*(*theElementVector)[i]->GetZ(); 405 theElementVector->push_back((*fElm)[i]); << 265 Amol += fMassFractionVector[i]*(*theElementVector)[i]->GetA(); 406 fAtomsVector[i] = (*fAtoms)[i]; << 266 } 407 G4double w = fAtomsVector[i] * (*fElm)[i << 267 if (std::abs(1.-wtSum) > perThousand) { 408 Amol += w; << 268 G4cerr << "WARNING !! for " << fName << " sum of fractional masses " 409 fMassFractionVector[i] = w; << 269 << wtSum << " is not 1 - results may be wrong" 410 } << 270 << G4endl; 411 for (G4int i = 0; i < fNumberOfElements; + << 271 } 412 fMassFractionVector[i] /= Amol; << 272 for (i=0;i<fNumberOfElements;i++) { 413 } << 273 fAtomsVector[i] = 414 delete fAtoms; << 274 G4int(fMassFractionVector[i]*Amol/(*theElementVector)[i]->GetA()+0.5); 415 delete fElm; << 275 } 416 fMassOfMolecule = Amol / CLHEP::Avogadro; << 276 417 ComputeDerivedQuantities(); << 277 ComputeDerivedQuantities(); 418 } 278 } 419 } 279 } 420 280 421 //....oooOO0OOooo........oooOO0OOooo........oo 281 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 422 282 423 void G4Material::AddElementByMassFraction(cons << 283 // AddMaterial -- composition by fraction of mass 424 { << 425 // perform checks consistency << 426 if (fraction < 0.0 || fraction > 1.0) { << 427 G4ExceptionDescription ed; << 428 ed << "For material " << fName << " and ad << 429 << " massFraction= " << fraction << " i << 430 G4Exception("G4Material::AddElementByMassF << 431 } << 432 if (! fMassFraction) { << 433 G4ExceptionDescription ed; << 434 ed << "For material " << fName << " and ad << 435 << ", massFraction= " << fraction << ", << 436 << " problem: cannot add by mass fracti << 437 << "addition of elements by number of a << 438 G4Exception("G4Material::AddElementByMassF << 439 } << 440 if (fIdxComponent >= fNbComponents) { << 441 G4ExceptionDescription ed; << 442 ed << "For material " << fName << " and ad << 443 << ", massFraction= " << fraction << ", << 444 << "; attempt to add more than the decl << 445 << " >= " << fNbComponents; << 446 G4Exception("G4Material::AddElementByMassF << 447 } << 448 if (0 == fIdxComponent) { << 449 fElmFrac = new std::vector<G4double>; << 450 fElm = new std::vector<const G4Element*>; << 451 } << 452 << 453 // filling << 454 G4bool isAdded = false; << 455 if (! fElm->empty()) { << 456 for (G4int i = 0; i < fNumberOfElements; + << 457 if (elm == (*fElm)[i]) { << 458 (*fElmFrac)[i] += fraction; << 459 isAdded = true; << 460 break; << 461 } << 462 } << 463 } << 464 if (! isAdded) { << 465 fElm->push_back(elm); << 466 fElmFrac->push_back(fraction); << 467 ++fNumberOfElements; << 468 } << 469 ++fIdxComponent; << 470 << 471 // is filled << 472 if (fIdxComponent == fNbComponents) { << 473 FillVectors(); << 474 } << 475 } << 476 << 477 //....oooOO0OOooo........oooOO0OOooo........oo << 478 284 479 // composition by fraction of mass << 480 void G4Material::AddMaterial(G4Material* mater 285 void G4Material::AddMaterial(G4Material* material, G4double fraction) 481 { 286 { 482 if (fraction < 0.0 || fraction > 1.0) { << 287 // initialization 483 G4ExceptionDescription ed; << 288 if (fNumberOfComponents == 0) { 484 ed << "For material " << fName << " and ad << 289 fMassFractionVector = new G4double[fArrayLength]; 485 << ", massFraction= " << fraction << " << 290 fAtomsVector = new G4int [fArrayLength]; 486 G4Exception("G4Material::AddMaterial()", " << 291 } 487 } << 292 488 if (! fMassFraction) { << 293 size_t nelm = material->GetNumberOfElements(); 489 G4ExceptionDescription ed; << 294 490 ed << "For material " << fName << " and ad << 295 // arrays should be extended 491 << ", massFraction= " << fraction << ", << 296 if(nelm > 1) { 492 << " problem: cannot add by mass fracti << 297 G4int nold = fArrayLength; 493 << "addition of elements by number of a << 298 fArrayLength += nelm - 1; 494 G4Exception("G4Material::AddMaterial()", " << 299 G4double* v1 = new G4double[fArrayLength]; 495 } << 300 G4int* i1 = new G4int[fArrayLength]; 496 if (fIdxComponent >= fNbComponents) { << 301 for(G4int i=0; i<nold; i++) { 497 G4ExceptionDescription ed; << 302 v1[i] = fMassFractionVector[i]; 498 ed << "For material " << fName << " and ad << 303 i1[i] = fAtomsVector[i]; 499 << ", massFraction= " << fraction << 304 } 500 << "; attempt to add more than the decl << 305 delete [] fAtomsVector; 501 << " >= " << fNbComponents; << 306 delete [] fMassFractionVector; 502 G4Exception("G4Material::AddMaterial()", " << 307 fMassFractionVector = v1; 503 } << 308 fAtomsVector = i1; 504 if (0 == fIdxComponent) { << 309 } 505 fElmFrac = new std::vector<G4double>; << 310 506 fElm = new std::vector<const G4Element*>; << 311 // filling ... 507 } << 312 if (G4int(fNumberOfComponents) < maxNbComponents) { 508 << 313 for (size_t elm=0; elm<nelm; elm++) 509 // filling << 314 { 510 auto nelm = (G4int)material->GetNumberOfElem << 315 G4Element* element = (*(material->GetElementVector()))[elm]; 511 for (G4int j = 0; j < nelm; ++j) { << 316 size_t el = 0; 512 auto elm = material->GetElement(j); << 317 while ((el<fNumberOfElements)&&(element!=(*theElementVector)[el])) el++; 513 auto frac = material->GetFractionVector(); << 318 if (el < fNumberOfElements) fMassFractionVector[el] += fraction 514 G4bool isAdded = false; << 319 *(material->GetFractionVector())[elm]; 515 if (! fElm->empty()) { << 320 else { 516 for (G4int i = 0; i < fNumberOfElements; << 321 theElementVector->push_back(element); 517 if (elm == (*fElm)[i]) { << 322 fMassFractionVector[el] = fraction 518 (*fElmFrac)[i] += fraction * frac[j] << 323 *(material->GetFractionVector())[elm]; 519 isAdded = true; << 324 fNumberOfElements++; 520 break; << 325 element->increaseCountUse(); 521 } 326 } 522 } << 327 } 523 } << 328 fNumberOfComponents++; 524 if (! isAdded) { << 329 } else { 525 fElm->push_back(elm); << 330 G4cerr << "G4Material::AddElement ERROR for " << fName << " nElement= " 526 fElmFrac->push_back(fraction * frac[j]); << 331 << fNumberOfElements << G4endl; 527 ++fNumberOfElements; << 332 G4Exception 528 } << 333 ("ERROR!!! - Attempt to add more than the declared number of components."); 529 } << 334 } 530 << 335 531 fMatComponents[material] = fraction; << 336 // filled. 532 ++fIdxComponent; << 337 if (G4int(fNumberOfComponents) == maxNbComponents) { 533 << 338 size_t i=0; 534 // is filled << 339 G4double Zmol(0.), Amol(0.); 535 if (fIdxComponent == fNbComponents) { << 340 // check sum of weights -- OK? 536 FillVectors(); << 341 G4double wtSum(0.0); >> 342 for (i=0;i<fNumberOfElements;i++) { >> 343 wtSum += fMassFractionVector[i]; >> 344 Zmol += fMassFractionVector[i]*(*theElementVector)[i]->GetZ(); >> 345 Amol += fMassFractionVector[i]*(*theElementVector)[i]->GetA(); >> 346 } >> 347 if (std::abs(1.-wtSum) > perThousand) { >> 348 G4cerr << "WARNING !! for " << fName << " sum of fractional masses " >> 349 << wtSum << " is not 1 - results may be wrong" >> 350 << G4endl; >> 351 } >> 352 for (i=0;i<fNumberOfElements;i++) { >> 353 fAtomsVector[i] = >> 354 G4int(fMassFractionVector[i]*Amol/(*theElementVector)[i]->GetA()+0.5); >> 355 } >> 356 >> 357 ComputeDerivedQuantities(); 537 } 358 } 538 } 359 } 539 360 540 //....oooOO0OOooo........oooOO0OOooo........oo 361 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 541 362 542 void G4Material::FillVectors() << 363 void G4Material::ComputeDerivedQuantities() 543 { 364 { 544 // there are material components << 365 // Header routine to compute various properties of material. 545 theElementVector = new G4ElementVector(); << 366 // 546 theElementVector->reserve(fNumberOfElements) << 547 fAtomsVector = new G4int[fNumberOfElements]; << 548 fMassFractionVector = new G4double[fNumberOf << 549 << 550 G4double wtSum(0.0); << 551 for (G4int i = 0; i < fNumberOfElements; ++i << 552 theElementVector->push_back((*fElm)[i]); << 553 fMassFractionVector[i] = (*fElmFrac)[i]; << 554 wtSum += fMassFractionVector[i]; << 555 } << 556 delete fElmFrac; << 557 delete fElm; << 558 367 559 // check sum of weights -- OK? << 368 // Number of atoms per volume (per element), total nb of electrons per volume 560 if (std::abs(1. - wtSum) > perThousand) { << 369 G4double Zi, Ai; 561 G4ExceptionDescription ed; << 370 TotNbOfAtomsPerVolume = 0.; 562 ed << "For material " << fName << " sum of << 371 if (VecNbOfAtomsPerVolume) delete [] VecNbOfAtomsPerVolume; 563 << " is not 1 - results may be wrong"; << 372 VecNbOfAtomsPerVolume = new G4double[fNumberOfElements]; 564 G4Exception("G4Material::FillVectors()", " << 373 TotNbOfElectPerVolume = 0.; 565 } << 374 for (size_t i=0;i<fNumberOfElements;i++) { 566 G4double coeff = (wtSum > 0.0) ? 1. / wtSum << 375 Zi = (*theElementVector)[i]->GetZ(); 567 G4double Amol(0.); << 376 Ai = (*theElementVector)[i]->GetA(); 568 for (G4int i = 0; i < fNumberOfElements; ++i << 377 VecNbOfAtomsPerVolume[i] = Avogadro*fDensity*fMassFractionVector[i]/Ai; 569 fMassFractionVector[i] *= coeff; << 378 TotNbOfAtomsPerVolume += VecNbOfAtomsPerVolume[i]; 570 Amol += fMassFractionVector[i] * (*theElem << 379 TotNbOfElectPerVolume += VecNbOfAtomsPerVolume[i]*Zi; 571 } << 572 for (G4int i = 0; i < fNumberOfElements; ++i << 573 fAtomsVector[i] = G4lrint(fMassFractionVec << 574 } 380 } 575 ComputeDerivedQuantities(); << 381 >> 382 ComputeRadiationLength(); >> 383 ComputeNuclearInterLength(); >> 384 >> 385 if (fIonisation) delete fIonisation; >> 386 fIonisation = new G4IonisParamMat(this); >> 387 if (fSandiaTable) delete fSandiaTable; >> 388 fSandiaTable = new G4SandiaTable(this); 576 } 389 } 577 390 578 //....oooOO0OOooo........oooOO0OOooo........oo 391 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 579 392 580 void G4Material::ComputeRadiationLength() 393 void G4Material::ComputeRadiationLength() 581 { 394 { 582 G4double radinv = 0.0; << 395 G4double radinv = 0.0 ; 583 for (G4int i = 0; i < fNumberOfElements; ++i << 396 for (size_t i=0;i<fNumberOfElements;i++) { 584 radinv += fVecNbOfAtomsPerVolume[i] * ((*t << 397 radinv += VecNbOfAtomsPerVolume[i]*((*theElementVector)[i]->GetfRadTsai()); 585 } << 398 } 586 fRadlen = (radinv <= 0.0 ? DBL_MAX : 1. / ra << 399 fRadlen = (radinv <= 0.0 ? DBL_MAX : 1./radinv); 587 } 400 } 588 401 589 //....oooOO0OOooo........oooOO0OOooo........oo 402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 590 403 591 void G4Material::ComputeNuclearInterLength() 404 void G4Material::ComputeNuclearInterLength() 592 { 405 { 593 const G4double lambda1 = CLHEP::amu*CLHEP::c << 406 const G4double lambda0 = 35*g/cm2; 594 G4double NILinv = 0.0; 407 G4double NILinv = 0.0; 595 for (G4int i = 0; i < fNumberOfElements; ++i << 408 for (size_t i=0;i<fNumberOfElements;i++) { 596 G4int Z = (*theElementVector)[i]->GetZasIn << 409 NILinv += 597 G4double A = (*theElementVector)[i]->GetN( << 410 VecNbOfAtomsPerVolume[i]*std::pow(((*theElementVector)[i]->GetN()),0.6666667); 598 if (1 == Z) { << 411 } 599 NILinv += fVecNbOfAtomsPerVolume[i] * A; << 412 NILinv *= amu/lambda0; 600 } << 413 fNuclInterLen = (NILinv <= 0.0 ? DBL_MAX : 1./NILinv); 601 else { << 602 NILinv += fVecNbOfAtomsPerVolume[i] * G4 << 603 } << 604 } << 605 NILinv *= lambda1; << 606 fNuclInterLen = 1.e+20*CLHEP::m; << 607 if (fNuclInterLen * NILinv > 1.0) { << 608 fNuclInterLen = 1.0 / NILinv; << 609 } << 610 } 414 } 611 415 612 //....oooOO0OOooo........oooOO0OOooo........oo 416 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 613 417 614 void G4Material::SetChemicalFormula(const G4St << 418 void G4Material::InitializePointers() 615 { 419 { 616 if (! IsLocked()) { << 420 theElementVector = 0; 617 fChemicalFormula = chF; << 421 fMassFractionVector = 0; 618 } << 422 fAtomsVector = 0; 619 } << 423 fMaterialPropertiesTable = 0; 620 << 424 621 //....oooOO0OOooo........oooOO0OOooo........oo << 425 VecNbOfAtomsPerVolume = 0; >> 426 fIonisation = 0; >> 427 fSandiaTable = 0; 622 428 623 void G4Material::SetFreeElectronDensity(G4doub << 429 // Store in the static Table of Materials 624 { << 430 theMaterialTable.push_back(this); 625 if (val >= 0. && ! IsLocked()) { << 431 fIndexInTable = theMaterialTable.size() - 1; 626 fFreeElecDensity = val; << 627 } << 628 } 432 } 629 433 630 //....oooOO0OOooo........oooOO0OOooo........oo 434 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 631 435 632 void G4Material::ComputeDensityEffectOnFly(G4b << 436 const G4MaterialTable* G4Material::GetMaterialTable() 633 { 437 { 634 if (! IsLocked()) { << 438 return &theMaterialTable; 635 if (nullptr == fIonisation) { << 636 fIonisation = new G4IonisParamMat(this); << 637 } << 638 fIonisation->ComputeDensityEffectOnFly(val << 639 } << 640 } 439 } 641 440 642 //....oooOO0OOooo........oooOO0OOooo........oo 441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 643 442 644 G4MaterialTable* G4Material::GetMaterialTable( << 443 size_t G4Material::GetNumberOfMaterials() 645 { 444 { 646 struct Holder { << 445 return theMaterialTable.size(); 647 G4MaterialTable instance; << 648 ~Holder() { << 649 for(auto item : instance) << 650 delete item; << 651 } << 652 }; << 653 static Holder _holder; << 654 return &_holder.instance; << 655 } 446 } 656 447 657 //....oooOO0OOooo........oooOO0OOooo........oo 448 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 658 449 659 std::size_t G4Material::GetNumberOfMaterials() << 450 G4Material* G4Material::GetMaterial(G4String materialName, G4bool warning) >> 451 { >> 452 // search the material by its name >> 453 for (size_t J=0 ; J<theMaterialTable.size() ; J++) >> 454 { >> 455 if (theMaterialTable[J]->GetName() == materialName) >> 456 return theMaterialTable[J]; >> 457 } >> 458 >> 459 // the material does not exist in the table >> 460 if (warning) { >> 461 G4cout << "\n---> warning from G4Material::GetMaterial(). The material: " >> 462 << materialName << " does not exist in the table. Return NULL pointer." >> 463 << G4endl; >> 464 } >> 465 return 0; >> 466 } 660 467 661 //....oooOO0OOooo........oooOO0OOooo........oo 468 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 662 469 663 G4Material* G4Material::GetMaterial(const G4St << 470 G4Material::G4Material(const G4Material& right) 664 { 471 { 665 // search the material by its name << 472 InitializePointers(); 666 for (auto const & j : *GetMaterialTable()) { << 473 *this = right; 667 if (j->GetName() == materialName) { << 668 return j; << 669 } << 670 } << 671 << 672 // the material does not exist in the table << 673 if (warn) { << 674 G4cout << "G4Material::GetMaterial() WARNI << 675 << " does not exist in the table. R << 676 } << 677 return nullptr; << 678 } 474 } 679 475 680 //....oooOO0OOooo........oooOO0OOooo........oo 476 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 681 477 682 G4Material* G4Material::GetMaterial(G4double z << 478 G4Material::~G4Material() 683 { 479 { 684 // search the material by its name << 480 // G4cout << "### Destruction of material " << fName << " started" <<G4endl; 685 for (auto const & mat : *GetMaterialTable()) << 481 if (theElementVector) delete theElementVector; 686 if (1 == mat->GetNumberOfElements() && z = << 482 if (fMassFractionVector) delete [] fMassFractionVector; 687 dens == mat->GetDensity()) << 483 if (fAtomsVector) delete [] fAtomsVector; 688 { << 484 if (VecNbOfAtomsPerVolume) delete [] VecNbOfAtomsPerVolume; 689 return mat; << 485 if (fIonisation) delete fIonisation; 690 } << 486 if (fSandiaTable) delete fSandiaTable; 691 } << 487 692 return nullptr; << 488 // Remove this material from theMaterialTable. >> 489 // >> 490 theMaterialTable[fIndexInTable] = 0; 693 } 491 } 694 492 695 //....oooOO0OOooo........oooOO0OOooo........oo 493 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 696 494 697 G4Material* G4Material::GetMaterial(std::size_ << 495 const G4Material& G4Material::operator=(const G4Material& right) 698 { 496 { 699 // search the material by its name << 497 if (this != &right) 700 for (auto const & mat : *GetMaterialTable()) << 498 { 701 if (nComp == mat->GetNumberOfElements() && << 499 fName = right.fName; 702 return mat; << 500 fChemicalFormula = right.fChemicalFormula; 703 } << 501 fDensity = right.fDensity; 704 } << 502 fState = right.fState; 705 return nullptr; << 503 fTemp = right.fTemp; >> 504 fPressure = right.fPressure; >> 505 >> 506 if (fImplicitElement) delete ((*theElementVector)[0]); >> 507 if (theElementVector) delete theElementVector; >> 508 if (fMassFractionVector) delete [] fMassFractionVector; >> 509 if (fAtomsVector) delete [] fAtomsVector; >> 510 >> 511 maxNbComponents = right.maxNbComponents; >> 512 fNumberOfComponents = right.fNumberOfComponents; >> 513 fNumberOfElements = right.fNumberOfElements; >> 514 fImplicitElement = right.fImplicitElement; >> 515 >> 516 if (fImplicitElement) { >> 517 G4double z = (*right.theElementVector)[0]->GetZ(); >> 518 G4double a = (*right.theElementVector)[0]->GetA(); >> 519 theElementVector = new G4ElementVector(1,(G4Element*)0); >> 520 (*theElementVector)[0] = new G4Element(fName," ",z,a); >> 521 fMassFractionVector = new G4double[1]; >> 522 fMassFractionVector[0] = 1.; >> 523 } else { >> 524 theElementVector = new G4ElementVector(fNumberOfElements,0); >> 525 fMassFractionVector = new G4double[fNumberOfElements]; >> 526 for (size_t i=0; i<fNumberOfElements; i++) { >> 527 (*theElementVector)[i]= (*right.theElementVector)[i]; >> 528 fMassFractionVector[i]= right.fMassFractionVector[i]; >> 529 } >> 530 } >> 531 >> 532 if (right.fAtomsVector) { >> 533 fAtomsVector = new G4int[fNumberOfElements]; >> 534 for (size_t i=0; i<fNumberOfElements; i++) >> 535 fAtomsVector[i] = right.fAtomsVector[i]; >> 536 } >> 537 >> 538 fMaterialPropertiesTable = right.fMaterialPropertiesTable; >> 539 >> 540 ComputeDerivedQuantities(); >> 541 } >> 542 return *this; 706 } 543 } 707 544 708 //....oooOO0OOooo........oooOO0OOooo........oo 545 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 709 546 710 G4double G4Material::GetZ() const << 547 G4int G4Material::operator==(const G4Material& right) const 711 { 548 { 712 if (fNumberOfElements > 1) { << 549 return (this == (G4Material *) &right); 713 G4ExceptionDescription ed; << 714 ed << "For material " << fName << " ERROR << 715 << " > 1, which is not allowed"; << 716 G4Exception("G4Material::GetZ()", "mat036" << 717 } << 718 return (*theElementVector)[0]->GetZ(); << 719 } 550 } 720 551 721 //....oooOO0OOooo........oooOO0OOooo........oo 552 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 722 553 723 G4double G4Material::GetA() const << 554 G4int G4Material::operator!=(const G4Material& right) const 724 { 555 { 725 if (fNumberOfElements > 1) { << 556 return (this != (G4Material *) &right); 726 G4ExceptionDescription ed; << 727 ed << "For material " << fName << " ERROR << 728 << " > 1, which is not allowed"; << 729 G4Exception("G4Material::GetA()", "mat036" << 730 } << 731 return (*theElementVector)[0]->GetA(); << 732 } 557 } 733 558 734 //....oooOO0OOooo........oooOO0OOooo........oo 559 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 735 560 736 std::ostream& operator<<(std::ostream& flux, c << 561 >> 562 std::ostream& operator<<(std::ostream& flux, G4Material* material) 737 { 563 { 738 std::ios::fmtflags mode = flux.flags(); 564 std::ios::fmtflags mode = flux.flags(); 739 flux.setf(std::ios::fixed, std::ios::floatfi << 565 flux.setf(std::ios::fixed,std::ios::floatfield); 740 G4long prec = flux.precision(3); 566 G4long prec = flux.precision(3); 741 << 567 742 flux << " Material: " << std::setw(8) << mat << 568 flux 743 << " " << 569 << " Material: " << std::setw(8) << material->fName 744 << " density: " << std::setw(6) << std << 570 << " " << material->fChemicalFormula << " " 745 << G4BestUnit(material->fDensity, "Volu << 571 << " density: " << std::setw(6) << std::setprecision(3) 746 << std::setprecision(3) << G4BestUnit(m << 572 << G4BestUnit(material->fDensity,"Volumic Mass") 747 << " Nucl.Int.Length: " << std::setw(7 << 573 << " RadL: " << std::setw(7) << std::setprecision(3) 748 << G4BestUnit(material->fNuclInterLen, << 574 << G4BestUnit(material->fRadlen,"Length") 749 << std::setw(30) << " Imean: " << std: << 575 << " Nucl.Int.Length: " << std::setw(7) << std::setprecision(3) 750 << G4BestUnit(material->GetIonisation() << 576 << G4BestUnit(material->fNuclInterLen,"Length") 751 << " temperature: " << std::setw(6) << << 577 << " Imean: " << std::setw(7) << std::setprecision(3) 752 << (material->fTemp) / CLHEP::kelvin << << 578 << G4BestUnit(material->GetIonisation()->GetMeanExcitationEnergy(),"Energy"); 753 << " pressure: " << std::setw(6) << st << 579 754 << (material->fPressure) / CLHEP::atmos << 580 if(material->fState == kStateGas) 755 << "\n"; << 581 flux 756 << 582 << " temperature: " << std::setw(6) << std::setprecision(2) 757 for (G4int i = 0; i < material->fNumberOfEle << 583 << (material->fTemp)/kelvin << " K" 758 flux << "\n ---> " << (*(material->theEl << 584 << " pressure: " << std::setw(6) << std::setprecision(2) 759 << "\n ElmMassFraction: " << << 585 << (material->fPressure)/atmosphere << " atm"; 760 << (material->fMassFractionVector[i]) << 586 761 << " ElmAbundance " << std::setw(6) << 587 for (size_t i=0; i<material->fNumberOfElements; i++) 762 << 100 * (material->fVecNbOfAtomsPerV << 588 flux 763 << " % \n"; << 589 << "\n ---> " << (*(material->theElementVector))[i] 764 } << 590 << " ElmMassFraction: " << std::setw(6)<< std::setprecision(2) 765 flux.precision(prec); << 591 << (material->fMassFractionVector[i])/perCent << " %" 766 flux.setf(mode, std::ios::floatfield); << 592 << " ElmAbundance " << std::setw(6)<< std::setprecision(2) 767 << 593 << 100*(material->VecNbOfAtomsPerVolume[i])/(material->TotNbOfAtomsPerVolume) 768 if (material->IsExtended()) { << 594 << " %"; 769 static_cast<const G4ExtendedMaterial*>(mat << 595 770 } << 596 flux.precision(prec); 771 << 597 flux.setf(mode,std::ios::floatfield); >> 598 772 return flux; 599 return flux; 773 } 600 } 774 601 775 //....oooOO0OOooo........oooOO0OOooo........oo 602 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 776 603 777 std::ostream& operator<<(std::ostream& flux, c << 604 std::ostream& operator<<(std::ostream& flux, G4Material& material) 778 { 605 { 779 flux << &material; << 606 flux << &material; 780 return flux; 607 return flux; 781 } 608 } 782 609 783 //....oooOO0OOooo........oooOO0OOooo........oo 610 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 784 << 611 785 std::ostream& operator<<(std::ostream& flux, c << 612 std::ostream& operator<<(std::ostream& flux, G4MaterialTable MaterialTable) 786 { 613 { 787 // Dump info for all known materials << 614 //Dump info for all known materials 788 flux << "\n***** Table : Nb of materials = " << 615 flux << "\n***** Table : Nb of materials = " << MaterialTable.size() 789 << 616 << " *****\n" << G4endl; 790 for (auto i : MaterialTable) { << 617 791 flux << i << G4endl << G4endl; << 618 for (size_t i=0; i<MaterialTable.size(); i++) flux << MaterialTable[i] 792 } << 619 << G4endl << G4endl; 793 << 794 return flux; << 795 } << 796 620 797 //....oooOO0OOooo........oooOO0OOooo........oo << 621 return flux; 798 << 622 } 799 G4bool G4Material::IsExtended() const { return << 800 623 801 //....oooOO0OOooo........oooOO0OOooo........oo 624 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 802 << 803 void G4Material::SetMaterialPropertiesTable(G4 << 804 { << 805 if (fMaterialPropertiesTable != anMPT && ! I << 806 delete fMaterialPropertiesTable; << 807 fMaterialPropertiesTable = anMPT; << 808 } << 809 } << 810 << 811 //....oooOO0OOooo........oooOO0OOooo........oo << 812 << 813 G4bool G4Material::IsLocked() << 814 { << 815 auto state = G4StateManager::GetStateManager << 816 return state != G4State_PreInit && state != << 817 } << 818 625