source: trunk/source/materials/test/G4MaterialsTest.cc @ 1315

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

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 7.1 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: G4MaterialsTest.cc,v 1.9 2006/06/29 19:13:14 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
29//
30//
31// ------------------------------------------------------------
32//
33//
34//  This program illustrates the different ways to define materials
35//
36
37#include "G4ios.hh"
38#include "G4Isotope.hh"
39#include "G4Element.hh"
40#include "G4Material.hh"
41#include "G4UnitsTable.hh"
42
43int main() {
44
45G4String name, symbol;             // a=mass of a mole;
46G4double a, z, density;            // z=mean number of protons; 
47G4int iz, n;                       //iz=nb of protons  in an isotope;
48                                   // n=nb of nucleons in an isotope;
49
50G4int ncomponents, natoms;
51G4double abundance, fractionmass;
52G4double temperature, pressure;
53
54G4UnitDefinition::BuildUnitsTable();
55
56//
57// define Elements
58//
59
60a = 1.01*g/mole;
61G4Element* elH  = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
62
63a = 12.01*g/mole;
64G4Element* elC  = new G4Element(name="Carbon"  ,symbol="C" , z= 6., a);
65
66a = 14.01*g/mole;
67G4Element* elN  = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
68
69a = 16.00*g/mole;
70G4Element* elO  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);
71
72a = 28.09*g/mole;
73G4Element* elSi = new G4Element(name="Silicon",symbol="Si" , z= 14., a);
74
75a = 55.85*g/mole;
76G4Element* elFe = new G4Element(name="Iron"    ,symbol="Fe", z=26., a);
77
78//
79// define an Element from isotopes, by relative abundance
80//
81
82G4Isotope* U5 = new G4Isotope(name="U235", iz=92, n=235);
83G4Isotope* U8 = new G4Isotope(name="U238", iz=92, n=238);
84
85G4Element* elU=new G4Element(name="enriched Uranium",symbol="U",ncomponents=2);
86elU->AddIsotope(U5, abundance= 90.*perCent);
87elU->AddIsotope(U8, abundance= 10.*perCent);
88
89
90G4cout << *(G4Isotope::GetIsotopeTable()) << G4endl;
91
92G4cout << *(G4Element::GetElementTable()) << G4endl;
93
94//
95// define simple materials
96//
97
98density = 2.700*g/cm3;
99a = 26.98*g/mole;
100G4Material* Al = new G4Material(name="Aluminium", z=13., a, density);
101
102density = 1.390*g/cm3;
103a = 39.95*g/mole;
104G4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density);
105
106density = 8.960*g/cm3;
107a = 63.55*g/mole;
108G4Material* Cu = new G4Material(name="Copper"   , z=29., a, density);
109
110density = 11.35*g/cm3;
111a = 207.19*g/mole;
112G4Material* Pb = new G4Material(name="Lead "     , z=82., a, density);
113
114//
115// define a material from elements.   case 1: chemical molecule
116//
117 
118density = 1.000*g/cm3;
119G4Material* H2O = new G4Material(name="Water", density, ncomponents=2);
120H2O->AddElement(elH, natoms=2);
121H2O->AddElement(elO, natoms=1);
122
123density = 1.032*g/cm3;
124G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
125Sci->AddElement(elC, natoms=9);
126Sci->AddElement(elH, natoms=10);
127
128density = 2.200*g/cm3;
129G4Material* SiO2 = new G4Material(name="quartz", density, ncomponents=2);
130SiO2->AddElement(elSi, natoms=1);
131SiO2->AddElement(elO , natoms=2);
132
133//
134// define a material from elements.   case 2: mixture by fractional mass
135//
136
137density = 1.290*mg/cm3;
138G4Material* Air = new G4Material(name="Air  "  , density, ncomponents=2);
139Air->AddElement(elN, fractionmass=0.7);
140Air->AddElement(elO, fractionmass=0.3);
141
142//
143// define a material from elements and/or others materials (mixture of mixtures)
144//
145
146density = 0.200*g/cm3;
147G4Material* Aerog = new G4Material(name="Aerogel", density, ncomponents=3);
148Aerog->AddMaterial(SiO2, fractionmass=0.625);
149Aerog->AddMaterial(H2O , fractionmass=0.374);
150Aerog->AddElement (elC , fractionmass=0.1*perCent);
151
152//
153// examples of gas in non STP conditions
154//
155
156density     = 27.*mg/cm3;
157pressure    = 50.*atmosphere;
158temperature = 325.*kelvin;
159G4Material* CO2 = new G4Material(name="Carbonic gas", density, ncomponents=2,
160                                     kStateGas,temperature,pressure);
161CO2->AddElement(elC, natoms=1);
162CO2->AddElement(elO, natoms=2);
163
164density     = 2.67*mg/cm3;
165pressure    = 1.*atmosphere;
166temperature = 273.15*kelvin;
167G4Material* C4H10 = new G4Material(name="isobutane", density, ncomponents=2,
168                                     kStateGas,temperature,pressure);
169C4H10->AddElement(elC, natoms=4);
170C4H10->AddElement(elH, natoms=10);
171 
172density     = 0.3*mg/cm3;
173pressure    = 2.*atmosphere;
174temperature = 500.*kelvin;
175G4Material* steam = new G4Material(name="Water steam ", density, ncomponents=1,
176                                      kStateGas,temperature,pressure);
177steam->AddMaterial(H2O, fractionmass=1.);
178
179//
180// examples of vacuum
181//
182
183density     = universe_mean_density;                //from PhysicalConstants.h
184pressure    = 3.e-18*pascal;
185temperature = 2.73*kelvin;
186new G4Material(name="Galactic", z=1., a=1.01*g/mole, density,
187                   kStateGas,temperature,pressure);
188
189density     = 1.e-5*g/cm3;
190pressure    = 2.e-2*bar;
191temperature = STP_Temperature;                      //from PhysicalConstants.h
192G4Material* beam = new G4Material(name="Beam ", density, ncomponents=1,
193                                      kStateGas,temperature,pressure);
194beam->AddMaterial(Air, fractionmass=1.);
195
196//
197// Print the table of materials
198//
199
200G4cout << *(G4Material::GetMaterialTable()) << G4endl;
201
202//
203// print additional informations
204//
205G4cout << " Nuclear interaction length of Aluminium: " 
206       << Al->GetNuclearInterLength()/cm << " cm" << G4endl;
207       
208G4cout << " Nuclear interaction length of Lead: " 
209       << Pb->GetNuclearInterLength()/cm << " cm" << G4endl;
210             
211G4cout << " Nuclear interaction length of Water: " 
212       << H2O->GetNuclearInterLength()/cm << " cm" << G4endl;
213       
214G4cout << " Nuclear interaction length of Aerogel: " 
215       << Aerog->GetNuclearInterLength()/cm << " cm" << G4endl;
216             
217return EXIT_SUCCESS;
218}
Note: See TracBrowser for help on using the repository browser.