Geant4 11.1.1
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 68 of file G4NistMaterialBuilder.hh.

Constructor & Destructor Documentation

◆ G4NistMaterialBuilder() [1/2]

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

Definition at line 89 of file G4NistMaterialBuilder.cc.

90: elmBuilder(eb),
91 verbose(vb),
92 nMaterials(0),
93 nComponents(0),
94 nCurrent(0)
95{
96 Initialise();
97}

◆ ~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 348 of file G4NistMaterialBuilder.cc.

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

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

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

◆ 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.

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

Referenced by G4NistManager::ConstructNewMaterial().

◆ FindMaterial()

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

Definition at line 240 of file G4NistMaterialBuilder.hh.

241{
242 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
243 G4Material* ptr = nullptr;
244 for(auto & mat : *theMaterialTable) {
245 if(name == mat->GetName()) {
246 ptr = mat;
247 break;
248 }
249 }
250 return ptr;
251}
std::vector< G4Material * > G4MaterialTable
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:677

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

◆ FindOrBuildMaterial()

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

Definition at line 101 of file G4NistMaterialBuilder.cc.

103{
104 if(verbose > 1) {
105 G4cout << "G4NistMaterialBuilder::FindOrBuildMaterial "
106 << matname << G4endl;
107 }
108 G4String name = matname;
109 if("G4_NYLON-6/6" == matname) { name = "G4_NYLON-6-6"; }
110 else if(name == "G4_NYLON-6/10") { name = "G4_NYLON-6-10"; }
111
112 G4Material* mat = FindMaterial(name);
113 if(mat != nullptr) { return mat; }
114
115 mat = BuildNistMaterial(name, warning);
116 return mat;
117}
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 153 of file G4NistMaterialBuilder.cc.

154{
156 if(mat == nullptr) {
157 mat = BuildNistMaterial(names[Z], warn);
158 }
159 return mat;
160}
G4Material * FindSimpleMaterial(G4int Z) const

Referenced by G4NistManager::FindOrBuildSimpleMaterial().

◆ FindSimpleMaterial()

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

Definition at line 254 of file G4NistMaterialBuilder.hh.

255{
256 return (Z>0 && Z<nElementary) ? FindMaterial(names[Z]) : nullptr;
257}

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

◆ GetMaterialNames()

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

Definition at line 222 of file G4NistMaterialBuilder.hh.

223{
224 return names;
225}

Referenced by G4NistManager::GetNistMaterialNames().

◆ GetMeanIonisationEnergy()

G4double G4NistMaterialBuilder::GetMeanIonisationEnergy ( G4int  index) const
inline

Definition at line 228 of file G4NistMaterialBuilder.hh.

229{
230 return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0*index;
231}

Referenced by G4NistManager::GetMeanIonisationEnergy().

◆ GetNominalDensity()

G4double G4NistMaterialBuilder::GetNominalDensity ( G4int  index) const
inline

Definition at line 234 of file G4NistMaterialBuilder.hh.

235{
236 return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
237}

Referenced by G4NistManager::GetNominalDensity().

◆ ListBioChemicalMaterials()

void G4NistMaterialBuilder::ListBioChemicalMaterials ( ) const

Definition at line 596 of file G4NistMaterialBuilder.cc.

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

Referenced by ListMaterials().

◆ ListHepMaterials()

void G4NistMaterialBuilder::ListHepMaterials ( ) const

Definition at line 572 of file G4NistMaterialBuilder.cc.

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

Referenced by ListMaterials().

◆ ListMaterials()

void G4NistMaterialBuilder::ListMaterials ( const G4String mnam) const

Definition at line 524 of file G4NistMaterialBuilder.cc.

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

Referenced by G4NistManager::ListMaterials().

◆ ListNistCompoundMaterials()

void G4NistMaterialBuilder::ListNistCompoundMaterials ( ) const

Definition at line 559 of file G4NistMaterialBuilder.cc.

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

Referenced by ListMaterials().

◆ ListNistSimpleMaterials()

void G4NistMaterialBuilder::ListNistSimpleMaterials ( ) const

Definition at line 547 of file G4NistMaterialBuilder.cc.

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

Referenced by ListMaterials().

◆ ListSpaceMaterials()

void G4NistMaterialBuilder::ListSpaceMaterials ( ) const

Definition at line 584 of file G4NistMaterialBuilder.cc.

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

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 516 of file G4NistMaterialBuilder.cc.

517{
518 verbose = val;
519 elmBuilder->SetVerbose(verbose);
520}

Referenced by G4NistManager::SetVerbose().


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