source: trunk/Documentation/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch04s02.html @ 901

Last change on this file since 901 was 901, checked in by garnier, 16 years ago

Add Geant4 Documentation at 8.12.2008

File size: 20.3 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>4.2.  Material</title><link rel="stylesheet" href="../xml/XSLCustomizationLayer/G4HTMLStylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="Geant4 User's Guide for Application Developers"><link rel="up" href="ch04.html" title="Chapter 4.  Detector Definition and Response"><link rel="prev" href="ch04.html" title="Chapter 4.  Detector Definition and Response"><link rel="next" href="ch04s03.html" title="4.3.  Electromagnetic Field"><script language="JavaScript">
2function remote_win(fName)
3{
4   var url = "AllResources/Detector/geometry.src/" + fName;
5   RemoteWin=window.open(url,"","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=520,height=520")
6   RemoteWin.creator=self
7}
8</script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.2. 
9Material
10</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><th width="60%" align="center">Chapter 4. 
11Detector Definition and Response
12</th><td width="20%" align="right"> <a accesskey="n" href="ch04s03.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect.Mate"></a>4.2. 
13Material
14</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.Mate.GenCons"></a>4.2.1. 
15General considerations
16</h3></div></div></div><p>
17In nature, materials (chemical compounds, mixtures) are made of
18elements, and elements are made of isotopes. Geant4 has three main
19classes designed to reflect this organization. Each of these
20classes has a table, which is a static data member, used to keep
21track of the instances of the respective classes created.
22
23</p><div class="variablelist"><p class="title"><b></b></p><dl><dt><span class="term">
24    <span class="emphasis"><em>G4Isotope</em></span>
25  </span></dt><dd><p>
26    This class describes the properties of atoms: atomic number,
27    number of nucleons, mass per mole, etc.
28  </p></dd><dt><span class="term">
29    <span class="emphasis"><em>G4Element</em></span>
30  </span></dt><dd><p>
31    This class describes the properties of elements: effective
32    atomic number, effective number of nucleons, effective mass per
33    mole, number of isotopes, shell energy, and quantities like cross
34    section per atom, etc.
35  </p></dd><dt><span class="term">
36    <span class="emphasis"><em>G4Material</em></span>
37  </span></dt><dd><p>
38    This class describes the macroscopic properties of matter:
39    density, state, temperature, pressure, and macroscopic quantities
40    like radiation length, mean free path, dE/dx, etc.
41  </p></dd></dl></div><p>
42</p><p>
43Only the <span class="emphasis"><em>G4Material</em></span> class is visible to the rest of the
44toolkit and used by the tracking, the geometry and the physics. It
45contains all the information relevant to its constituent elements
46and isotopes, while at the same time hiding their implementation
47details.
48</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.Mate.Intro"></a>4.2.2. 
49Introduction to the Classes
50</h3></div></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.Mate.Intro.Iso"></a>4.2.2.1. 
51G4Isotope
52</h4></div></div></div><p>
53A <span class="emphasis"><em>G4Isotope</em></span> object has a name, atomic number, number of
54nucleons, mass per mole, and an index in the table. The constructor
55automatically stores "this" isotope in the isotopes table, which
56will assign it an index number.
57</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.Mate.Intro.Ele"></a>4.2.2.2. 
58G4Element
59</h4></div></div></div><p>
60A <span class="emphasis"><em>G4Element</em></span> object has a name, symbol, effective atomic
61number, effective number of nucleons, effective mass of a mole, an
62index in the elements table, the number of isotopes, a vector of
63pointers to such isotopes, and a vector of relative abundances
64referring to such isotopes (where relative abundance means the
65number of atoms per volume). In addition, the class has methods to
66add, one by one, the isotopes which are to form the element.
67</p><p>
68A <span class="emphasis"><em>G4Element</em></span> object can be constructed by directly
69providing the effective atomic number, effective number of
70nucleons, and effective mass of a mole, if the user explicitly
71wants to do so. Alternatively, a <span class="emphasis"><em>G4Element</em></span> object can be
72constructed by declaring the number of isotopes of which it will be
73composed. The constructor will "new" a vector of pointers to
74<span class="emphasis"><em>G4Isotopes</em></span> and a vector of doubles to store their relative
75abundances. Finally, the method to add an isotope must be invoked
76for each of the desired (pre-existing) isotope objects, providing
77their addresses and relative abundances. At the last isotope entry,
78the system will automatically compute the effective atomic number,
79effective number of nucleons and effective mass of a mole, and will
80store "this" element in the elements table.
81</p><p>
82A few quantities, with physical meaning or not, which are
83constant in a given element, are computed and stored here as
84"derived data members".
85</p><p>
86Using the internal Geant4 database, a <span class="emphasis"><em>G4Element</em></span> can be accessed
87by atomic number or by atomic symbol ("Al", "Fe", "Pb"...). In that
88case <span class="emphasis"><em>G4Element</em></span> will be found from the list of existing elements or
89will be constructed using data from the Geant4 database, which is
90derived from the
91<a href="http://physics.nist.gov/PhysRefData/Compositions/index.html" target="_top">NIST database
92of elements and isotope compositions</a>.
93Thus, the natural isotope composition can be built by default.
94The same element
95can be created as using the NIST database with the
96natural composition of isotopes
97and from scratch in user code with user defined isotope composition.
98</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.Mate.Intro.Mate"></a>4.2.2.3. 
99G4Material
100</h4></div></div></div><p>
101A <span class="emphasis"><em>G4Material</em></span> object has a name, density, physical state,
102temperature and pressure (by default the standard conditions), the
103number of elements and a vector of pointers to such elements, a
104vector of the fraction of mass for each element, a vector of the
105atoms (or molecules) numbers of each element, and an index in the
106materials table. In addition, the class has methods to add, one by
107one, the elements which will comprise the material.
108</p><p>
109A <span class="emphasis"><em>G4Material</em></span> object can be constructed by directly
110providing the resulting effective numbers, if the user explicitly
111wants to do so (an underlying element will be created with these
112numbers). Alternatively, a <span class="emphasis"><em>G4Material</em></span> object can be
113constructed by declaring the number of elements of which it will be
114composed. The constructor will "new" a vector of pointers to
115<span class="emphasis"><em>G4Element</em></span> and a vector of doubles to store their fraction of
116mass. Finally, the method to add an element must be invoked for
117each of the desired (pre-existing) element objects, providing their
118addresses and mass fractions. At the last element entry, the system
119will automatically compute the vector of the number of atoms of
120each element per volume, the total number of electrons per volume,
121and will store "this" material in the materials table. In the same
122way, a material can be constructed as a mixture of other materials
123and elements.
124</p><p>
125It should be noted that if the user provides the number of atoms
126(or molecules) for each element comprising the chemical compound,
127the system automatically computes the mass fraction. A few
128quantities, with physical meaning or not, which are constant in a
129given material, are computed and stored here as "derived data
130members".
131</p><p>
132Some materials are included in the internal Geant4 database,
133which were derived from the
134<a href="http://physics.nist.gov/PhysRefData/Star/Text/method.html" target="_top">NIST database
135of material properties</a>.
136Additionally a number of materials friquently used in HEP is
137included in the database. Materials are interrogated or constructed
138by their <span class="emphasis"><em>names</em></span> (<a href="apas08.html" title="8. 
139Geant4 Material Database
140">Section 8</a>). 
141There are UI commands for the material category, which provide
142an interactive access to the database. If material is created
143using the NIST database by it will
144consist by default of elements with the natural composition of isotopes.
145</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.Mate.Intro.Fin"></a>4.2.2.4. 
146Final Considerations
147</h4></div></div></div><p>
148The classes will automatically decide
149if the total of the mass fractions is correct, and perform the
150necessary checks. The main reason why a fixed index is kept as a
151data member is that many cross section and energy tables will be
152built in the physics processes "by rows of materials (or elements,
153or even isotopes)". The tracking gives the physics process the
154address of a material object (the material of the current volume).
155If the material has an index according to which the cross section
156table has been built, then direct access is available when a number
157in such a table must be accessed. We get directly to the correct
158row, and the energy of the particle will tell us the column.
159Without such an index, every access to the cross section or energy
160tables would imply a search to get to the correct material's row.
161More details will be given in the section on processes.
162</p><p>
163Isotopes, elements and materials must be instantiated dynamically
164in the user application; they are automatically registered in
165internal stores and the system takes care to free the memory
166allocated at the end of the job.
167</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.Mate.Recep"></a>4.2.3. 
168Recipes for Building Elements and Materials
169</h3></div></div></div><p>
170<a href="ch04s02.html#programlist_Mate_1" title="Example 4.10. 
171A program which illustrates the different ways to define materials.
172">Example 4.10</a> illustrates the different ways to define
173materials.
174</p><div class="example"><a name="programlist_Mate_1"></a><p class="title"><b>Example 4.10. 
175A program which illustrates the different ways to define materials.
176</b></p><div class="example-contents"><pre class="programlisting">
177#include "G4Isotope.hh"
178#include "G4Element.hh"
179#include "G4Material.hh"
180#include "G4UnitsTable.hh"
181
182int main() {
183G4String name, symbol;             // a=mass of a mole;
184G4double a, z, density;            // z=mean number of protons; 
185G4int iz, n;                       // iz=nb of protons  in an isotope;
186                                   // n=nb of nucleons in an isotope;
187G4int ncomponents, natoms;
188G4double abundance, fractionmass;
189G4double temperature, pressure;
190
191G4UnitDefinition::BuildUnitsTable();
192
193// define Elements
194a = 1.01*g/mole;
195G4Element* elH  = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
196
197a = 12.01*g/mole;
198G4Element* elC  = new G4Element(name="Carbon"  ,symbol="C" , z= 6., a);
199
200a = 14.01*g/mole;
201G4Element* elN  = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
202
203a = 16.00*g/mole;
204G4Element* elO  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);
205
206a = 28.09*g/mole;
207G4Element* elSi = new G4Element(name="Silicon", symbol="Si", z=14., a);
208
209a = 55.85*g/mole;
210G4Element* elFe = new G4Element(name="Iron"    ,symbol="Fe", z=26., a);
211
212a = 183.84*g/mole;
213G4Element* elW = new G4Element(name="Tungsten" ,symbol="W",  z=74., a);
214
215a = 207.20*g/mole;
216G4Element* elPb = new G4Element(name="Lead"    ,symbol="Pb", z=82., a);
217
218// define an Element from isotopes, by relative abundance
219G4Isotope* U5 = new G4Isotope(name="U235", iz=92, n=235, a=235.01*g/mole);
220G4Isotope* U8 = new G4Isotope(name="U238", iz=92, n=238, a=238.03*g/mole);
221
222G4Element* elU  = new G4Element(name="enriched Uranium", symbol="U", ncomponents=2);
223elU-&gt;AddIsotope(U5, abundance= 90.*perCent);
224elU-&gt;AddIsotope(U8, abundance= 10.*perCent);
225
226cout &lt;&lt; *(G4Isotope::GetIsotopeTable()) &lt;&lt; endl;
227cout &lt;&lt; *(G4Element::GetElementTable()) &lt;&lt; endl;
228</pre></div></div><br class="example-break"><div class="informalexample"><pre class="programlisting">
229// define simple materials
230density = 2.700*g/cm3;
231a = 26.98*g/mole;
232G4Material* Al = new G4Material(name="Aluminum", z=13., a, density);
233
234density = 1.390*g/cm3;
235a = 39.95*g/mole;
236vG4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density);
237
238density = 8.960*g/cm3;
239a = 63.55*g/mole;
240G4Material* Cu = new G4Material(name="Copper"   , z=29., a, density);
241
242// define a material from elements.   case 1: chemical molecule
243density = 1.000*g/cm3;
244G4Material* H2O = new G4Material(name="Water", density, ncomponents=2);
245H2O-&gt;AddElement(elH, natoms=2);
246H2O-&gt;AddElement(elO, natoms=1);
247
248density = 1.032*g/cm3;
249G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
250Sci-&gt;AddElement(elC, natoms=9);
251Sci-&gt;AddElement(elH, natoms=10);
252
253density = 2.200*g/cm3;
254G4Material* SiO2 = new G4Material(name="quartz", density, ncomponents=2);
255SiO2-&gt;AddElement(elSi, natoms=1);
256SiO2-&gt;AddElement(elO , natoms=2);
257
258density = 8.280*g/cm3;
259G4Material* PbWO4= new G4Material(name="PbWO4", density, ncomponents=3);
260PbWO4-&gt;AddElement(elO , natoms=4);
261PbWO4-&gt;AddElement(elW , natoms=1);
262PbWO4-&gt;AddElement(elPb, natoms=1);
263
264// define a material from elements.   case 2: mixture by fractional mass
265density = 1.290*mg/cm3;
266G4Material* Air = new G4Material(name="Air  "  , density, ncomponents=2);
267Air-&gt;AddElement(elN, fractionmass=0.7);
268Air-&gt;AddElement(elO, fractionmass=0.3);
269
270// define a material from elements and/or others materials (mixture of mixtures)
271density = 0.200*g/cm3;
272G4Material* Aerog = new G4Material(name="Aerogel", density, ncomponents=3);
273Aerog-&gt;AddMaterial(SiO2, fractionmass=62.5*perCent);
274Aerog-&gt;AddMaterial(H2O , fractionmass=37.4*perCent);
275Aerog-&gt;AddElement (elC , fractionmass= 0.1*perCent);
276</pre></div><div class="informalexample"><pre class="programlisting">
277// examples of gas in non STP conditions
278density     = 27.*mg/cm3;
279pressure    = 50.*atmosphere;
280temperature = 325.*kelvin;
281G4Material* CO2 = new G4Material(name="Carbonic gas", density, ncomponents=2,
282                                     kStateGas,temperature,pressure);
283CO2-&gt;AddElement(elC, natoms=1);
284CO2-&gt;AddElement(elO, natoms=2);
285 
286density     = 0.3*mg/cm3;
287pressure    = 2.*atmosphere;
288temperature = 500.*kelvin;
289G4Material* steam = new G4Material(name="Water steam ", density, ncomponents=1,
290                                      kStateGas,temperature,pressure);
291steam-&gt;AddMaterial(H2O, fractionmass=1.);
292
293// What about vacuum ?  Vacuum is an ordinary gas with very low density
294density     = universe_mean_density;                //from PhysicalConstants.h
295pressure    = 1.e-19*pascal;
296temperature = 0.1*kelvin;
297new G4Material(name="Galactic", z=1., a=1.01*g/mole, density,
298                   kStateGas,temperature,pressure);
299
300density     = 1.e-5*g/cm3;
301pressure    = 2.e-2*bar;
302temperature = STP_Temperature;                      //from PhysicalConstants.h
303G4Material* beam = new G4Material(name="Beam ", density, ncomponents=1,
304                                      kStateGas,temperature,pressure);
305beam-&gt;AddMaterial(Air, fractionmass=1.);
306
307// print the table of materials
308G4cout &lt;&lt; *(G4Material::GetMaterialTable()) &lt;&lt; endl;
309
310return EXIT_SUCCESS;
311}
312</pre></div><p>
313As can be seen in the later examples, a material has a state:
314solid (the default), liquid, or gas. The constructor checks the
315density and automatically sets the state to gas below a given
316threshold (10 mg/cm3).
317</p><p>
318In the case of a gas, one may specify the temperature and
319pressure. The defaults are STP conditions defined in
320<code class="literal">PhysicalConstants.hh</code>.
321</p><p>
322An element must have the number of nucleons &gt;= number of
323protons &gt;= 1.
324</p><p>
325A material must have non-zero values of density, temperature and
326pressure.
327</p><p>
328Materials can also be defined using the internal Geant4
329database. <a href="ch04s02.html#programlist_Mate_2" title="Example 4.11. 
330A program which shows how to define materials from the internal database.
331">Example 4.11</a> illustrates
332how to do this for the same materials used in
333<a href="ch04s02.html#programlist_Mate_1" title="Example 4.10. 
334A program which illustrates the different ways to define materials.
335">Example 4.10</a>.
336There are also UI commands which allow the database to be accessed.
337<span class="emphasis"><em>The list of currently avalable material names</em></span>
338(<a href="apas08.html" title="8. 
339Geant4 Material Database
340">Section 8</a>) is extended permanetly.
341</p><div class="example"><a name="programlist_Mate_2"></a><p class="title"><b>Example 4.11. 
342A program which shows how to define materials from the internal database.
343</b></p><div class="example-contents"><pre class="programlisting">
344#include "globals.hh"
345#include "G4Material.hh"
346#include "G4NistManager.hh"
347
348int main() {
349  G4NistManager* man = G4NistManager::Instance();
350  man-&gt;SetVerbose(1);
351
352  // define elements
353  G4Element* C  = man-&gt;FindOrBuildElement("C");
354  G4Element* Pb = man-&gt;FindOrBuildMaterial("Pb");
355
356  // define pure NIST materials
357  G4Material* Al = man-&gt;FindOrBuildMaterial("G4_Al");
358  G4Material* Cu = man-&gt;FindOrBuildMaterial("G4_Cu");
359
360  // define NIST materials
361  G4Material* H2O  = man-&gt;FindOrBuildMaterial("G4_WATER");
362  G4Material* Sci  = man-&gt;FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
363  G4Material* SiO2 = man-&gt;FindOrBuildMaterial("G4_SILICON_DIOXIDE");
364  G4Material* Air  = man-&gt;FindOrBuildMaterial("G4_AIR");
365
366  // HEP materials
367  G4Material* PbWO4  = man-&gt;FindOrBuildMaterial("G4_PbWO4");
368  G4Material* lAr    = man-&gt;FindOrBuildMaterial("G4_lAr");
369  G4Material* vac    = man-&gt;FindOrBuildMaterial("G4_Galactic");
370
371  // define gas material at non STP conditions (T = 120K, P=0.5atm)
372  G4Material* coldAr = man-&gt;ConstructNewGasdMaterial("ColdAr","G4_Ar",120.*kelvin,0.5*atmosphere);
373
374  // print the table of materials
375  G4cout &lt;&lt; *(G4Material::GetMaterialTable()) &lt;&lt; endl;
376
377  return EXIT_SUCCESS;
378}
379</pre></div></div><br class="example-break"></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.Mate.Tables"></a>4.2.4. 
380The Tables
381</h3></div></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.Mate.Tables.PrintCons"></a>4.2.4.1. 
382Print a constituent
383</h4></div></div></div><p>
384The following shows how to print a constituent:
385
386</p><div class="informalexample"><pre class="programlisting">
387  G4cout &lt;&lt; elU &lt;&lt; endl;
388  G4cout &lt;&lt; Air &lt;&lt; endl;
389</pre></div><p>
390</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.Mate.Tables.PrintTab"></a>4.2.4.2. 
391Print the table of materials
392</h4></div></div></div><p>
393The following shows how to print the table of materials:
394
395</p><div class="informalexample"><pre class="programlisting">
396  G4cout &lt;&lt; *(G4Material::GetMaterialTable()) &lt;&lt; endl;
397</pre></div><p>
398</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="ch04.html"><img src="AllResources/IconsGIF/up.gif" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="ch04s03.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. 
399Detector Definition and Response
400 </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="AllResources/IconsGIF/home.gif" alt="Home"></a></td><td width="40%" align="right" valign="top"> 4.3. 
401Electromagnetic Field
402</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.