Geant4 10.7.0
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 ()
 
G4MaterialFindMaterial (const G4String &name) const
 
G4MaterialFindOrBuildMaterial (const G4String &name, G4bool isotopes=true, 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, G4bool isotopes=true, 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, G4bool isotopes=true, G4State state=kStateSolid, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
 
G4MaterialConstructNewGasMaterial (const G4String &name, const G4String &nameDB, G4double temp, G4double pres, G4bool isotopes=true)
 
G4MaterialConstructNewIdealGasMaterial (const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4bool isotopes=true, 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
 

Detailed Description

Definition at line 69 of file G4NistMaterialBuilder.hh.

Constructor & Destructor Documentation

◆ G4NistMaterialBuilder()

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

Definition at line 85 of file G4NistMaterialBuilder.cc.

86: elmBuilder(eb),
87 verbose(vb),
88 nMaterials(0),
89 nComponents(0),
90 nCurrent(0)
91{
92 Initialise();
93}

◆ ~G4NistMaterialBuilder()

G4NistMaterialBuilder::~G4NistMaterialBuilder ( )

Definition at line 97 of file G4NistMaterialBuilder.cc.

98{}

Member Function Documentation

◆ ConstructNewGasMaterial()

G4Material * G4NistMaterialBuilder::ConstructNewGasMaterial ( const G4String name,
const G4String nameDB,
G4double  temp,
G4double  pres,
G4bool  isotopes = true 
)

Definition at line 347 of file G4NistMaterialBuilder.cc.

353{
354 // Material name is in DB
355 G4Material* mat = FindOrBuildMaterial(name);
356 if(mat) {
357 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
358 << " WARNING: the material <" << name
359 << "> already exists." << G4endl;
360 G4cout << " New material will NOT be built!"
361 << G4endl;
362 return mat;
363 }
364
365 G4Material* bmat = FindOrBuildMaterial(nameDB);
366 if(!bmat) {
367 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
368 << " WARNING: the Name <" << nameDB
369 << "> is NOT in the database: no new gas will be constructed."
370 << G4endl;
371 return 0;
372 }
373 if(bmat->GetState() != kStateGas) {
374 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
375 << " WARNING: <" << nameDB
376 << "> is NOT a gas - no new gas will be constructed."
377 << G4endl;
378 return 0;
379 }
380
381 G4double dens = bmat->GetDensity()*pres*bmat->GetTemperature()
382 /(temp*bmat->GetPressure());
383 mat = new G4Material(name,dens,bmat,kStateGas,temp,pres);
384
385 if (verbose>1) {
386 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial: done" << G4endl;
387 G4cout << &mat << G4endl;
388 }
389 return mat;
390}
@ kStateGas
Definition: G4Material.hh:111
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4double GetPressure() const
Definition: G4Material.hh:181
G4double GetDensity() const
Definition: G4Material.hh:178
G4State GetState() const
Definition: G4Material.hh:179
G4double GetTemperature() const
Definition: G4Material.hh:180
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, 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,
G4bool  isotopes = true,
G4double  temp = NTP_Temperature,
G4double  pressure = CLHEP::STP_Pressure 
)

Definition at line 394 of file G4NistMaterialBuilder.cc.

401{
402 G4State state = kStateGas;
403
404 // Material is in DB
405 G4Material* mat = FindOrBuildMaterial(name);
406 if(mat) {
407 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
408 << " WARNING: the material <" << name
409 << "> already exists." << G4endl;
410 G4cout << " New material will NOT be built!"
411 << G4endl;
412 return mat;
413 }
414
415 // Material not in DB
416 G4int els = elm.size();
417 if(els == 0) {
418 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
419 << " WARNING: empty list of elements for " << name
420 << G4endl;
421 G4cout << " New material will NOT be built!"
422 << G4endl;
423 return 0;
424 }
425
426 // add parameters of material into internal vectors
427 // density in g/cm3, mean ionisation potential is not defined
428 G4bool stp = true;
429 if(temp != NTP_Temperature || pres != CLHEP::STP_Pressure)
430 { stp = false; }
431
432 G4double massPerMole = 0.;
433
434 G4int Z = 0;
435 for (G4int i=0; i<els; ++i) {
436 Z = elmBuilder->GetZ(elm[i]);
437 massPerMole += nbAtoms[i]*elmBuilder->GetAtomicMassAmu(Z)*CLHEP::amu_c2;
438 }
439
440 G4double dens = massPerMole/(CLHEP::Avogadro*CLHEP::k_Boltzmann*temp/pres);
441
442 if (els == 1) { AddMaterial(name,dens,Z,0.,els,state,stp); }
443 else {
444 AddMaterial(name,dens,0,0.,els,state,stp);
445 for (G4int i=0; i<els; ++i) {
446 AddElementByAtomCount(elmBuilder->GetZ(elm[i]), nbAtoms[i]);
447 }
448 }
449
450 if(!stp) { AddGas(name,temp,pres); }
451
452 return BuildMaterial(nMaterials-1);
453}
G4State
Definition: G4Material.hh:111
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,
G4bool  isotopes = true,
G4State  state = kStateSolid,
G4double  temp = NTP_Temperature,
G4double  pressure = CLHEP::STP_Pressure 
)

