00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #include "G4NistManager.hh"
00061 #include "G4NistMessenger.hh"
00062 #include "G4Isotope.hh"
00063
00064 G4NistManager* G4NistManager::instance = 0;
00065
00066
00067
00068 G4NistManager* G4NistManager::Instance()
00069 {
00070 if (instance == 0) {
00071 static G4NistManager manager;
00072 instance = &manager;
00073 }
00074 return instance;
00075 }
00076
00077
00078
00079 G4NistManager::G4NistManager()
00080 {
00081 nElements = 0;
00082 nMaterials = 0;
00083 verbose = 0;
00084
00085 elmBuilder = new G4NistElementBuilder(verbose);
00086 matBuilder = new G4NistMaterialBuilder(elmBuilder,verbose);
00087
00088 messenger = new G4NistMessenger(this);
00089 g4pow = G4Pow::GetInstance();
00090
00091
00092 for(G4int j=1; j<101; ++j) {
00093 G4double A = elmBuilder->GetAtomicMassAmu(j);
00094 POWERA27[j] = std::pow(A,0.27);
00095 LOGAZ[j] = std::log(A);
00096 }
00097 POWERA27[0] = 1.0;
00098 LOGAZ[0] = 0.0;
00099 }
00100
00101
00102
00103 G4NistManager::~G4NistManager()
00104 {
00105
00106 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
00107 size_t nmat = theMaterialTable->size();
00108 size_t i;
00109 for(i=0; i<nmat; i++) {
00110 if((*theMaterialTable)[i]) { delete (*theMaterialTable)[i]; }
00111 }
00112
00113 const G4ElementTable* theElementTable = G4Element::GetElementTable();
00114 size_t nelm = theElementTable->size();
00115 for(i=0; i<nelm; i++) {
00116 if((*theElementTable)[i]) { delete (*theElementTable)[i]; }
00117 }
00118
00119 const G4IsotopeTable* theIsotopeTable = G4Isotope::GetIsotopeTable();
00120 size_t niso = theIsotopeTable->size();
00121 for(i=0; i<niso; i++) {
00122 if((*theIsotopeTable)[i]) { delete (*theIsotopeTable)[i]; }
00123 }
00124
00125 delete messenger;
00126 delete matBuilder;
00127 delete elmBuilder;
00128
00129 }
00130
00131
00132
00133 G4Material*
00134 G4NistManager::BuildMaterialWithNewDensity(const G4String& name,
00135 const G4String& basename,
00136 G4double density,
00137 G4double temperature,
00138 G4double pressure)
00139 {
00140 G4Material* bmat = FindOrBuildMaterial(name);
00141 if(bmat) {
00142 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
00143 G4cout << " New material <" << name << "> cannot be built because material"
00144 << " with the same name already exist" << G4endl;
00145 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat101",
00146 FatalException, "Wrong material name");
00147 return 0;
00148 }
00149 bmat = FindOrBuildMaterial(basename);
00150 if(!bmat) {
00151 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
00152 G4cout << " New material <" << name << "> cannot be built because " << G4endl;
00153 G4cout << " base material <" << basename << "> does not exist" << G4endl;
00154 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat102",
00155 FatalException, "Wrong material name");
00156 return 0;
00157 }
00158 G4double dens = density;
00159 G4double temp = temperature;
00160 G4double pres = pressure;
00161 if(dens == 0.0) {
00162 dens = bmat->GetDensity();
00163 temp = bmat->GetTemperature();
00164 pres = bmat->GetPressure();
00165 }
00166 G4Material* mat = new G4Material(name, dens, bmat, bmat->GetState(),
00167 temp, pres);
00168 return mat;
00169 }
00170
00171
00172
00173 void G4NistManager::PrintElement(const G4String& symbol)
00174 {
00175 if (symbol == "all") { elmBuilder->PrintElement(0); }
00176 else { elmBuilder->PrintElement(elmBuilder->GetZ(symbol)); }
00177 }
00178
00179
00180
00181 void G4NistManager::PrintG4Element(const G4String& name)
00182 {
00183 const G4ElementTable* theElementTable = G4Element::GetElementTable();
00184 size_t nelm = theElementTable->size();
00185 for(size_t i=0; i<nelm; i++) {
00186 G4Element* elm = (*theElementTable)[i];
00187 if ( name == elm->GetName() || "all" == name) {
00188 G4cout << *elm << G4endl;
00189 return;
00190 }
00191 }
00192 }
00193
00194
00195
00196 void G4NistManager::PrintG4Material(const G4String& name)
00197 {
00198 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
00199 size_t nmat = theMaterialTable->size();
00200 for(size_t i=0; i<nmat; i++) {
00201 G4Material* mat = (*theMaterialTable)[i];
00202 if ( name == mat->GetName() || "all" == name) {
00203 G4cout << *mat << G4endl;
00204 return;
00205 }
00206 }
00207 }
00208
00209
00210
00211 void G4NistManager::SetVerbose(G4int val)
00212 {
00213 verbose = val;
00214 elmBuilder->SetVerbose(val);
00215 matBuilder->SetVerbose(val);
00216 }
00217
00218