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) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSMATERIALS_H
19#define BDSMATERIALS_H
20
21#include <list>
22#include <map>
23#include <set>
24#include <vector>
25
26#include "globals.hh"
27#include "G4Material.hh" // for G4State
28
29class G4Element;
30class G4MaterialPropertiesTable;
31
38{
39public:
40
42 static BDSMaterials* Instance();
44
46 void PrepareRequiredMaterials(G4bool verbose = false);
47
49 void ListMaterials()const;
50
52 G4Material* GetMaterial(G4String material) const;
54 G4Element* GetElement(const G4String& symbol) const;
55
57 void CacheMaterialsFromGDML(const std::map<G4String, G4Material*>& materialsGDML);
58
64 void CheckForConflictingMaterialsAfterLoad(const G4String& geometryFileName,
65 const G4String& componentName) const;
66
67protected:
70 void AddMaterial(G4Material* material, G4String name);
72 void AddExistingMaterialAlias(const G4String &existingMaterialName,
73 G4String alias);
74
83 void AddMaterial(G4String name,
84 G4double Z,
85 G4double A,
86 G4double density,
87 G4State state,
88 G4double temperature,
89 G4double pressure);
90
99 template <typename Type>
100 void AddMaterial(G4String name,
101 G4double density,
102 G4State state,
103 G4double temperature,
104 G4double pressure,
105 const std::list<G4String>& components,
106 const std::list<Type>& componentFractions);
107
109 G4Element* CheckElement(const G4String& symbol) const;
110
111private:
114
116 void DefineMetals();
119 void DefineScintillators();
120 void DefineLHCComponents();
121 void DefineLiquids();
122 void DefineGases();
123 void DefinePlasmas();
124 void DefineVacuums();
126
128 void AddElement(G4Element* element, const G4String& symbol);
129 void AddElement(const G4String& name, const G4String& symbol, G4double itsZ, G4double itsA);
131
133 void DensityCheck(G4double density,
134 const G4String& materialName) const;
135
137 void PrintBasicMaterialMassFraction(G4Material* material) const;
138
140 std::set<G4String> materialNames;
141 std::map<G4String, G4Material*> materials;
143 std::set<G4String> aliasNames;
144 std::map<G4String, G4Material*> aliases;
146 std::map<G4Material*, std::vector<G4String>> materialToAliases;
148 std::set<G4String> externalMaterialNames;
149 std::map<G4String, G4Material*> externalMaterials;
151 std::map<G4String,G4Element*> elements;
153 std::vector<G4MaterialPropertiesTable*> propertiesTables;
155 G4MaterialPropertiesTable* CreatePropertiesTable();
156};
157
158#endif
A class for all material definitions known to BDSIM. Additional materials can be added in the parser ...
void DefineMetals()
Methods called by constructor.
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.
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.