source: trunk/source/materials/src/G4MaterialPropertiesTable.cc@ 1131

Last change on this file since 1131 was 1058, checked in by garnier, 17 years ago

file release beta

File size: 6.5 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//
27// $Id: G4MaterialPropertiesTable.cc,v 1.21 2009/04/21 15:35:45 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
29//
30//
31////////////////////////////////////////////////////////////////////////
32// G4MaterialPropertiesTable Implementation
33////////////////////////////////////////////////////////////////////////
34//
35// File: G4MaterialPropertiesTable.cc
36// Version: 1.0
37// Created: 1996-02-08
38// Author: Juliet Armstrong
39// Updated: 2005-05-12 add SetGROUPVEL(), courtesy of
40// Horton-Smith (bug report #741), by P. Gumplinger
41// 2002-11-05 add named material constants by P. Gumplinger
42// 1999-11-05 Migration from G4RWTPtrHashDictionary to STL
43// by John Allison
44// 1997-03-26 by Peter Gumplinger
45// > cosmetics (only)
46// mail: gum@triumf.ca
47//
48////////////////////////////////////////////////////////////////////////
49
50#include "globals.hh"
51#include "G4MaterialPropertiesTable.hh"
52
53/////////////////
54// Constructors
55/////////////////
56
57G4MaterialPropertiesTable::G4MaterialPropertiesTable()
58{
59}
60
61////////////////
62// Destructor
63////////////////
64
65G4MaterialPropertiesTable::~G4MaterialPropertiesTable()
66{
67 MPTiterator i;
68 for (i = MPT.begin(); i != MPT.end(); ++i)
69 {
70 delete (*i).second;
71 }
72 MPT.clear();
73 MPTC.clear();
74}
75
76////////////
77// Methods
78////////////
79
80void G4MaterialPropertiesTable::DumpTable()
81{
82 MPTiterator i;
83 for (i = MPT.begin(); i != MPT.end(); ++i)
84 {
85 G4cout << (*i).first << G4endl;
86 if ( (*i).second != 0 )
87 {
88 (*i).second->DumpVector();
89 }
90 else
91 {
92 G4Exception("G4MaterialPropertiesTable::DumpTable()", "NullVector",
93 JustWarning, "NULL Material Property Vector Pointer.");
94 }
95 }
96 MPTCiterator j;
97 for (j = MPTC.begin(); j != MPTC.end(); ++j)
98 {
99 G4cout << j->first << G4endl;
100 if ( j->second != 0 )
101 {
102 G4cout << j->second << G4endl;
103 }
104 else
105 {
106 G4Exception("G4MaterialPropertiesTable::DumpTable()", "NotFound",
107 JustWarning, "No Material Constant Property.");
108 }
109 }
110}
111
112G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
113{
114 // fetch RINDEX data, give up if unavailable
115 //
116 G4MaterialPropertyVector *rindex = this->GetProperty("RINDEX");
117 if (rindex==0) { return 0; }
118 rindex->ResetIterator();
119
120 // RINDEX exists but has no entries, give up
121 //
122 if ( (++*rindex) == false ) { return 0; }
123
124 // add GROUPVEL vector
125 //
126 G4MaterialPropertyVector* groupvel = new G4MaterialPropertyVector();
127
128 this->AddProperty( "GROUPVEL", groupvel );
129
130 // fill GROUPVEL vector using RINDEX values
131 // rindex built-in "iterator" was advanced to first entry above
132 //
133 G4double E0 = rindex->GetPhotonEnergy();
134 G4double n0 = rindex->GetProperty();
135
136 if (E0 <= 0.)
137 {
138 G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "ZeroEnergy",
139 FatalException, "Optical Photon Energy <= 0");
140 }
141
142 if ( ++*rindex )
143 {
144 // good, we have at least two entries in RINDEX
145 // get next energy/value pair
146
147 G4double E1 = rindex->GetPhotonEnergy();
148 G4double n1 = rindex->GetProperty();
149
150 if (E1 <= 0.)
151 {
152 G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "ZeroEnergy",
153 FatalException, "Optical Photon Energy <= 0");
154 }
155
156 G4double vg;
157
158 // add entry at first photon energy
159 //
160 vg = c_light/(n0+(n1-n0)/std::log(E1/E0));
161
162 // allow only for 'normal dispersion' -> dn/d(logE) > 0
163 //
164 if((vg<0) || (vg>c_light/n0)) { vg = c_light/n0; }
165
166 groupvel->AddElement( E0, vg );
167
168 // add entries at midpoints between remaining photon energies
169 //
170 while(1)
171 {
172 vg = c_light/( 0.5*(n0+n1)+(n1-n0)/std::log(E1/E0));
173
174 // allow only for 'normal dispersion' -> dn/d(logE) > 0
175 //
176 if((vg<0) || (vg>c_light/(0.5*(n0+n1)))) { vg = c_light/(0.5*(n0+n1)); }
177 groupvel->AddElement( 0.5*(E0+E1), vg );
178
179 // get next energy/value pair, or exit loop
180 //
181 if (!(++*rindex)) { break; }
182 E0 = E1;
183 n0 = n1;
184 E1 = rindex->GetPhotonEnergy();
185 n1 = rindex->GetProperty();
186
187 if (E1 <= 0.)
188 {
189 G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "ZeroEnergy",
190 FatalException, "Optical Photon Energy <= 0");
191 }
192 }
193
194 // add entry at last photon energy
195 //
196 vg = c_light/(n1+(n1-n0)/std::log(E1/E0));
197
198 // allow only for 'normal dispersion' -> dn/d(logE) > 0
199 //
200 if((vg<0) || (vg>c_light/n1)) { vg = c_light/n1; }
201 groupvel->AddElement( E1, vg );
202 }
203 else // only one entry in RINDEX -- weird!
204 {
205 groupvel->AddElement( E0, c_light/n0 );
206 }
207
208 return groupvel;
209}
Note: See TracBrowser for help on using the repository browser.