source: trunk/source/materials/src/G4NistManager.cc@ 1238

Last change on this file since 1238 was 1196, checked in by garnier, 16 years ago

update CVS release candidate geant4.9.3.01

File size: 6.4 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id: G4NistManager.cc,v 1.19 2008/07/23 14:49:31 vnivanch Exp $
27// GEANT4 tag $Name: materials-V09-02-18 $
28//
29// -------------------------------------------------------------------
30//
31// GEANT4 Class file
32//
33//
34// File name: G4NistManager
35//
36// Author: Vladimir Ivanchenko
37//
38// Creation date: 23.12.2004
39//
40// Modifications:
41// 27.02.06 V.Ivanchneko add ConstructNewGasMaterial
42// 18.04.06 V.Ivanchneko add combined creation of materials (NIST + user)
43// 11.05.06 V.Ivanchneko add warning flag to FindMaterial method
44// 26.07.07 V.Ivanchneko modify destructor to provide complete destruction
45// of all elements and materials
46// 27-07-07, improve destructor (V.Ivanchenko)
47// 28.07.07 V.Ivanchneko make simple methods inline
48// 28.07.07 V.Ivanchneko simplify Print methods
49//
50// -------------------------------------------------------------------
51//
52// Class Description:
53//
54// Element data from the NIST DB on Atomic Weights and Isotope Compositions
55// http://physics.nist.gov/PhysRefData/Compositions/index.html
56//
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59
60#include "G4NistManager.hh"
61#include "G4NistMessenger.hh"
62#include "G4Isotope.hh"
63
64G4NistManager* G4NistManager::instance = 0;
65
66//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
67
68G4NistManager* G4NistManager::Instance()
69{
70 if (instance == 0) {
71 static G4NistManager manager;
72 instance = &manager;
73 }
74 return instance;
75}
76
77//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78
79G4NistManager::G4NistManager()
80{
81 nElements = 0;
82 nMaterials = 0;
83 verbose = 0;
84
85 elmBuilder = new G4NistElementBuilder(verbose);
86 matBuilder = new G4NistMaterialBuilder(elmBuilder,verbose);
87
88 messenger = new G4NistMessenger(this);
89
90 // compute frequently used values
91 for(G4int i=1; i<256; i++) {
92 G4double x = G4double(i);
93 POWERZ13[i] = std::pow(x,1.0/3.0);
94 LOGA[i] = std::log(x);
95 }
96 for(G4int j=1; j<101; j++) {
97 G4double A = elmBuilder->GetA(j);
98 POWERA27[j] = std::pow(A,0.27);
99 LOGAZ[j] = std::log(A);
100 }
101 POWERZ13[0] = 1.0;
102 POWERA27[0] = 1.0;
103 LOGA[0] = 0.0;
104 LOGAZ[0] = 0.0;
105}
106
107//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108
109G4NistManager::~G4NistManager()
110{
111 // G4cout << "NistManager: start material destruction" << G4endl;
112 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
113 size_t nmat = theMaterialTable->size();
114 size_t i;
115 for(i=0; i<nmat; i++) {
116 if((*theMaterialTable)[i]) delete (*theMaterialTable)[i];
117 }
118 // G4cout << "NistManager: start element destruction" << G4endl;
119 const G4ElementTable* theElementTable = G4Element::GetElementTable();
120 size_t nelm = theElementTable->size();
121 for(i=0; i<nelm; i++) {
122 if((*theElementTable)[i]) delete (*theElementTable)[i];
123 }
124 // G4cout << "NistManager: start isotope destruction" << G4endl;
125 const G4IsotopeTable* theIsotopeTable = G4Isotope::GetIsotopeTable();
126 size_t niso = theIsotopeTable->size();
127 for(i=0; i<niso; i++) {
128 if((*theIsotopeTable)[i]) delete (*theIsotopeTable)[i];
129 }
130 // G4cout << "NistManager: end isotope destruction" << G4endl;
131 delete messenger;
132 delete matBuilder;
133 delete elmBuilder;
134 // G4cout << "NistManager: end destruction" << G4endl;
135}
136
137//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138
139void G4NistManager::PrintElement(const G4String& symbol)
140{
141 if (symbol == "all") elmBuilder->PrintElement(0);
142 else elmBuilder->PrintElement(elmBuilder->GetZ(symbol));
143}
144
145//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146
147void G4NistManager::PrintG4Element(const G4String& name)
148{
149 const G4ElementTable* theElementTable = G4Element::GetElementTable();
150 size_t nelm = theElementTable->size();
151 for(size_t i=0; i<nelm; i++) {
152 G4Element* elm = (*theElementTable)[i];
153 if ( name == elm->GetName() || "all" == name) {
154 G4cout << *elm << G4endl;
155 return;
156 }
157 }
158}
159
160//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
161
162void G4NistManager::PrintG4Material(const G4String& name)
163{
164 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
165 size_t nmat = theMaterialTable->size();
166 for(size_t i=0; i<nmat; i++) {
167 G4Material* mat = (*theMaterialTable)[i];
168 if ( name == mat->GetName() || "all" == name) {
169 G4cout << *mat << G4endl;
170 return;
171 }
172 }
173}
174
175//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176
177void G4NistManager::SetVerbose(G4int val)
178{
179 verbose = val;
180 elmBuilder->SetVerbose(val);
181 matBuilder->SetVerbose(val);
182}
183
184//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.