Geant4 9.6.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 ()
 
G4MaterialFindOrBuildMaterial (const G4String &name, G4bool isotopes=true, G4bool warning=true)
 
G4MaterialConstructNewMaterial (const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double dens, G4bool isotopes=true, G4State state=kStateSolid, G4double temp=CLHEP::STP_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=CLHEP::STP_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=CLHEP::STP_Temperature, G4double pressure=CLHEP::STP_Pressure)
 
void SetVerbose (G4int val)
 
void ListMaterials (const G4String &)
 
void ListNistSimpleMaterials ()
 
void ListNistCompoundMaterials ()
 
void ListHepMaterials ()
 
void ListSpaceMaterials ()
 
void ListBioChemicalMaterials ()
 
const std::vector< G4String > & GetMaterialNames () const
 
G4double GetMeanIonisationEnergy (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 76 of file G4NistMaterialBuilder.cc.

77: elmBuilder(eb),
78 verbose(vb),
79 nMaterials(0),
80 nComponents(0),
81 nCurrent(0),
82 first(true)
83{
84 Initialise();
85}

◆ ~G4NistMaterialBuilder()

G4NistMaterialBuilder::~G4NistMaterialBuilder ( )

Definition at line 89 of file G4NistMaterialBuilder.cc.

90{}

Member Function Documentation

◆ ConstructNewGasMaterial()

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

Definition at line 320 of file G4NistMaterialBuilder.cc.

326{
327 // Material name is in DB
328 G4Material* mat = FindOrBuildMaterial(name);
329 if(mat) {
330 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
331 << " WARNING: the material <" << name
332 << "> is already exist" << G4endl;
333 G4cout << " New material will NOT be built!"
334 << G4endl;
335 return mat;
336 }
337
338 G4Material* bmat = FindOrBuildMaterial(nameDB);
339 if(!bmat) {
340 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
341 << " WARNING: the Name <" << nameDB
342 << "> is NOT in the DB: no new gas will be constructed"
343 << G4endl;
344 return 0;
345 }
346 if(bmat->GetState() != kStateGas) {
347 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial:"
348 << " WARNING: <" << nameDB
349 << "> is NOT a gas - no new gas will be constructed"
350 << G4endl;
351 return 0;
352 }
353
354 G4double dens = bmat->GetDensity()*pres*STP_Temperature/(temp*STP_Pressure);
355 mat = new G4Material(name,dens,bmat,kStateGas,temp,pres);
356
357 if (verbose>1) {
358 G4cout << "G4NistMaterialBuilder::ConstructNewGasMaterial: done" << G4endl;
359 G4cout << &mat << G4endl;
360 }
361 return mat;
362}
@ kStateGas
Definition: G4Material.hh:114
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4double GetDensity() const
Definition: G4Material.hh:179
G4State GetState() const
Definition: G4Material.hh:180
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=true)

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 = CLHEP::STP_Temperature,
G4double  pressure = CLHEP::STP_Pressure 
)

Definition at line 366 of file G4NistMaterialBuilder.cc.

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

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 = CLHEP::STP_Temperature,
G4double  pressure = CLHEP::STP_Pressure 
)

Definition at line 271 of file G4NistMaterialBuilder.cc.

280{
281 // Material is in DB
282 G4Material* mat = FindOrBuildMaterial(name);
283 if(mat) {
284 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
285 << " WARNING: the material <" << name
286 << "> is already exist" << G4endl;
287 G4cout << " New material will NOT be built!"
288 << G4endl;
289 return mat;
290 }
291
292 // Material not in DB
293 G4int els = elm.size();
294 if(els == 0) {
295 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
296 << " WARNING: empty list of elements for " << name
297 << G4endl;
298 G4cout << " New material will NOT be built!"
299 << G4endl;
300 return 0;
301 }
302
303 // add parameters of material into internal vectors
304 // density in g/cm3, mean ionisation potential is not defined
305 G4bool stp = true;
306 if(state == kStateGas && temp != STP_Temperature && pres != STP_Pressure)
307 { stp = false; }
308 AddMaterial(name,dens*cm3/g,0,0.,els,state,stp);
309 if(!stp) { AddGas(name,temp,pres); }
310
311 for (G4int i=0; i<els; ++i) {
312 AddElementByWeightFraction(elmBuilder->GetZ(elm[i]), w[i]);
313 }
314
315 return BuildMaterial(nMaterials-1, isotopes);
316}