Definition at line 297 of file G4NistMaterialBuilder.cc.

306{
307 // Material is in DB
308 G4Material* mat = FindOrBuildMaterial(name);
309 if(mat) {
310 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
311 << " WARNING: the material <" << name
312 << "> already exists." << G4endl;
313 G4cout << " New material will NOT be built!"
314 << G4endl;
315 return mat;
316 }
317
318 // Material not in DB
319 G4int els = elm.size();
320 if(els == 0) {
321 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
322 << " WARNING: empty list of elements for " << name
323 << G4endl;
324 G4cout << " New material will NOT be built!"
325 << G4endl;
326 return 0;
327 }
328
329 // add parameters of material into internal vectors
330 // density in g/cm3, mean ionisation potential is not defined
331 G4bool stp = true;
332 if(state == kStateGas &&
333 (temp != NTP_Temperature || pres != CLHEP::STP_Pressure))
334 { stp = false; }
335 AddMaterial(name,dens*CLHEP::cm3/CLHEP::g,0,0.,els,state,stp);
336 if(!stp) { AddGas(name,temp,pres); }
337
338 for (G4int i=0; i<els; ++i) {
339 AddElementByWeightFraction(elmBuilder->GetZ(elm[i]), w[i]);
340 }
341
342 return BuildMaterial(nMaterials-1);
343}

◆ ConstructNewMaterial() [2/2]

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

Definition at line 246 of file G4NistMaterialBuilder.cc.

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

Referenced by G4NistManager::ConstructNewMaterial().

◆ FindMaterial()

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

Definition at line 247 of file G4NistMaterialBuilder.hh.

248{
249 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
250 size_t nmat = theMaterialTable->size();
251 G4Material* ptr = nullptr;
252 for(size_t i=0; i<nmat; ++i) {
253 if(name == ((*theMaterialTable)[i])->GetName()) {
254 ptr = (*theMaterialTable)[i];
255 break;
256 }
257 }
258 return ptr;
259}
std::vector< G4Material * > G4MaterialTable
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:637

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

◆ FindOrBuildMaterial()

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

Definition at line 102 of file G4NistMaterialBuilder.cc.

104{
105 if(verbose > 1) {
106 G4cout << "G4NistMaterialBuilder::FindOrBuildMaterial "
107 << matname << G4endl;
108 }
109 G4Material* mat = FindMaterial(matname);
110 if(mat != nullptr) { return mat; }
111 G4String name = matname;
112 if(name == "G4_NYLON-6/6" || name == "G4_NYLON-6/10") {
113 if("G4_NYLON-6/6" == matname) { name = "G4_NYLON-6-6"; }
114 else { name = "G4_NYLON-6-10";}
115 mat = FindMaterial(name);
116 }
117 return (mat == nullptr) ? BuildNistMaterial(name, warning) : mat;
118}
G4Material * FindMaterial(const G4String &name) const

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

◆ FindOrBuildSimpleMaterial()

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

Definition at line 160 of file G4NistMaterialBuilder.cc.

161{
163 if(mat == nullptr) {
164 mat = BuildNistMaterial(names[Z], warn);
165 }
166 return mat;
167}
G4Material * FindSimpleMaterial(G4int Z) const

Referenced by G4NistManager::FindOrBuildSimpleMaterial().

◆ FindSimpleMaterial()

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

Definition at line 262 of file G4NistMaterialBuilder.hh.

263{
264 return (Z>0 && Z<nElementary) ? FindMaterial(names[Z]) : nullptr;
265}

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

◆ GetMaterialNames()

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

Definition at line 229 of file G4NistMaterialBuilder.hh.

230{
231 return names;
232}

Referenced by G4NistManager::GetNistMaterialNames().

◆ GetMeanIonisationEnergy()

G4double G4NistMaterialBuilder::GetMeanIonisationEnergy ( G4int  index) const
inline

Definition at line 235 of file G4NistMaterialBuilder.hh.

