commit eed5ad079a3d8853ca1998588f4ed77d0f810d37
parent d14964d5b60830389409bfb2c89971ac7e970a79
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 3 Apr 2017 14:47:22 +0200
Make spectrum optional for suns.
Diffstat:
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/doc/input b/doc/input
@@ -296,7 +296,7 @@
<sun> ::=
sun:
dni: REAL # Direct Normal Irradiance in ]0, INF)
- <spectrum>
+[ <spectrum> ]
[ <radial-angular-distribution> ]
<radial-angular-distribution> ::=
diff --git a/src/parser/solparser_sun.c b/src/parser/solparser_sun.c
@@ -243,7 +243,6 @@ parse_sun
goto error; \
} (void)0
CHECK_PARAM(DNI, "dni");
- CHECK_PARAM(SPECTRUM, "spectrum");
#undef CHECK_PARAM
exit:
diff --git a/src/parser/yaml/test_ko_0.yaml b/src/parser/yaml/test_ko_0.yaml
@@ -130,9 +130,6 @@
# <pillbox> | <buie>
#
-# missing spectrum
-- sun: { dni: 1 }
----
# missing dni
- sun: { spectrum: [{wavelength: 1, data: 1}] }
---
diff --git a/src/solstice_sun.c b/src/solstice_sun.c
@@ -195,13 +195,15 @@ solstice_create_sun(struct solstice* solstice)
}
if(res != RES_OK) goto error;
- res = create_sun_spectrum(solstice, solparser_sun, &spectrum);
- if(res != RES_OK) goto error;
-
- res = ssol_sun_set_spectrum(sun, spectrum);
- if(res != RES_OK) {
- fprintf(stderr, "Could not attach the spectrum to the sun.\n");
- goto error;
+ if(solparser_sun->spectrum.size) {
+ res = create_sun_spectrum(solstice, solparser_sun, &spectrum);
+ if (res != RES_OK) goto error;
+
+ res = ssol_sun_set_spectrum(sun, spectrum);
+ if(res != RES_OK) {
+ fprintf(stderr, "Could not attach the spectrum to the sun.\n");
+ goto error;
+ }
}
res = ssol_sun_set_dni(sun, solparser_sun->dni);