1 #include <geometry/Materials.h>
2 #include <gtest/gtest.h>
6 #include <framework/gearbox/Gearbox.h>
7 #include <framework/gearbox/GearDir.h>
8 #include <framework/utilities/TestHelpers.h>
10 #include <G4Element.hh>
11 #include <G4Material.hh>
12 #include <G4OpticalSurface.hh>
13 #include <G4MaterialPropertiesTable.hh>
29 G4Element* e1 = m.getElement(
"H");
31 EXPECT_EQ(
"H", e1->GetName());
32 EXPECT_EQ(
"H", e1->GetSymbol());
33 EXPECT_EQ(1., e1->GetZ());
41 G4Material* m1 = Materials::get(
"Air");
42 G4Material* m2 = Materials::get(
"G4_AIR");
45 EXPECT_EQ(
"G4_AIR", m1->GetName());
46 EXPECT_TRUE(Materials::get(
"Si"));
54 Gearbox& gb = Gearbox::getInstance();
55 vector<string> backends;
56 backends.emplace_back(
"string:<Material name='Test'><state>Gas</state><Components>"
57 "<Material fraction='1.5'>Si</Material>"
58 "<Material fraction='2.5612'>Au</Material>"
59 "</Components></Material>");
66 G4Material* au = Materials::get(
"Au");
67 G4Material* si = Materials::get(
"Si");
68 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
70 EXPECT_EQ(
"Test", mat->GetName());
71 EXPECT_DOUBLE_EQ((2.5612 * au->GetDensity() + 1.5 * si->GetDensity()) / 4.0612, mat->GetDensity());
79 Gearbox& gb = Gearbox::getInstance();
80 vector<string> backends;
81 backends.emplace_back(
"string:<Material name='Test1'><state>Solid</state><Components>"
82 "<Material fraction='0.5'>Si</Material>"
83 "<Element fraction='0.5'>Au</Element>"
84 "</Components></Material>");
89 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
98 Gearbox& gb = Gearbox::getInstance();
99 vector<string> backends;
100 backends.emplace_back(
"string:<Material name='Test2'><state>Liquid</state><density>1</density><Components>"
101 "<Material>Si</Material>"
102 "<Element>Au</Element>"
103 "</Components></Material>");
108 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
117 Gearbox& gb = Gearbox::getInstance();
118 vector<string> backends;
119 backends.emplace_back(
"string:<Material name='Test3'><Components>"
120 "<Material>Foo</Material>"
121 "</Components></Material>");
126 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
135 Gearbox& gb = Gearbox::getInstance();
136 vector<string> backends;
137 backends.emplace_back(
"string:<Material name='Test4'><density>1</density><Components>"
138 "<Element>Foo</Element>"
139 "</Components></Material>");
144 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
153 Gearbox& gb = Gearbox::getInstance();
154 vector<string> backends;
155 backends.emplace_back(
"string:<test><Surface/>"
156 "<Surface name='test'><Model>unified</Model><Finish>Ground</Finish>"
157 "<Type>x_ray</Type><Value>2.0</Value></Surface>"
158 "<Surface><Model>not existing</Model></Surface>"
159 "<Surface><Finish>not existing</Finish></Surface>"
160 "<Surface><Type>not existing</Type></Surface></test>"
167 G4OpticalSurface* surf1 = m.createOpticalSurface(
GearDir(
"/test/Surface[1]"));
169 EXPECT_EQ(
"OpticalSurface", surf1->GetName());
170 EXPECT_EQ(glisur, surf1->GetModel());
171 EXPECT_EQ(polished, surf1->GetFinish());
172 EXPECT_EQ(dielectric_dielectric, surf1->GetType());
173 EXPECT_EQ(1.0, surf1->GetPolish());
175 G4OpticalSurface* surf2 = m.createOpticalSurface(
GearDir(
"/test/Surface[2]"));
177 EXPECT_EQ(
"test", surf2->GetName());
178 EXPECT_EQ(unified, surf2->GetModel());
179 EXPECT_EQ(ground, surf2->GetFinish());
180 EXPECT_EQ(x_ray, surf2->GetType());
181 EXPECT_EQ(2.0, surf2->GetSigmaAlpha());
183 EXPECT_B2FATAL(m.createOpticalSurface(
GearDir(
"/test/Surface[3]")));
184 EXPECT_B2FATAL(m.createOpticalSurface(
GearDir(
"/test/Surface[4]")));
185 EXPECT_B2FATAL(m.createOpticalSurface(
GearDir(
"/test/Surface[5]")));
192 Gearbox& gb = Gearbox::getInstance();
193 vector<string> backends;
194 backends.emplace_back(
"string:<Material name='TestProperties'>"
195 "<Components><Material>Si</Material></Components>"
196 "<Property name='RINDEX' unit='eV'>"
197 "<value energy='1.0'>1.40</value>"
198 "<value energy='1.5'>1.41</value>"
199 "<value energy='2.0'>1.42</value>"
200 "<value energy='3.5'>1.43</value>"
207 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
209 G4MaterialPropertiesTable* properties = mat->GetMaterialPropertiesTable();
210 ASSERT_TRUE(properties);
211 G4MaterialPropertyVector*
property = properties->GetProperty(
"RINDEX");
212 ASSERT_TRUE(property);
213 EXPECT_EQ(4u, property->GetVectorLength());
214 EXPECT_DOUBLE_EQ(1.40, property->GetMinValue());
215 EXPECT_DOUBLE_EQ(1.43, property->GetMaxValue());
216 EXPECT_DOUBLE_EQ(1 * CLHEP::eV, property->GetMinLowEdgeEnergy());
217 EXPECT_DOUBLE_EQ(3.5 * CLHEP::eV, property->GetMaxLowEdgeEnergy());
218 EXPECT_DOUBLE_EQ(1.0 * CLHEP::eV, property->Energy(0));
219 EXPECT_DOUBLE_EQ(1.5 * CLHEP::eV, property->Energy(1));
220 EXPECT_DOUBLE_EQ(2.0 * CLHEP::eV, property->Energy(2));
221 EXPECT_DOUBLE_EQ(3.5 * CLHEP::eV, property->Energy(3));
222 EXPECT_DOUBLE_EQ(1.40, (*property)[0]);
223 EXPECT_DOUBLE_EQ(1.41, (*property)[1]);
224 EXPECT_DOUBLE_EQ(1.42, (*property)[2]);
225 EXPECT_DOUBLE_EQ(1.43, (*property)[3]);