commit d1b2c2a80248409f0fc12b05981191e857bab4ad
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 26 Jul 2017 09:19:55 +0200
Commit drafts of several Solstice Scripts
Diffstat:
| A | .gitignore | | | 9 | +++++++++ |
| A | src/Makefile | | | 55 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/solpp.c | | | 297 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/solpp.h | | | 383 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/solsplit.c | | | 107 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/solvtk.c | | | 233 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/themis.c | | | 1277 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 files changed, 2361 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,9 @@
+.gitignore
+tmp
+[Bb]uild*
+*.sw[po]
+*.[ao]
+*.orig
+*~
+tags
+
diff --git a/src/Makefile b/src/Makefile
@@ -0,0 +1,55 @@
+# Copyright (C) |Meso|Star> 2017
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+STAR_ENGINE=/home/moi/code/star-engine-solstice/local
+NEXPERIMENTS=1000000
+NPATHS=1000
+SUN_DIRS=270,45
+RCV_FILE=themis-rcv.yaml
+
+CFLAGS = -O2 -std=c99 -pedantic -Wall
+SCRIPT = themis.c solsplit.c solpp.c solvtk.c
+PROG = $(SCRIPT:%.c=%)
+PATH := $(PATH):$(STAR_ENGINE)/bin:.
+
+.PHONY: all
+all: $(PROG)
+
+.PHONY: input
+input: $(PROG)
+ @./themis
+
+.PHONY: output
+output: receiver
+ @themis | solstice -q -n$(NEXPERIMENTS) -D$(SUN_DIRS) -R $(RCV_FILE)
+
+.PHONY: obj
+obj: $(PROG)
+ themis | solstice -D$(SUN_DIRS) -qg format=obj:split=geometry | solsplit
+
+.PHONY: run
+run: $(PROG) receiver
+ themis | solstice -q -n$(NEXPERIMENTS) -D$(SUN_DIRS) -R $(RCV_FILE) | solpp
+
+.PHONY: clean
+clean:
+ rm -rf $(PROG) themis*.yaml *.obj *.vtk *simulation*.txt *map*.txt
+
+.PHONY: receiver
+receiver:
+ @echo "- {name: target, side: BACK, per_primitive: 1}" > $(RCV_FILE)
+
+$(PROG): %: %.c solpp.h
+ $(CC) -o $@ $(CFLAGS) $< -I$(STAR_ENGINE)/include -L$(STAR_ENGINE)/lib -lrsys
diff --git a/src/solpp.c b/src/solpp.c
@@ -0,0 +1,297 @@
+/* Copyright (C) |Meso|Star> 2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define _ISOC99_SOURCE /* snprintf support */
+#define _POSIX_C_SOURCE 200809L /* strdup support */
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define CHK(A, B) { \
+ if((A) != (B)) { \
+ fprintf(stderr, "error:%s:%u\n", __FILE__, __LINE__); \
+ assert(0); \
+ exit(0); \
+ } \
+} (void)0
+#define NCHK(A, B) { \
+ if((A) == (B)) { \
+ fprintf(stderr, "error:%s:%u\n", __FILE__, __LINE__); \
+ assert(0); \
+ exit(0); \
+ } \
+} (void)0
+
+struct estimation {
+ float E; /* Expected value */
+ float SE; /* Standard error */
+};
+struct buf {
+ char* mem;
+ size_t sz;
+};
+
+struct entity {
+ char* name;
+ int id;
+};
+
+static char*
+read_line(struct buf* buf, FILE* stream)
+{
+ char* c;
+
+ if(!fgets(buf->mem, (int)buf->sz, stream)) return NULL;
+
+ /* Ensure that the whole line is read */
+ while(!strrchr(buf->mem, '\n') && !feof(stream)) {
+ NCHK(buf->mem = realloc(buf->mem, (buf->sz*=2)), NULL);
+ NCHK(fgets(buf->mem+strlen(buf->mem), (int)buf->sz-strlen(buf->mem), stream), NULL);
+ }
+
+ /* Remove the carriage return */
+ if((c=strrchr(buf->mem, '\n'))) *c = '\0';
+ return buf->mem;
+}
+
+static void
+print_receiver_side_estimations(FILE* output, struct estimation mc[5])
+{
+ fprintf(output, " Absorbed irradiance | %16g +/- %-16g\n", mc[0].E, mc[0].SE);
+ fprintf(output, " Irradiance | %16g +/- %-16g\n", mc[1].E, mc[1].SE);
+ fprintf(output, " Reflectivity loss | %16g +/- %-16g\n", mc[2].E, mc[2].SE);
+ fprintf(output, " Absorptivity loss | %16g +/- %-16g\n", mc[3].E, mc[3].SE);
+ fprintf(output, " Efficiency | %16g +/- %-16g\n", mc[4].E, mc[4].SE);
+}
+
+static void
+print_rcvXprim_side_estimations(FILE* output, struct estimation mc[4])
+{
+ fprintf(output, " Absorbed irradiance | %16g +/- %-16g\n", mc[0].E, mc[0].SE);
+ fprintf(output, " Irradiance | %16g +/- %-16g\n", mc[1].E, mc[1].SE);
+ fprintf(output, " Reflectivity loss | %16g +/- %-16g\n", mc[2].E, mc[2].SE);
+ fprintf(output, " Absorptivity loss | %16g +/- %-16g\n", mc[3].E, mc[3].SE);
+}
+
+static void
+format_simulation_results(FILE* input, FILE* output)
+{
+ struct buf buf;
+ struct estimation mc[10];
+ struct entity* rcvs = NULL;
+ struct entity* prims = NULL;
+ char* line;
+ int nrcvs, nprims, nsamps;
+ int i;
+
+ NCHK(buf.mem = malloc(buf.sz=32), NULL);
+
+ /* Counters */
+ line = read_line(&buf, input);
+ CHK(sscanf(line, "%*d %d %d %d %*d", &nrcvs, &nprims, &nsamps), 3);
+
+ /* Global results */
+ CHK(sscanf(read_line(&buf, input), "%f %f", &mc[0].E, &mc[0].SE), 2);
+ CHK(sscanf(read_line(&buf, input), "%f %f", &mc[1].E, &mc[1].SE), 2);
+ CHK(sscanf(read_line(&buf, input), "%f %f", &mc[2].E, &mc[2].SE), 2);
+ CHK(sscanf(read_line(&buf, input), "%f %f", &mc[3].E, &mc[3].SE), 2);
+ CHK(sscanf(read_line(&buf, input), "%f %f", &mc[4].E, &mc[4].SE), 2);
+ CHK(sscanf(read_line(&buf, input), "%f %f", &mc[5].E, &mc[5].SE), 2);
+ CHK(sscanf(read_line(&buf, input), "%f %f", &mc[6].E, &mc[6].SE), 2);
+ fprintf(output, " Overall results (#Samples = %d)\n", nsamps);
+ fprintf(output, "------------------------------------------------------------\n");
+ fprintf(output, "Potential irradiance | %16g +/- %-16g\n", mc[0].E, mc[0].SE);
+ fprintf(output, " Absorbed irradiance | %16g +/- %-16g\n", mc[1].E, mc[1].SE);
+ fprintf(output, " Cosine factor | %16g +/- %-16g\n", mc[2].E, mc[2].SE);
+ fprintf(output, " Shadow loss | %16g +/- %-16g\n", mc[3].E, mc[3].SE);
+ fprintf(output, " Missing loss | %16g +/- %-16g\n", mc[4].E, mc[4].SE);
+ fprintf(output, " Reflectivity loss | %16g +/- %-16g\n", mc[5].E, mc[5].SE);
+ fprintf(output, " Absorptivity loss | %16g +/- %-16g\n", mc[6].E, mc[6].SE);
+ fprintf(output, "\n");
+
+ /* Per receivers results */
+ NCHK(rcvs = malloc(sizeof(struct entity)*nrcvs), NULL);
+ for(i=0; i<nrcvs; ++i) {
+ const char* name = strtok(read_line(&buf, input), " \t");
+ float area;
+ line = strtok(NULL, "");
+ NCHK(rcvs[i].name = strdup(name), NULL);
+ CHK(sscanf
+ (line,
+ "%d %f "
+ "%f %f %f %f %f %f %f %f %f %f "
+ "%f %f %f %f %f %f %f %f %f %f",
+ &rcvs[i].id, &area,
+ &mc[0].E, &mc[0].SE,
+ &mc[1].E, &mc[1].SE,
+ &mc[2].E, &mc[2].SE,
+ &mc[3].E, &mc[3].SE,
+ &mc[4].E, &mc[4].SE,
+ &mc[5].E, &mc[5].SE,
+ &mc[6].E, &mc[6].SE,
+ &mc[7].E, &mc[7].SE,
+ &mc[8].E, &mc[8].SE,
+ &mc[9].E, &mc[9].SE), 22);
+ fprintf(output, " Receiver `%s' (Area = %g)\n", name, area);
+ if(mc[0].E >= 0) {
+ fprintf(output, "------------------[Front]-----------------------------------\n");
+ print_receiver_side_estimations(output, mc + 0);
+ }
+ if(mc[5].E >= 0) {
+ fprintf(output, "-------------------[Back]-----------------------------------\n");
+ print_receiver_side_estimations(output, mc + 5);
+ }
+ fprintf(output, "\n");
+ }
+
+ /* Per primary results */
+ NCHK(prims = malloc(sizeof(struct entity)*nprims), NULL);
+ for(i=0; i<nprims; ++i) {
+ const char* name = strtok(read_line(&buf, input), " \t");
+ int nsamples;
+ float area;
+ line = strtok(NULL, "");
+ NCHK(prims[i].name = strdup(name), NULL);
+ CHK(sscanf(line, "%d %f %d %f %f %f %f",
+ &prims[i].id, &area, &nsamples,
+ &mc[0].E, &mc[0].SE,
+ &mc[1].E, &mc[1].SE), 7);
+
+ fprintf(output, " Primary `%s' (Area = %g; #Samples = %d)\n",
+ name, area, nsamples);
+ fprintf(output, "------------------------------------------------------------\n");
+ fprintf(output, " Cosine factor | %16g +/- %-16g\n", mc[0].E, mc[0].SE);
+ fprintf(output, " Shadow loss | %16g +/- %-16g\n", mc[1].E, mc[1].SE);
+ fprintf(output, "\n");
+ }
+
+ /* Per receiverXprimary results */
+ for(i=0; i<nrcvs*nprims; ++i) {
+ int ircv, iprim;
+ int isearch;
+ line = read_line(&buf, input);
+ CHK(sscanf
+ (line,
+ "%d %d "
+ "%f %f %f %f %f %f %f %f "
+ "%f %f %f %f %f %f %f %f",
+ &ircv, &iprim,
+ &mc[0].E, &mc[0].SE,
+ &mc[1].E, &mc[1].SE,
+ &mc[2].E, &mc[2].SE,
+ &mc[3].E, &mc[3].SE,
+ &mc[4].E, &mc[4].SE,
+ &mc[5].E, &mc[5].SE,
+ &mc[6].E, &mc[6].SE,
+ &mc[7].E, &mc[7].SE), 18);
+ /* Look for the receiver */
+ for(isearch=0; isearch<nrcvs && rcvs[isearch].id != ircv; ++isearch);
+ NCHK(isearch, nrcvs);
+ ircv = isearch;
+ /* Look for the primary */
+ for(isearch=0; isearch<nprims && prims[isearch].id != iprim; ++isearch);
+ NCHK(isearch, nprims);
+ iprim = isearch;
+ fprintf(output, " Receiver `%s' X Primary `%s'\n",
+ rcvs[ircv].name, prims[iprim].name);
+ if(mc[0].E >= 0) {
+ fprintf(output, "------------------[Front]-----------------------------------\n");
+ print_rcvXprim_side_estimations(output, mc + 0);
+ }
+ if(mc[4].E >= 0) {
+ fprintf(output, "-------------------[Back]-----------------------------------\n");
+ print_rcvXprim_side_estimations(output, mc + 4);
+ }
+ fprintf(output, "\n");
+ }
+
+ /* Free temporary data */
+ for(i=0; i<nrcvs; free(rcvs[i].name), ++i);
+ for(i=0; i<nprims; free(prims[i].name), ++i);
+ free(rcvs);
+ free(prims);
+ free(buf.mem);
+}
+
+int
+main(int argc, char** argv)
+{
+ struct buf buf = {0};
+ struct buf str = {0};
+ FILE* input = stdin;
+ FILE* output = NULL;
+ float azim = 0;
+ float elev = 0;
+ char* line = NULL;
+ int err = 0;
+ int n;
+
+ if(argc > 1) {
+ input = fopen(argv[1], "r");
+ if(!input) {
+ fprintf(stderr, "Could not open the file `%s'.\n", argv[1]);
+ goto error;
+ }
+ }
+
+ NCHK(buf.mem = malloc(buf.sz=32), NULL);
+ NCHK(str.mem = malloc(str.sz=32), NULL);
+
+ while((line = read_line(&buf, input))) {
+
+ if(!strncmp(line, "#--- Sun direction:", 19)) {
+ CHK(sscanf(line+5, "Sun direction: %f %f (%*f %*f %*f)", &azim, &elev), 2);
+ for(;;) {
+ n = snprintf(str.mem, str.sz, "%g-%g-simulation.txt", azim, elev);
+ if(n < str.sz) break;
+ NCHK(str.mem = realloc(str.mem, (str.sz*=2)), NULL);
+ }
+ if(output) fclose(output);
+ NCHK(output = fopen(str.mem, "w"), NULL);
+ format_simulation_results(input, output);
+ } else if(!strncmp(line, "# vtk", 5)) {
+ char* header = strdup(line);
+ NCHK(header, NULL);
+ line = read_line(&buf, input);
+ for(;;) {
+ n = snprintf(str.mem, str.sz, "%g-%g-map-%s.vtk", azim, elev, line);
+ if(n < str.sz) break;
+ NCHK(str.mem = realloc(str.mem, (str.sz*=2)), NULL);
+ }
+ if(output) fclose(output);
+ NCHK(output = fopen(str.mem, "w"), NULL);
+ fprintf(output, "%s\n", header);
+ fprintf(output, "%s\n", str.mem);
+ free(header);
+ } else if(!output) {
+ fprintf(stderr, "Parsing error.\n");
+ goto error;
+ } else {
+ fprintf(output, "%s\n", line);
+ }
+ }
+
+exit:
+ if(buf.mem) free(buf.mem);
+ if(str.mem) free(str.mem);
+ if(output) fclose(output);
+ if(input && input != stdin) fclose(input);
+ return err;
+error:
+ err = 1;
+ goto exit;
+}
+
diff --git a/src/solpp.h b/src/solpp.h
@@ -0,0 +1,383 @@
+/* Copyright (C) |Meso|Star> 2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SOLPP_H
+#define SOLPP_H
+
+#include <rsys/dynamic_array.h>
+#include <rsys/str.h>
+#include <rsys/stretchy_array.h>
+
+enum side {
+ FRONT,
+ BACK
+};
+
+struct mc {
+ double E; /* Expected value */
+ double SE; /* Standard Error */
+};
+
+static INLINE char*
+read_line(char** b, FILE* stream)
+{
+ if(!*b) *b = sa_add(*b, 32);
+ if(!fgets(*b, (int)sa_size(*b), stream)) return NULL;
+ /* Ensure that the whole line is read */
+ while(!strrchr(*b, '\n') && !feof(stream)) {
+ NCHECK(sa_add(*b, 32), NULL);
+ NCHECK(fgets(*b+strlen(*b), (int)(sa_size(*b)-strlen(*b)), stream), NULL);
+ }
+ /* Remove the carriage return */
+ if((*b)[strlen(*b)-1] == '\n') (*b)[strlen(*b)-1] = '\0';
+ return *b;
+}
+
+/*******************************************************************************
+ * Per receiver double sided estimations
+ ******************************************************************************/
+struct rcv {
+ struct mc absorbed_irradiance[2];
+ struct mc irradiance[2];
+ struct mc reflectivity_loss[2];
+ struct mc absorptivity_loss[2];
+ struct mc efficiency[2];
+ struct str name;
+ size_t id;
+ double area;
+};
+
+static INLINE void
+rcv_init(struct mem_allocator* allocator, struct rcv* rcv)
+{
+ memset(rcv, 0, sizeof(struct rcv));
+ str_init(allocator, &rcv->name);
+}
+
+static INLINE void
+rcv_release(struct rcv* rcv)
+{
+ str_release(&rcv->name);
+}
+
+static INLINE res_T
+rcv_copy(struct rcv* dst, const struct rcv* src)
+{
+ int i;
+ if(dst == src) return RES_OK;
+ FOR_EACH(i, 0, 2) {
+ dst->absorbed_irradiance[i] = src->absorbed_irradiance[i];
+ dst->irradiance[i] = src->irradiance[i];
+ dst->reflectivity_loss[i] = src->reflectivity_loss[i];
+ dst->absorptivity_loss[i] = src->absorptivity_loss[i];
+ dst->efficiency[i] = src->efficiency[i];
+ }
+ dst->area = src->area;
+ CHECK(str_copy(&dst->name, &src->name), RES_OK);
+ return RES_OK;
+}
+
+static INLINE res_T
+rcv_copy_and_release(struct rcv* dst, struct rcv* src)
+{
+ int i;
+ if(dst == src) return RES_OK;
+ FOR_EACH(i, 0, 2) {
+ dst->absorbed_irradiance[i] = src->absorbed_irradiance[i];
+ dst->irradiance[i] = src->irradiance[i];
+ dst->reflectivity_loss[i] = src->reflectivity_loss[i];
+ dst->absorptivity_loss[i] = src->absorptivity_loss[i];
+ dst->efficiency[i] = src->efficiency[i];
+ }
+ dst->area = src->area;
+ CHECK(str_copy_and_release(&dst->name, &src->name), RES_OK);
+ return RES_OK;
+}
+
+#define DARRAY_NAME rcv
+#define DARRAY_DATA struct rcv
+#define DARRAY_FUNCTOR_INIT rcv_init
+#define DARRAY_FUNCTOR_RELEASE rcv_release
+#define DARRAY_FUNCTOR_COPY rcv_copy
+#define DARRAY_FUNCTOR_COPY_AND_RELEASE rcv_copy_and_release
+#include <rsys/dynamic_array.h>
+
+/*******************************************************************************
+ * Per primary estimations
+ ******************************************************************************/
+struct prim {
+ struct mc cos_factor;
+ struct mc shadow_loss;
+ struct str name;
+ size_t id;
+ size_t nsamps;
+ double area;
+};
+
+static INLINE void
+prim_init(struct mem_allocator* allocator, struct prim* prim)
+{
+ memset(prim, 0, sizeof(struct prim));
+ str_init(allocator, &prim->name);
+}
+
+static INLINE void
+prim_release(struct prim* prim)
+{
+ str_release(&prim->name);
+}
+
+static INLINE res_T
+prim_copy(struct prim* dst, const struct prim* src)
+{
+ if(dst == src) return RES_OK;
+ dst->cos_factor = src->cos_factor;
+ dst->shadow_loss = src->cos_factor;
+ dst->id = src->id;
+ dst->nsamps = src->nsamps;
+ dst->area = src->area;
+ CHECK(str_copy(&dst->name, &src->name), RES_OK);
+ return RES_OK;
+}
+
+static INLINE res_T
+prim_copy_and_release(struct prim* dst, struct prim* src)
+{
+ if(dst == src) return RES_OK;
+ dst->cos_factor = src->cos_factor;
+ dst->shadow_loss = src->cos_factor;
+ dst->id = src->id;
+ dst->nsamps = src->nsamps;
+ dst->area = src->area;
+ CHECK(str_copy_and_release(&dst->name, &src->name), RES_OK);
+ return RES_OK;
+}
+
+#define DARRAY_NAME prim
+#define DARRAY_DATA struct prim
+#define DARRAY_FUNCTOR_INIT prim_init
+#define DARRAY_FUNCTOR_RELEASE prim_release
+#define DARRAY_FUNCTOR_COPY prim_copy
+#define DARRAY_FUNCTOR_COPY_AND_RELEASE prim_copy_and_release
+#include <rsys/dynamic_array.h>
+
+/*******************************************************************************
+ * Per receiver X primary estimations
+ ******************************************************************************/
+struct rcvXprim {
+ struct mc absorbed_irradiance[2];
+ struct mc irradiance[2];
+ struct mc reflectivity_loss[2];
+ struct mc absorptivity_loss[2];
+ size_t rcv_id;
+ size_t prim_id;
+};
+
+#define DARRAY_NAME rcvXprim
+#define DARRAY_DATA struct rcvXprim
+#include <rsys/dynamic_array.h>
+
+/*******************************************************************************
+ * Overall estimations of a simulation
+ ******************************************************************************/
+struct simul {
+ struct mc potential_irradiance;
+ struct mc absorbed_irradiance;
+ struct mc cos_factor;
+ struct mc shadow_loss;
+ struct mc missing_loss;
+ struct mc reflectivity_loss;
+ struct mc absorptivity_loss;
+
+ struct darray_rcv rcvs;
+ struct darray_prim prims;
+ struct darray_rcvXprim rcvXprims;
+
+ double azimuth;
+ double elevation;
+ size_t nsamps;
+};
+
+static INLINE void
+simul_init(struct mem_allocator* allocator, struct simul* simul)
+{
+ darray_rcv_init(allocator, &simul->rcvs);
+ darray_prim_init(allocator, &simul->prims);
+ darray_rcvXprim_init(allocator, &simul->rcvXprims);
+ simul->azimuth = -1;
+ simul->elevation = -1;
+}
+
+static INLINE void
+simul_release(struct simul* simul)
+{
+ darray_rcv_release(&simul->rcvs);
+ darray_prim_release(&simul->prims);
+ darray_rcvXprim_release(&simul->rcvXprims);
+}
+
+static INLINE res_T
+simul_copy(struct simul* dst, const struct simul* src)
+{
+ CHECK(darray_rcv_copy(&dst->rcvs, &src->rcvs), RES_OK);
+ CHECK(darray_prim_copy(&dst->prims, &src->prims), RES_OK);
+ CHECK(darray_rcvXprim_copy(&dst->rcvXprims, &src->rcvXprims), RES_OK);
+ dst->azimuth = src->azimuth;
+ dst->elevation = src->elevation;
+ return RES_OK;
+}
+
+static INLINE res_T
+simul_copy_and_release(struct simul* dst, struct simul* src)
+{
+ CHECK(darray_rcv_copy_and_release(&dst->rcvs, &src->rcvs), RES_OK);
+ CHECK(darray_prim_copy_and_release(&dst->prims, &src->prims), RES_OK);
+ CHECK(darray_rcvXprim_copy_and_release(&dst->rcvXprims, &src->rcvXprims), RES_OK);
+ dst->azimuth = src->azimuth;
+ dst->elevation = src->elevation;
+ return RES_OK;
+}
+
+#define DARRAY_NAME simul
+#define DARRAY_DATA struct simul
+#define DARRAY_FUNCTOR_INIT simul_init
+#define DARRAY_FUNCTOR_RELEASE simul_release
+#define DARRAY_FUNCTOR_COPY_AND_RELEASE simul_copy_and_release
+#include <rsys/dynamic_array.h>
+
+static INLINE void
+read_simulation(struct simul* simul, FILE* input)
+{
+ char* buf = NULL;
+ char* line = NULL;
+ char* tk = NULL;
+ size_t nrcvs, nprims;
+ size_t i;
+
+ /* Counters */
+ NCHECK(line = read_line(&buf, input), NULL);
+ CHECK(sscanf(line, "%*u %zu %zu %zu %*u", &nrcvs, &nprims, &simul->nsamps), 3);
+
+ /* Global results */
+ #define READ(Name) { \
+ NCHECK(line = read_line(&buf, input), NULL); \
+ CHECK(sscanf(line, "%lf %lf", &simul->Name.E, &simul->Name.SE), 2); \
+ } (void)0
+ READ(potential_irradiance);
+ READ(absorbed_irradiance);
+ READ(cos_factor);
+ READ(shadow_loss);
+ READ(missing_loss);
+ READ(reflectivity_loss);
+ READ(absorptivity_loss);
+ #undef READ
+
+ /* Read per receiver results */
+ CHECK(darray_rcv_resize(&simul->rcvs, nrcvs), RES_OK);
+ FOR_EACH(i, 0, nrcvs) {
+ struct rcv* rcv = darray_rcv_data_get(&simul->rcvs) + i;
+
+ NCHECK(line = read_line(&buf, input), NULL);
+ NCHECK(tk = strtok(line, " \t"), NULL);
+ CHECK(str_set(&rcv->name, tk), RES_OK);
+
+ NCHECK(tk = strtok(NULL, ""), NULL);
+ #define GET(Side, Name) &rcv->Name[Side].E, &rcv->Name[Side].SE
+ CHECK(sscanf
+ (tk,
+ "%zu %lf "
+ "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf "
+ "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
+ &rcv->id, &rcv->area,
+ GET(FRONT, absorbed_irradiance),
+ GET(FRONT, irradiance),
+ GET(FRONT, reflectivity_loss),
+ GET(FRONT, absorptivity_loss),
+ GET(FRONT, efficiency),
+ GET(BACK, absorbed_irradiance),
+ GET(BACK, irradiance),
+ GET(BACK, reflectivity_loss),
+ GET(BACK, absorptivity_loss),
+ GET(BACK, efficiency)), 22);
+ #undef GET
+ }
+
+ /* Read per primary results */
+ CHECK(darray_prim_resize(&simul->prims, nprims), RES_OK);
+ FOR_EACH(i, 0, nprims) {
+ struct prim* prim = darray_prim_data_get(&simul->prims) + i;
+
+ NCHECK(line = read_line(&buf, input), NULL);
+ NCHECK(tk = strtok(line, " \t"), NULL);
+ CHECK(str_set(&prim->name, tk), RES_OK);
+
+ NCHECK(tk = strtok(NULL, ""), NULL);
+ CHECK(sscanf(tk, "%zu %lf %zu %lf %lf %lf %lf",
+ &prim->id, &prim->area, &prim->nsamps,
+ &prim->cos_factor.E, &prim->cos_factor.SE,
+ &prim->shadow_loss.E, &prim->shadow_loss.SE), 7);
+ }
+
+ /* Per receiverXprimary results */
+ CHECK(darray_rcvXprim_resize(&simul->rcvXprims, nprims*nrcvs), RES_OK);
+ FOR_EACH(i, 0, nprims*nrcvs) {
+ struct rcvXprim* rcvXprim = darray_rcvXprim_data_get(&simul->rcvXprims) + i;
+
+ NCHECK(line = read_line(&buf, input), NULL);
+ #define GET(Side, Name) &rcvXprim->Name[Side].E, &rcvXprim->Name[Side].SE
+ CHECK(sscanf
+ (line,
+ "%zu %zu "
+ "%lf %lf %lf %lf %lf %lf %lf %lf "
+ "%lf %lf %lf %lf %lf %lf %lf %lf",
+ &rcvXprim->rcv_id, &rcvXprim->prim_id,
+ GET(FRONT, absorbed_irradiance),
+ GET(FRONT, irradiance),
+ GET(FRONT, reflectivity_loss),
+ GET(FRONT, absorptivity_loss),
+ GET(BACK, absorbed_irradiance),
+ GET(BACK, irradiance),
+ GET(BACK, reflectivity_loss),
+ GET(BACK, absorptivity_loss)), 18);
+ #undef GET
+ }
+ sa_release(buf);
+}
+
+static INLINE const struct prim*
+find_primary(const struct simul* simul, const char* name)
+{
+ size_t i;
+ for(i=0; i<darray_prim_size_get(&simul->prims); ++i) {
+ const struct prim* prim = darray_prim_cdata_get(&simul->prims)+i;
+ if(!strcmp(str_cget(&prim->name), name)) return prim;
+ }
+ return NULL;
+}
+
+static INLINE const struct rcv*
+find_receiver(const struct simul* simul, const char* name)
+{
+ size_t i;
+ for(i=0; i<darray_rcv_size_get(&simul->rcvs); ++i) {
+ const struct rcv* rcv = darray_rcv_cdata_get(&simul->rcvs)+i;
+ if(!strcmp(str_cget(&rcv->name), name)) return rcv;
+ }
+ return NULL;
+}
+
+
+#endif /* SOLPP_H */
+
diff --git a/src/solsplit.c b/src/solsplit.c
@@ -0,0 +1,107 @@
+/* Copyright (C) |Meso|Star> 2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define _ISOC99_SOURCE /* snprintf support */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char** argv)
+{
+ char* c = NULL;
+ char* str = NULL;
+ char* buf = NULL;
+ FILE* input = stdin;
+ FILE* output = NULL;
+ float azim = -1; /* Azimuth angle of the sun direction */
+ float elev = -1; /* Elevation angle of the sun direction */
+ int bufsz = 32;
+ int strsz = 32;
+ int err = 0;
+ int n = 0;
+
+ /* Helper macros */
+ #define MALLOC(Mem, Sz) { \
+ if(!((Mem) = malloc(Sz))) { \
+ fprintf(stderr, "Memory error.\n"); \
+ goto error; \
+ } \
+ } (void)0
+ #define REALLOC(Mem, Sz) { \
+ if(!((Mem) = realloc((Mem), (Sz)))) { \
+ fprintf(stderr, "Memory error.\n"); \
+ goto error; \
+ } \
+ } (void)0
+
+ /* Load the submitted file if provided on the command line */
+ if(argc > 1 && !(input = fopen(argv[1], "r"))) {
+ fprintf(stderr, "Cannot open the file `%s'.\n", argv[1]);
+ goto error;
+ }
+
+ MALLOC(buf, bufsz); /* Buffer that stores the input lines */
+ MALLOC(str, strsz); /* Temporary string */
+
+ while(fgets(buf, (int)bufsz, input)) { /* Read the input line */
+
+ /* Ensure that the whole line is read */
+ while(!strrchr(buf,'\n') && !feof(input)) {
+ REALLOC(buf, (bufsz*=2));
+ c = fgets(buf+strlen(buf), (int)bufsz-strlen(buf), input);
+ }
+
+ /* Remove the carriage return */
+ if((c=strrchr(buf, '\n'))) *c = '\0';
+
+ if(!strcmp(buf, "#--- No Sun direction")) {
+ azim = elev = -1;
+ } else if(!strncmp(buf, "#--- Sun direction:", 19)) {
+ n = sscanf(buf+5, "Sun direction: %f %f (%*f %*f %*f)", &azim, &elev);
+ if(n != 2) {
+ fprintf(stderr, "Could not parse `%s'.\n", buf);
+ goto error;
+ }
+ } else if(!strncmp(buf, "g ", 2)) {
+ for(;;) {
+ n = (azim < 0 || elev < 0)
+ ? snprintf(str, strsz, "%s.obj", buf+2)
+ : snprintf(str, strsz, "%g-%g-%s.obj", azim, elev, buf+2);
+ if(n < strsz) break;
+ REALLOC(str, (strsz*=2));
+ }
+ if(!output && !(output = fopen(str, "w"))) {
+ fprintf(stderr, "Could not open '%s'.\n", str);
+ goto error;
+ }
+ } else if(!strcmp(buf, "---")) {
+ if(output) fclose(output);
+ output = NULL;
+ }
+ if(output) fprintf(output, "%s\n", buf);
+ }
+
+exit:
+ if(str) free(str);
+ if(buf) free(buf);
+ if(output) fclose(output);
+ if(input && input!=stdin) fclose(input);
+ return err;
+error:
+ err = 1;
+ goto exit;
+}
+
diff --git a/src/solvtk.c b/src/solvtk.c
@@ -0,0 +1,233 @@
+/* Copyright (C) |Meso|Star> 2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "solpp.h"
+#include <rsys/str.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+struct mesh {
+ double* coords;
+ size_t* ids;
+ size_t* entities;
+ size_t* ncells;
+ size_t voffset;
+};
+static const struct mesh MESH_NULL = {NULL, NULL, NULL, NULL, 0};
+
+static void
+mesh_release(struct mesh* msh)
+{
+ sa_release(msh->coords);
+ sa_release(msh->ids);
+ sa_release(msh->entities);
+ sa_release(msh->ncells);
+ msh->voffset = 0;
+}
+
+static void
+mesh_write_vtk(FILE* output, struct mesh* msh)
+{
+ size_t i, n;
+
+ fprintf(output, "# vtk DataFile Version 2.0\n");
+ fprintf(output, "Test\n");
+ fprintf(output, "ASCII\n");
+ fprintf(output, "DATASET POLYDATA\n");
+
+ n = sa_size(msh->coords)/3;
+ fprintf(output, "POINTS %zu float\n", n);
+ FOR_EACH(i, 0, n) {
+ fprintf(output, "%g %g %g\n", SPLIT3(msh->coords + i*3));
+ }
+
+ n = sa_size(msh->ids)/3;
+ fprintf(output, "POLYGONS %zu %zu\n", n, n*4);
+ FOR_EACH(i, 0, n) {
+ fprintf(output, "3 %zu %zu %zu\n", SPLIT3(msh->ids + i*3));
+ }
+}
+
+static void
+mesh_write_obj(FILE* output, struct mesh* msh)
+{
+ size_t i, n;
+
+ n = sa_size(msh->coords)/3;
+ FOR_EACH(i, 0, n) {
+ fprintf(output, "v %g %g %g\n", SPLIT3(msh->coords + i*3));
+ }
+
+ n = sa_size(msh->ids)/3;
+ FOR_EACH(i, 0, n) {
+ fprintf(output, "f %zu %zu %zu\n",
+ msh->ids[i*3+0] + 1,
+ msh->ids[i*3+1] + 1,
+ msh->ids[i*3+2] + 1);
+ }
+}
+
+int
+main(int argc, char** argv)
+{
+ struct simul simul;
+ struct str name;
+
+ FILE* input;
+ FILE* output;
+
+ struct mesh msh_rcv = MESH_NULL;
+ struct mesh msh_prim = MESH_NULL;
+ struct mesh msh_misc = MESH_NULL;
+
+ const struct rcv* rcv = NULL;
+ const struct prim* prim = NULL;
+
+ char* line = NULL;
+ char* buf = NULL;
+ char* str = NULL;
+ size_t ntris = 0, nverts = 0;
+ float azim, elev;
+ int err = 0;
+
+ simul_init(NULL, &simul);
+ str_init(NULL, &name);
+
+ if(argc < 3) {
+ fprintf(stderr, "Usage: %s solstice-geometry solstice-simulation\n", argv[0]);
+ goto error;
+ }
+
+ NCHECK(input = fopen(argv[2], "r"), NULL);
+ NCHECK(line = read_line(&buf, input), NULL);
+ CHECK(strncmp(line, "#--- Sun direction:", 19), 0);
+ CHECK(sscanf(line+19, "%lf %lf (%*f %*f %*f)", &simul.azimuth, &simul.elevation), 2);
+ read_simulation(&simul, input);
+ fclose(input);
+
+ NCHECK(input = fopen(argv[1], "r"), NULL);
+ while((line = read_line(&buf, input))) {
+ if(!strcmp(line, "#--- No Sun direction")) {
+ azim = elev = -1;
+ } else if(!strncmp(line, "#--- Sun direction:", 19)) {
+ CHECK(sscanf(line+19, "%f %f (%*f %*f %*f)", &azim, &elev), 2);
+ } else if(!strncmp(line, "g ", 2)) {
+ CHECK(str_set(&name, line+2), RES_OK);
+ prim = find_primary(&simul, line+2);
+ rcv = find_receiver(&simul, line+2);
+ if(prim) sa_push(msh_prim.entities, prim->id);
+ if(rcv) sa_push(msh_rcv.entities, rcv->id);
+ ntris = 0;
+ nverts = 0;
+ } else if(!strncmp(line, "v ", 2)) {
+ double pos[3];
+ CHECK(sscanf(line+2, "%lf %lf %lf", pos+0, pos+1, pos+2), 3);
+ if(prim) {
+ sa_push(msh_prim.coords, pos[0]);
+ sa_push(msh_prim.coords, pos[1]);
+ sa_push(msh_prim.coords, pos[2]);
+ }
+ if(rcv) {
+ sa_push(msh_rcv.coords, pos[0]);
+ sa_push(msh_rcv.coords, pos[1]);
+ sa_push(msh_rcv.coords, pos[2]);
+ }
+ if(!prim && !rcv) {
+ sa_push(msh_misc.coords, pos[0]);
+ sa_push(msh_misc.coords, pos[1]);
+ sa_push(msh_misc.coords, pos[2]);
+ }
+ ++nverts;
+ } else if(!strncmp(line, "f ", 2)) {
+ size_t tri[3];
+ CHECK(sscanf(line+2, "%zu %zu %zu", tri+0, tri+1, tri+2), 3);
+ if(prim) {
+ sa_push(msh_prim.ids, tri[0] - 1 + msh_prim.voffset);
+ sa_push(msh_prim.ids, tri[1] - 1 + msh_prim.voffset);
+ sa_push(msh_prim.ids, tri[2] - 1 + msh_prim.voffset);
+ }
+ if(rcv) {
+ sa_push(msh_rcv.ids, tri[0] - 1 + msh_rcv.voffset);
+ sa_push(msh_rcv.ids, tri[1] - 1 + msh_rcv.voffset);
+ sa_push(msh_rcv.ids, tri[2] - 1 + msh_rcv.voffset);
+ }
+ if(!prim && !rcv) {
+ sa_push(msh_misc.ids, tri[0] - 1 + msh_misc.voffset);
+ sa_push(msh_misc.ids, tri[1] - 1 + msh_misc.voffset);
+ sa_push(msh_misc.ids, tri[2] - 1 + msh_misc.voffset);
+ }
+ ++ntris;
+ } else if(!strcmp(line, "---")) {
+ if(prim) {
+ sa_push(msh_prim.ncells, ntris);
+ msh_prim.voffset += nverts;
+ }
+ if(rcv) {
+ sa_push(msh_rcv.ncells, ntris);
+ msh_rcv.voffset += nverts;
+ }
+ if(!prim && !rcv) {
+ msh_misc.voffset += nverts;
+ }
+ prim = NULL;
+ rcv = NULL;
+ }
+ }
+ fclose(input);
+
+ NCHECK(output = fopen("primaries.vtk", "w"), NULL);
+ mesh_write_vtk(output, &msh_prim);
+ fclose(output);
+
+ NCHECK(output = fopen("receivers.vtk", "w"), NULL);
+ mesh_write_vtk(output, &msh_rcv);
+ fclose(output);
+
+ NCHECK(output = fopen("miscellaneous.obj", "w"), NULL);
+ mesh_write_obj(output, &msh_misc);
+ fclose(output);
+
+#if 0
+ fprintf(output, "CELL_DATA %zu\n", n);
+ fprintf(output, "FIELD PrimaryData 2\n");
+ fprintf(output, "cos_factor 2 %zu float\n", n);
+ FOR_EACH(i, 0, sa_size(prim_ids)) {
+ FOR_EACH(j, 0, ncells[i]) {
+ fprintf(output, "%g %g\n",
+ prims[prim_ids[i]].cos_factor.E,
+ prims[prim_ids[i]].cos_factor.SE);
+ }}
+ fprintf(output, "shadow_loss 2 %zu float\n", n);
+ FOR_EACH(i, 0, sa_size(prim_ids)) {
+ FOR_EACH(j, 0, ncells[i]) {
+ fprintf(output, "%g %g\n",
+ prims[prim_ids[i]].shadow_loss.E,
+ prims[prim_ids[i]].shadow_loss.SE);
+ }}
+#endif
+
+exit:
+ mesh_release(&msh_prim);
+ mesh_release(&msh_rcv);
+ mesh_release(&msh_misc);
+ sa_release(buf);
+ sa_release(str);
+ simul_release(&simul);
+ str_release(&name);
+ return err;
+error:
+ goto exit;
+}
diff --git a/src/themis.c b/src/themis.c
@@ -0,0 +1,1277 @@
+/* Copyright (C) |Meso|Star> 2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include <stdio.h>
+
+/*******************************************************************************
+ * Data
+ ******************************************************************************/
+static const double solar_spectrum[][2] = { /* Wavelength data */
+ {2.800000e-01, 1.755832e-22},
+ {2.850000e-01, 3.294496e-13},
+ {2.900000e-01, 9.825731e-07},
+ {2.950000e-01, 4.867814e-03},
+ {3.000000e-01, 5.930555e-01},
+ {3.050000e-01, 1.009141e+01},
+ {3.100000e-01, 3.418097e+01},
+ {3.150000e-01, 8.042174e+01},
+ {3.200000e-01, 1.269513e+02},
+ {3.250000e-01, 1.755832e+02},
+ {3.300000e-01, 2.802401e+02},
+ {3.350000e-01, 2.853227e+02},
+ {3.400000e-01, 3.165119e+02},
+ {3.450000e-01, 3.021880e+02},
+ {3.500000e-01, 3.613318e+02},
+ {3.550000e-01, 4.239411e+02},
+ {3.600000e-01, 4.052276e+02},
+ {3.650000e-01, 4.730351e+02},
+ {3.700000e-01, 5.417667e+02},
+ {3.750000e-01, 4.694541e+02},
+ {3.800000e-01, 5.618663e+02},
+ {3.850000e-01, 5.083828e+02},
+ {3.900000e-01, 6.487338e+02},
+ {3.950000e-01, 6.482718e+02},
+ {4.000000e-01, 9.550803e+02},
+ {4.050000e-01, 9.825730e+02},
+ {4.100000e-01, 9.814178e+02},
+ {4.150000e-01, 1.076949e+03},
+ {4.200000e-01, 1.098781e+03},
+ {4.250000e-01, 1.125350e+03},
+ {4.300000e-01, 8.677508e+02},
+ {4.350000e-01, 1.148568e+03},
+ {4.400000e-01, 1.220997e+03},
+ {4.450000e-01, 1.329581e+03},
+ {4.500000e-01, 1.492457e+03},
+ {4.550000e-01, 1.458958e+03},
+ {4.600000e-01, 1.491302e+03},
+ {4.650000e-01, 1.502854e+03},
+ {4.700000e-01, 1.461268e+03},
+ {4.750000e-01, 1.546750e+03},
+ {4.800000e-01, 1.581404e+03},
+ {4.850000e-01, 1.485527e+03},
+ {4.900000e-01, 1.568698e+03},
+ {4.950000e-01, 1.591801e+03},
+ {5.000000e-01, 1.539819e+03},
+ {5.050000e-01, 1.549060e+03},
+ {5.100000e-01, 1.569853e+03},
+ {5.150000e-01, 1.554836e+03},
+ {5.200000e-01, 1.516716e+03},
+ {5.250000e-01, 1.613748e+03},
+ {5.300000e-01, 1.609128e+03},
+ {5.350000e-01, 1.610283e+03},
+ {5.400000e-01, 1.515560e+03},
+ {5.450000e-01, 1.592956e+03},
+ {5.500000e-01, 1.595266e+03},
+ {5.550000e-01, 1.618369e+03},
+ {5.600000e-01, 1.557146e+03},
+ {5.650000e-01, 1.554836e+03},
+ {5.700000e-01, 1.515560e+03},
+ {5.750000e-01, 1.542129e+03},
+ {5.800000e-01, 1.561767e+03},
+ {5.850000e-01, 1.582559e+03},
+ {5.900000e-01, 1.363080e+03},
+ {5.950000e-01, 1.440476e+03},
+ {6.000000e-01, 1.523647e+03},
+ {6.050000e-01, 1.558301e+03},
+ {6.100000e-01, 1.539819e+03},
+ {6.150000e-01, 1.543284e+03},
+ {6.200000e-01, 1.555991e+03},
+ {6.250000e-01, 1.473975e+03},
+ {6.300000e-01, 1.460113e+03},
+ {6.350000e-01, 1.519026e+03},
+ {6.400000e-01, 1.524802e+03},
+ {6.450000e-01, 1.524802e+03},
+ {6.500000e-01, 1.461268e+03},
+ {6.550000e-01, 1.398890e+03},
+ {6.600000e-01, 1.465889e+03},
+ {6.650000e-01, 1.490147e+03},
+ {6.700000e-01, 1.493613e+03},
+ {6.750000e-01, 1.482061e+03},
+ {6.800000e-01, 1.473975e+03},
+ {6.850000e-01, 1.438165e+03},
+ {6.900000e-01, 1.227927e+03},
+ {6.950000e-01, 1.281064e+03},
+ {7.000000e-01, 1.282220e+03},
+ {7.050000e-01, 1.331891e+03},
+ {7.100000e-01, 1.342288e+03},
+ {7.150000e-01, 1.306478e+03},
+ {7.200000e-01, 8.671732e+02},
+ {7.250000e-01, 9.532321e+02},
+ {7.300000e-01, 1.061239e+03},
+ {7.350000e-01, 1.217531e+03},
+ {7.400000e-01, 1.253341e+03},
+ {7.450000e-01, 1.311098e+03},
+ {7.500000e-01, 1.303012e+03},
+ {7.550000e-01, 1.293771e+03},
+ {7.600000e-01, 2.831280e+02},
+ {7.650000e-01, 7.233567e+02},
+ {7.700000e-01, 1.226772e+03},
+ {7.750000e-01, 1.236014e+03},
+ {7.800000e-01, 1.237169e+03},
+ {7.850000e-01, 1.229083e+03},
+ {7.900000e-01, 1.118765e+03},
+ {7.950000e-01, 1.164394e+03},
+ {8.000000e-01, 1.134014e+03},
+ {8.050000e-01, 1.121307e+03},
+ {8.100000e-01, 1.091042e+03},
+ {8.150000e-01, 8.507700e+02},
+ {8.200000e-01, 8.317100e+02},
+ {8.250000e-01, 1.000362e+03},
+ {8.300000e-01, 9.195016e+02},
+ {8.350000e-01, 1.049456e+03},
+ {8.400000e-01, 1.061354e+03},
+ {8.450000e-01, 1.078220e+03},
+ {8.500000e-01, 1.017921e+03},
+ {8.550000e-01, 9.829195e+02},
+ {8.600000e-01, 1.063665e+03},
+ {8.650000e-01, 1.007640e+03},
+ {8.700000e-01, 1.043219e+03},
+ {8.750000e-01, 1.036288e+03},
+ {8.800000e-01, 1.023003e+03},
+ {8.850000e-01, 1.012145e+03},
+ {8.900000e-01, 1.000016e+03},
+ {8.950000e-01, 8.095311e+02},
+ {9.000000e-01, 7.268221e+02},
+ {9.050000e-01, 8.257032e+02},
+ {9.100000e-01, 5.527406e+02},
+ {9.150000e-01, 6.158120e+02},
+ {9.200000e-01, 7.346772e+02},
+ {9.250000e-01, 6.600543e+02},
+ {9.300000e-01, 3.049603e+02},
+ {9.350000e-01, 1.475130e+02},
+ {9.400000e-01, 3.614473e+02},
+ {9.450000e-01, 2.581767e+02},
+ {9.500000e-01, 6.159275e+01},
+ {9.550000e-01, 2.303375e+02},
+ {9.600000e-01, 3.137395e+02},
+ {9.650000e-01, 4.293703e+02},
+ {9.700000e-01, 5.969830e+02},
+ {9.750000e-01, 5.647542e+02},
+ {9.800000e-01, 5.682197e+02},
+ {9.850000e-01, 6.823488e+02},
+ {9.900000e-01, 7.674835e+02},
+ {9.950000e-01, 8.192344e+02},
+ {1.000000e+00, 8.012140e+02},
+ {1.005000e+00, 7.822695e+02},
+ {1.010000e+00, 7.758006e+02},
+ {1.015000e+00, 7.794971e+02},
+ {1.020000e+00, 7.657508e+02},
+ {1.025000e+00, 7.675990e+02},
+ {1.030000e+00, 7.572027e+02},
+ {1.035000e+00, 7.464597e+02},
+ {1.040000e+00, 7.380271e+02},
+ {1.045000e+00, 7.256670e+02},
+ {1.050000e+00, 7.190826e+02},
+ {1.055000e+00, 7.090328e+02},
+ {1.060000e+00, 6.904348e+02},
+ {1.065000e+00, 6.854677e+02},
+ {1.070000e+00, 6.587836e+02},
+ {1.075000e+00, 6.438822e+02},
+ {1.080000e+00, 6.396081e+02},
+ {1.085000e+00, 6.422650e+02},
+ {1.090000e+00, 5.934020e+02},
+ {1.095000e+00, 5.304462e+02},
+ {1.100000e+00, 4.647180e+02},
+ {1.105000e+00, 4.916330e+02},
+ {1.110000e+00, 4.297168e+02},
+ {1.115000e+00, 1.782401e+02},
+ {1.120000e+00, 6.423805e+01},
+ {1.125000e+00, 6.967882e+01},
+ {1.130000e+00, 2.260634e+01},
+ {1.135000e+00, 4.263669e+00},
+ {1.140000e+00, 1.699230e+02},
+ {1.145000e+00, 6.558958e+01},
+ {1.150000e+00, 6.521993e+01},
+ {1.155000e+00, 2.327633e+02},
+ {1.160000e+00, 2.165912e+02},
+ {1.165000e+00, 3.331461e+02},
+ {1.170000e+00, 4.473907e+02},
+ {1.175000e+00, 4.572095e+02},
+ {1.180000e+00, 4.366478e+02},
+ {1.185000e+00, 3.854745e+02},
+ {1.190000e+00, 4.808901e+02},
+ {1.195000e+00, 4.510872e+02},
+ {1.200000e+00, 4.587112e+02},
+ {1.205000e+00, 4.491234e+02},
+ {1.210000e+00, 4.704937e+02},
+ {1.215000e+00, 4.268290e+02},
+ {1.220000e+00, 4.885141e+02},
+ {1.225000e+00, 4.982174e+02},
+ {1.230000e+00, 4.974088e+02},
+ {1.235000e+00, 5.173929e+02},
+ {1.240000e+00, 5.160068e+02},
+ {1.245000e+00, 5.130034e+02},
+ {1.250000e+00, 5.102310e+02},
+ {1.255000e+00, 5.015674e+02},
+ {1.260000e+00, 4.792729e+02},
+ {1.265000e+00, 4.427701e+02},
+ {1.270000e+00, 4.321427e+02},
+ {1.275000e+00, 4.596353e+02},
+ {1.280000e+00, 4.599818e+02},
+ {1.285000e+00, 4.644869e+02},
+ {1.290000e+00, 4.539751e+02},
+ {1.295000e+00, 4.331823e+02},
+ {1.300000e+00, 3.504734e+02},
+ {1.305000e+00, 4.007225e+02},
+ {1.310000e+00, 2.752729e+02},
+ {1.315000e+00, 2.498596e+02},
+ {1.320000e+00, 2.327633e+02},
+ {1.325000e+00, 3.078482e+02},
+ {1.330000e+00, 1.720023e+02},
+ {1.335000e+00, 1.822831e+02},
+ {1.340000e+00, 1.253341e+02},
+ {1.345000e+00, 5.043397e+01},
+ {1.350000e+00, 1.852865e+00},
+ {1.355000e+00, 1.421993e-06},
+ {1.360000e+00, 4.201291e-07},
+ {1.365000e+00, 2.019207e-16},
+ {1.370000e+00, 8.799954e-09},
+ {1.375000e+00, 7.149241e-04},
+ {1.380000e+00, 2.424666e-04},
+ {1.385000e+00, 1.434700e-06},
+ {1.390000e+00, 1.954519e-03},
+ {1.395000e+00, 2.606025e-07},
+ {1.400000e+00, 3.272548e-12},
+ {1.405000e+00, 6.190464e-08},
+ {1.410000e+00, 5.661404e-03},
+ {1.415000e+00, 1.804349e-03},
+ {1.420000e+00, 7.145775e-01},
+ {1.425000e+00, 4.718799e+00},
+ {1.430000e+00, 2.378460e+01},
+ {1.435000e+00, 3.674541e+00},
+ {1.440000e+00, 1.269513e+01},
+ {1.445000e+00, 1.381563e+01},
+ {1.450000e+00, 7.487701e+00},
+ {1.455000e+00, 3.016104e+01},
+ {1.460000e+00, 4.723420e+01},
+ {1.465000e+00, 5.845073e+01},
+ {1.470000e+00, 1.375787e+01},
+ {1.475000e+00, 1.321495e+02},
+ {1.480000e+00, 2.521699e+01},
+ {1.485000e+00, 8.132276e+01},
+ {1.490000e+00, 1.404666e+02},
+ {1.495000e+00, 1.506319e+02},
+ {1.500000e+00, 2.457010e+02},
+ {1.505000e+00, 1.679592e+02},
+ {1.510000e+00, 2.838210e+02},
+ {1.515000e+00, 2.803556e+02},
+ {1.520000e+00, 2.709988e+02},
+ {1.525000e+00, 2.742333e+02},
+ {1.530000e+00, 2.812797e+02},
+ {1.535000e+00, 2.921381e+02},
+ {1.540000e+00, 3.012639e+02},
+ {1.545000e+00, 3.099275e+02},
+ {1.550000e+00, 3.042673e+02},
+ {1.555000e+00, 3.003397e+02},
+ {1.560000e+00, 3.006863e+02},
+ {1.565000e+00, 2.990691e+02},
+ {1.570000e+00, 2.735402e+02},
+ {1.575000e+00, 2.793159e+02},
+ {1.580000e+00, 2.746953e+02},
+ {1.585000e+00, 2.874020e+02},
+ {1.590000e+00, 2.694972e+02},
+ {1.595000e+00, 2.856693e+02},
+ {1.600000e+00, 2.646455e+02},
+ {1.605000e+00, 2.668403e+02},
+ {1.610000e+00, 2.498596e+02},
+ {1.615000e+00, 2.667248e+02},
+ {1.620000e+00, 2.664938e+02},
+ {1.625000e+00, 2.700747e+02},
+ {1.630000e+00, 2.686885e+02},
+ {1.635000e+00, 2.596784e+02},
+ {1.640000e+00, 2.400408e+02},
+ {1.645000e+00, 2.470872e+02},
+ {1.650000e+00, 2.502061e+02},
+ {1.655000e+00, 2.505526e+02},
+ {1.660000e+00, 2.503216e+02},
+ {1.665000e+00, 2.378460e+02},
+ {1.670000e+00, 2.482423e+02},
+ {1.675000e+00, 2.396942e+02},
+ {1.680000e+00, 2.306840e+02},
+ {1.685000e+00, 2.391166e+02},
+ {1.690000e+00, 2.287203e+02},
+ {1.695000e+00, 2.350736e+02},
+ {1.700000e+00, 2.195945e+02},
+ {1.705000e+00, 2.177463e+02},
+ {1.710000e+00, 2.065413e+02},
+ {1.715000e+00, 2.040000e+02},
+ {1.720000e+00, 2.040000e+02},
+ {1.725000e+00, 1.882899e+02},
+ {1.730000e+00, 1.879434e+02},
+ {1.735000e+00, 1.700385e+02},
+ {1.740000e+00, 1.747746e+02},
+ {1.745000e+00, 1.594111e+02},
+ {1.750000e+00, 1.725798e+02},
+ {1.755000e+00, 1.523647e+02},
+ {1.760000e+00, 1.639162e+02},
+ {1.765000e+00, 1.238324e+02},
+ {1.770000e+00, 1.276444e+02},
+ {1.775000e+00, 9.467632e+01},
+ {1.780000e+00, 7.652887e+01},
+ {1.785000e+00, 4.875900e+01},
+ {1.790000e+00, 6.226274e+01},
+ {1.795000e+00, 1.964915e+01},
+ {1.800000e+00, 1.596421e+01},
+ {1.805000e+00, 2.681110e+00},
+ {1.810000e+00, 1.351529e+00},
+ {1.815000e+00, 1.782401e-01},
+ {1.820000e+00, 2.100068e-02},
+ {1.825000e+00, 2.950260e-02},
+ {1.830000e+00, 5.069966e-06},
+ {1.835000e+00, 3.109671e-06},
+ {1.840000e+00, 1.126390e-08},
+ {1.845000e+00, 7.945141e-07},
+ {1.850000e+00, 2.736557e-07},
+ {1.855000e+00, 5.976761e-08},
+ {1.860000e+00, 3.084258e-05},
+ {1.865000e+00, 2.344960e-05},
+ {1.870000e+00, 4.700317e-13},
+ {1.875000e+00, 1.053730e-12},
+ {1.880000e+00, 3.766953e-04},
+ {1.885000e+00, 1.557146e-04},
+ {1.890000e+00, 8.908538e-04},
+ {1.895000e+00, 8.015605e-04},
+ {1.900000e+00, 3.690713e-07},
+ {1.905000e+00, 3.564802e-07},
+ {1.910000e+00, 3.483941e-05},
+ {1.915000e+00, 8.942038e-05},
+ {1.920000e+00, 3.726523e-03},
+ {1.925000e+00, 2.120861e-02},
+ {1.930000e+00, 1.522491e-02},
+ {1.935000e+00, 3.087723e-01},
+ {1.940000e+00, 3.988743e-01},
+ {1.945000e+00, 2.781608e+00},
+ {1.950000e+00, 6.680249e+00},
+ {1.955000e+00, 2.853227e+00},
+ {1.960000e+00, 1.102131e+01},
+ {1.965000e+00, 1.737350e+01},
+ {1.970000e+00, 3.748471e+01},
+ {1.975000e+00, 5.294065e+01},
+ {1.980000e+00, 6.599388e+01},
+ {1.985000e+00, 7.625164e+01},
+ {1.990000e+00, 7.612457e+01},
+ {1.995000e+00, 7.584733e+01},
+ {2.000000e+00, 3.413477e+01},
+ {2.005000e+00, 1.133320e+01},
+ {2.010000e+00, 3.980657e+01},
+ {2.015000e+00, 2.313771e+01},
+ {2.020000e+00, 4.245187e+01},
+ {2.025000e+00, 7.589354e+01},
+ {2.030000e+00, 8.488063e+01},
+ {2.035000e+00, 1.036519e+02},
+ {2.040000e+00, 9.467632e+01},
+ {2.045000e+00, 9.695198e+01},
+ {2.050000e+00, 7.200067e+01},
+ {2.055000e+00, 5.648697e+01},
+ {2.060000e+00, 7.166568e+01},
+ {2.065000e+00, 6.471166e+01},
+ {2.070000e+00, 6.833884e+01},
+ {2.075000e+00, 8.371392e+01},
+ {2.080000e+00, 9.408720e+01},
+ {2.085000e+00, 9.265481e+01},
+ {2.090000e+00, 9.914677e+01},
+ {2.095000e+00, 9.885798e+01},
+ {2.100000e+00, 9.155741e+01},
+ {2.105000e+00, 1.043450e+02},
+ {2.110000e+00, 9.829195e+01},
+ {2.115000e+00, 1.024158e+02},
+ {2.120000e+00, 9.531166e+01},
+ {2.125000e+00, 9.782989e+01},
+ {2.130000e+00, 9.974745e+01},
+ {2.135000e+00, 1.005561e+02},
+ {2.140000e+00, 1.021848e+02},
+ {2.145000e+00, 1.008102e+02},
+ {2.150000e+00, 9.193861e+01},
+ {2.155000e+00, 9.273567e+01},
+ {2.160000e+00, 9.260860e+01},
+ {2.165000e+00, 8.261653e+01},
+ {2.170000e+00, 9.129173e+01},
+ {2.175000e+00, 8.697146e+01},
+ {2.180000e+00, 9.136104e+01},
+ {2.185000e+00, 7.770713e+01},
+ {2.190000e+00, 8.627836e+01},
+ {2.195000e+00, 8.574699e+01},
+ {2.200000e+00, 7.709490e+01},
+ {2.205000e+00, 8.019071e+01},
+ {2.210000e+00, 8.848471e+01},
+ {2.215000e+00, 8.380634e+01},
+ {2.220000e+00, 8.744507e+01},
+ {2.225000e+00, 8.378323e+01},
+ {2.230000e+00, 8.583941e+01},
+ {2.235000e+00, 8.345979e+01},
+ {2.240000e+00, 8.287066e+01},
+ {2.245000e+00, 7.990192e+01},
+ {2.250000e+00, 8.172706e+01},
+ {2.255000e+00, 7.652887e+01},
+ {2.260000e+00, 7.598595e+01},
+ {2.265000e+00, 7.731438e+01},
+ {2.270000e+00, 7.353703e+01},
+ {2.275000e+00, 7.257825e+01},
+ {2.280000e+00, 7.551234e+01},
+ {2.285000e+00, 7.141155e+01},
+ {2.290000e+00, 7.159637e+01},
+ {2.295000e+00, 6.921676e+01},
+ {2.300000e+00, 6.564733e+01},
+ {2.305000e+00, 6.586681e+01},
+ {2.310000e+00, 6.974813e+01},
+ {2.315000e+00, 6.378754e+01},
+ {2.320000e+00, 5.589784e+01},
+ {2.325000e+00, 5.843918e+01},
+ {2.330000e+00, 6.036829e+01},
+ {2.335000e+00, 6.296738e+01},
+ {2.340000e+00, 4.414994e+01},
+ {2.345000e+00, 5.389943e+01},
+ {2.350000e+00, 4.024552e+01},
+ {2.355000e+00, 4.850487e+01},
+ {2.360000e+00, 5.193567e+01},
+ {2.365000e+00, 4.863193e+01},
+ {2.370000e+00, 2.624507e+01},
+ {2.375000e+00, 4.312185e+01},
+ {2.380000e+00, 3.800453e+01},
+ {2.385000e+00, 2.428131e+01},
+ {2.390000e+00, 3.251755e+01},
+ {2.395000e+00, 3.768108e+01},
+ {2.400000e+00, 4.099637e+01},
+ {2.405000e+00, 2.709988e+01},
+ {2.410000e+00, 2.648765e+01},
+ {2.415000e+00, 1.916399e+01},
+ {2.420000e+00, 1.944122e+01},
+ {2.425000e+00, 2.625662e+01},
+ {2.430000e+00, 3.942537e+01},
+ {2.435000e+00, 8.307859e+00},
+ {2.440000e+00, 3.668765e+01},
+ {2.445000e+00, 1.312254e+01},
+ {2.450000e+00, 6.917055e+00},
+ {2.455000e+00, 1.529422e+01},
+ {2.460000e+00, 2.475492e+01},
+ {2.465000e+00, 1.468199e+01},
+ {2.470000e+00, 7.535062e+00},
+ {2.475000e+00, 7.232412e+00},
+ {2.480000e+00, 2.036534e+00},
+ {2.485000e+00, 1.159773e+00},
+ {2.490000e+00, 4.409218e-01},
+ {2.495000e+00, 3.889400e-01},
+ {2.500000e+00, 1.192118e+00},
+ {2.505000e+00, 1.178256e-01},
+ {2.510000e+00, 2.302220e-01},
+ {2.515000e+00, 2.307995e-02},
+ {2.520000e+00, 5.186636e-03},
+ {2.525000e+00, 8.529648e-05},
+ {2.530000e+00, 5.429218e-08},
+ {2.535000e+00, 2.571370e-09},
+ {2.540000e+00, 1.254496e-08},
+ {2.545000e+00, 7.580113e-14},
+ {2.550000e+00, 1.089194e-20},
+ {2.555000e+00, 1.036288e-12},
+ {2.560000e+00, 6.137327e-14},
+ {2.565000e+00, 1.341132e-19},
+ {2.570000e+00, 4.495855e-27},
+ {2.575000e+00, 2.718519e-43},
+ {2.580000e+00, 8.278980e-35},
+ {2.585000e+00, 0.000000e+00},
+ {2.590000e+00, 0.000000e+00},
+ {2.595000e+00, 0.000000e+00},
+ {2.600000e+00, 1.401298e-45},
+ {2.605000e+00, 0.000000e+00},
+ {2.610000e+00, 0.000000e+00},
+ {2.615000e+00, 0.000000e+00},
+ {2.620000e+00, 6.389921e-43},
+ {2.625000e+00, 0.000000e+00},
+ {2.630000e+00, 0.000000e+00},
+ {2.635000e+00, 8.243170e-23},
+ {2.640000e+00, 1.977622e-25},
+ {2.645000e+00, 3.870917e-28},
+ {2.650000e+00, 5.282514e-31},
+ {2.655000e+00, 2.101948e-44},
+ {2.660000e+00, 7.691007e-38},
+ {2.665000e+00, 0.000000e+00},
+ {2.670000e+00, 0.000000e+00},
+ {2.675000e+00, 0.000000e+00},
+ {2.680000e+00, 0.000000e+00},
+ {2.685000e+00, 0.000000e+00},
+ {2.690000e+00, 4.203895e-45},
+ {2.695000e+00, 0.000000e+00},
+ {2.700000e+00, 0.000000e+00},
+ {2.705000e+00, 0.000000e+00},
+ {2.710000e+00, 0.000000e+00},
+ {2.715000e+00, 9.111803e-41},
+ {2.720000e+00, 0.000000e+00},
+ {2.725000e+00, 1.520181e-30},
+ {2.730000e+00, 1.561767e-30},
+ {2.735000e+00, 7.793816e-32},
+ {2.740000e+00, 3.076172e-38},
+ {2.745000e+00, 1.721178e-37},
+ {2.750000e+00, 5.867237e-42},
+ {2.755000e+00, 0.000000e+00},
+ {2.760000e+00, 0.000000e+00},
+ {2.765000e+00, 2.810487e-38},
+ {2.770000e+00, 6.439977e-34},
+ {2.775000e+00, 0.000000e+00},
+ {2.780000e+00, 3.463169e-41},
+ {2.785000e+00, 1.364235e-36},
+ {2.790000e+00, 8.396806e-22},
+ {2.795000e+00, 9.365979e-23},
+ {2.800000e+00, 1.356149e-14},
+ {2.805000e+00, 2.779298e-16},
+ {2.810000e+00, 4.397667e-12},
+ {2.815000e+00, 3.218256e-12},
+ {2.820000e+00, 7.425322e-14},
+ {2.825000e+00, 1.903692e-08},
+ {2.830000e+00, 3.691868e-06},
+ {2.835000e+00, 4.135447e-13},
+ {2.840000e+00, 6.424960e-08},
+ {2.845000e+00, 2.679955e-04},
+ {2.850000e+00, 4.470441e-07},
+ {2.855000e+00, 3.652593e-07},
+ {2.860000e+00, 2.067724e-04},
+ {2.865000e+00, 3.345323e-03},
+ {2.870000e+00, 1.248720e-05},
+ {2.875000e+00, 1.402356e-02},
+ {2.880000e+00, 8.862332e-03},
+ {2.885000e+00, 1.924485e-02},
+ {2.890000e+00, 7.473839e-03},
+ {2.895000e+00, 4.261359e-01},
+ {2.900000e+00, 9.198482e-02},
+ {2.905000e+00, 2.128947e-03},
+ {2.910000e+00, 6.100362e-01},
+ {2.915000e+00, 1.715402e-01},
+ {2.920000e+00, 6.144258e-01},
+ {2.925000e+00, 2.073499e-01},
+ {2.930000e+00, 1.656489e+00},
+ {2.935000e+00, 2.313771e+00},
+ {2.940000e+00, 2.400408e-01},
+ {2.945000e+00, 1.966070e-01},
+ {2.950000e+00, 1.638007e+00},
+ {2.955000e+00, 7.849263e-01},
+ {2.960000e+00, 1.492457e+00},
+ {2.965000e+00, 3.734609e+00},
+ {2.970000e+00, 4.676059e-02},
+ {2.975000e+00, 1.094623e-01},
+ {2.980000e+00, 2.450079e-01},
+ {2.985000e+00, 3.056534e+00},
+ {2.990000e+00, 6.057621e+00},
+ {2.995000e+00, 1.480906e+00},
+ {3.000000e+00, 3.981812e+00},
+ {3.005000e+00, 9.241222e-01},
+ {3.010000e+00, 3.634111e+00},
+ {3.015000e+00, 2.126636e+00},
+ {3.020000e+00, 4.987950e-02},
+ {3.025000e+00, 3.859366e+00},
+ {3.030000e+00, 2.861314e+00},
+ {3.035000e+00, 7.404530e-01},
+ {3.040000e+00, 5.771143e-01},
+ {3.045000e+00, 1.351529e+00},
+ {3.050000e+00, 1.505164e-01},
+ {3.055000e+00, 2.044620e-02},
+ {3.060000e+00, 3.115447e+00},
+ {3.065000e+00, 8.756058e-01},
+ {3.070000e+00, 3.492027e-01},
+ {3.075000e+00, 2.830124e+00},
+ {3.080000e+00, 1.386183e+00},
+ {3.085000e+00, 3.766953e-01},
+ {3.090000e+00, 5.635991e-01},
+ {3.095000e+00, 7.939365e-02},
+ {3.100000e+00, 1.830917e+00},
+ {3.105000e+00, 2.093137e-01},
+ {3.110000e+00, 8.597802e-02},
+ {3.115000e+00, 5.444235e-01},
+ {3.120000e+00, 5.816194e+00},
+ {3.125000e+00, 1.196738e+00},
+ {3.130000e+00, 3.370736e+00},
+ {3.135000e+00, 7.649422e+00},
+ {3.140000e+00, 1.336512e+00},
+ {3.145000e+00, 1.344598e+00},
+ {3.150000e+00, 3.883624e+00},
+ {3.155000e+00, 3.158188e+00},
+ {3.160000e+00, 6.340634e+00},
+ {3.165000e+00, 1.286840e+01},
+ {3.170000e+00, 9.983986e+00},
+ {3.175000e+00, 7.336376e+00},
+ {3.180000e+00, 8.348289e+00},
+ {3.185000e+00, 5.731868e+00},
+ {3.190000e+00, 2.194790e+00},
+ {3.195000e+00, 8.751438e-01},
+ {3.200000e+00, 4.146999e-02},
+ {3.205000e+00, 2.004190e-02},
+ {3.210000e+00, 9.394858e-03},
+ {3.215000e+00, 4.889762e-02},
+ {3.220000e+00, 4.417304e-01},
+ {3.225000e+00, 2.447769e-02},
+ {3.230000e+00, 5.661404e-02},
+ {3.235000e+00, 4.230170e+00},
+ {3.240000e+00, 1.881744e+00},
+ {3.245000e+00, 1.957984e-01},
+ {3.250000e+00, 1.468199e+00},
+ {3.255000e+00, 6.918210e+00},
+ {3.260000e+00, 5.117327e-01},
+ {3.265000e+00, 7.144620e-01},
+ {3.270000e+00, 3.461993e-01},
+ {3.275000e+00, 3.131619e+00},
+ {3.280000e+00, 1.364235e+00},
+ {3.285000e+00, 8.155379e+00},
+ {3.290000e+00, 6.398391e+00},
+ {3.295000e+00, 3.224031e-01},
+ {3.300000e+00, 6.914745e-01},
+ {3.305000e+00, 1.679592e+00},
+ {3.310000e+00, 2.510147e+00},
+ {3.315000e+00, 1.062972e-02},
+ {3.320000e+00, 8.433771e-03},
+ {3.325000e+00, 2.253703e+00},
+ {3.330000e+00, 3.401925e+00},
+ {3.335000e+00, 7.758006e+00},
+ {3.340000e+00, 1.736195e+00},
+ {3.345000e+00, 2.252548e+00},
+ {3.350000e+00, 6.016036e+00},
+ {3.355000e+00, 2.031914e+00},
+ {3.360000e+00, 3.474700e+00},
+ {3.365000e+00, 5.899365e+00},
+ {3.370000e+00, 2.852072e+00},
+ {3.375000e+00, 6.880090e+00},
+ {3.380000e+00, 4.453114e+00},
+ {3.385000e+00, 6.382219e+00},
+ {3.390000e+00, 1.068632e+01},
+ {3.395000e+00, 9.365979e+00},
+ {3.400000e+00, 1.320340e+01},
+ {3.405000e+00, 3.969105e+00},
+ {3.410000e+00, 5.988312e+00},
+ {3.415000e+00, 7.733748e+00},
+ {3.420000e+00, 1.455493e+01},
+ {3.425000e+00, 1.114838e+01},
+ {3.430000e+00, 1.007986e+01},
+ {3.435000e+00, 1.171325e+01},
+ {3.440000e+00, 8.677508e+00},
+ {3.445000e+00, 1.164394e+01},
+ {3.450000e+00, 1.297237e+01},
+ {3.455000e+00, 8.471891e+00},
+ {3.460000e+00, 1.351529e+01},
+ {3.465000e+00, 1.125581e+01},
+ {3.470000e+00, 1.354994e+01},
+ {3.475000e+00, 1.190963e+01},
+ {3.480000e+00, 1.279909e+01},
+ {3.485000e+00, 1.338822e+01},
+ {3.490000e+00, 1.101785e+01},
+ {3.495000e+00, 1.378097e+01},
+ {3.500000e+00, 1.314564e+01},
+ {3.505000e+00, 1.318029e+01},
+ {3.510000e+00, 1.311098e+01},
+ {3.515000e+00, 1.164394e+01},
+ {3.520000e+00, 1.328426e+01},
+ {3.525000e+00, 1.208290e+01},
+ {3.530000e+00, 1.186342e+01},
+ {3.535000e+00, 9.635130e+00},
+ {3.540000e+00, 9.058708e+00},
+ {3.545000e+00, 9.734473e+00},
+ {3.550000e+00, 1.095316e+01},
+ {3.555000e+00, 8.415288e+00},
+ {3.560000e+00, 1.149146e+01},
+ {3.565000e+00, 1.214066e+01},
+ {3.570000e+00, 7.699093e+00},
+ {3.575000e+00, 8.362151e+00},
+ {3.580000e+00, 1.120383e+01},
+ {3.585000e+00, 9.255084e+00},
+ {3.590000e+00, 9.442219e+00},
+ {3.595000e+00, 9.932004e+00},
+ {3.600000e+00, 1.093930e+01},
+ {3.605000e+00, 1.156308e+01},
+ {3.610000e+00, 9.555424e+00},
+ {3.615000e+00, 9.627044e+00},
+ {3.620000e+00, 1.319185e+01},
+ {3.625000e+00, 1.099243e+01},
+ {3.630000e+00, 1.045760e+01},
+ {3.635000e+00, 1.072906e+01},
+ {3.640000e+00, 1.296081e+01},
+ {3.645000e+00, 1.189807e+01},
+ {3.650000e+00, 1.092312e+01},
+ {3.655000e+00, 1.193273e+01},
+ {3.660000e+00, 1.182876e+01},
+ {3.665000e+00, 1.105135e+01},
+ {3.670000e+00, 7.242808e+00},
+ {3.675000e+00, 2.920226e+00},
+ {3.680000e+00, 7.257825e+00},
+ {3.685000e+00, 9.436443e+00},
+ {3.690000e+00, 1.000940e+01},
+ {3.695000e+00, 1.061470e+01},
+ {3.700000e+00, 1.223307e+01},
+ {3.705000e+00, 1.205980e+01},
+ {3.710000e+00, 9.839592e+00},
+ {3.715000e+00, 9.526545e+00},
+ {3.720000e+00, 1.134938e+01},
+ {3.725000e+00, 1.208290e+01},
+ {3.730000e+00, 9.712525e+00},
+ {3.735000e+00, 8.408357e+00},
+ {3.740000e+00, 9.006726e+00},
+ {3.745000e+00, 1.160929e+01},
+ {3.750000e+00, 9.896194e+00},
+ {3.755000e+00, 9.294360e+00},
+ {3.760000e+00, 8.864643e+00},
+ {3.765000e+00, 8.670577e+00},
+ {3.770000e+00, 9.617802e+00},
+ {3.775000e+00, 9.493046e+00},
+ {3.780000e+00, 1.045991e+01},
+ {3.785000e+00, 8.957055e+00},
+ {3.790000e+00, 7.537372e+00},
+ {3.795000e+00, 9.389082e+00},
+ {3.800000e+00, 1.133089e+01},
+ {3.805000e+00, 1.009604e+01},
+ {3.810000e+00, 8.170396e+00},
+ {3.815000e+00, 7.491166e+00},
+ {3.820000e+00, 1.101207e+01},
+ {3.825000e+00, 1.056734e+01},
+ {3.830000e+00, 1.079721e+01},
+ {3.835000e+00, 7.306342e+00},
+ {3.840000e+00, 9.927383e+00},
+ {3.845000e+00, 9.710215e+00},
+ {3.850000e+00, 9.877712e+00},
+ {3.855000e+00, 9.170758e+00},
+ {3.860000e+00, 8.479977e+00},
+ {3.865000e+00, 9.136104e+00},
+ {3.870000e+00, 8.273204e+00},
+ {3.875000e+00, 7.294790e+00},
+ {3.880000e+00, 7.233567e+00},
+ {3.885000e+00, 7.671370e+00},
+ {3.890000e+00, 7.663284e+00},
+ {3.895000e+00, 8.552751e+00},
+ {3.900000e+00, 8.527338e+00},
+ {3.905000e+00, 9.039071e+00},
+ {3.910000e+00, 8.155379e+00},
+ {3.915000e+00, 7.950917e+00},
+ {3.920000e+00, 7.851574e+00},
+ {3.925000e+00, 7.636715e+00},
+ {3.930000e+00, 8.031777e+00},
+ {3.935000e+00, 8.475356e+00},
+ {3.940000e+00, 8.463805e+00},
+ {3.945000e+00, 8.571234e+00},
+ {3.950000e+00, 8.652095e+00},
+ {3.955000e+00, 8.907383e+00},
+ {3.960000e+00, 8.891211e+00},
+ {3.965000e+00, 8.962831e+00},
+ {3.970000e+00, 8.746817e+00},
+ {3.975000e+00, 8.585096e+00},
+ {3.980000e+00, 8.561993e+00},
+ {3.985000e+00, 8.552751e+00},
+ {3.990000e+00, 8.494994e+00},
+ {3.995000e+00, 8.284756e+00},
+ {4.000000e+00, 8.193499e+00}
+};
+
+static const double ref_mirror[][2] = { /* Wavelength data */
+ {2.500000e+03, 9.002169e+01},
+ {2.490000e+03, 8.875519e+01},
+ {2.480000e+03, 8.935681e+01},
+ {2.470000e+03, 8.933026e+01},
+ {2.460000e+03, 8.959640e+01},
+ {2.450000e+03, 8.948807e+01},
+ {2.440000e+03, 8.930347e+01},
+ {2.430000e+03, 8.987267e+01},
+ {2.420000e+03, 8.969878e+01},
+ {2.410000e+03, 8.985492e+01},
+ {2.400000e+03, 8.983934e+01},
+ {2.390000e+03, 9.015015e+01},
+ {2.380000e+03, 9.033044e+01},
+ {2.370000e+03, 9.021459e+01},
+ {2.360000e+03, 9.036620e+01},
+ {2.350000e+03, 9.070931e+01},
+ {2.340000e+03, 9.090450e+01},
+ {2.330000e+03, 9.102770e+01},
+ {2.320000e+03, 9.156487e+01},
+ {2.310000e+03, 9.187077e+01},
+ {2.300000e+03, 9.185011e+01},
+ {2.290000e+03, 9.168735e+01},
+ {2.280000e+03, 9.153958e+01},
+ {2.270000e+03, 9.148136e+01},
+ {2.260000e+03, 9.142628e+01},
+ {2.250000e+03, 9.115726e+01},
+ {2.240000e+03, 9.120969e+01},
+ {2.230000e+03, 9.117910e+01},
+ {2.220000e+03, 9.116260e+01},
+ {2.210000e+03, 9.127687e+01},
+ {2.200000e+03, 9.131850e+01},
+ {2.190000e+03, 9.132679e+01},
+ {2.180000e+03, 9.134534e+01},
+ {2.170000e+03, 9.114151e+01},
+ {2.160000e+03, 9.068787e+01},
+ {2.150000e+03, 9.051109e+01},
+ {2.140000e+03, 9.048801e+01},
+ {2.130000e+03, 9.050297e+01},
+ {2.120000e+03, 9.101611e+01},
+ {2.110000e+03, 9.129543e+01},
+ {2.100000e+03, 9.170773e+01},
+ {2.090000e+03, 9.191200e+01},
+ {2.080000e+03, 9.210053e+01},
+ {2.070000e+03, 9.224890e+01},
+ {2.060000e+03, 9.238735e+01},
+ {2.050000e+03, 9.265939e+01},
+ {2.040000e+03, 9.294904e+01},
+ {2.030000e+03, 9.320248e+01},
+ {2.020000e+03, 9.360339e+01},
+ {2.010000e+03, 9.394395e+01},
+ {2.000000e+03, 9.445172e+01},
+ {1.990000e+03, 9.481448e+01},
+ {1.980000e+03, 9.514061e+01},
+ {1.970000e+03, 9.537082e+01},
+ {1.960000e+03, 9.562746e+01},
+ {1.950000e+03, 9.585700e+01},
+ {1.940000e+03, 9.592551e+01},
+ {1.930000e+03, 9.583197e+01},
+ {1.920000e+03, 9.581526e+01},
+ {1.910000e+03, 9.551694e+01},
+ {1.900000e+03, 9.513596e+01},
+ {1.890000e+03, 9.482872e+01},
+ {1.880000e+03, 9.450699e+01},
+ {1.870000e+03, 9.433634e+01},
+ {1.860000e+03, 9.431637e+01},
+ {1.850000e+03, 9.432624e+01},
+ {1.840000e+03, 9.447005e+01},
+ {1.830000e+03, 9.459088e+01},
+ {1.820000e+03, 9.478791e+01},
+ {1.810000e+03, 9.496258e+01},
+ {1.800000e+03, 9.518331e+01},
+ {1.790000e+03, 9.525677e+01},
+ {1.780000e+03, 9.536103e+01},
+ {1.770000e+03, 9.542614e+01},
+ {1.760000e+03, 9.543584e+01},
+ {1.750000e+03, 9.539315e+01},
+ {1.740000e+03, 9.536543e+01},
+ {1.730000e+03, 9.531860e+01},
+ {1.720000e+03, 9.536415e+01},
+ {1.710000e+03, 9.538762e+01},
+ {1.700000e+03, 9.532991e+01},
+ {1.690000e+03, 9.526815e+01},
+ {1.680000e+03, 9.526891e+01},
+ {1.670000e+03, 9.535363e+01},
+ {1.660000e+03, 9.535061e+01},
+ {1.650000e+03, 9.539629e+01},
+ {1.640000e+03, 9.543298e+01},
+ {1.630000e+03, 9.547403e+01},
+ {1.620000e+03, 9.553451e+01},
+ {1.610000e+03, 9.546091e+01},
+ {1.600000e+03, 9.544562e+01},
+ {1.590000e+03, 9.541650e+01},
+ {1.580000e+03, 9.536031e+01},
+ {1.570000e+03, 9.532507e+01},
+ {1.560000e+03, 9.522473e+01},
+ {1.550000e+03, 9.511299e+01},
+ {1.540000e+03, 9.504054e+01},
+ {1.530000e+03, 9.497032e+01},
+ {1.520000e+03, 9.484760e+01},
+ {1.510000e+03, 9.478913e+01},
+ {1.500000e+03, 9.472796e+01},
+ {1.490000e+03, 9.467186e+01},
+ {1.480000e+03, 9.458646e+01},
+ {1.470000e+03, 9.444527e+01},
+ {1.460000e+03, 9.425820e+01},
+ {1.450000e+03, 9.401962e+01},
+ {1.440000e+03, 9.379675e+01},
+ {1.430000e+03, 9.353042e+01},
+ {1.420000e+03, 9.318069e+01},
+ {1.410000e+03, 9.295930e+01},
+ {1.400000e+03, 9.276019e+01},
+ {1.390000e+03, 9.260818e+01},
+ {1.380000e+03, 9.244196e+01},
+ {1.370000e+03, 9.226486e+01},
+ {1.360000e+03, 9.220292e+01},
+ {1.350000e+03, 9.219144e+01},
+ {1.340000e+03, 9.213460e+01},
+ {1.330000e+03, 9.210777e+01},
+ {1.320000e+03, 9.208756e+01},
+ {1.310000e+03, 9.196632e+01},
+ {1.300000e+03, 9.183512e+01},
+ {1.290000e+03, 9.170703e+01},
+ {1.280000e+03, 9.168185e+01},
+ {1.270000e+03, 9.168346e+01},
+ {1.260000e+03, 9.158861e+01},
+ {1.250000e+03, 9.150678e+01},
+ {1.240000e+03, 9.147020e+01},
+ {1.230000e+03, 9.145164e+01},
+ {1.220000e+03, 9.144785e+01},
+ {1.210000e+03, 9.139342e+01},
+ {1.200000e+03, 9.134400e+01},
+ {1.190000e+03, 9.130375e+01},
+ {1.180000e+03, 9.123543e+01},
+ {1.170000e+03, 9.119971e+01},
+ {1.160000e+03, 9.117647e+01},
+ {1.150000e+03, 9.119447e+01},
+ {1.140000e+03, 9.112846e+01},
+ {1.130000e+03, 9.102717e+01},
+ {1.120000e+03, 9.098567e+01},
+ {1.110000e+03, 9.101431e+01},
+ {1.100000e+03, 9.103447e+01},
+ {1.090000e+03, 9.103535e+01},
+ {1.080000e+03, 9.104751e+01},
+ {1.070000e+03, 9.104776e+01},
+ {1.060000e+03, 9.105524e+01},
+ {1.050000e+03, 9.105882e+01},
+ {1.040000e+03, 9.100527e+01},
+ {1.030000e+03, 9.098834e+01},
+ {1.020000e+03, 9.099553e+01},
+ {1.010000e+03, 9.097986e+01},
+ {1.000000e+03, 9.099072e+01},
+ {9.900000e+02, 9.101458e+01},
+ {9.800000e+02, 9.102811e+01},
+ {9.700000e+02, 9.107101e+01},
+ {9.600000e+02, 9.113153e+01},
+ {9.500000e+02, 9.115299e+01},
+ {9.400000e+02, 9.120361e+01},
+ {9.300000e+02, 9.129536e+01},
+ {9.200000e+02, 9.134410e+01},
+ {9.100000e+02, 9.139206e+01},
+ {9.000000e+02, 9.149245e+01},
+ {8.900000e+02, 9.162473e+01},
+ {8.800000e+02, 9.170761e+01},
+ {8.700000e+02, 9.175441e+01},
+ {8.600000e+02, 9.183147e+01},
+ {8.500000e+02, 9.193368e+01},
+ {8.400000e+02, 9.194690e+01},
+ {8.300000e+02, 9.171778e+01},
+ {8.200000e+02, 9.176028e+01},
+ {8.100000e+02, 9.201883e+01},
+ {8.000000e+02, 9.219911e+01},
+ {7.900000e+02, 9.231172e+01},
+ {7.800000e+02, 9.241025e+01},
+ {7.700000e+02, 9.257628e+01},
+ {7.600000e+02, 9.270184e+01},
+ {7.500000e+02, 9.294644e+01},
+ {7.400000e+02, 9.311713e+01},
+ {7.300000e+02, 9.325057e+01},
+ {7.200000e+02, 9.335799e+01},
+ {7.100000e+02, 9.342017e+01},
+ {7.000000e+02, 9.359630e+01},
+ {6.900000e+02, 9.374759e+01},
+ {6.800000e+02, 9.377639e+01},
+ {6.700000e+02, 9.382298e+01},
+ {6.600000e+02, 9.401642e+01},
+ {6.500000e+02, 9.414445e+01},
+ {6.400000e+02, 9.416447e+01},
+ {6.300000e+02, 9.422827e+01},
+ {6.200000e+02, 9.429821e+01},
+ {6.100000e+02, 9.440004e+01},
+ {6.000000e+02, 9.444127e+01},
+ {5.900000e+02, 9.435277e+01},
+ {5.800000e+02, 9.419932e+01},
+ {5.700000e+02, 9.412157e+01},
+ {5.600000e+02, 9.399156e+01},
+ {5.500000e+02, 9.370412e+01},
+ {5.400000e+02, 9.335538e+01},
+ {5.300000e+02, 9.332679e+01},
+ {5.200000e+02, 9.322582e+01},
+ {5.100000e+02, 9.292740e+01},
+ {5.000000e+02, 9.256215e+01},
+ {4.900000e+02, 9.206820e+01},
+ {4.800000e+02, 9.164663e+01},
+ {4.700000e+02, 9.113393e+01},
+ {4.600000e+02, 9.048467e+01},
+ {4.500000e+02, 8.966771e+01},
+ {4.400000e+02, 8.882944e+01},
+ {4.300000e+02, 8.800727e+01},
+ {4.200000e+02, 8.709829e+01},
+ {4.100000e+02, 8.630209e+01},
+ {4.000000e+02, 8.492516e+01},
+ {3.900000e+02, 8.232475e+01},
+ {3.800000e+02, 7.954367e+01},
+ {3.700000e+02, 7.680205e+01},
+ {3.600000e+02, 7.167577e+01},
+ {3.500000e+02, 6.186407e+01},
+ {3.400000e+02, 4.548824e+01},
+ {3.300000e+02, 2.374455e+01},
+ {3.200000e+02, 9.198518e+00},
+ {3.100000e+02, 5.704781e+00},
+ {3.000000e+02, 5.738476e+00},
+ {2.900000e+02, 5.864941e+00},
+ {2.800000e+02, 6.030176e+00},
+ {2.700000e+02, 6.278084e+00},
+ {2.600000e+02, 6.773841e+00}
+};
+
+struct nine_mod {
+ double position[3];
+ double corner[2];
+};
+static const struct nine_mod nine_mods[] = {
+ {{-3.454, -1.86, 0.048}, {0.897, 1.81}},
+ {{-1.468, -1.86, 0.018}, {0.897, 1.81}},
+ {{ 1.468, -1.86, 0.018}, {0.897, 1.81}},
+ {{ 3.454, -1.86, 0.048}, {0.897, 1.81}},
+ {{-3.454, 1.86, 0.048}, {0.897, 1.81}},
+ {{-1.468, 1.86, 0.018}, {0.897, 1.81}},
+ {{ 1.468, 1.86, 0.018}, {0.897, 1.81}},
+ {{ 3.454, 1.86, 0.048}, {0.897, 1.81}},
+ {{ 0.000, 2.39, 0.018}, {0.414, 1.23}}
+};
+
+struct heliostat {
+ const char* name;
+ double position[3];
+ double focal;
+};
+static const struct heliostat heliostats[] = {
+ {"B01", {-11.8340, 46.539, 17.84}, 100},
+ {"B02", {-0.1490, 48.302, 17.82}, 100},
+ {"B03", {11.6700, 47.095, 17.82}, 100},
+ {"A01", {-23.6440, 56.246, 20.58}, 100},
+ {"B04", {-12.2040, 59.919, 21.07}, 100},
+ {"B05", {-0.2320, 60.911, 21.08}, 100},
+ {"B06", {11.6830, 59.625, 21.08}, 100},
+ {"C01", {23.2590, 56.299, 20.06}, 100},
+ {"A02", {-34.9700, 64.211, 21.08}, 100},
+ {"A03", {-23.9610, 69.246, 22.08}, 100},
+ {"B07", {-12.3260, 72.401, 22.08}, 100},
+ {"B08", {-0.2880, 73.22, 22.08}, 100},
+ {"B09", {11.7100, 72.156, 22.08}, 100},
+ {"C02", {34.5770, 64.338, 20.57}, 100},
+ {"C03", {23.3390, 68.96, 21.58}, 100},
+ {"A04", {-56.4100, 64.734, 20.57}, 100},
+ {"A05", {-46.4600, 71.829, 20.68}, 100},
+ {"A06", {-35.6270, 77.407, 21.79}, 100},
+ {"A07", {-24.2400, 81.6, 23.58}, 100},
+ {"B10", {-12.3970, 84.186, 23.88}, 100},
+ {"B11", {-0.3100, 85.049, 23.28}, 100},
+ {"B12", {11.7380, 84.168, 23.08}, 100},
+ {"C04", {23.4850, 81.342, 22.68}, 100},
+ {"C05", {34.8230, 77.083, 22.57}, 100},
+ {"C06", {45.7280, 71.581, 21.57}, 100},
+ {"A08", {-76.1610, 63.161, 20.97}, 140},
+ {"A09", {-67.2300, 71.623, 20.98}, 140},
+ {"A10", {-57.5040, 79.046, 21.77}, 140},
+ {"A11", {-47.2340, 85.563, 22.17}, 140},
+ {"A12", {-36.0550, 90.471, 23.28}, 140},
+ {"A13", {-24.4030, 94.008, 24.87}, 140},
+ {"B13", {-12.4910, 96.285, 25.17}, 140},
+ {"B14", {-0.3820, 96.908, 24.88}, 140},
+ {"B15", {11.7240, 96.223, 24.47}, 140},
+ {"C07", {23.6220, 93.93, 23.88}, 140},
+ {"C08", {35.1820, 90.172, 24.07}, 140},
+ {"C09", {46.1050, 84.895, 24.09}, 140},
+ {"C10", {56.1270, 78.041, 23.69}, 140},
+ {"C11", {66.0610, 70.824, 23.19}, 140},
+ {"A14", {-86.4690, 69.749, 22.08}, 140},
+ {"A15", {-78.2180, 78.758, 22.59}, 140},
+ {"A16", {-68.7400, 86.574, 22.89}, 140},
+ {"A17", {-58.6550, 93.434, 23.79}, 140},
+ {"A18", {-47.7270, 98.92, 24.59}, 140},
+ {"A19", {-36.3690, 103.313, 26.08}, 140},
+ {"A20", {-24.6600, 106.615, 26.79}, 140},
+ {"B16", {-12.6160, 108.352, 27.29}, 140},
+ {"B17", {11.7500, 108.23, 26.38}, 140},
+ {"C12", {23.8020, 106.594, 26.08}, 140},
+ {"C13", {35.5140, 103.362, 26.08}, 140},
+ {"C14", {46.6490, 98.487, 26.08}, 140},
+ {"C15", {57.0640, 92.301, 25.17}, 140},
+ {"C16", {67.0710, 85.344, 25.18}, 140},
+ {"C17", {77.0880, 78.083, 24.58}, 140},
+ {"C18", {85.8240, 69.393, 23.29}, 140},
+ {"D01", {-98.3820, 79.186, 23.18}, 140},
+ {"D02", {-88.9220, 87.315, 24.08}, 140},
+ {"D03", {-79.5600, 95.245, 24.58}, 140},
+ {"D04", {-69.1900, 101.875, 26.27}, 140},
+ {"D05", {-58.1580, 107.337, 27.19}, 140},
+ {"D06", {-47.3180, 112.903, 28.36}, 140},
+ {"E01", {-36.1280, 117.572, 28.85}, 140},
+ {"E02", {-24.5960, 121.288, 28.77}, 140},
+ {"E03", {-12.6570, 123.567, 28.46}, 140},
+ {"E04", {-0.4750, 123.792, 28.26}, 140},
+ {"E05", {11.6570, 123.129, 27.77}, 140},
+ {"E06", {23.4160, 120.183, 28.37}, 140},
+ {"E07", {35.2270, 117.24, 28.55}, 140},
+ {"F01", {46.8990, 113.692, 28.75}, 140},
+ {"F02", {57.5370, 107.794, 28.45}, 140},
+ {"F03", {67.3980, 100.753, 27.67}, 140},
+ {"F04", {77.2170, 93.558, 27.65}, 140},
+ {"F05", {87.4920, 86.435, 26.99}, 140},
+ {"F06", {95.2200, 77.038, 26.08}, 140},
+ {"D07", {-110.017, 89.957, 24.68}, 200},
+ {"D08", {-100.877, 98.302, 25.78}, 200},
+ {"D09", {-90.1820, 105.059, 26.87}, 200},
+ {"D10", {-80.4400, 112.431, 27.86}, 200},
+ {"D11", {-69.7650, 118.547, 28.77}, 140},
+ {"D12", {-58.7820, 123.826, 29.75}, 140},
+ {"D13", {-48.0520, 129.561, 29.98}, 140},
+ {"E08", {-36.7080, 133.913, 30.66}, 140},
+ {"E09", {-24.8130, 136.403, 30.77}, 140},
+ {"E10", {-12.7110, 137.909, 30.85}, 140},
+ {"E11", {-0.5520, 138.269, 30.66}, 140},
+ {"F07", {47.2000, 129.579, 30.55}, 140},
+ {"F08", {58.3950, 124.823, 30.36}, 140},
+ {"F09", {68.5430, 118.115, 30.24}, 140},
+ {"F10", {77.7420, 110.194, 30.23}, 140},
+ {"F11", {87.8490, 103.232, 30.15}, 140},
+ {"F12", {97.5330, 95.576, 29.66}, 140},
+ {"F13", {104.4740, 85.645, 28.96}, 140},
+ {"D14", {-121.779, 102.198, 26.26}, 200},
+ {"D15", {-112.519, 110.4, 27.27}, 200},
+ {"D16", {-102.334, 117.583, 28.26}, 200},
+ {"D17", {-92.7160, 125.102, 29.27}, 200},
+ {"D18", {-82.1320, 131.386, 30.17}, 200},
+ {"D19", {-71.1180, 136.747, 31.06}, 200},
+ {"D20", {-59.9610, 141.661, 32.07}, 200},
+ {"D21", {-48.9840, 146.93, 32.66}, 200},
+ {"E15", {-37.3880, 150.568, 33.48}, 200},
+ {"E16", {-25.0940, 151.617, 33.68}, 200},
+ {"E17", {-12.7640, 151.597, 33.76}, 200},
+ {"E18", {-0.6340, 152.314, 33.66}, 200},
+ {"E19", {11.5570, 152.435, 33.57}, 200},
+ {"E20", {23.7670, 151.509, 33.46}, 200},
+ {"E21", {35.8480, 149.697, 33.25}, 200},
+ {"F14", {47.7370, 146.913, 32.75}, 200},
+ {"F15", {59.2600, 142.885, 32.55}, 200},
+ {"F16", {70.1740, 137.545, 32.26}, 200},
+ {"F17", {80.0350, 130.385, 32.26}, 200},
+ {"F18", {89.1590, 122.299, 32.15}, 200},
+ {"F19", {98.8470, 114.88, 32.06}, 200},
+ {"F20", {107.5660, 106.391, 31.84}, 200},
+ {"F21", {114.6430, 96.48, 31.65}, 200}
+};
+
+/*******************************************************************************
+ * Helper macros
+ ******************************************************************************/
+#define SZ(Array) (sizeof(Array)/sizeof(Array[0]))
+#define SPLIT2(Array) Array[0], Array[1]
+#define SPLIT3(Array) Array[0], Array[1], Array[2]
+
+/*******************************************************************************
+ * Helper functions
+ ******************************************************************************/
+static void
+print_section(const char* name)
+{
+ printf("########################################\n");
+ printf("# %s\n", name);
+ printf("########################################\n");
+}
+
+static void
+print_spectrum
+ (const char* name,
+ const double spectrum[][2],
+ const size_t ndata,
+ const double scale[2])
+{
+ size_t i;
+ printf("- spectrum: &%s\n", name);
+ for(i=0; i<ndata; ++i) {
+ printf(" - {wavelength: %e, data: %e}\n",
+ spectrum[i][0]*scale[0],
+ spectrum[i][1]*scale[1]);
+ }
+}
+
+static void
+print_heliostat_template(const double focal)
+{
+ size_t i;
+ printf("- template: &hstat%g\n", focal);
+ printf(" name: cethel3\n");
+ printf(" primary: 0\n");
+ printf(" geometry:\n");
+ printf(" - material: *occultant\n");
+ printf(" transform: {translation: [0, 0, -2.5]}\n");
+ printf(" cylinder: {height: 5, radius: 0.3}\n");
+ printf(" children:\n");
+ printf(" - name: pivot\n");
+ printf(" zx_pivot: {target: {position: [0, 9, 70]}}\n");
+ printf(" children:\n");
+ printf(" - name: nine_mods\n");
+ printf(" primary: 1\n");
+ printf(" transform: {rotation: [90, 0, 0]}\n");
+ printf(" geometry:\n");
+ for(i=0; i<SZ(nine_mods); ++i) {
+ const double* xyz = nine_mods[i].position;
+ const double* corner = nine_mods[i].corner;
+ printf(" - material: *specular\n");
+ printf(" transform: {translation: [%g, %g, %g]}\n", SPLIT3(xyz));
+ printf(" parabol: {\
+focal: %g, \
+clip: [{operation: AND, vertices: [[-%g,-%g],[-%g, %g],[%g,%g],[%g,-%g]]}]}\n",
+ focal, SPLIT2(corner), SPLIT2(corner), SPLIT2(corner), SPLIT2(corner));
+ }
+}
+
+static void
+print_target(const double size, const unsigned slices)
+{
+ const double hsz = size * 0.5; /* Half size */
+ printf("- entity:\n");
+ printf(" name: target\n");
+ printf(" primary: 0\n");
+ printf(" transform: {translation: [0, 9, 70], rotation: [53, 0, 0]}\n");
+ printf(" geometry:\n");
+ printf(" - material: *occultant\n");
+ printf(" plane:\n");
+ printf(" slices: %u\n", slices);
+ printf(" clip:\n");
+ printf(" - operation: AND\n");
+ printf(" vertices: [[%g, %g],[%g, %G],[%g, %g],[%g, %g]]\n",
+ -hsz, -hsz, -hsz, hsz, hsz, hsz, hsz, -hsz);
+}
+
+/*******************************************************************************
+ * Main program
+ ******************************************************************************/
+int
+main(int argc, char** argv)
+{
+ const double one[2] = {1, 1};
+ const double scl[2] = {0.001, 0.01};
+ size_t i;
+
+ /* Spectra */
+ print_section("Spectra");
+ print_spectrum("solar_spectrum", solar_spectrum, SZ(solar_spectrum), one);
+ printf("\n");
+ print_spectrum("ref_mirror", ref_mirror, SZ(ref_mirror), scl);
+ printf("\n");
+
+ /* Sun & atmosphere */
+ print_section("Sun & atmosphere");
+ printf("- sun: {dni: 1000, spectrum: *solar_spectrum}\n");
+ printf("- atmosphere: {absorption: 0.0001}\n");
+ printf("\n");
+
+ /* Materials */
+ print_section("Materials");
+ printf("- material: &occultant {matte: {reflectivity: 0}}\n");
+ printf("- material: &specular {mirror: {reflectivity: *ref_mirror, roughness: 0}}\n");
+ printf("- material: &lambertian\n");
+ printf(" front: {matte: {reflectivity: 0.9}}\n");
+ printf(" back: {matte: {reflectivity: 0.0}}\n");
+ printf("\n");
+
+ /* Templates of the heliostat */
+ print_section("Templates of the heliostats");
+ print_heliostat_template(100); printf("\n");
+ print_heliostat_template(140); printf("\n");
+ print_heliostat_template(200); printf("\n");
+
+ /* Entities */
+ print_section("Entities");
+ print_target(5, 64);
+ printf("\n");
+ printf("- entity:\n");
+ printf(" name: tower\n");
+ printf(" primary: 0\n");
+ printf(" transform: {translation: [0, 0, 40.0]}\n");
+ printf(" geometry:\n");
+ printf(" - material: *occultant\n");
+ printf(" cylinder: {height: 80, radius: 4, slices: 128}\n");
+ printf("\n");
+
+ for(i=0; i<SZ(heliostats); ++i) {
+ printf("- entity: {name: %s, children: [*hstat%g], transform: {translation: [%g, %g, %g]}}\n",
+ heliostats[i].name,
+ heliostats[i].focal,
+ SPLIT3(heliostats[i].position));
+ }
+ return 0;
+}
+