Skip to content

Commit 2bc5de3

Browse files
committed
Material
1 parent bec44b9 commit 2bc5de3

File tree

9 files changed

+73
-21
lines changed

9 files changed

+73
-21
lines changed

Intern/rayx-core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data/nff
256256
DESTINATION ${INSTALL_DATA_DIR}/Data)
257257
install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data/PALIK
258258
DESTINATION ${INSTALL_DATA_DIR}/Data)
259+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data/CROMER
260+
DESTINATION ${INSTALL_DATA_DIR}/Data)
261+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data/MOLEC
262+
DESTINATION ${INSTALL_DATA_DIR}/Data)
259263
install(DIRECTORY ${CMAKE_SOURCE_DIR}/Scripts
260264
DESTINATION ${INSTALL_DATA_DIR})
261265
include(InstallRequiredSystemLibraries)

Intern/rayx-core/src/Beamline/Beamline.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,25 @@ void Group::addChild(std::unique_ptr<BeamlineNode> child) {
8181

8282
MaterialTables Group::calcMinimalMaterialTables() const {
8383
auto elements = getElements();
84-
std::array<bool, 92> relevantMaterials{};
84+
std::array<bool, 99> relevantMaterials{};
8585
relevantMaterials.fill(false);
8686
for (const auto& elemPtr : elements) {
87+
auto coating = elemPtr->getCoating();
88+
if (coating.is<Coating::OneCoating>()) {
89+
int materialcoating = static_cast<int>(elemPtr->getMaterialCoating());
90+
if (materialcoating >= 1 && materialcoating <= 99) {
91+
relevantMaterials[materialcoating - 1] = true;
92+
}
93+
} else if (coating.is<Coating::MultilayerCoating>()) {
94+
auto mlCoating = variant::get<Coating::MultilayerCoating>(coating.m_coating);
95+
for (const auto& mat : mlCoating.material) {
96+
if (mat >= 1 && mat <= 99) {
97+
relevantMaterials[mat - 1] = true;
98+
}
99+
}
100+
}
87101
int material = static_cast<int>(elemPtr->getMaterial()); // assuming getMaterial() exists
88-
if (material >= 1 && material <= 92) {
102+
if (material >= 1 && material <= 99) {
89103
relevantMaterials[material - 1] = true;
90104
}
91105
}

Intern/rayx-core/src/Material/Material.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ bool materialFromString(const char* matname, Material* out) {
5555
return false;
5656
}
5757

58-
MaterialTables loadMaterialTables(std::array<bool, 92> relevantMaterials) {
58+
MaterialTables loadMaterialTables(std::array<bool, 99> relevantMaterials) {
5959
MaterialTables out;
6060

6161
auto mats = allNormalMaterials();
62-
if (mats.size() != 92) {
62+
if (mats.size() != 99) {
6363
RAYX_EXIT << "unexpected number of materials. this is a bug.";
6464
}
6565

@@ -106,7 +106,8 @@ MaterialTables loadMaterialTables(std::array<bool, 92> relevantMaterials) {
106106
CromerTable t;
107107

108108
if (!CromerTable::load(getMaterialName(mats[i]), &t)) {
109-
RAYX_EXIT << "could not load CromerTable!";
109+
RAYX_VERB << "could not load CromerTable!";
110+
continue;
110111
}
111112

112113
for (auto x : t.m_Lines) {

Intern/rayx-core/src/Material/Material.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ struct RAYX_API MaterialTables {
3737

3838
// the following function loads the Palik, Nff, and Cromer tables.
3939
// the tables will later be written to the mat and matIdx buffers of shader.comp
40-
MaterialTables RAYX_API loadMaterialTables(std::array<bool, 92> relevantMaterials);
40+
MaterialTables RAYX_API loadMaterialTables(std::array<bool, 99> relevantMaterials);
4141

4242
} // namespace RAYX

Intern/rayx-core/src/Material/materials.xmacro

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,17 @@ X(Ac, 89, 227.0278, 10.05)
9595
X(Th, 90, 232.0381, 11.70)
9696
X(Pa, 91, 231.0359, 15.34)
9797
X(U, 92, 238.0289, 18.92)
98+
// Pseudo-Element für Al2O3
99+
X(AL2O3, 93, 101.96, 3.97)
100+
// Pseudo-Element für B4C
101+
X(B4C, 94, 55.25, 2.52)
102+
// Pseudo-Element für Diamant
103+
X(DIAMOND, 95, 12.011, 3.51)
104+
//weitere elemente aus molec
105+
X(MgF2, 96, 62.304, 3.15)
106+
// Pseudo-Element für Si8O26Al4Li2P (Glas/Glaskeramik)
107+
X(Si8O26Al4Li2P, 97, 793.44, 2.40)
108+
// Pseudo-Element für SiC
109+
X(SiC, 98, 40.10, 3.21)
110+
// Pseudo-Element für SiO2 (Quarz)
111+
X(SiO2, 99, 60.08, 2.65)

Intern/rayx-core/src/Rml/xml.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,22 @@ bool paramVls(const rapidxml::xml_node<>* node, std::array<double, 6>* out) {
299299
return true;
300300
}
301301

302+
303+
double Parser::parseThicknessCoating() const {
304+
if(!xml::paramDouble(node, "thicknessCoating", nullptr)) {
305+
return Parser::parseDouble("thicknessCoating1");
306+
}
307+
return Parser::parseDouble("thicknessCoating");
308+
}
309+
310+
double Parser::parseRoughnessCoating() const {
311+
if(!xml::paramDouble(node, "roughnessCoating", nullptr)) {
312+
return Parser::parseDouble("roughnessCoating1");
313+
}
314+
return Parser::parseDouble("roughnessCoating");
315+
}
316+
317+
302318
bool paramRAYUICoating(const rapidxml::xml_node<>* node, Coating::MultilayerCoating* out) {
303319
if (!node || !out) { return false; }
304320

@@ -334,10 +350,10 @@ bool paramRAYUICoating(const rapidxml::xml_node<>* node, Coating::MultilayerCoat
334350
}
335351
}
336352

337-
const char* materialStr = nullptr;
338-
if (paramStr(node, "materialTopLayer", &materialStr)) {
353+
const char* materialTopLayer = nullptr;
354+
if (!paramStr(node, "materialTopLayer", &materialTopLayer)) {
339355
Material material;
340-
materialFromString(materialStr, &material);
356+
materialFromString(materialTopLayer, &material);
341357
out->material[numberLayer] = static_cast<int>(material);
342358

343359
if (!paramDouble(node, "thicknessTopLayer", &out->thickness[numberLayer])) {
@@ -351,6 +367,7 @@ bool paramRAYUICoating(const rapidxml::xml_node<>* node, Coating::MultilayerCoat
351367
}
352368
out->numLayers += 1;
353369
}
370+
return true;
354371
}
355372

356373
// multilayer coating

Intern/rayx-core/src/Rml/xml.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ struct RAYX_API Parser {
114114
Rad parseAzimuthalAngle() const;
115115
std::filesystem::path parseEnergyDistributionFile() const;
116116
Coating::MultilayerCoating parseCoating() const;
117+
double parseThicknessCoating() const;
118+
double parseRoughnessCoating() const;
117119

118120
// Parsers for trivial derived parameters
119121
// this allows for convenient type-safe access to the corresponding parameters.
@@ -223,9 +225,9 @@ struct RAYX_API Parser {
223225
if (parseInt("surfaceCoating") == 3) {
224226
return SurfaceCoatingType::MultipleCoatings;
225227
}
226-
return static_cast<SurfaceCoatingType>(parseInt("surfaceCoating"));} // 0 = substrate only, 1 = one coating, 2 = multiple coatings
227-
inline double parseThicknessCoating() const { return parseDouble("thicknessCoating"); }
228-
inline double parseRoughnessCoating() const { return parseDouble("roughnessCoating"); }
228+
return static_cast<SurfaceCoatingType>(parseInt("surfaceCoating"));
229+
} // 0 = substrate only, 1 = one coating, 2 = multiple coatings
230+
229231

230232
// the XML node of the object you intend to parse.
231233
rapidxml::xml_node<>* node;

Intern/rayx-core/src/Shader/RefractiveIndex.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ namespace RAYX {
88
// Thus, when you want to get some concrete palik entry for a particular element, you need the materialIndices table to "know where to look" in
99
// materialTable:
1010
// * materialIndices[i] is the beginning of the Palik Table in materialTable for the element with atomic number i+1, for i in [0, 91].
11-
// * materialIndices[i+92] is the beginning of the Nff Table in materialTable for the element with atomic number i+1, for i in [0, 91].
11+
// * materialIndices[i+99] is the beginning of the Nff Table in materialTable for the element with atomic number i+1, for i in [0, 91].
1212
// The `i+1` is necessary as atomic numbers start at 1 (Hydrogen), while array indices start at 0.
1313
// See InvocationState.cpp for more information about these tables.
1414

15-
// If you will, the materialTable table is a "sparse" 4d-datastructure of shape (2, 92, N, 3).
15+
// If you will, the materialTable table is a "sparse" 4d-datastructure of shape (2, 99, N, 3).
1616
// - 2 because we store a Palik-table, and an Nff-table
17-
// - 92, because we support 92 elements of the periodic table (from Hydrogen to Uranium)
17+
// - 99, because we support 99 elements of the periodic table (from Hydrogen to Uranium)
1818
// - N is the number of entries in a given Palik/Nff table (this number depends on the periodic element)
1919
// - 3 because each Palik / Nff entry consists of three doubles.
2020
// - It is a "sparse" data structure as most of the entries are actually missing, we only load the actually "used" materials into the shader, not all
@@ -38,9 +38,9 @@ int RAYX_API getPalikEntryCount(const int material, const int* materialIndices)
3838
RAYX_FN_ACC
3939
int RAYX_API getNffEntryCount(const int material, const int* materialIndices) {
4040
int m = material - 1; // in [0, 91]
41-
// the offset of 92 (== number of materials), skips the palik table and
41+
// the offset of 99 (== number of materials), skips the palik table and
4242
// reaches into the nff table. the rest of the logic is as above.
43-
return (materialIndices[92 + m + 1] - materialIndices[92 + m]) / 3;
43+
return (materialIndices[99 + m + 1] - materialIndices[99 + m]) / 3;
4444

4545
}
4646

@@ -72,9 +72,9 @@ PalikEntry RAYX_API getPalikEntry(int index, int material, const int* __restrict
7272
RAYX_FN_ACC
7373
NffEntry RAYX_API getNffEntry(int index, int material, const int* __restrict materialIndices, const double* __restrict materialTable) {
7474
int m = material - 1; // in [0, 91]
75-
// materialIndices[92+m] is the start of the Nff table of material m.
75+
// materialIndices[99+m] is the start of the Nff table of material m.
7676
// 3*index skips 'index'-many entries.
77-
int i = materialIndices[92 + m] + 3 * index;
77+
int i = materialIndices[99 + m] + 3 * index;
7878

7979
NffEntry e;
8080
e.m_energy = materialTable[i];
@@ -108,7 +108,7 @@ complex::Complex RAYX_API getRefractiveIndex(double energy, int material, const
108108
}
109109

110110
// out of range check
111-
if (material < 1 || material > 92) {
111+
if (material < 1 || material > 99) {
112112
_throw("getRefractiveIndex material out of range!");
113113
return complex::Complex(-1.0, -1.0);
114114
}

Intern/rayx-core/tests/setupTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void compareAgainstCorrect(std::string filename, double tolerance) {
257257
}
258258

259259
MaterialTables createMaterialTables(std::vector<Material> mats_vec) {
260-
std::array<bool, 92> mats;
260+
std::array<bool, 99> mats;
261261
mats.fill(false);
262262
for (auto m : mats_vec) {
263263
mats[static_cast<int>(m) - 1] = true;

0 commit comments

Comments
 (0)