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

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 6.5 KB
RevLine 
[822]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//
[1058]27// $Id: G4MaterialPropertiesTable.cc,v 1.21 2009/04/21 15:35:45 gcosmo Exp $
[1337]28// GEANT4 tag $Name: geant4-09-04-beta-01 $
[822]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
[1058]53/////////////////
54// Constructors
55/////////////////
[822]56
[1058]57G4MaterialPropertiesTable::G4MaterialPropertiesTable()
[822]58{
59}
60
[1058]61////////////////
62// Destructor
63////////////////
[822]64
[1058]65G4MaterialPropertiesTable::~G4MaterialPropertiesTable()
[822]66{
[1058]67  MPTiterator i;
68  for (i = MPT.begin(); i != MPT.end(); ++i)
69  {
70    delete (*i).second;
71  }
72  MPT.clear();
73  MPTC.clear();
[822]74}
75
[1058]76////////////
77// Methods
78////////////
[822]79
80void G4MaterialPropertiesTable::DumpTable()
81{
82  MPTiterator i;
[1058]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    }
[822]95  }
96  MPTCiterator j;
[1058]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    }
[822]109  }
[1058]110}
[822]111
112G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
113{
114  // fetch RINDEX data, give up if unavailable
[1058]115  //
[822]116  G4MaterialPropertyVector *rindex = this->GetProperty("RINDEX");
[1058]117  if (rindex==0)  { return 0; }
[822]118  rindex->ResetIterator();
[1058]119
[822]120  // RINDEX exists but has no entries, give up
[1058]121  //
122  if ( (++*rindex) == false )  { return 0; }
[822]123
124  // add GROUPVEL vector
[1058]125  //
[822]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
[1058]132  //
[850]133  G4double E0 = rindex->GetPhotonEnergy();
[822]134  G4double n0 = rindex->GetProperty();
135
[1058]136  if (E0 <= 0.)
137  {
138    G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "ZeroEnergy",
139                FatalException, "Optical Photon Energy <= 0");
140  }
[822]141                                                                               
[1058]142  if ( ++*rindex )
143  {
[822]144    // good, we have at least two entries in RINDEX
145    // get next energy/value pair
[1058]146
[850]147    G4double E1 = rindex->GetPhotonEnergy();
[822]148    G4double n1 = rindex->GetProperty();
149
[1058]150    if (E1 <= 0.)
151    {
152      G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "ZeroEnergy",
153                  FatalException, "Optical Photon Energy <= 0");
154    }
155
[822]156    G4double vg;
[1058]157
[822]158    // add entry at first photon energy
[1058]159    //
[822]160    vg = c_light/(n0+(n1-n0)/std::log(E1/E0));
[1058]161
[822]162    // allow only for 'normal dispersion' -> dn/d(logE) > 0
[1058]163    //
164    if((vg<0) || (vg>c_light/n0))  { vg = c_light/n0; }
165
[822]166    groupvel->AddElement( E0, vg );
[1058]167
[822]168    // add entries at midpoints between remaining photon energies
[1058]169    //
170    while(1)
171    {
[822]172      vg = c_light/( 0.5*(n0+n1)+(n1-n0)/std::log(E1/E0));
[1058]173
[822]174      // allow only for 'normal dispersion' -> dn/d(logE) > 0
[1058]175      //
176      if((vg<0) || (vg>c_light/(0.5*(n0+n1))))  { vg = c_light/(0.5*(n0+n1)); }
[822]177      groupvel->AddElement( 0.5*(E0+E1), vg );
[1058]178
[822]179      // get next energy/value pair, or exit loop
[1058]180      //
181      if (!(++*rindex))  { break; }
[822]182      E0 = E1;
183      n0 = n1;
[850]184      E1 = rindex->GetPhotonEnergy();
[822]185      n1 = rindex->GetProperty();
186
[1058]187      if (E1 <= 0.)
188      {
189        G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "ZeroEnergy",
190                    FatalException, "Optical Photon Energy <= 0");
191      }
[822]192    }
[1058]193
[822]194    // add entry at last photon energy
[1058]195    //
[822]196    vg = c_light/(n1+(n1-n0)/std::log(E1/E0));
[1058]197
[822]198    // allow only for 'normal dispersion' -> dn/d(logE) > 0
[1058]199    //
200    if((vg<0) || (vg>c_light/n1))  { vg = c_light/n1; }
[822]201    groupvel->AddElement( E1, vg );
[1058]202  }
203  else // only one entry in RINDEX -- weird!
204  {
[822]205    groupvel->AddElement( E0, c_light/n0 );
206  }
207                                                                               
208  return groupvel;
209}
Note: See TracBrowser for help on using the repository browser.