236{
237 return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0*index;
238}

Referenced by G4NistManager::GetMeanIonisationEnergy().

◆ GetNominalDensity()

G4double G4NistMaterialBuilder::GetNominalDensity ( G4int  index) const
inline

Definition at line 241 of file G4NistMaterialBuilder.hh.

242{
243 return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
244}

Referenced by G4NistManager::GetNominalDensity().

◆ ListBioChemicalMaterials()

void G4NistMaterialBuilder::ListBioChemicalMaterials ( ) const

Definition at line 594 of file G4NistMaterialBuilder.cc.

595{
596 G4cout << "=============================================================" << G4endl;
597 G4cout << "### Bio-Chemical Materials ##" << G4endl;
598 G4cout << "=============================================================" << G4endl;
599 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
600 G4cout << "=============================================================" << G4endl;
601 for (G4int i=nSpace; i<nMaterials; ++i) {DumpMix(i);}
602 G4cout << "=============================================================" << G4endl;
603}

Referenced by ListMaterials().

◆ ListHepMaterials()

void G4NistMaterialBuilder::ListHepMaterials ( ) const

Definition at line 570 of file G4NistMaterialBuilder.cc.

571{
572 G4cout << "=============================================================" << G4endl;
573 G4cout << "### HEP & Nuclear Materials ##" << G4endl;
574 G4cout << "=============================================================" << G4endl;
575 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
576 G4cout << "=============================================================" << G4endl;
577 for (G4int i=nNIST; i<nHEP; ++i) {DumpMix(i);}
578}

Referenced by ListMaterials().

◆ ListMaterials()

void G4NistMaterialBuilder::ListMaterials ( const G4String mnam) const

Definition at line 522 of file G4NistMaterialBuilder.cc.

523{
524 if (mnam == "simple") { ListNistSimpleMaterials(); }
525 else if (mnam == "compound") { ListNistCompoundMaterials(); }
526 else if (mnam == "hep") { ListHepMaterials(); }
527 else if (mnam == "space") { ListSpaceMaterials(); }
528 else if (mnam == "bio") { ListBioChemicalMaterials(); }
529
530 else if (mnam == "all") {
536
537 } else {
538 G4cout << "### G4NistMaterialBuilder::ListMaterials: Warning "
539 << mnam << " list is not known." << G4endl;
540 }
541}

Referenced by G4NistManager::ListMaterials().

◆ ListNistCompoundMaterials()

void G4NistMaterialBuilder::ListNistCompoundMaterials ( ) const

Definition at line 557 of file G4NistMaterialBuilder.cc.

558{
559 G4cout << "=============================================================" << G4endl;
560 G4cout << "### Compound Materials from the NIST Data Base ##" << G4endl;
561 G4cout << "=============================================================" << G4endl;
562 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
563 G4cout << "=============================================================" << G4endl;
564 for (G4int i=nElementary; i<nNIST; ++i) {DumpMix(i);}
565 DumpMix(0);
566}

Referenced by ListMaterials().

◆ ListNistSimpleMaterials()

void G4NistMaterialBuilder::ListNistSimpleMaterials ( ) const

Definition at line 545 of file G4NistMaterialBuilder.cc.

546{
547 G4cout << "=======================================================" << G4endl;
548 G4cout << "### Simple Materials from the NIST Data Base ###" << G4endl;
549 G4cout << "=======================================================" << G4endl;
550 G4cout << " Z Name density(g/cm^3) I(eV) " << G4endl;
551 G4cout << "=======================================================" << G4endl;
552 for (G4int i=1; i<nElementary; ++i) {DumpElm(i);}
553}

Referenced by ListMaterials().

◆ ListSpaceMaterials()

void G4NistMaterialBuilder::ListSpaceMaterials ( ) const

Definition at line 582 of file G4NistMaterialBuilder.cc.

583{
584 G4cout << "=============================================================" << G4endl;
585 G4cout << "### Space ISS Materials ##" << G4endl;
586 G4cout << "=============================================================" << G4endl;
587 G4cout << " Ncomp Name density(g/cm^3) I(eV) ChFormula" << G4endl;
588 G4cout << "=============================================================" << G4endl;
589 for (G4int i=nHEP; i<nSpace; ++i) {DumpMix(i);}
590}

Referenced by ListMaterials().

◆ SetVerbose()

void G4NistMaterialBuilder::SetVerbose ( G4int  val)

Definition at line 514 of file G4NistMaterialBuilder.cc.

515{
516 verbose = val;
517 elmBuilder->SetVerbose(verbose);
518}

Referenced by G4NistManager::SetVerbose().


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