commit cfc9cec38bd6a1a5ac3ec7a2f529a8a9314d64bd
parent 2159bfc23ebd2d1ab743681e9ed6e602a6da241f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 18 Sep 2017 14:34:45 +0200
Update the themis program
Diffstat:
3 files changed, 93 insertions(+), 47 deletions(-)
diff --git a/Makefile b/Makefile
@@ -39,6 +39,9 @@ clean:
$(PROG): %: %.c solpp.h
@echo -e " CC $<"; $(CC) -o $@ $(CFLAGS) $<
+.PHONY: run
+run: $(PROJECTS)
+
.PHONY: $(PROJECTS)
$(PROJECTS): $(PROG)
@tput bold
diff --git a/themis/Makefile b/themis/Makefile
@@ -34,12 +34,8 @@ default: all
.PHONY: all
all: run
-.PHONY: receiver
-receiver:
- @echo "- {name: target, side: BACK, per_primitive: 1}" > $(RCV)
-
.PHONY: simul
-simul: $(INPUT) receiver $(PROG)
+simul: $(INPUT) $(PROG)
@tput bold
@echo -e ">>> Run simulation: Sun dirs = $(SUN_DIRS); #Experiments = $(NEXPERIMENTS)"
@tput sgr0
@@ -49,7 +45,7 @@ simul: $(INPUT) receiver $(PROG)
@solpp $(GEOM) $(SIMUL)
.PHONY: paths
-paths: $(PROG) $(INPUT) receiver
+paths: $(PROG) $(INPUT)
@tput bold
@echo -e ">>> Sample paths: Sun dirs = $(SUN_DIRS); #Paths = $(NPATHS)"
@tput sgr0
@@ -60,7 +56,7 @@ run: paths simul
.PHONY: clean
clean:
- @rm -rf $(PROG) $(INPUT) $(GEOM) $(SIMUL) $(RCV) \
+ @rm -rf $(PROG) $(INPUT) $(GEOM) $(SIMUL) \
*-miscellaneous.obj \
*-paths.vtk \
*-primaries.vtk \
@@ -68,7 +64,7 @@ clean:
*-raw-results.txt
$(PROG): %: %.c
- @echo -e " CC $<"; $(CC) -o $@ $(CFLAGS) $<
+ @echo -e " CC $<"; $(CC) -o $@ $(CFLAGS) $< -lm
$(INPUT): $(PROG)
@themis > $@
diff --git a/themis/themis.c b/themis/themis.c
@@ -12,7 +12,10 @@
*
* 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 <float.h>
#include <stdio.h>
+#include <math.h>
/*******************************************************************************
* Data
@@ -1166,45 +1169,78 @@ print_spectrum
}
}
+/* Heliostat */
static void
-print_heliostat_template(const double focal)
+print_heliostat
+ (const struct heliostat* hstat,
+ const double tgt_pt[3],
+ const double themis_target[3])
{
+ const double PI = acos(-1.0);
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("- entity:\n");
+ printf(" name: %s\n", hstat->name);
+ printf(" transform: {translation: [%g,%g,%g]}\n", SPLIT3(hstat->position));
printf(" children:\n");
- printf(" - name: pivot\n");
- printf(" zx_pivot: {target: {position: [0, 9, 70]}}\n");
+ 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: nine_mods\n");
- printf(" primary: 1\n");
- printf(" transform: {rotation: [90, 0, 0]}\n");
- printf(" geometry:\n");
+ printf(" - name: pivot\n");
+ printf(" zx_pivot: {target: {position: [%g,%g,%g]}}\n", SPLIT3(tgt_pt));
+ printf(" children:\n");
+ printf(" - name: nine_mods\n");
+ printf(" primary: 1\n");
+ printf(" transform: {rotation: [-90, 0, 180]}\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, \
+ double v[3];
+ double rotx, roty, zbar, focal_h, slant_range;
+
+ /* compute the rotation of the modules : parabolic structure with focal =
+ * slant_range */
+ v[0] = themis_target[0] - hstat->position[0];
+ v[1] = themis_target[1] - hstat->position[1];
+ v[2] = themis_target[2] - hstat->position[2];
+ slant_range = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
+
+ focal_h = slant_range; /* structure parabolique et module sphérique */
+ zbar = 2.0 * focal_h ; /* - 0.25*xyz[1]*xyz[1]/focal_h ;*/
+ rotx = atan(xyz[1]/zbar) * 180.0 / PI;
+ roty = -atan(xyz[0]/zbar) * 180.0 / PI;
+
+ /* print the module transform and the spherical module surface */
+ printf(" - material: *specular\n");
+ printf(" transform: {translation: [%g, %g, %g], rotation: [%g, %g, 0]}\n",
+ SPLIT3(xyz), rotx, roty);
+ printf(" hemisphere: {\
+radius: %g, slices: 32, \
clip: [{operation: AND, vertices: [[-%g,-%g],[-%g, %g],[%g,%g],[%g,-%g]]}]}\n",
- focal, SPLIT2(corner), SPLIT2(corner), SPLIT2(corner), SPLIT2(corner));
+ hstat->focal * 2,
+ SPLIT2(corner),
+ SPLIT2(corner),
+ SPLIT2(corner),
+ SPLIT2(corner));
}
}
+/* Target definition */
static void
-print_target(const double size, const unsigned slices)
+print_target(const double size, const unsigned slices, const double tgt_pt[3])
{
const double hsz = size * 0.5; /* Half size */
printf("- entity:\n");
- printf(" name: target\n");
+ printf(" name: target_e\n");
printf(" primary: 0\n");
- printf(" transform: {translation: [0, 9, 70], rotation: [53, 0, 0]}\n");
+ printf(" transform: {translation: [%g, %g, %g], rotation: [-90, 0, 0]}\n",
+ tgt_pt[0], tgt_pt[1]+0.5, tgt_pt[2] - 0.1); /* X rotation -37-90 = -127*/
printf(" geometry:\n");
printf(" - material: *occultant\n");
printf(" plane:\n");
@@ -1215,6 +1251,7 @@ print_target(const double size, const unsigned slices)
-hsz, -hsz, -hsz, hsz, hsz, hsz, hsz, -hsz);
}
+
/*******************************************************************************
* Main program
******************************************************************************/
@@ -1223,6 +1260,9 @@ main(int argc, char** argv)
{
const double one[2] = {1, 1};
const double scl[2] = {0.001, 0.01};
+ const double target_point[3] = {0, 6.2, 87.15};/* Aiming point for the flux computation */
+ const double themis_target[3] = { 0, 6.2, 87.15};/* to compute slant range */
+ const double corr = 4. ;/* correction length due to offset of the stl */
size_t i;
/* Spectra */
@@ -1241,36 +1281,43 @@ main(int argc, char** argv)
/* Materials */
print_section("Materials");
printf("- material: &occultant {matte: {reflectivity: 0}}\n");
- printf("- material: &specular {mirror: {reflectivity: *ref_mirror, roughness: 0}}\n");
+ printf("- material: &specular {mirror: {reflectivity: *ref_mirror, roughness: 1.e-3}}\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");
+ /* Themis tower */
+ print_section("Tower");
+
+ print_target(3, 128, target_point);
- /* 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(" transform: {translation: [0, %g, 0]}\n", -corr);
printf(" geometry:\n");
- printf(" - material: *occultant\n");
- printf(" cylinder: {height: 80, radius: 4, slices: 128}\n");
+ printf(" - {material: *occultant, stl: {path: top_tower.stl}}\n");
+ printf(" - {material: *occultant, stl: {path: grd_tower.stl}}\n");
printf("\n");
+ printf("- entity:\n");
+ printf(" name: nextcsp_rcv\n");
+ printf(" primary: 0\n");
+ printf(" transform: {translation: [0, %g, %g]}\n",
+ target_point[1], target_point[2] - 2.5);
+ printf(" geometry: \n");
+ printf(" - {material: *lambertian, stl: {path: disp.stl}}\n");
+ printf(" - {material: *lambertian, stl: {path: pnew1.stl}}\n");
+ printf(" - {material: *lambertian, stl: {path: pnew2.stl}}\n");
+ printf(" - {material: *lambertian, stl: {path: pnup.stl}}\n");
+ printf("\n");
+
+ /* Templates of the heliostat */
+ print_section("Heliostats");
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));
+ print_heliostat(&heliostats[i], target_point, themis_target);
+ printf("\n");
}
return 0;
}