solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit 6a827eb234e440647b70fe00d7fbdc74c8a8cbe6
parent 7249782799b6b650685d3423a5c955c31ed9a0f6
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Mon, 13 Mar 2017 16:14:12 +0100

Change output order (globals first) and small refactoring.

Diffstat:
Msrc/solstice_solve.c | 12+++++++-----
Msrc/test_solstice_simulation.c | 45++++++++++++++++++++++++---------------------
Myaml/beam_down.ref | 10++++++----
Myaml/test01.ref | 5+++--
Myaml/test02.ref | 5+++--
Myaml/test03.ref | 5+++--
Myaml/test04.ref | 8+++++---
Myaml/test05.ref | 5+++--
8 files changed, 54 insertions(+), 41 deletions(-)

diff --git a/src/solstice_solve.c b/src/solstice_solve.c @@ -50,6 +50,13 @@ write_global_mc(struct solstice* solstice, struct ssol_estimator* estimator) (unsigned long)htable_receiver_size_get(&solstice->receivers), (unsigned long)nexperiments); + fprintf(solstice->output, "%g %g # Shadowing\n", + mc_global.shadowed.E, mc_global.shadowed.SE); + fprintf(solstice->output, "%g %g # Missing\n", + mc_global.missing.E, mc_global.missing.SE); + fprintf(solstice->output, "%g %g # Cos\n", + mc_global.cos_factor.E, mc_global.cos_factor.SE); + htable_receiver_begin(&solstice->receivers, &it); htable_receiver_end(&solstice->receivers, &end); while(!htable_receiver_iterator_eq(&it, &end)) { @@ -96,11 +103,6 @@ write_global_mc(struct solstice* solstice, struct ssol_estimator* estimator) back.absorptivity_loss.E, back.absorptivity_loss.SE, f_eff_E, f_eff_SE, b_eff_E, b_eff_SE); } - - fprintf(solstice->output, "%g %g\n", - mc_global.shadowed.E, mc_global.shadowed.SE); - fprintf(solstice->output, "%g %g\n", - mc_global.missing.E, mc_global.missing.SE); } /******************************************************************************* diff --git a/src/test_solstice_simulation.c b/src/test_solstice_simulation.c @@ -167,7 +167,7 @@ read_line(char* line, size_t max_line_len, FILE* stream) } static void -get_dir_and_counts +get_angles_and_counts (FILE* ref_file, double angles[2], unsigned long* recv_count, @@ -245,7 +245,7 @@ is_compatible_with } static void -check_1_reference +check_1_receiver (FILE* tested_file, const char* rcv_name, const double* reference_E, @@ -260,16 +260,22 @@ check_1_reference NCHECK(reference_E, NULL); NCHECK(reference_SE, NULL); - get_dir_and_counts(tested_file, a, &c1, &c2); /* Skip headers */ + get_angles_and_counts(tested_file, a, &c1, &c2); /* Skip headers */ while(!feof(tested_file) && !found) { char line[MAX_LINE_LEN]; char tested_rcv_name[MAX_LINE_LEN]; double tested_E[MAX_RESULTS_COUNT__], tested_SE[MAX_RESULTS_COUNT__]; + double v, s; + size_t nb; enum result_type r; CHECK(read_line(line, sizeof(line), tested_file), 1); + nb = sscanf(line, "%lg %lg # %s", &v, &s, tested_rcv_name); + CHECK(nb == 0 || nb == 3, 1); + + if(nb == 3) continue; /* skip global */ read_recv(line, tested_rcv_name, tested_E, tested_SE); if(strcmp(rcv_name, tested_rcv_name)) continue; @@ -287,32 +293,29 @@ check_1_global (FILE* tested_file, const double reference_E, const double reference_SE, - const unsigned rank) + const char* ref_name) { - char line[MAX_LINE_LEN]; + char line[MAX_LINE_LEN], tested_name[MAX_LINE_LEN]; double a[2]; - unsigned long recv_count, r2; - unsigned i; + unsigned long r1, r2; int nb; double tested_E, tested_SE; - get_dir_and_counts(tested_file, a, &recv_count, &r2); - - /* Skip receivers */ - while(recv_count--) CHECK(read_line(line, sizeof(line), tested_file), 1); + get_angles_and_counts(tested_file, a, &r1, &r2); - /* Read the rank th global data */ - FOR_EACH(i, 0, rank+1) CHECK(read_line(line, sizeof(line), tested_file), 1); + do { + CHECK(read_line(line, sizeof(line), tested_file), 1); + nb = sscanf(line, "%lg %lg # %s", &tested_E, &tested_SE, tested_name); + } while (nb != 3 || strcmp(ref_name, tested_name)); - nb = sscanf(line, "%lg%lg", &tested_E, &tested_SE); - CHECK(nb, 2); + CHECK(strcmp(ref_name, tested_name), 0); CHECK(is_compatible_with(reference_E, reference_SE, tested_E, tested_SE), 1); } static void check_references(FILE* ref_file, FILE* tested_file) { - char line[MAX_LINE_LEN]; + char line[MAX_LINE_LEN], g_name[MAX_LINE_LEN]; unsigned nb_global = 0; fpos_t pos; @@ -330,19 +333,19 @@ check_references(FILE* ref_file, FILE* tested_file) break; } - nb = sscanf(line, "%lg%lg", &val, &std); - CHECK(nb == 0 || nb == 2, 1); + nb = sscanf(line, "%lg %lg # %s", &val, &std, g_name); + CHECK(nb == 0 || nb == 3, 1); rewind(tested_file); if(nb != 0) { - check_1_global(tested_file, val, std, nb_global); + check_1_global(tested_file, val, std, g_name); nb_global++; } else { char ref_name[MAX_LINE_LEN]; double reference_E[MAX_RESULTS_COUNT__]; double reference_SE[MAX_RESULTS_COUNT__]; read_recv(line, ref_name, reference_E, reference_SE); - check_1_reference(tested_file, ref_name, reference_E, reference_SE); + check_1_receiver(tested_file, ref_name, reference_E, reference_SE); } CHECK(fgetpos(ref_file, &pos), 0); @@ -384,7 +387,7 @@ do_check(const char* binary, const char* dir, const char* base_name) FILE* fp = NULL; int fd = -1; - get_dir_and_counts(ref_file, sun_angles, &c1, &realisation_count); + get_angles_and_counts(ref_file, sun_angles, &c1, &realisation_count); fd = create_tmp_file(tested_file_name, sizeof(tested_file_name)); fp = fdopen(fd, "r"); diff --git a/yaml/beam_down.ref b/yaml/beam_down.ref @@ -1,12 +1,14 @@ #--- Sun direction: 0 90 (-3.7494e-33 -6.12323e-17 -1) 2 10000 +0 0 # Shadowing +0 0 # Missing +0.92387953251128675612818318939679 0.1 # Cos tower.secondary.hyperbol 10 465.464 0.00509812 0 0 0 0 0 0 0 0 0 0 0.930847 1.01954e-05 0 0 tower.receptor 14 465.464 0.00509812 -1 -1 0 0 -1 -1 0 0 -1 -1 0.930847 1.01954e-05 -1 -1 -0 0 -0 0 #--- Sun direction: 50 50 (-0.413176 -0.492404 -0.766044) 2 10000 +0 0 # Shadowing +0 0 # Missing +0.8 0.1 # Cos tower.secondary.hyperbol 10 400.231 0.107226 0 0 0 0 0 0 0 0 0 0 0.800393 0.000214433 0 0 tower.receptor 14 136.51 1.90718 -1 -1 0 0 -1 -1 0 0 -1 -1 0.272997 0.00381404 -1 -1 -0 0 -0 0 diff --git a/yaml/test01.ref b/yaml/test01.ref @@ -1,5 +1,6 @@ #--- Sun direction: 0 90 (-6.12323e-17 -0 -1) 1 10000 +0 0 # Shadowing +0 0 # Missing +1 0 # Cos square_receiver 2 -1 -1 1 0 -1 -1 0 0 -1 -1 0 0 -1 -1 1 0 -0 0 -0 0 diff --git a/yaml/test02.ref b/yaml/test02.ref @@ -1,5 +1,6 @@ #--- Sun direction: 0 90 (-6.12323e-17 -0 -1) 1 100000 +0 0 # Shadowing +99 0.0313065 # Missing +1 0 # Cos square_receiver 2 -1 -1 1 0.0313065 -1 -1 0 0 -1 -1 0 0 -1 -1 0.01003 0.000315109 -0 0 -99 0.0313065 diff --git a/yaml/test03.ref b/yaml/test03.ref @@ -1,5 +1,6 @@ #--- Sun direction: 0 45 (-0.707107 -0 -0.707107) 1 10000 +0 0 # Shadowing +0 0 # Missing +0.707107 0 # Cos square_receiver 2 -1 -1 0.707107 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0.707107 0 -0 0 -0 0 diff --git a/yaml/test04.ref b/yaml/test04.ref @@ -1,5 +1,6 @@ #--- Sun direction: 0 45 (-0.707107 -0 -0.707107) 1 10000 -square_receiver 2 0 0 0.707107 0 0 0 0 0 0 0 0 0 0 0 0.707107 0 -0 0 -0 0 +0 0 # Shadowing +0 0 # Missing +0.707107 0 # Cos +square_receiver 2 0 0 0.707107 0 0 0 0 0 0 0 0 0 0 0 0.707107 0 +\ No newline at end of file diff --git a/yaml/test05.ref b/yaml/test05.ref @@ -1,5 +1,6 @@ #--- Sun direction: 0 90 (-6.12323e-17 -0 -1) 1 10000 +0 0 # Shadowing +0 0 # Missing +1 0 # Cos spherical_receiver 2 -1 -1 1 0 -1 -1 0 0 -1 -1 0 0 -1 -1 1 0 -0 0 -0 0