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

Last change on this file since 834 was 822, checked in by garnier, 17 years ago

import all except CVS

File size: 6.8 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.15 2007/12/11 13:32:08 gcosmo Exp $
27// GEANT4 tag $Name: geant4-09-01-patch-02 $
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;
65G4double G4NistManager::POWERZ13[256] = {0};
66G4double G4NistManager::LOGA[256] = {0};
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
69
70G4NistManager* G4NistManager::Instance()
71{
72 if (instance == 0) {
73 static G4NistManager manager;
74 instance = &manager;
75 }
76 return instance;
77}
78
79//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80
81G4NistManager::G4NistManager()
82{
83 nElements = 0;
84 nMaterials = 0;
85 verbose = 0;
86
87 elmBuilder = new G4NistElementBuilder(verbose);
88 matBuilder = new G4NistMaterialBuilder(elmBuilder,verbose);
89
90 messenger = new G4NistMessenger(this);
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 POWERZ13[0] = 1.0;
97 LOGA[0] = 0.0;
98}
99
100//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101
102G4NistManager::~G4NistManager()
103{
104 // G4cout << "NistManager: start material destruction" << G4endl;
105 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
106 size_t nmat = theMaterialTable->size();
107 size_t i;
108 for(i=0; i<nmat; i++) {
109 if((*theMaterialTable)[i]) delete (*theMaterialTable)[i];
110 }
111 // G4cout << "NistManager: start element destruction" << G4endl;
112 const G4ElementTable* theElementTable = G4Element::GetElementTable();
113 size_t nelm = theElementTable->size();
114 for(i=0; i<nelm; i++) {
115 if((*theElementTable)[i]) delete (*theElementTable)[i];
116 }
117 // G4cout << "NistManager: start isotope destruction" << G4endl;
118 const G4IsotopeTable* theIsotopeTable = G4Isotope::GetIsotopeTable();
119 size_t niso = theIsotopeTable->size();
120 for(i=0; i<niso; i++) {
121 if((*theIsotopeTable)[i]) delete (*theIsotopeTable)[i];
122 }
123 // G4cout << "NistManager: end isotope destruction" << G4endl;
124 delete messenger;
125 delete matBuilder;
126 delete elmBuilder;
127 // G4cout << "NistManager: end destruction" << G4endl;
128}
129
130//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131
132void G4NistManager::PrintElement(const G4String& symbol)
133{
134 if (symbol == "all") elmBuilder->PrintElement(0);
135 else elmBuilder->PrintElement(elmBuilder->GetZ(symbol));
136}
137
138//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139
140void G4NistManager::PrintG4Element(const G4String& name)
141{
142 const G4ElementTable* theElementTable = G4Element::GetElementTable();
143 size_t nelm = theElementTable->size();
144 for(size_t i=0; i<nelm; i++) {
145 G4Element* elm = (*theElementTable)[i];
146 if ( name == elm->GetName() || "all" == name) {
147 G4cout << *elm << G4endl;
148 return;
149 }
150 }
151}
152
153//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154
155void G4NistManager::PrintG4Material(const G4String& name)
156{
157 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
158 size_t nmat = theMaterialTable->size();
159 for(size_t i=0; i<nmat; i++) {
160 G4Material* mat = (*theMaterialTable)[i];
161 if ( name == mat->GetName() || "all" == name) {
162 G4cout << *mat << G4endl;
163 return;
164 }
165 }
166}
167
168//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169
170void G4NistManager::SetVerbose(G4int val)
171{
172 verbose = val;
173 elmBuilder->SetVerbose(val);
174 matBuilder->SetVerbose(val);
175}
176
177//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
178
179G4double G4NistManager::GetZ13(G4double Z)
180{
181 G4int iz = G4int(Z);
182 G4double x = (Z - G4double(iz))/(3.0*Z);
183 if(iz > 255) iz = 255;
184 else if(iz < 0) iz = 0;
185 return POWERZ13[iz]*(1.0 + x);
186}
187
188//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
189
190G4double G4NistManager::GetLOGA(G4double A)
191{
192 G4int ia = G4int(A);
193 G4double x = (A - G4double(ia))/A;
194 if(ia > 255) ia = 255;
195 else if(ia < 0) ia = 0;
196 return LOGA[ia] + x;
197}
198
199//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.