Geant4-11
G4Material.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
28//
29// 26-06-96, Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban
30// 10-07-96, new data members added by L.Urban
31// 12-12-96, new data members added by L.Urban
32// 20-01-97, aesthetic rearrangement. RadLength calculation modified.
33// Data members Zeff and Aeff REMOVED (i.e. passed to the Elements).
34// (local definition of Zeff in DensityEffect and FluctModel...)
35// Vacuum defined as a G4State. Mixture flag removed, M.Maire.
36// 29-01-97, State=Vacuum automatically set density=0 in the contructors.
37// Subsequent protections have been put in the calculation of
38// MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire.
39// 11-02-97, ComputeDensityEffect() rearranged, M.Maire.
40// 20-03-97, corrected initialization of pointers, M.Maire.
41// 28-05-98, the kState=kVacuum has been removed.
42// automatic check for a minimal density, M.Maire
43// 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire
44// 09-07-98, ionisation parameters removed from the class, M.Maire
45// 05-10-98, change names: NumDensity -> NbOfAtomsPerVolume
46// 18-11-98, new interface to SandiaTable
47// 19-01-99 enlarge tolerance on test of coherence of gas conditions
48// 19-07-99, Constructors with chemicalFormula added by V.Ivanchenko
49// 16-01-01, Nuclear interaction length, M.Maire
50// 12-03-01, G4bool fImplicitElement;
51// copy constructor and assignement operator revised (mma)
52// 03-05-01, flux.precision(prec) at begin/end of operator<<
53// 17-07-01, migration to STL. M. Verderi.
54// 14-09-01, Suppression of the data member fIndexInTable
55// 26-02-02, fIndexInTable renewed
56// 16-04-02, G4Exception put in constructor with chemical formula
57// 06-05-02, remove the check of the ideal gas state equation
58// 06-08-02, remove constructors with chemical formula (mma)
59// 22-01-04, proper STL handling of theElementVector (Hisaya)
60// 30-03-05, warning in GetMaterial(materialName)
61// 09-03-06, minor change of printout (V.Ivanchenko)
62// 10-01-07, compute fAtomVector in the case of mass fraction (V.Ivanchenko)
63// 27-07-07, improve destructor (V.Ivanchenko)
64// 18-10-07, moved definition of mat index to InitialisePointers (V.Ivanchenko)
65// 13-08-08, do not use fixed size arrays (V.Ivanchenko)
66// 26-10-11, new scheme for G4Exception (mma)
67// 13-04-12, map<G4Material*,G4double> fMatComponents, filled in AddMaterial()
68// 21-04-12, fMassOfMolecule, computed for AtomsCount (mma)
69//
70//
71//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72
73#include <iomanip>
74
75#include "G4Material.hh"
76#include "G4NistManager.hh"
77#include "G4UnitsTable.hh"
79#include "G4SystemOfUnits.hh"
80#include "G4Exp.hh"
81#include "G4Log.hh"
82#include "G4ExtendedMaterial.hh"
83#include "G4AtomicShells.hh"
84
86
87#ifdef G4MULTITHREADED
88 G4Mutex G4Material::materialMutex = G4MUTEX_INITIALIZER;
89#endif
90
91//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92
93// Constructor to create a material from scratch
94
96 G4double a, G4double density,
97 G4State state, G4double temp, G4double pressure)
98 : fName(name)
99{
101
102 if (density < universe_mean_density)
103 {
104 G4cout << " G4Material WARNING:"
105 << " define a material with density=0 is not allowed. \n"
106 << " The material " << name << " will be constructed with the"
107 << " default minimal density: " << universe_mean_density/(g/cm3)
108 << "g/cm3" << G4endl;
109 density = universe_mean_density;
110 }
111
112 fDensity = density;
113 fState = state;
114 fTemp = temp;
115 fPressure = pressure;
116
117 // Initialize theElementVector allocating one
118 // element corresponding to this material
121
122 // take element from DB
124 G4int iz = G4lrint(z);
125 auto elm = nist->FindOrBuildElement(iz);
126 if(!elm) { elm = new G4Element("ELM_" + name, name, z, a); }
127 theElementVector->push_back(elm);
128
130 fMassFractionVector[0] = 1.;
132
133 if (fState == kStateUndefined)
134 {
136 else { fState = kStateGas; }
137 }
138
140}
141
142//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143
144// Constructor to create a material from a List of constituents
145// (elements and/or materials) added with AddElement or AddMaterial
146
148 G4int nComponents,
149 G4State state, G4double temp, G4double pressure)
150 : fName(name)
151{
153
154 if (density < universe_mean_density)
155 {
156 G4cout << "--- Warning from G4Material::G4Material()"
157 << " define a material with density=0 is not allowed. \n"
158 << " The material " << name << " will be constructed with the"
159 << " default minimal density: " << universe_mean_density/(g/cm3)
160 << "g/cm3" << G4endl;
161 density = universe_mean_density;
162 }
163
164 fDensity = density;
165 fState = state;
166 fTemp = temp;
167 fPressure = pressure;
168
169 fNbComponents = nComponents;
170 fMassFraction = true;
171
172 if (fState == kStateUndefined)
173 {
175 else { fState = kStateGas; }
176 }
177}
178
179//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180
181// Constructor to create a material from base material
182
184 const G4Material* bmat,
185 G4State state, G4double temp, G4double pressure)
186 : fName(name)
187{
189
190 if (density < universe_mean_density)
191 {
192 G4cout << "--- Warning from G4Material::G4Material()"
193 << " define a material with density=0 is not allowed. \n"
194 << " The material " << name << " will be constructed with the"
195 << " default minimal density: " << universe_mean_density/(g/cm3)
196 << "g/cm3" << G4endl;
197 density = universe_mean_density;
198 }
199
200 fDensity = density;
201 fState = state;
202 fTemp = temp;
203 fPressure = pressure;
204
205 fBaseMaterial = bmat;
208
211
213}
214
215//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
216
217// Fake default constructor - sets only member data and allocates memory
218// for usage restricted to object persistency
219
221 : fName("")
222{
224}
225
226//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
227
229{
230 // G4cout << "### Destruction of material " << fName << " started" <<G4endl;
231 if(fBaseMaterial == nullptr) {
232 delete theElementVector;
233 delete fSandiaTable;
234 delete [] fMassFractionVector;
235 delete [] fAtomsVector;
236 }
237 delete fIonisation;
238 delete [] fVecNbOfAtomsPerVolume;
239
240 // Remove this material from theMaterialTable.
241 //
243}
244
245//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
246
248{
249 fBaseMaterial = nullptr;
250 fMaterialPropertiesTable = nullptr;
251 theElementVector = nullptr;
252 fAtomsVector = nullptr;
253 fMassFractionVector = nullptr;
254 fVecNbOfAtomsPerVolume = nullptr;
255
256 fIonisation = nullptr;
257 fSandiaTable = nullptr;
258
263
265
267
268 fMassFraction = true;
269
270 fChemicalFormula = "";
271
272 // initilized data members
273
274 // Store in the static Table of Materials
276 for(size_t i=0; i<fIndexInTable; ++i) {
277 if(theMaterialTable[i]->GetName() == fName) {
278 G4cout << "G4Material WARNING: duplicate name of material "
279 << fName << G4endl;
280 break;
281 }
282 }
283 theMaterialTable.push_back(this);
284}
285
286//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
287
289{
290 // Header routine to compute various properties of material.
291 //
292 // Number of atoms per volume (per element), total nb of electrons per volume
293 G4double Zi, Ai;
295 delete [] fVecNbOfAtomsPerVolume;
298 fFreeElecDensity = 0.;
299 const G4double elecTh = 15.*CLHEP::eV; // threshold for conductivity e-
300 for (G4int i=0; i<fNumberOfElements; ++i) {
301 Zi = (*theElementVector)[i]->GetZ();
302 Ai = (*theElementVector)[i]->GetA();
306 if(fState != kStateGas) {
309 }
310 }
311
314
315 if (!fIonisation) { fIonisation = new G4IonisParamMat(this); }
316 if (!fSandiaTable){ fSandiaTable = new G4SandiaTable(this); }
317}
318
319//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320
322{
327
329
335
339 for (G4int i=0; i<fNumberOfElements; ++i) {
340 fVecNbOfAtomsPerVolume[i] = factor*v[i];
341 }
342 fRadlen = fBaseMaterial->GetRadlen()/factor;
344
345 if(!fIonisation) { fIonisation = new G4IonisParamMat(this); }
349 }
350
353}
354
355//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
356
357// AddElement -- composition by atom count
358
359void
361{
362 // perform checks consistency
363 if(0 == fIdxComponent) {
364 fMassFraction = false;
365 fAtoms = new std::vector<G4int>;
366 fElm = new std::vector<const G4Element*>;
367 }
370 ed << "For material " << fName << " and added element "
371 << elm->GetName() << " with Natoms=" << nAtoms
372 << " wrong attempt to add more than the declared number of elements "
373 << fIdxComponent << " >= " << fNbComponents;
374 G4Exception ("G4Material::AddElementByNumberOfAtoms()", "mat031",
375 FatalException, ed, "");
376 }
377 if(fMassFraction) {
379 ed << "For material " << fName << " and added element "
380 << elm->GetName() << " with Natoms=" << nAtoms
381 << " problem: cannot add by number of atoms after "
382 << "addition of elements by mass fraction";
383 G4Exception ("G4Material::AddElementByNumberOfAtoms()", "mat031",
384 FatalException, ed, "");
385 }
386 // filling
387 G4bool isAdded = false;
388 if(!fElm->empty()) {
389 for (G4int i=0; i<fNumberOfElements; ++i) {
390 if ( elm == (*fElm)[i] ) {
391 (*fAtoms)[i] += nAtoms;
392 isAdded = true;
393 break;
394 }
395 }
396 }
397 if(!isAdded) {
398 fElm->push_back(elm);
399 fAtoms->push_back(nAtoms);
401 }
403
404 // is filled - complete composition of atoms
410
411 G4double Amol = 0.;
412 for (G4int i=0; i<fNumberOfElements; ++i) {
413 theElementVector->push_back((*fElm)[i]);
414 fAtomsVector[i] = (*fAtoms)[i];
415 G4double w = fAtomsVector[i]*(*fElm)[i]->GetA();
416 Amol += w;
417 fMassFractionVector[i] = w;
418 }
419 for (G4int i=0; i<fNumberOfElements; ++i) {
420 fMassFractionVector[i] /= Amol;
421 }
422 delete fAtoms;
423 delete fElm;
426 }
427}
428
429//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
430
431// AddElement -- composition by fraction of mass
432
433void
435{
436 // perform checks consistency
437 if(fraction < 0.0 || fraction > 1.0) {
439 ed << "For material " << fName << " and added element "
440 << elm->GetName() << " massFraction= " << fraction
441 << " is wrong ";
442 G4Exception ("G4Material::AddElementByMassFraction()", "mat031",
443 FatalException, ed, "");
444 }
445 if(!fMassFraction) {
447 ed << "For material " << fName << " and added element "
448 << elm->GetName() << ", massFraction= " << fraction
449 << ", fIdxComponent=" << fIdxComponent
450 << " problem: cannot add by mass fraction after "
451 << "addition of elements by number of atoms";
452 G4Exception ("G4Material::AddElementByMassFraction()", "mat031",
453 FatalException, ed, "");
454 }
457 ed << "For material " << fName << " and added element "
458 << elm->GetName() << ", massFraction= " << fraction
459 << ", fIdxComponent=" << fIdxComponent
460 << "; attempt to add more than the declared number of components "
461 << fIdxComponent << " >= " << fNbComponents;
462 G4Exception ("G4Material::AddElementByMassFraction()", "mat031",
463 FatalException, ed, "");
464 }
465 if(0 == fIdxComponent) {
466 fElmFrac = new std::vector<G4double>;
467 fElm = new std::vector<const G4Element*>;
468 }
469
470 // filling
471 G4bool isAdded = false;
472 if(!fElm->empty()) {
473 for (G4int i=0; i<fNumberOfElements; ++i) {
474 if ( elm == (*fElm)[i] ) {
475 (*fElmFrac)[i] += fraction;
476 isAdded = true;
477 break;
478 }
479 }
480 }
481 if(!isAdded) {
482 fElm->push_back(elm);
483 fElmFrac->push_back(fraction);
485 }
487
488 // is filled
490}
491
492//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
493
494// AddMaterial -- composition by fraction of mass
495
497{
498 if(fraction < 0.0 || fraction > 1.0) {
500 ed << "For material " << fName << " and added material "
501 << material->GetName() << ", massFraction= " << fraction
502 << " is wrong ";
503 G4Exception ("G4Material::AddMaterial()", "mat031", FatalException,
504 ed, "");
505 }
506 if(!fMassFraction) {
508 ed << "For material " << fName << " and added material "
509 << material->GetName() << ", massFraction= " << fraction
510 << ", fIdxComponent=" << fIdxComponent
511 << " problem: cannot add by mass fraction after "
512 << "addition of elements by number of atoms";
513 G4Exception ("G4Material::AddMaterial()", "mat031", FatalException,
514 ed, "");
515 }
518 ed << "For material " << fName << " and added material "
519 << material->GetName() << ", massFraction= " << fraction
520 << "; attempt to add more than the declared number of components "
521 << fIdxComponent << " >= " << fNbComponents;
522 G4Exception ("G4Material::AddMaterial()", "mat031", FatalException,
523 ed, "");
524 }
525
526 if(0 == fIdxComponent) {
527 fElmFrac = new std::vector<G4double>;
528 fElm = new std::vector<const G4Element*>;
529 }
530
531 // filling
532 G4int nelm = material->GetNumberOfElements();
533 for(G4int j=0; j<nelm; ++j) {
534 auto elm = material->GetElement(j);
535 auto frac = material->GetFractionVector();
536 G4bool isAdded = false;
537 if(!fElm->empty()) {
538 for (G4int i=0; i<fNumberOfElements; ++i) {
539 if ( elm == (*fElm)[i] ) {
540 (*fElmFrac)[i] += fraction*frac[j];
541 isAdded = true;
542 break;
543 }
544 }
545 }
546 if(!isAdded) {
547 fElm->push_back(elm);
548 fElmFrac->push_back(fraction*frac[j]);
550 }
551 }
552
553 fMatComponents[material] = fraction;
555
556 // is filled
558}
559
560//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
561
563{
564 // there are material components
569 G4double wtSum(0.0);
570 for (G4int i=0; i<fNumberOfElements; ++i) {
571 theElementVector->push_back((*fElm)[i]);
572 fMassFractionVector[i] = (*fElmFrac)[i];
573 wtSum += fMassFractionVector[i];
574 }
575 delete fElmFrac;
576 delete fElm;
577
578 // check sum of weights -- OK?
579 if (std::abs(1.-wtSum) > perThousand) {
581 ed << "For material " << fName << " sum of fractional masses "
582 << wtSum << " is not 1 - results may be wrong";
583 G4Exception ("G4Material::FillVectors()", "mat031", JustWarning,
584 ed, "");
585 }
586 G4double coeff = (wtSum > 0.0) ? 1./wtSum : 1.0;
587 G4double Amol(0.);
588 for (G4int i=0; i<fNumberOfElements; ++i) {
589 fMassFractionVector[i] *= coeff;
590 Amol += fMassFractionVector[i]*(*theElementVector)[i]->GetA();
591 }
592 for (G4int i=0; i<fNumberOfElements; ++i) {
593 fAtomsVector[i] =
595 }
597}
598
599//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
600
602{
603 G4double radinv = 0.0 ;
604 for (G4int i=0; i<fNumberOfElements; ++i) {
605 radinv += fVecNbOfAtomsPerVolume[i]*((*theElementVector)[i]->GetfRadTsai());
606 }
607 fRadlen = (radinv <= 0.0 ? DBL_MAX : 1./radinv);
608}
609
610//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
611
613{
614 const G4double lambda0 = 35*CLHEP::g/CLHEP::cm2;
615 const G4double twothird = 2.0/3.0;
616 G4double NILinv = 0.0;
617 for (G4int i=0; i<fNumberOfElements; ++i) {
618 G4int Z = (*theElementVector)[i]->GetZasInt();
619 G4double A = (*theElementVector)[i]->GetN();
620 if(1 == Z) {
621 NILinv += fVecNbOfAtomsPerVolume[i]*A;
622 } else {
623 NILinv += fVecNbOfAtomsPerVolume[i]*G4Exp(twothird*G4Log(A));
624 }
625 }
626 NILinv *= amu/lambda0;
627 fNuclInterLen = (NILinv <= 0.0 ? DBL_MAX : 1./NILinv);
628}
629
630//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
631
633{
634#ifdef G4MULTITHREADED
635 G4MUTEXLOCK(&materialMutex);
636#endif
637 fChemicalFormula = chF;
638#ifdef G4MULTITHREADED
639 G4MUTEXUNLOCK(&materialMutex);
640#endif
641}
642
643//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
644
646{
647#ifdef G4MULTITHREADED
648 G4MUTEXLOCK(&materialMutex);
649#endif
650 if(val >= 0.) { fFreeElecDensity = val; }
651#ifdef G4MULTITHREADED
652 G4MUTEXUNLOCK(&materialMutex);
653#endif
654}
655
656//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
657
659{
660#ifdef G4MULTITHREADED
661 G4MUTEXLOCK(&materialMutex);
662#endif
663 if (nullptr == fIonisation) { fIonisation = new G4IonisParamMat(this); }
665#ifdef G4MULTITHREADED
666 G4MUTEXUNLOCK(&materialMutex);
667#endif
668}
669
670//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
671
673{
674 return &theMaterialTable;
675}
676
677//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
678
680{
681 return theMaterialTable.size();
682}
683
684//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
685
687{
688 // search the material by its name
689 for (size_t j=0; j<theMaterialTable.size(); ++j) {
690 if (theMaterialTable[j]->GetName() == materialName) {
691 return theMaterialTable[j];
692 }
693 }
694
695 // the material does not exist in the table
696 if (warn) {
697 G4cout << "G4Material::GetMaterial() WARNING: The material: "
698 << materialName
699 << " does not exist in the table. Return NULL pointer."
700 << G4endl;
701 }
702 return nullptr;
703}
704
705//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
706
708{
709 // search the material by its name
710 for (size_t j=0; j<theMaterialTable.size(); ++j) {
711 G4Material* mat = theMaterialTable[j];
712 if (1 == mat->GetNumberOfElements() &&
713 z == mat->GetZ() && a == mat->GetA() && dens == mat->GetDensity()) {
714 return mat;
715 }
716 }
717 return nullptr;
718}
719
720//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
721
723{
724 // search the material by its name
725 for (size_t j=0; j<theMaterialTable.size(); ++j) {
726 G4Material* mat = theMaterialTable[j];
727 if (nComp == mat->GetNumberOfElements() && dens == mat->GetDensity()) {
728 return mat;
729 }
730 }
731 return nullptr;
732}
733
734//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
735
737{
738 if (fNumberOfElements > 1) {
740 ed << "For material " << fName << " ERROR in GetZ() - Nelm="
741 << fNumberOfElements << " > 1, which is not allowed";
742 G4Exception ("G4Material::GetZ()", "mat036", FatalException,
743 ed, "");
744 }
745 return (*theElementVector)[0]->GetZ();
746}
747
748//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
749
751{
752 if (fNumberOfElements > 1) {
754 ed << "For material " << fName << " ERROR in GetA() - Nelm="
755 << fNumberOfElements << " > 1, which is not allowed";
756 G4Exception ("G4Material::GetA()", "mat036", FatalException,
757 ed, "");
758 }
759 return (*theElementVector)[0]->GetA();
760}
761
762//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
763
764std::ostream& operator<<(std::ostream& flux, const G4Material* material)
765{
766 std::ios::fmtflags mode = flux.flags();
767 flux.setf(std::ios::fixed,std::ios::floatfield);
768 G4long prec = flux.precision(3);
769
770 flux
771 << " Material: " << std::setw(8) << material->fName
772 << " " << material->fChemicalFormula << " "
773 << " density: " << std::setw(6) << std::setprecision(3)
774 << G4BestUnit(material->fDensity,"Volumic Mass")
775 << " RadL: " << std::setw(7) << std::setprecision(3)
776 << G4BestUnit(material->fRadlen,"Length")
777 << " Nucl.Int.Length: " << std::setw(7) << std::setprecision(3)
778 << G4BestUnit(material->fNuclInterLen,"Length")
779 << "\n" << std::setw(30)
780 << " Imean: " << std::setw(7) << std::setprecision(3)
781 << G4BestUnit(material->GetIonisation()->GetMeanExcitationEnergy(),"Energy")
782 << " temperature: " << std::setw(6) << std::setprecision(2)
783 << (material->fTemp)/CLHEP::kelvin << " K"
784 << " pressure: " << std::setw(6) << std::setprecision(2)
785 << (material->fPressure)/CLHEP::atmosphere << " atm" << "\n";
786
787 for (G4int i=0; i<material->fNumberOfElements; i++) {
788 flux
789 << "\n ---> " << (*(material->theElementVector))[i]
790 << "\n ElmMassFraction: "
791 << std::setw(6)<< std::setprecision(2)
792 << (material->fMassFractionVector[i])/perCent << " %"
793 << " ElmAbundance " << std::setw(6)<< std::setprecision(2)
794 << 100*(material->fVecNbOfAtomsPerVolume[i])
795 /(material->fTotNbOfAtomsPerVolume)
796 << " % \n";
797 }
798 flux.precision(prec);
799 flux.setf(mode,std::ios::floatfield);
800
801 if(material->IsExtended())
802 { static_cast<const G4ExtendedMaterial*>(material)->Print(flux); }
803
804 return flux;
805}
806
807//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
808
809std::ostream& operator<<(std::ostream& flux, const G4Material& material)
810{
811 flux << &material;
812 return flux;
813}
814
815//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
816
817std::ostream& operator<<(std::ostream& flux, const G4MaterialTable& MaterialTable)
818{
819 //Dump info for all known materials
820 flux << "\n***** Table : Nb of materials = " << MaterialTable.size()
821 << " *****\n" << G4endl;
822
823 for (size_t i=0; i<MaterialTable.size(); ++i) {
824 flux << MaterialTable[i] << G4endl << G4endl;
825 }
826
827 return flux;
828}
829
830//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
831
833{
834 return false;
835}
836
837//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
838
840{
841 if(nullptr != anMPT && fMaterialPropertiesTable != anMPT) {
842#ifdef G4MULTITHREADED
843 G4MUTEXLOCK(&materialMutex);
844 if(fMaterialPropertiesTable != anMPT) {
845#endif
848#ifdef G4MULTITHREADED
849 }
850 G4MUTEXUNLOCK(&materialMutex);
851#endif
852 }
853}
854
855//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< const G4Element * > G4ElementVector
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:179
G4double G4Log(G4double x)
Definition: G4Log.hh:226
std::vector< G4Material * > G4MaterialTable
G4State
Definition: G4Material.hh:111
@ kStateSolid
Definition: G4Material.hh:111
@ kStateGas
Definition: G4Material.hh:111
@ kStateUndefined
Definition: G4Material.hh:111
static constexpr double perCent
Definition: G4SIunits.hh:325
static constexpr double cm3
Definition: G4SIunits.hh:101
static constexpr double g
Definition: G4SIunits.hh:168
static constexpr double perThousand
Definition: G4SIunits.hh:326
#define G4BestUnit(a, b)
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:251
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:254
std::mutex G4Mutex
Definition: G4Threading.hh:81
double G4double
Definition: G4Types.hh:83
long G4long
Definition: G4Types.hh:87
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
const G4int Z[17]
const G4double A[17]
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4int GetNumberOfFreeElectrons(G4int Z, G4double th)
const G4String & GetName() const
Definition: G4Element.hh:127
G4double GetMeanExcitationEnergy() const
void ComputeDensityEffectOnFly(G4bool)
void SetMeanExcitationEnergy(G4double value)
G4DensityEffectCalculator * GetDensityEffectCalculator()
G4double fTotNbOfElectPerVolume
Definition: G4Material.hh:340
G4double GetDensity() const
Definition: G4Material.hh:176
G4double fFreeElecDensity
Definition: G4Material.hh:335
G4int fIdxComponent
Definition: G4Material.hh:351
const G4String & GetChemicalFormula() const
Definition: G4Material.hh:174
void SetFreeElectronDensity(G4double)
Definition: G4Material.cc:645
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:186
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
Definition: G4Material.hh:252
const G4Material * fBaseMaterial
Definition: G4Material.hh:318
G4State fState
Definition: G4Material.hh:345
void ComputeDerivedQuantities()
Definition: G4Material.cc:288
static G4MaterialTable theMaterialTable
Definition: G4Material.hh:316
G4double fDensity
Definition: G4Material.hh:334
G4double fPressure
Definition: G4Material.hh:337
G4double GetTotNbOfAtomsPerVolume() const
Definition: G4Material.hh:205
void InitializePointers()
Definition: G4Material.cc:247
G4String fChemicalFormula
Definition: G4Material.hh:363
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:679
G4State GetState() const
Definition: G4Material.hh:177
G4int fNbComponents
Definition: G4Material.hh:350
G4bool fMassFraction
Definition: G4Material.hh:352
G4SandiaTable * fSandiaTable
Definition: G4Material.hh:332
G4double fTemp
Definition: G4Material.hh:336
virtual G4bool IsExtended() const
Definition: G4Material.cc:832
G4double GetZ() const
Definition: G4Material.cc:736
const G4double * GetFractionVector() const
Definition: G4Material.hh:190
void CopyPointersOfBaseMaterial()
Definition: G4Material.cc:321
G4double GetTotNbOfElectPerVolume() const
Definition: G4Material.hh:208
G4int fNumberOfElements
Definition: G4Material.hh:347
G4double fNuclInterLen
Definition: G4Material.hh:342
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:222
G4double GetFreeElectronDensity() const
Definition: G4Material.hh:175
virtual ~G4Material()
Definition: G4Material.cc:228
size_t GetNumberOfElements() const
Definition: G4Material.hh:182
std::map< G4Material *, G4double > fMatComponents
Definition: G4Material.hh:360
G4double fTotNbOfAtomsPerVolume
Definition: G4Material.hh:339
void SetChemicalFormula(const G4String &chF)
Definition: G4Material.cc:632
const G4int * GetAtomsVector() const
Definition: G4Material.hh:194
G4double * fVecNbOfAtomsPerVolume
Definition: G4Material.hh:329
G4double * fMassFractionVector
Definition: G4Material.hh:328
G4double GetA() const
Definition: G4Material.cc:750
G4SandiaTable * GetSandiaTable() const
Definition: G4Material.hh:225
std::vector< G4int > * fAtoms
Definition: G4Material.hh:355
void AddElementByNumberOfAtoms(const G4Element *elm, G4int nAtoms)
Definition: G4Material.cc:360
G4ElementVector * theElementVector
Definition: G4Material.hh:326
G4double fRadlen
Definition: G4Material.hh:341
G4double GetRadlen() const
Definition: G4Material.hh:216
G4double GetMassOfMolecule() const
Definition: G4Material.hh:237
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:202
G4Material(const G4String &name, G4double z, G4double a, G4double density, G4State state=kStateUndefined, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
Definition: G4Material.cc:95
size_t fIndexInTable
Definition: G4Material.hh:346
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
G4double fMassOfMolecule
Definition: G4Material.hh:343
void FillVectors()
Definition: G4Material.cc:562
void ComputeNuclearInterLength()
Definition: G4Material.cc:612
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:496
void ComputeRadiationLength()
Definition: G4Material.cc:601
G4int * fAtomsVector
Definition: G4Material.hh:327
const G4String & GetName() const
Definition: G4Material.hh:173
void SetMaterialPropertiesTable(G4MaterialPropertiesTable *anMPT)
Definition: G4Material.cc:839
void AddElementByMassFraction(const G4Element *elm, G4double fraction)
Definition: G4Material.cc:434
std::vector< G4double > * fElmFrac
Definition: G4Material.hh:356
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:686
void ComputeDensityEffectOnFly(G4bool)
Definition: G4Material.cc:658
G4String fName
Definition: G4Material.hh:362
G4IonisParamMat * fIonisation
Definition: G4Material.hh:331
G4double GetNuclearInterLength() const
Definition: G4Material.hh:219
G4MaterialPropertiesTable * fMaterialPropertiesTable
Definition: G4Material.hh:319
std::vector< const G4Element * > * fElm
Definition: G4Material.hh:357
static G4NistManager * Instance()
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
static const double prec
Definition: RanecuEngine.cc:61
static constexpr double kelvin
static constexpr double g
static constexpr double atmosphere
static constexpr double cm2
static constexpr double Avogadro
static constexpr double eV
const char * name(G4int ptype)
string material
Definition: eplot.py:19
void Print(G4Element &ele)
Definition: pyG4Element.cc:55
int kGasThreshold
Definition: hepunit.py:303
int universe_mean_density
Definition: hepunit.py:306
float Avogadro
Definition: hepunit.py:252
int G4lrint(double ad)
Definition: templates.hh:134
#define DBL_MAX
Definition: templates.hh:62