◆ 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 = CLHEP::STP_Temperature,
G4double  pressure = CLHEP::STP_Pressure 
)

Definition at line 221 of file G4NistMaterialBuilder.cc.

230{
231 // Material is in DB
232 G4Material* mat = FindOrBuildMaterial(name);
233 if(mat) {
234 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
235 << " WARNING: the material <" << name
236 << "> is already exist" << G4endl;
237 G4cout << " New material will NOT be built!"
238 << G4endl;
239 return mat;
240 }
241
242 // Material not in DB
243 G4int els = elm.size();
244 if(els == 0) {
245 G4cout << "G4NistMaterialBuilder::ConstructNewMaterial:"
246 << " WARNING: empty list of elements for " << name
247 << G4endl;
248 G4cout << " New material will NOT be built!"
249 << G4endl;
250 return 0;
251 }
252
253 // add parameters of material into internal vectors
254 // density in g/cm3, mean ionisation potential is not defined
255 G4bool stp = true;
256 if(state == kStateGas && temp != STP_Temperature && pres != STP_Pressure)
257 { stp = false; }
258
259 AddMaterial(name,dens*cm3/g,0,0.,els,state,stp);
260 if(!stp) { AddGas(name,temp,pres); }
261
262 for (G4int i=0; i<els; ++i) {
263 AddElementByAtomCount(elmBuilder->GetZ(elm[i]), nbAtoms[i]);
264 }
265
266 return BuildMaterial(nMaterials-1, isotopes);
267}

Referenced by G4NistManager::ConstructNewMaterial().

◆ FindOrBuildMaterial()

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

Definition at line 94 of file G4NistMaterialBuilder.cc.

97{
98 if(first) {
99 if(verbose > 0) {
100 G4cout << "### NIST DataBase for Materials is used" << G4endl;
101 }
102 first = false;
103 }
104
105 G4String name = matname;
106 if("G4_NYLON-6/6" == matname) { name = "G4_NYLON-6-6"; }
107 if("G4_NYLON-6/10" == matname) { name = "G4_NYLON-6-10";}
108
109 if (verbose > 1) {
110 G4cout << "G4NistMaterialBuilder::FindOrBuildMaterial " << name << G4endl;
111 }
112 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
113 G4int nmat = theMaterialTable->size();
114
115 // Check if name inside DB
116 G4Material* mat = 0;
117
118 for (G4int i=0; i<nMaterials; ++i) {
119
120 if (name == names[i]) {
121 // Build new Nist material
122 if(matIndex[i] == -1) { mat = BuildMaterial(i, isotopes); }
123 // Nist material was already built
124 else { mat = (*theMaterialTable)[matIndex[i]]; }
125 return mat;
126 }
127 }
128
129 // Check the list of all materials
130 if (nmat > 0) {
131 for (G4int i=0; i<nmat; ++i) {
132 if(name == ((*theMaterialTable)[i])->GetName()) {
133 mat = (*theMaterialTable)[i];
134 return mat;
135 }
136 }
137 }
138
139 if( (verbose == 1 && warning) || verbose > 1) {
140 G4cout << "G4NistMaterialBuilder::FindOrBuildMaterial WARNING:"
141 << " material <" << name
142 << "> is not found out" << G4endl;
143 }
144 return mat;
145}
std::vector< G4Material * > G4MaterialTable
static const G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:562

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

◆ GetMaterialNames()

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

Definition at line 218 of file G4NistMaterialBuilder.hh.

219{
220 return names;
221}

Referenced by G4NistManager::GetNistMaterialNames().

◆ GetMeanIonisationEnergy()

G4double G4NistMaterialBuilder::GetMeanIonisationEnergy ( G4int  index) const
inline

Definition at line 224 of file G4NistMaterialBuilder.hh.

225{
226 G4double res = 10*index;
227 if(index >= 0 && index < nMaterials) { res = ionPotentials[index]; }
228 return res;
229}

Referenced by G4NistManager::GetMeanIonisationEnergy().

◆ ListBioChemicalMaterials()

void G4NistMaterialBuilder::ListBioChemicalMaterials ( )

Definition at line 568 of file G4NistMaterialBuilder.cc.

