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