commit b96ac44384536715c59ca522d28cc1defc2d48f7
parent 5e0fea070caf71d7c190603f72666f6a2550af45
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 1 Mar 2017 17:27:00 +0100
Add the absorption parameter to the thin_dielectric material
Diffstat:
4 files changed, 59 insertions(+), 51 deletions(-)
diff --git a/doc/input b/doc/input
@@ -83,46 +83,46 @@
# <solar-factory> ::=
# <sun>
# <items>
-#
+#
# <items> ::=
# - <item>
# [ - <item> ... ]
-#
+#
# <item> ::=
# <geometry>
# | <material>
# | <entity>
# | <template>
-#
+#
# ----------------------------------------
# <geometry> ::=
# geometry:
# - <object>
# [ - <object> ... ]
-#
+#
# <object> ::=
# <shape>
# <material>
# [ <transform> ]
-#
+#
# <x_pivot> ::=
# x_pivot:
# [ ref_point: <real3>. Default 0,0,0 ]
# <target>
-#
+#
# <zx_pivot> ::=
# zx_pivot:
# [ spacing: REAL # in [0, INF). Default 0 ]
# [ ref_point: <real3>. Default 0,0,0 ]
# <target>
-#
+#
# <target> ::=
# target:
# anchor: <anchor-identifier>
# | direction: <real3>
# | position: <real3>
# | <sun>
-#
+#
# ----------------------------------------
# <shape> ::=
# <cuboid>
@@ -133,172 +133,173 @@
# | <plane>
# | <sphere>
# | <stl>
-#
+#
# <cuboid> ::=
# cuboid:
# size: <real3*+>
-#
+#
# <cylinder> ::=
# cylinder:
# height: REAL # in ]0, INF)
# radius: REAL # in ]0, INF)
# [ slices: INTEGER ] # in [4, 4096]. Default 16
-#
+#
# <obj> ::=
# obj:
# path: PATH
-#
+#
# <parabol> ::=
# parabol: # x^2 + y^2 - 4*focal*z = 0
# focal: REAL # in ]0, INF)
# clip: <polyclip-list>
-#
+#
# <parabolic-cylinder> ::=
# parabolic-cylinder: # y^2 - 4*focal*z = 0
# focal: REAL # in ]0, INF)
# clip: <polyclip-list>
-#
+#
# <plane> ::=
# plane:
# clip: <polyclip-list>
-#
+#
# <sphere> ::=
# sphere:
# radius: REAL # in ]0, INF)
# [ slices: INTEGER ] # in [4, 4096]. Default 16
-#
+#
# <stl> ::=
# stl:
# path: PATH
-#
+#
# ----------------------------------------
# <polyclip-list> ::=
# - <polyclip>
# [ - <polyclip> ... ]
-#
+#
# <polyclip> ::=
# operation: <AND|SUB>
# vertices: <vertices-list>
-#
+#
# <vertices-list> ::=
# - <real2>
# - <real2>
# - <real2>
# [ - <real2> ... ]
-#
+#
# ----------------------------------------
# <material> ::=
# <material-descriptor> | <double-sided-material>
-#
+#
# <double-sided-material> ::=
# front: <material-descriptor>
# back: <material-descriptor>
-#
+#
# <material-descriptor> ::=
# <mirror> | <matte> | <thin-dielectric> | <virtual>
-#
+#
# <mirror> ::=
# mirror:
# reflectivity: REAL # in [0, 1]
# roughness: REAL # in [0, 1]
-#
+#
# <matte> ::=
# matte:
# reflectivity: REAL # in [0, 1]
-#
+#
# <virtual> ::=
# virtual: EMPTY-STRING
#
# <thin-dielectric> ::=
# thin_dielectric:
-# thickness: REAL
-# refractive_index: REAL
-#
+# absorption: REAL # in [0, 1]
+# thickness: REAL # in [0, INF)
+# refractive_index: REAL # in ]0, INF)
+#
# ----------------------------------------
# <entity> ::=
# entity:
# <entity-data>
-#
+#
# <template> ::=
# template:
# <entity-data>
-#
+#
# <entity-data> ::=
# name: STRING # except "self"
# [ <geometry-data> | <x_pivot> | <zx_pivot> ]
# [ <anchors> ]
# [ <transform> ]
# [ <children> ]
-#
+#
# <geometry-data> ::=
# primary: INTEGER # in [0, 1]
-# <geometry>
-#
+# <geometry>
+#
# <children> ::=
# children:
# - <entity-data>
# [ - <entity-data> ... ]
-#
+#
# <anchors> ::=
# anchors:
# - <anchor-data>
# [ - <anchor-data> ... ]
-#
+#
# <anchor-data> ::=
# name: STRING
# position: <real3>
-#
+#
# # "self" references the first level entity
# <entity-identifier> ::=
# <self|STRING>[.STRING ... ]
-#
+#
# <anchor-identifier> ::=
# <entity-identifier>.STRING
-#
+#
# ----------------------------------------
# <sun> ::=
# sun:
# dni: REAL # Direct Normal Irradiance in ]0, INF)
# <spectrum>
# [ <radial-angular-distribution> ]
-#
+#
# <radial-angular-distribution> ::=
# <pillbox> | <buie>
-#
+#
# <buie> ::=
# buie:
# csr: REAL # in [1e-6, 0.849]
-#
+#
# <pillbox> ::=
# pillbox:
# aperture: REAL # in ]0, 90]
-#
+#
# ----------------------------------------
# <transform> ::=
# transform:
# translation: <real3>
# rotation: <real3>
-#
+#
# <real2> ::=
# - REAL
# - REAL
-#
+#
# <real3> ::=
# - REAL
# - REAL
# - REAL
-#
+#
# <real3*+> ::=
# - REAL # in ]0, inf)
# - REAL # in ]0, inf)
# - REAL # in ]0, inf)
-#
+#
# <spectrum> ::=
# spectrum:
# - <spectrum-data>
# [ - <spectrum-data> ... ]
-#
+#
# <spectrum-data> ::=
# wavelength: REAL # in [0, INF)
# data: REAL # in [0, INF)
-#
+#
diff --git a/src/parser/solparser.c b/src/parser/solparser.c
@@ -1028,7 +1028,7 @@ parse_material_thin_dielectric
yaml_node_t* thin,
struct solparser_material_thin_dielectric_id* out_imtl)
{
- enum { REFRACTIVE_INDEX, THICKNESS };
+ enum { ABSORPTION, REFRACTIVE_INDEX, THICKNESS };
struct solparser_material_thin_dielectric* mtl = NULL;
size_t imtl = SIZE_MAX;
int mask = 0; /* Register the parsed attributes */
@@ -1075,7 +1075,10 @@ parse_material_thin_dielectric
} \
mask |= BIT(Flag); \
} (void)0
- if(!strcmp((char*)key->data.scalar.value, "refractive_index")) {
+ if(!strcmp((char*)key->data.scalar.value, "absorption")) {
+ SETUP_MASK(ABSORPTION, "absorption");
+ res = parse_real(parser, val, 0, 1, &mtl->absorption);
+ } else if(!strcmp((char*)key->data.scalar.value, "refractive_index")) {
SETUP_MASK(REFRACTIVE_INDEX, "refractive_index");
res = parse_real
(parser, val, nextafter(0, 1), DBL_MAX, &mtl->refractive_index);
@@ -1102,6 +1105,7 @@ parse_material_thin_dielectric
res = RES_BAD_ARG; \
goto error; \
} (void)0
+ CHECK_PARAM(ABSORPTION, "absorption");
CHECK_PARAM(REFRACTIVE_INDEX, "refractive_index");
CHECK_PARAM(THICKNESS, "thickness");
#undef CHECK_PARAM
diff --git a/src/parser/solparser_material.h b/src/parser/solparser_material.h
@@ -39,6 +39,7 @@ struct solparser_material_mirror {
struct solparser_material_mirror_id { size_t i; };
struct solparser_material_thin_dielectric {
+ double absorption;
double refractive_index;
double thickness;
};
diff --git a/src/parser/test_solparser7.c b/src/parser/test_solparser7.c
@@ -44,11 +44,12 @@ main(int argc, char** argv)
fprintf(stream, "- sun: { dni: 1, spectrum: [{wavelength: 1, data: 1 }] }\n");
fprintf(stream, "- entity:\n");
fprintf(stream, " name: test\n");
- fprintf(stream, " primary: 0\n");
+ fprintf(stream, " primary: 0\n");
fprintf(stream, " geometry:\n");
fprintf(stream, " - sphere: { radius: 1 }\n");
fprintf(stream, " material:\n");
fprintf(stream, " thin_dielectric:\n");
+ fprintf(stream, " absorption: 0.5\n");
fprintf(stream, " thickness: 0.123\n");
fprintf(stream, " refractive_index: 1.5\n");
rewind(stream);
@@ -78,6 +79,7 @@ main(int argc, char** argv)
CHECK(mtl->type, SOLPARSER_MATERIAL_THIN_DIELECTRIC);
thin = solparser_get_material_thin_dielectric
(parser, mtl->data.thin_dielectric);
+ CHECK(thin->absorption, 0.5);
CHECK(thin->thickness, 0.123);
CHECK(thin->refractive_index, 1.5);