BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSMaterials.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSMATERIALS_H
20#define BDSMATERIALS_H
21
22#include <list>
23#include <map>
24#include <set>
25#include <vector>
26
27#include "globals.hh"
28#include "G4Material.hh" // for G4State
29
30class G4Element;
31class G4MaterialPropertiesTable;
32
39{
40public:
41
43 static BDSMaterials* Instance();
45
47 void PrepareRequiredMaterials(G4bool verbose = false);
48
50 void ListMaterials()const;
51
53 G4Material* GetMaterial(G4String material) const;
55 G4Element* GetElement(const G4String& symbol) const;
56
58 void CacheMaterialsFromGDML(const std::map<G4String, G4Material*>& materialsGDML);
59
65 void CheckForConflictingMaterialsAfterLoad(const G4String& geometryFileName,
66 const G4String& componentName) const;
67
68protected:
71 void AddMaterial(G4Material* material, G4String name);
73 void AddExistingMaterialAlias(const G4String &existingMaterialName,
74 G4String alias);
75
84 void AddMaterial(G4String name,
85 G4double Z,
86 G4double A,
87 G4double density,
88 G4State state,
89 G4double temperature,
90 G4double pressure);
91
100 template <typename Type>
101 void AddMaterial(G4String name,
102 G4double density,
103 G4State state,
104 G4double temperature,
105 G4double pressure,
106 const std::list<G4String>& components,
107 const std::list<Type>& componentFractions);
108
110 G4Element* CheckElement(const G4String& symbol) const;
111
112private:
115
117 void DefineMetals();
120 void DefineScintillators();
121 void DefineLHCComponents();
122 void DefineLiquids();
123 void DefineGases();
124 void DefinePlasmas();
125 void DefineVacuums();
127
129 void AddElement(G4Element* element, const G4String& symbol);
130 void AddElement(const G4String& name, const G4String& symbol, G4double itsZ, G4double itsA);
132
134 void DensityCheck(G4double density,
135 const G4String& materialName) const;
136
138 void PrintBasicMaterialMassFraction(G4Material* material) const;
139
141 std::set<G4String> materialNames;
142 std::map<G4String, G4Material*> materials;
144 std::set<G4String> aliasNames;
145 std::map<G4String, G4Material*> aliases;
147 std::map<G4Material*, std::vector<G4String>> materialToAliases;
149 std::set<G4String> externalMaterialNames;
150 std::map<G4String, G4Material*> externalMaterials;
152 std::map<G4String,G4Element*> elements;
154 std::vector<G4MaterialPropertiesTable*> propertiesTables;
156 G4MaterialPropertiesTable* CreatePropertiesTable();
157};
158
159#endif
A class for all material definitions known to BDSIM. Additional materials can be added in the parser ...
Definition: BDSMaterials.hh:39
void DefineMetals()
Methods called by constructor.
Definition: BDSMaterials.cc:67
std::set< G4String > aliasNames
Map of other names to existing materials. To avoid double deletion. Also in lower case.
void DefineLHCComponents()
Methods called by constructor.
std::map< G4Material *, std::vector< G4String > > materialToAliases
Keep a vector of possible aliases for every material for print out and user feedback.
void DefineGases()
Methods called by constructor.
void DefineNonMetalSolids()
Methods called by constructor.
void DensityCheck(G4double density, const G4String &materialName) const
Print warning if density suspiciously high. Should be in g/cm3 in G4 units already.
void DefineScintillators()
Methods called by constructor.
void DefineVacuums()
Methods called by constructor.
static BDSMaterials * Instance()
Singleton pattern access.
Definition: BDSMaterials.cc:39
G4MaterialPropertiesTable * CreatePropertiesTable()
Create new properties table and store in vector.
static BDSMaterials * instance
Singleton instance.
std::set< G4String > materialNames
Map of materials, convention name lowercase.
std::map< G4String, G4Element * > elements
Map of elements, no lowercase convention.
void DefineLiquids()
Methods called by constructor.
G4Material * GetMaterial(G4String material) const
Get material by name.
void PrepareRequiredMaterials(G4bool verbose=false)
converts parser material list
void CacheMaterialsFromGDML(const std::map< G4String, G4Material * > &materialsGDML)
Introduce materials loaded from GDML into this instance.
void ListMaterials() const
output available materials
void DefinePlasmas()
Methods called by constructor.
std::set< G4String > externalMaterialNames
Keep hold of externally constructed materials to indicate conflicts to the user but not to delete.
void CheckForConflictingMaterialsAfterLoad(const G4String &geometryFileName, const G4String &componentName) const
void AddElement(G4Element *element, const G4String &symbol)
Add a G4Element.
void AddMaterial(G4Material *material, G4String name)
Add G4Material.
void DefineSuperconductors()
Methods called by constructor.
G4Element * CheckElement(const G4String &symbol) const
Return element if defined (nullptr if not)
void AddExistingMaterialAlias(const G4String &existingMaterialName, G4String alias)
Add alias to a material.
G4Element * GetElement(const G4String &symbol) const
Get element by name.
void PrintBasicMaterialMassFraction(G4Material *material) const
Print mass fractions of consituents of a given material.
std::vector< G4MaterialPropertiesTable * > propertiesTables
Material tables for storing pointers.