Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NistMaterialBuilder Class Reference

#include <G4NistMaterialBuilder.hh>

Public Member Functions

 G4NistMaterialBuilder (G4NistElementBuilder *, G4int verb=0)
 
 ~G4NistMaterialBuilder ()=default
 
G4MaterialFindMaterial (const G4String &name) const
 
G4MaterialFindOrBuildMaterial (const G4String &name, G4bool warning=true)
 
G4MaterialFindSimpleMaterial (G4int Z) const
 
G4MaterialFindOrBuildSimpleMaterial (G4int Z, G4bool warning)
 
G4MaterialConstructNewMaterial (const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double dens, G4State state=kStateSolid, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
 
G4MaterialConstructNewMaterial (const G4String &name, const std::vector< G4String > &elm, const std::vector< G4double > &weight, G4double dens, G4State state=kStateSolid, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
 
G4MaterialConstructNewGasMaterial (const G4String &name, const G4String &nameDB, G4double temp, G4double pres)
 
G4MaterialConstructNewIdealGasMaterial (const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
 
void SetVerbose (G4int val)
 
void ListMaterials (const G4String &) const
 
void ListNistSimpleMaterials () const
 
void ListNistCompoundMaterials () const
 
void ListHepMaterials () const
 
void ListSpaceMaterials () const
 
void ListBioChemicalMaterials () const
 
const std::vector< G4String > & GetMaterialNames () const
 
G4double GetMeanIonisationEnergy (G4int index) const
 
G4double GetNominalDensity (G4int index) const
 
G4bool operator== (const G4NistMaterialBuilder &) const =delete
 
G4bool operator!= (const G4NistMaterialBuilder &) const =delete
 
 G4NistMaterialBuilder (const G4NistMaterialBuilder &)=delete
 
const G4NistMaterialBuilderoperator= (const G4NistMaterialBuilder &)=delete
 

Detailed Description

Definition at line 65 of file G4NistMaterialBuilder.hh.

Constructor & Destructor Documentation

◆ G4NistMaterialBuilder() [1/2]

G4NistMaterialBuilder::G4NistMaterialBuilder ( G4NistElementBuilder * eb,
G4int verb = 0 )

Definition at line 87 of file G4NistMaterialBuilder.cc.

88 : elmBuilder(eb), verbose(vb)
89{
90 Initialise();
91}

◆ ~G4NistMaterialBuilder()

G4NistMaterialBuilder::~G4NistMaterialBuilder ( )
default

◆ G4NistMaterialBuilder() [2/2]

G4NistMaterialBuilder::G4NistMaterialBuilder ( const G4NistMaterialBuilder & )
delete

Member Function Documentation

◆ ConstructNewGasMaterial()

G4Material * G4NistMaterialBuilder::ConstructNewGasMaterial ( const G4String & name,
const G4String & nameDB,
G4double temp,
G4double pres )

Definition at line 332 of file G4NistMaterialBuilder.cc.

334{
335 // Material name is in DB
336 G4Material* mat = FindOrBuildMaterial(name);
337 if (mat != nullptr) {
338 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
339 << " WARNING: the material <" << name << "> already exists." << G4endl;
340 G4cout << " New material will NOT be built!" << G4endl;
341 return mat;
342 }
343
344 G4Material* bmat = FindOrBuildMaterial(nameDB);
345 if (bmat == nullptr) {
346 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
347 << " WARNING: the Name <" << nameDB
348 << "> is NOT in the database: no new gas will be constructed." << G4endl;
349 return nullptr;
350 }
351 if (bmat->GetState() != kStateGas) {
352 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
353 << " WARNING: <" << nameDB << "> is NOT a gas - no new gas will be constructed."
354 << G4endl;
355 return nullptr;
356 }
357
358 G4double dens = bmat->GetDensity() * pres * bmat->GetTemperature() / (temp * bmat->GetPressure());
359 mat = new G4Material(name, dens, bmat, kStateGas, temp, pres);
360
361 if (verbose > 1) {
362 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial: done" << G4endl;
363 G4cout << &mat << G4endl;
364 }
365 return mat;
366}
@ kStateGas
double G4double
Definition G4Types.hh:83
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4double GetPressure() const
G4double GetDensity() const
G4State GetState() const
G4double GetTemperature() const
G4Material * FindOrBuildMaterial(const G4String &name, G4bool warning=true)
const char * name(G4int ptype)

Referenced by G4NistManager::ConstructNewGasMaterial().

◆ ConstructNewIdealGasMaterial()

G4Material * G4NistMaterialBuilder::ConstructNewIdealGasMaterial ( const G4String & name,
const std::vector< G4String > & elm,
const std::vector< G4int > & nbAtoms,
G4double temp = NTP_Temperature,
G4double pressure = CLHEP::STP_Pressure )

Definition at line 370 of file G4NistMaterialBuilder.cc.

372{
373 G4State state = kStateGas;
374
375 // Material is in DB
376 G4Material* mat = FindOrBuildMaterial(name);
377 if (mat != nullptr) {
378 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
379 << " WARNING: the material <" << name << "> already exists." << G4endl;
380 G4cout << " New material will NOT be built!" << G4endl;
381 return mat;
382 }
383
384 // Material not in DB
385 auto els = (G4int)elm.size();
386 if (els == 0) {
387 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
388 << " WARNING: empty list of elements for " << name << G4endl;
389 G4cout << " New material will NOT be built!" << G4endl;
390 return nullptr;
391 }
392
393 // add parameters of material into internal vectors
394 // density in g/cm3, mean ionisation potential is not defined
395 G4bool stp = true;
396 if (temp != NTP_Temperature || pres != CLHEP::STP_Pressure) {
397 stp = false;
398 }
399
400 G4double massPerMole = 0.;
401
402 G4int Z = 0;
403 for (G4int i = 0; i < els; ++i) {
404 Z = elmBuilder->GetZ(elm[i]);
405 massPerMole += nbAtoms[i] * elmBuilder->GetAtomicMassAmu(Z) * CLHEP::amu_c2;
406 }
407
408 G4double dens = massPerMole / (CLHEP::Avogadro * CLHEP::k_Boltzmann * temp / pres);
409
410 if (els == 1) {
411 AddMaterial(name, dens, Z, 0., els, state, stp);
412 }
413 else {
414 AddMaterial(name, dens, 0, 0., els, state, stp);
415 for (G4int i = 0; i < els; ++i) {
416 AddElementByAtomCount(elmBuilder->GetZ(elm[i]), nbAtoms[i]);
417 }
418 }
419
420 if (! stp) {
421 AddGas(name, temp, pres);
422 }
423
424 return BuildMaterial(nMaterials - 1);
425}
G4State
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4double GetAtomicMassAmu(const G4String &symb) const
G4int GetZ(const G4String &symb) const

Referenced by G4NistManager::ConstructNewIdealGasMaterial().

◆ ConstructNewMaterial() [1/2]

G4Material * G4NistMaterialBuilder::ConstructNewMaterial ( const G4String & name,
const std::vector< G4String > & elm,
const std::vector< G4double > & weight,
G4double dens,
G4State state = kStateSolid,
G4double temp = NTP_Temperature,
G4double pressure = CLHEP::STP_Pressure )

Definition at line 290 of file G4NistMaterialBuilder.cc.

293{
294 // Material is in DB
295 G4Material* mat = FindOrBuildMaterial(name);
296 if (mat != nullptr) {
297 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
298 << " WARNING: the material <" << name << "> already exists." << G4endl;
299 G4cout << " New material will NOT be built!" << G4endl;
300 return mat;
301 }
302
303 // Material not in DB
304 auto els = (G4int)elm.size();
305 if (els == 0) {
306 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
307 << " WARNING: empty list of elements for " << name << G4endl;
308 G4cout << " New material will NOT be built!" << G4endl;
309 return nullptr;
310 }
311
312 // add parameters of material into internal vectors
313 // density in g/cm3, mean ionisation potential is not defined
314 G4bool stp = true;
315 if (state == kStateGas && (temp != NTP_Temperature || pres != CLHEP::STP_Pressure)) {
316 stp = false;
317 }
318 AddMaterial(name, dens * CLHEP::cm3 / CLHEP::g, 0, 0., els, state, stp);
319 if (! stp) {
320 AddGas(name, temp, pres);
321 }
322
323 for (G4int i = 0; i < els; ++i) {
324 AddElementByWeightFraction(elmBuilder->GetZ(elm[i]), w[i]);
325 }
326
327 return BuildMaterial(nMaterials - 1);
328}

◆ ConstructNewMaterial() [2/2]

G4Material * G4NistMaterialBuilder::ConstructNewMaterial ( const G4String & name,
const std::vector< G4String > & elm,
const std::vector< G4int > & nbAtoms,
G4double dens,
G4State state = kStateSolid,
G4double temp = NTP_Temperature,
G4double pressure = CLHEP::STP_Pressure )

Definition at line 247 of file G4NistMaterialBuilder.cc.

250{
251 // Material is in DB
252 G4Material* mat = FindOrBuildMaterial(name);
253 if (mat != nullptr) {
254 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
255 << " WARNING: the material <" << name << "> already exists." << G4endl;
256 G4cout << " New material will NOT be built!" << G4endl;
257 return mat;
258 }
259
260 // Material not in DB
261 auto els = (G4int)elm.size();
262 if (els == 0) {
263 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
264 << " WARNING: empty list of elements for " << name << G4endl;
265 G4cout << " New material will NOT be built!" << G4endl;
266 return nullptr;
267 }
268
269 // add parameters of material into internal vectors
270 // density in g/cm3, mean ionisation potential is not defined
271 G4bool stp = true;
272 if (state == kStateGas && (temp != NTP_Temperature || pres != CLHEP::STP_Pressure)) {
273 stp = false;
274 }
275
276 AddMaterial(name, dens * CLHEP::cm3 / CLHEP::g, 0, 0., els, state, stp);
277 if (! stp) {
278 AddGas(name, temp, pres);
279 }
280
281 for (G4int i = 0; i < els; ++i) {
282 AddElementByAtomCount(elmBuilder->GetZ(elm[i]), nbAtoms[i]);
283 }
284
285 return BuildMaterial(nMaterials - 1);
286}

Referenced by G4NistManager::ConstructNewMaterial(), and G4NistManager::ConstructNewMaterial().

◆ FindMaterial()

G4Material * G4NistMaterialBuilder::FindMaterial ( const G4String & name) const
inline

Definition at line 205 of file G4NistMaterialBuilder.hh.

206{
207 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
208 G4Material* ptr = nullptr;
209 for (auto& mat : *theMaterialTable) {
210 if (name == mat->GetName()) {
211 ptr = mat;
212 break;
213 }
214 }
215 return ptr;
216}
std::vector< G4Material * > G4MaterialTable
static G4MaterialTable * GetMaterialTable()

Referenced by G4NistManager::FindMaterial(), FindOrBuildMaterial(), and FindSimpleMaterial().

◆ FindOrBuildMaterial()

G4Material * G4NistMaterialBuilder::FindOrBuildMaterial ( const G4String & name,
G4bool warning = true )

Definition at line 95 of file G4NistMaterialBuilder.cc.

96{
97 if (verbose > 1) {
98 G4cout << "G4NistMaterialBuilder::FindOrBuildMaterial " << matname << G4endl;
99 }
100 G4String name = matname;
101 if ("G4_NYLON-6/6" == matname) {
102 name = "G4_NYLON-6-6";
103 }
104 else if (name == "G4_NYLON-6/10") {
105 name = "G4_NYLON-6-10";
106 }
107
108 G4Material* mat = FindMaterial(name);
109 if (mat != nullptr) {
110 return mat;
111 }
112
113 mat = BuildNistMaterial(name, warning);
114 return mat;
115}
G4Material * FindMaterial(const G4String &name) const

Referenced by ConstructNewGasMaterial(), ConstructNewIdealGasMaterial(), ConstructNewMaterial(), ConstructNewMaterial(), and G4NistManager::FindOrBuildMaterial().

◆ FindOrBuildSimpleMaterial()

G4Material * G4NistMaterialBuilder::FindOrBuildSimpleMaterial ( G4int Z,
G4bool warning )

Definition at line 147 of file G4NistMaterialBuilder.cc.

148{
150 if (mat == nullptr) {
151 mat = BuildNistMaterial(names[Z], warn);
152 }
153 return mat;
154}
G4Material * FindSimpleMaterial(G4int Z) const

Referenced by G4NistManager::FindOrBuildSimpleMaterial().

◆ FindSimpleMaterial()

G4Material * G4NistMaterialBuilder::FindSimpleMaterial ( G4int Z) const
inline

Definition at line 218 of file G4NistMaterialBuilder.hh.

219{
220 return (Z > 0 && Z < nElementary) ? FindMaterial(names[Z]) : nullptr;
221}

Referenced by FindOrBuildSimpleMaterial(), and G4NistManager::FindSimpleMaterial().

◆ GetMaterialNames()

const std::vector< G4String > & G4NistMaterialBuilder::GetMaterialNames ( ) const
inline

Definition at line 190 of file G4NistMaterialBuilder.hh.

191{
192 return names;
193}

Referenced by G4NistManager::GetNistMaterialNames().

◆ GetMeanIonisationEnergy()

G4double G4NistMaterialBuilder::GetMeanIonisationEnergy ( G4int index) const
inline

Definition at line 195 of file G4NistMaterialBuilder.hh.

196{
197 return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0 * index;
198}

Referenced by G4NistManager::GetMeanIonisationEnergy().

◆ GetNominalDensity()

G4double G4NistMaterialBuilder::GetNominalDensity ( G4int index) const
inline

Definition at line 200 of file G4NistMaterialBuilder.hh.

201{
202 return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
203}

Referenced by G4NistManager::GetNominalDensity().

◆ ListBioChemicalMaterials()

void G4NistMaterialBuilder::ListBioChemicalMaterials ( ) const

Definition at line 579 of file G4NistMaterialBuilder.cc.

580{
581 G4cout << "=============================================================" << G4endl;
582 G4cout << "### Bio-Chemical Materials ##" << G4endl;
583 G4cout << "=============================================================" << G4endl;
584 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
585 G4cout << "=============================================================" << G4endl;
586 for (G4int i = nSpace; i < nMaterials; ++i) {
587 DumpMix(i);
588 }
589 G4cout << "=============================================================" << G4endl;
590}

Referenced by ListMaterials().

◆ ListHepMaterials()

void G4NistMaterialBuilder::ListHepMaterials ( ) const

Definition at line 551 of file G4NistMaterialBuilder.cc.

552{
553 G4cout << "=============================================================" << G4endl;
554 G4cout << "### HEP & Nuclear Materials ##" << G4endl;
555 G4cout << "=============================================================" << G4endl;
556 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
557 G4cout << "=============================================================" << G4endl;
558 for (G4int i = nNIST; i < nHEP; ++i) {
559 DumpMix(i);
560 }
561}

Referenced by ListMaterials().

◆ ListMaterials()

void G4NistMaterialBuilder::ListMaterials ( const G4String & mnam) const

Definition at line 489 of file G4NistMaterialBuilder.cc.

490{
491 if (mnam == "simple") {
493 }
494 else if (mnam == "compound") {
496 }
497 else if (mnam == "hep") {
499 }
500 else if (mnam == "space") {
502 }
503 else if (mnam == "bio") {
505 }
506
507 else if (mnam == "all") {
513 }
514 else {
515 G4cout << "### G4NistMaterialBuilder::ListMaterials: Warning " << mnam << " list is not known."
516 << G4endl;
517 }
518}

Referenced by G4NistManager::ListMaterials().

◆ ListNistCompoundMaterials()

void G4NistMaterialBuilder::ListNistCompoundMaterials ( ) const

Definition at line 536 of file G4NistMaterialBuilder.cc.

537{
538 G4cout << "=============================================================" << G4endl;
539 G4cout << "### Compound Materials from the NIST Data Base ##" << G4endl;
540 G4cout << "=============================================================" << G4endl;
541 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
542 G4cout << "=============================================================" << G4endl;
543 for (G4int i = nElementary; i < nNIST; ++i) {
544 DumpMix(i);
545 }
546 DumpMix(0);
547}

Referenced by ListMaterials().

◆ ListNistSimpleMaterials()

void G4NistMaterialBuilder::ListNistSimpleMaterials ( ) const

Definition at line 522 of file G4NistMaterialBuilder.cc.

523{
524 G4cout << "=======================================================" << G4endl;
525 G4cout << "### Simple Materials from the NIST Data Base ###" << G4endl;
526 G4cout << "=======================================================" << G4endl;
527 G4cout << " Z Name density(g/cm^3) I(eV) " << G4endl;
528 G4cout << "=======================================================" << G4endl;
529 for (G4int i = 1; i < nElementary; ++i) {
530 DumpElm(i);
531 }
532}

Referenced by ListMaterials().

◆ ListSpaceMaterials()

void G4NistMaterialBuilder::ListSpaceMaterials ( ) const

Definition at line 565 of file G4NistMaterialBuilder.cc.

566{
567 G4cout << "=============================================================" << G4endl;
568 G4cout << "### Space ISS Materials ##" << G4endl;
569 G4cout << "=============================================================" << G4endl;
570 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
571 G4cout << "=============================================================" << G4endl;
572 for (G4int i = nHEP; i < nSpace; ++i) {
573 DumpMix(i);
574 }
575}

Referenced by ListMaterials().

◆ operator!=()

G4bool G4NistMaterialBuilder::operator!= ( const G4NistMaterialBuilder & ) const
delete

◆ operator=()

const G4NistMaterialBuilder & G4NistMaterialBuilder::operator= ( const G4NistMaterialBuilder & )
delete

◆ operator==()

G4bool G4NistMaterialBuilder::operator== ( const G4NistMaterialBuilder & ) const
delete

◆ SetVerbose()

void G4NistMaterialBuilder::SetVerbose ( G4int val)

Definition at line 481 of file G4NistMaterialBuilder.cc.

482{
483 verbose = val;
484 elmBuilder->SetVerbose(verbose);
485}

Referenced by G4NistManager::SetVerbose().


The documentation for this class was generated from the following files: