In nature, general materials (chemical compounds, mixtures) are made of elements, and elements are made of isotopes. Therefore, these are the three main classes designed in Geant4. Each of these classes has a table as a static data member, which is for keeping track of the instances created of the respective classes. All three objects automatically register themselves into the corresponding table on construction, and should never be deleted in user code.
G4Element class describes the properties of the
G4Material class describes the macroscopic properties
G4Material class is the one which is visible to the
rest of the toolkit, and is used by the tracking, the geometry, and
the physics. It contains all the information relative to the
eventual elements and isotopes of which it is made, at the same
time hiding the implementation details.
In the example below, liquid argon is created, by specifying its name, density, mass per mole, and atomic number.
Example 2.7. Creating liquid argon.
G4double z, a, density; density = 1.390*g/cm3; a = 39.95*g/mole; G4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density);
The pointer to the material, lAr, will be used to specify the matter of which a given logical volume is made:
G4LogicalVolume* myLbox = new G4LogicalVolume(aBox,lAr,"Lbox",0,0,0);
In the example below, the water, H2O, is built from its components, by specifying the number of atoms in the molecule.
Example 2.8. Creating water by defining its molecular components.
G4double z, a, density; G4String name, symbol; G4int ncomponents, natoms; a = 1.01*g/mole; G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a); a = 16.00*g/mole; G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); density = 1.000*g/cm3; G4Material* H2O = new G4Material(name="Water",density,ncomponents=2); H2O->AddElement(elH, natoms=2); H2O->AddElement(elO, natoms=1);
In the example below, air is built from nitrogen and oxygen, by giving the fractional mass of each component.
Example 2.9. Creating air by defining the fractional mass of its components.
G4double z, a, fractionmass, density; G4String name, symbol; G4int ncomponents; a = 14.01*g/mole; G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); a = 16.00*g/mole; G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); density = 1.290*mg/cm3; G4Material* Air = new G4Material(name="Air ",density,ncomponents=2); Air->AddElement(elN, fractionmass=70*perCent); Air->AddElement(elO, fractionmass=30*perCent);
In the example below, air and water are accessed via the Geant4 material database.
Example 2.10. Defining air and water from the internal Geant4 database.
G4NistManager* man = G4NistManager::Instance(); G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); G4Material* Air = man->FindOrBuildMaterial("G4_AIR");
It is possible to build new material on base of an existing "base" material. This feature is useful for electromagnetic physics allowing to peak up for the derived material all correction data and precomputed tables of stopping powers and cross sections of the base material. In the example below, two methods how to create water with unusual density are shown.
Example 2.11. Defining water with user defined density on base of G4_WATER.
G4double density; density = 1.05*mg/cm3; G4Material* water1 = new G4Material("Water_1.05",density,"G4_WATER"); density = 1.03*mg/cm3; G4NistManager* man = G4NistManager::Instance(); G4Material* water2 = man->BuildMaterialWithNewDensity("Water_1.03","G4_WATER",density);
Example 2.12. Printing information about materials.
G4cout << H2O; \\ print a given material G4cout << *(G4Material::GetMaterialTable()); \\ print the list of materials
In Geant4 examples you all possible ways to build a material.
Example 2.13. Geant4 material database may be accessed via UI commands.
/material/nist/printElement Fe \\ print element by name /material/nist/printElementZ 13 \\ print element by atomic number /material/nist/listMaterials type \\ print materials type = [simple | compound | hep | all] /material/g4/printElement elmName \\ print instantiated element by name /material/g4/printMaterial matName \\ print instantiated material by name
In Geant4 examples you with find all possible ways to build a material.