G4tgbMaterialMixtureByVolume Class Reference

#include <G4tgbMaterialMixtureByVolume.hh>

Inheritance diagram for G4tgbMaterialMixtureByVolume:

G4tgbMaterialMixture G4tgbMaterial

Public Member Functions

 G4tgbMaterialMixtureByVolume ()
 G4tgbMaterialMixtureByVolume (G4tgrMaterial *tgr)
 ~G4tgbMaterialMixtureByVolume ()
G4MaterialBuildG4Material ()
void TransformToFractionsByWeight ()

Detailed Description

Definition at line 50 of file G4tgbMaterialMixtureByVolume.hh.


Constructor & Destructor Documentation

G4tgbMaterialMixtureByVolume::G4tgbMaterialMixtureByVolume (  ) 

Definition at line 44 of file G4tgbMaterialMixtureByVolume.cc.

00045 {
00046 }

G4tgbMaterialMixtureByVolume::G4tgbMaterialMixtureByVolume ( G4tgrMaterial tgr  ) 

Definition at line 56 of file G4tgbMaterialMixtureByVolume.cc.

References G4tgbMaterial::theTgrMate.

00057 {
00058   theTgrMate = hg;
00059 }

G4tgbMaterialMixtureByVolume::~G4tgbMaterialMixtureByVolume (  ) 

Definition at line 50 of file G4tgbMaterialMixtureByVolume.cc.

00051 {
00052 }


Member Function Documentation

G4Material * G4tgbMaterialMixtureByVolume::BuildG4Material (  )  [virtual]

Implements G4tgbMaterial.

Definition at line 63 of file G4tgbMaterialMixtureByVolume.cc.

References G4Material::AddMaterial(), FatalException, G4tgbMaterialMgr::FindOrBuildG4Material(), G4cout, G4endl, G4Exception(), G4tgbMaterialMixture::GetComponent(), G4tgrMaterial::GetDensity(), G4tgbMaterialMgr::GetInstance(), G4tgrMaterial::GetName(), G4tgrMaterial::GetNumberOfComponents(), G4tgrMaterial::GetPressure(), G4tgrMaterial::GetState(), G4tgrMaterial::GetTemperature(), G4tgrMessenger::GetVerboseLevel(), G4tgbMaterial::theTgrMate, and TransformToFractionsByWeight().

00064 {
00065  
00066   //----- construct new G4Material with components materials (a mixture)
00067   G4Material* mate = new G4Material( theTgrMate->GetName(),
00068                                      theTgrMate->GetDensity(),
00069                                      theTgrMate->GetNumberOfComponents(),
00070                                      theTgrMate->GetState(),
00071                                      theTgrMate->GetTemperature(),
00072                                      theTgrMate->GetPressure() );
00073 #ifdef G4VERBOSE
00074   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00075   {
00076     G4cout << " G4tgbMaterialMixtureByVolume::buildG4Material() -"
00077            << " Constructing new G4Material:"
00078            << " " << theTgrMate->GetName() 
00079            << " " << theTgrMate->GetDensity()/g*cm3
00080            << " " << theTgrMate->GetNumberOfComponents()
00081            << " " << theTgrMate->GetState()
00082            << " " << theTgrMate->GetTemperature()
00083            << " " << theTgrMate->GetPressure() << G4endl;
00084   }
00085 #endif
00086  
00087   //----- Transform fractions by volume to fractions by weight
00088   TransformToFractionsByWeight();
00089 
00090   //----- Add components
00091   G4Material* compMate = 0;
00092   G4tgbMaterialMgr* mf = G4tgbMaterialMgr::GetInstance();
00093   for( G4int ii = 0; ii < theTgrMate->GetNumberOfComponents(); ii++)
00094   {
00095     // Look if this component is a material
00096     compMate = mf->FindOrBuildG4Material( GetComponent(ii) );
00097     if( compMate != 0 )
00098     { 
00099       // If it is a material add it by weight fraction 
00100       mate->AddMaterial( compMate, theFractionsByWeight[ii] );
00101     }
00102     else
00103     {
00104       G4String ErrMessage = "Component " + GetComponent(ii)
00105                           + " of material " + theTgrMate->GetName()
00106                           + "\n" + "is not an element nor a material !";
00107       G4Exception("G4tgbMaterialMixtureByVolume::BuildG4Material()",
00108                   "InvalidSetup", FatalException, ErrMessage);
00109     }
00110   } 
00111 
00112 #ifdef G4VERBOSE
00113   if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00114   {
00115     G4cout << " Constructing new G4Material by volume: " << *mate << G4endl; 
00116   }
00117 #endif      
00118 
00119   return mate;
00120 }

void G4tgbMaterialMixtureByVolume::TransformToFractionsByWeight (  )  [virtual]

Reimplemented from G4tgbMaterialMixture.

Definition at line 124 of file G4tgbMaterialMixtureByVolume.cc.

References FatalException, G4tgbMaterialMgr::FindOrBuildG4Material(), G4cout, G4endl, G4Exception(), G4tgbMaterialMixture::GetComponent(), G4Material::GetDensity(), G4tgbMaterialMixture::GetFraction(), G4tgbMaterialMgr::GetInstance(), G4Material::GetName(), G4tgrMaterial::GetName(), G4tgrMaterial::GetNumberOfComponents(), G4tgrMessenger::GetVerboseLevel(), and G4tgbMaterial::theTgrMate.

Referenced by BuildG4Material().

00125 { 
00126   G4tgbMaterialMgr* mf = G4tgbMaterialMgr::GetInstance();
00127   G4Material* compMate = 0;
00128   G4double totalfd = 0.;
00129   for( G4int ii = 0; ii < theTgrMate->GetNumberOfComponents(); ii++ )
00130   {
00131     compMate = mf->FindOrBuildG4Material( GetComponent(ii) );
00132     if( compMate != 0 )
00133     {
00134       // If it is a material add it by weight fraction 
00135       theFractionsByWeight.push_back( GetFraction(ii)*compMate->GetDensity() );
00136       totalfd += theFractionsByWeight[ii];
00137     }
00138     else
00139     {
00140       G4String ErrMessage = "Component " + GetComponent(ii)
00141                           + " of material " + theTgrMate->GetName()
00142                           + "\n" + "is not a material !";
00143       G4Exception("G4tgbMaterialMixtureByVolume::BuildG4Material()",
00144                   "InvalidSetup", FatalException, ErrMessage);
00145     }   
00146   }
00147   for( G4int ii = 0; ii < theTgrMate->GetNumberOfComponents(); ii++ )
00148   {
00149     theFractionsByWeight[ii] /= totalfd;
00150 #ifdef G4VERBOSE
00151     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00152     {
00153       G4cout << " G4tgbMaterialMixtureByVolume::TransformToFractionsByWeight()"
00154              << " Component " << ii  << " : "
00155              << mf->FindOrBuildG4Material( GetComponent(ii) )->GetName()
00156              << " FractionByVolume= " << GetFraction(ii)
00157              << " FractionByWeight= " << theFractionsByWeight[ii] 
00158              << G4endl;
00159     }
00160 #endif
00161   }
00162 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:29 2013 for Geant4 by  doxygen 1.4.7