569{
570 G4cout << "=======================================================" << G4endl;
571 G4cout << "### Bio-Chemical Materials ##" << G4endl;
572 G4cout << "=======================================================" << G4endl;
573 G4cout << " Ncomp Name ChFormula density(g/cm^3) I(eV) " << G4endl;
574 G4cout << "=======================================================" << G4endl;
575 for (G4int i=nSpace; i<nMaterials; ++i) {DumpMix(i);}
576 G4cout << "=======================================================" << G4endl;
577}

Referenced by ListMaterials().

◆ ListHepMaterials()

void G4NistMaterialBuilder::ListHepMaterials ( )

Definition at line 542 of file G4NistMaterialBuilder.cc.

543{
544 G4cout << "=======================================================" << G4endl;
545 G4cout << "### HEP & Nuclear Materials ##" << G4endl;
546 G4cout << "=======================================================" << G4endl;
547 G4cout << " Ncomp Name ChFormula density(g/cm^3) I(eV) " << G4endl;
548 G4cout << "=======================================================" << G4endl;
549 for (G4int i=nNIST; i<nHEP; ++i) {DumpMix(i);}
550 G4cout << "=======================================================" << G4endl;
551}

Referenced by ListMaterials().

◆ ListMaterials()

void G4NistMaterialBuilder::ListMaterials ( const G4String mnam)

Definition at line 494 of file G4NistMaterialBuilder.cc.

495{
496 if (mnam == "simple") { ListNistSimpleMaterials(); }
497 else if (mnam == "compound") { ListNistCompoundMaterials(); }
498 else if (mnam == "hep") { ListHepMaterials(); }
499 else if (mnam == "space") { ListSpaceMaterials(); }
500 else if (mnam == "biochemical") { ListBioChemicalMaterials(); }
501
502 else if (mnam == "all") {
508
509 } else {
510 G4cout << "### G4NistMaterialBuilder::ListMaterials: Warning "
511 << mnam << " list is not known" << G4endl;
512 }
513}

Referenced by G4NistManager::ListMaterials().

◆ ListNistCompoundMaterials()

void G4NistMaterialBuilder::ListNistCompoundMaterials ( )

Definition at line 530 of file G4NistMaterialBuilder.cc.

531{
532 G4cout << "### Compound Materials from the NIST Data Base ##" << G4endl;
533 G4cout << "=======================================================" << G4endl;
534 G4cout << " Ncomp Name ChFormula density(g/cm^3) I(eV) " << G4endl;
535 G4cout << "=======================================================" << G4endl;
536 for (G4int i=nElementary; i<nNIST; ++i) {DumpMix(i);}
537 G4cout << "=======================================================" << G4endl;
538}

Referenced by ListMaterials().

◆ ListNistSimpleMaterials()

void G4NistMaterialBuilder::ListNistSimpleMaterials ( )

Definition at line 517 of file G4NistMaterialBuilder.cc.

518{
519 G4cout << "=======================================================" << G4endl;
520 G4cout << "### Simple Materials from the NIST Data Base ###" << G4endl;
521 G4cout << "=======================================================" << G4endl;
522 G4cout << " Z Name ChFormula density(g/cm^3) I(eV) " << G4endl;
523 G4cout << "=======================================================" << G4endl;
524 for (G4int i=0; i<nElementary; ++i) {DumpElm(i);}
525 G4cout << "=======================================================" << G4endl;
526}

Referenced by ListMaterials().

◆ ListSpaceMaterials()

void G4NistMaterialBuilder::ListSpaceMaterials ( )

Definition at line 555 of file G4NistMaterialBuilder.cc.

556{
557 G4cout << "=======================================================" << G4endl;
558 G4cout << "### Space ISS Materials ##" << G4endl;
559 G4cout << "=======================================================" << G4endl;
560 G4cout << " Ncomp Name ChFormula density(g/cm^3) I(eV) " << G4endl;
561 G4cout << "=======================================================" << G4endl;
562 for (G4int i=nHEP; i<nSpace; ++i) {DumpMix(i);}
563 G4cout << "=======================================================" << G4endl;
564}

Referenced by ListMaterials().

◆ SetVerbose()

void G4NistMaterialBuilder::SetVerbose ( G4int  val)

Definition at line 486 of file G4NistMaterialBuilder.cc.

487{
488 verbose = val;
489 elmBuilder->SetVerbose(verbose);
490}

Referenced by G4NistManager::SetVerbose().


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