commit 331ccc3a56fc3ff9a832e3556320eadead2ec4ce
parent b48a33661021b60dde935a798fd13063e0191021
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Sat, 2 May 2020 18:24:22 +0200
Small improvements in summaries and documentation
Diffstat:
6 files changed, 123 insertions(+), 105 deletions(-)
diff --git a/doc/sgreen-input.5.txt b/doc/sgreen-input.5.txt
@@ -32,7 +32,7 @@ A settings file is composed of lines of text, each one describing the settings
to apply for a Green function call. Each line contains *variable = value* pairs
in any number (at least one pair for a line to be meaningful). A list of all
legit variable names can be found in the Green function summary, as produced
-by option *-s*.
+by *sgreen*(1) option *-s*.
GRAMMAR
-------
diff --git a/doc/sgreen-output.5.txt b/doc/sgreen-output.5.txt
@@ -24,9 +24,6 @@ sgreen-output - output format of sgreen(1) results
DESCRIPTION
-----------
-*sgreen-output* describes the output format of option *-a* of the *sgreen*(1)
-program.
-
The type of the data that are generated depends on the options used when
*sgreen*(1) is invoked. When invoked with the option *-a*, *sgreen*(1) outputs
Monte-Carlo results, either in extended or compact format, whether option *-e*
@@ -37,7 +34,7 @@ GRAMMAR
-------
As Green summaries comply with HTML format, that can be found in HTML
specification documents [1], they will not be further described. Only
-Monte-Carlo results are described in this section.
+Monte-Carlo results grammar is described in the section.
In what follows, text appearing between quote marks is a verbatim part of the
output, except the quote characters, and text introduced by the *#* character
diff --git a/doc/sgreen.1.txt.in b/doc/sgreen.1.txt.in
@@ -30,15 +30,15 @@ SYNOPSIS
DESCRIPTION
-----------
*sgreen* is a post processing tool that can be used on *stardis*(1) Green
-functions, as contained in binary green files. The main functionality is to
-apply different boundary conditions to a system once solved by *stardis*(1)
-in Green mode (*-G* option of *stardis*(1)). The provided file should comply
-with the *sgreen-input*(5) format, that is also the output format of
-*stardis*(1) in binary Green mode (see *stardis-output*(5)).
-
-Using this Green function (a.k.a propagator) approach, when possible, produces
-the very same results as a full Monte-Carlo computation, but only requires a
-fraction of the computation time.
+functions (a.k.a propagators), as contained in binary files. The main
+functionality is to apply different boundary conditions to a system once solved
+by *stardis*(1) in Green mode (*-G* option of *stardis*(1)). The provided file
+should comply with the *sgreen-input*(5) format, that is also the
+*stardis-output*(1) format in binary Green mode.
+
+Using this Green function approach, when possible, produces the very same
+results as a full Monte-Carlo computation, but only requires a fraction of the
+computation time.
The propagator is of great value for thermicist engineers as it gives some
crucial information to analyse heat transfers in the system. It helps engineers
diff --git a/src/green-compute.c b/src/green-compute.c
@@ -39,41 +39,44 @@ check_green_table_variables_use
/* Clear previous data */
FOR_EACH(i, 0, 1 + green->counts.desc_count) {
- green->table[i].end_references_count = 0;
- green->table[i].other_references_weight = 0;
+ green->table[i].end_weight = 0;
+ green->table[i].other_weight = 0;
}
FOR_EACH(i, 0, green->counts.ok_count) {
const struct sample* sample = green->samples + i;
unsigned id = sample->header.end_id;
ASSERT(!DESC_IS_H(green->descriptions[id].type));
ASSERT(id <= green->counts.desc_count); /* Ambient ID is desc_count */
- green->table[id].end_references_count++;
+ green->table[id].end_weight++;
FOR_EACH(j, 0, sample->header.pw_count) {
const double w = sample->pw_weights[j];
id = sample->pw_ids[j];
ASSERT(id < green->counts.desc_count);
ASSERT(DESC_IS_MEDIUM(green->descriptions[id].type));
- green->table[id].other_references_weight += w;
+ green->table[id].other_weight += w;
}
FOR_EACH(j, 0, sample->header.fx_count) {
const double w = sample->fx_weights[j];
id = sample->fx_ids[j];
ASSERT(id < green->counts.desc_count);
- ASSERT(DESC_IS_F(type = green->descriptions[id].type));
- green->table[id].other_references_weight += w;
+ ASSERT(DESC_IS_F(green->descriptions[id].type));
+ green->table[id].other_weight += w;
}
}
green->references_checked = 1;
}
-#define INSERT(Name, Val, Used) { \
+#define INSERT(Elt, Field) { \
struct variable_data vd___; \
- vd___.value = &(Val); vd___.used = (Used) != 0;\
- if(!vd___.used) green->unused_variables = 1; \
- if(htable_variable_ptr_find(&green->variable_ptrs, &(Name))) \
+ vd___.value = &green->table[Elt].Field ## _value; \
+ vd___.used = (green->table[Elt].Field ## _weight != 0); \
+ vd___.unknown = green->table[Elt].Field ## _unknown; \
+ if(vd___.unknown) green->unknown_variables = 1; \
+ else if(!vd___.used) green->unused_variables = 1; \
+ if(htable_variable_ptr_find(&green->variable_ptrs, &(green->table[Elt].Field ## _name))) \
FATAL("Name already known"); \
- ERR(htable_variable_ptr_set(&green->variable_ptrs, &(Name), &vd___)); \
+ ERR(htable_variable_ptr_set(&green->variable_ptrs, &(green->table[Elt].Field ## _name), &vd___)); \
} (void)0
#define MK_VAR(Str) \
@@ -116,41 +119,42 @@ build_green_table
str_set(&green->table[i].end_name, buf);
green->table[i].end_value = desc->d.t_boundary.imposed_temperature;
green->table[i].end_defined = 1;
- INSERT(green->table[i].end_name, green->table[i].end_value,
- green->table[i].end_references_count);
+ INSERT(i, end);
}
else if(DESC_IS_H(desc->type)) {
MK_VAR("%s.T");
str_set(&green->table[i].end_name, buf);
green->table[i].end_value = desc->d.h_boundary.imposed_temperature;
green->table[i].end_defined = 1;
- INSERT(green->table[i].end_name, green->table[i].end_value,
- green->table[i].end_references_count);
+ INSERT(i, end);
}
else if(DESC_IS_F(desc->type)) {
MK_VAR("%s.F");
str_set(&green->table[i].other_name, buf);
green->table[i].other_value = desc->d.f_boundary.imposed_flux;
green->table[i].other_defined = 1;
- INSERT(green->table[i].other_name, green->table[i].other_value,
- green->table[i].other_references_weight);
+ INSERT(i, other);
}
else if(DESC_IS_MEDIUM(desc->type)) {
- MK_VAR("%s.T");
- str_set(&green->table[i].end_name, buf);
- green->table[i].end_defined = 1;
- INSERT(green->table[i].end_name, green->table[i].end_value,
- green->table[i].end_references_count);
if(desc->type == DESC_MAT_SOLID) {
+ MK_VAR("%s.T");
+ str_set(&green->table[i].end_name, buf);
green->table[i].end_value = desc->d.solid.imposed_temperature;
+ green->table[i].end_defined = 1;
+ if(green->table[i].end_value < 0) green->table[i].end_unknown = 1;
+ INSERT(i, end);
MK_VAR("%s.VP");
str_set(&green->table[i].other_name, buf);
green->table[i].other_value = desc->d.solid.vpower;
green->table[i].other_defined = 1;
- INSERT(green->table[i].other_name, green->table[i].other_value,
- green->table[i].other_references_weight);
- } else { /* No VP for fluids yet */
+ INSERT(i, other);
+ } else {
+ MK_VAR("%s.T");
+ str_set(&green->table[i].end_name, buf);
green->table[i].end_value = desc->d.fluid.imposed_temperature;
+ green->table[i].end_defined = 1;
+ if(green->table[i].end_value < 0) green->table[i].end_unknown = 1;
+ INSERT(i, end);
}
}
else if(desc->type == DESC_SOLID_FLUID_CONNECT) {
@@ -164,8 +168,7 @@ build_green_table
str_set(&green->table[ambient_id].end_name, "AMBIENT");
green->table[ambient_id].end_value = green->ambient_temp;
green->table[ambient_id].end_defined = 1;
- INSERT(green->table[ambient_id].end_name, green->table[ambient_id].end_value,
- green->table[ambient_id].end_references_count);
+ INSERT(ambient_id, end);
end:
MEM_RM(green->allocator, buf);
diff --git a/src/green-output.c b/src/green-output.c
@@ -21,19 +21,26 @@
#include "green-types.h"
#include "green-version.h"
+#include <stdio.h>
+
#define CELL(T,Val) \
fprintf(stream, " <td>%" #T "</td>\n", (Val))
-#define MCELL(T,Used,Name,Val) { \
- if(Used) \
- fprintf(stream, " <td><u><b>%s = %" #T "</b></u></td>\n", (Name), (Val)); \
- else fprintf(stream, " <td>%s = %" #T "</td>\n", (Name), (Val)); \
+#define VAR_CELL(Elt, Field) { \
+ const char* name___ = str_cget(&(green->table[Elt].Field ## _name)); \
+ if((green->table[Elt]). Field ## _unknown) { \
+ fprintf(stream, " <td>%s = Unknown</td>\n", name___); \
+ } else if(green->table[Elt].Field ## _defined \
+ && green->table[Elt].Field ## _weight > 0) \
+ { \
+ fprintf(stream, " <td><u><b>%s = %g</b></u></td>\n", \
+ name___, green->table[Elt].Field ## _value); \
+ } else { \
+ fprintf(stream, " <td>%s = %g</td>\n", \
+ name___, green->table[Elt].Field ## _value); \
+ } \
} (void)0
-#define MCELLif(T,Used,Name,Val) \
- if((Val) != 0) { MCELL(T,(Used),(Name),(Val)); } \
- else { CELL(T,(Val)); } (void)0
-
void
print_version
(FILE* stream)
@@ -128,7 +135,7 @@ dump_green_info
fprintf(stream, "<h2>List of variables</h2>\n");
- fprintf(stream, "<h3>Variable used in the Green function</h3>\n");
+ fprintf(stream, "<h3>Variables used in the Green function</h3>\n");
fprintf(stream, "<p>These variable names are used in the following formula. "
"Using the syntax NAME=value in a settings file, their values are "
@@ -138,12 +145,12 @@ dump_green_info
fst = 1;
FOR_EACH(i, 0, green->counts.desc_count + 1) {
struct table_elt* elt = green->table + i;
- if(elt->end_defined && elt->end_references_count) {
+ if(elt->end_defined && elt->end_weight) {
if(!fst) fprintf(stream, ", ");
fst = 0;
fprintf(stream, "%s", str_cget(&elt->end_name));
}
- if(elt->other_defined && elt->other_references_weight) {
+ if(elt->other_defined && elt->other_weight) {
if(!fst) fprintf(stream, ", ");
fst = 0;
fprintf(stream, "%s", str_cget(&elt->other_name));
@@ -152,22 +159,51 @@ dump_green_info
if(green->unused_variables) {
fprintf(stream,
- "<h3>Variable not used in the Green function</h3>\n");
+ "<h3>Unused variables in the Green function</h3>\n");
fprintf(stream, "<p>These variable names are not used in the following "
- "formula. Changing their values in a settings file has no effect on "
- "the applied Green function results. They are listed NAME = value "
- "in the tables below.</p>\n");
+ "formula, just because they where not sampled. As a consequence, "
+ "changing their values in a settings file has no effect on the applied "
+ "Green function results. They are listed NAME = value in the tables "
+ "below.</p>\n");
+
+ fst = 1;
+ FOR_EACH(i, 0, green->counts.desc_count + 1) {
+ struct table_elt* elt = green->table + i;
+ if(elt->end_defined
+ && !elt->end_unknown && !elt->end_weight) {
+ if(!fst) fprintf(stream, ", ");
+ fst = 0;
+ fprintf(stream, "%s", str_cget(&elt->end_name));
+ }
+ if(elt->other_defined
+ && !elt->other_unknown && !elt->other_weight) {
+ if(!fst) fprintf(stream, ", ");
+ fst = 0;
+ fprintf(stream, "%s", str_cget(&elt->other_name));
+ }
+ }
+ }
+
+ if(green->unknown_variables) {
+ fprintf(stream,
+ "<h3>Unknown variables in the Green function</h3>\n");
+
+ fprintf(stream, "<p>These names are not true variable names because their "
+ "values where defined as <i>unknown</i> in the system, meaning they "
+ "required to be solved. Attempting to change their values in a settings "
+ "file is an error. They are listed NAME = Unknown in the tables below."
+ "</p>\n");
fst = 1;
FOR_EACH(i, 0, green->counts.desc_count + 1) {
struct table_elt* elt = green->table + i;
- if(elt->end_defined && !elt->end_references_count) {
+ if(elt->end_unknown) {
if(!fst) fprintf(stream, ", ");
fst = 0;
fprintf(stream, "%s", str_cget(&elt->end_name));
}
- if(elt->other_defined && !elt->other_references_weight) {
+ if(elt->other_defined && !elt->other_weight) {
if(!fst) fprintf(stream, ", ");
fst = 0;
fprintf(stream, "%s", str_cget(&elt->other_name));
@@ -183,13 +219,13 @@ dump_green_info
/* Print result */
fst = 1;
FOR_EACH(i, 0, 1 + green->counts.desc_count) {
- if(green->table[i].end_references_count) {
+ if(green->table[i].end_weight) {
double k;
ASSERT(green->table[i].end_defined);
if(fst) fprintf(stream, "<p>E[T] = ");
else fprintf(stream, " + ");
fst = 0;
- k = (double)green->table[i].end_references_count
+ k = (double)green->table[i].end_weight
/ (double)green->counts.ok_count;
t += k * green->table[i].end_value;
fprintf(stream, "%g * <b>%s</b>", k, str_cget(&green->table[i].end_name));
@@ -197,23 +233,23 @@ dump_green_info
}
ASSERT(!fst);
FOR_EACH(i, 0, green->counts.desc_count) {
- if(green->table[i].other_references_weight) {
+ if(green->table[i].other_weight) {
double k;
ASSERT(green->table[i].other_defined);
- k = (double)green->table[i].other_references_weight
+ k = (double)green->table[i].other_weight
/ (double)green->counts.ok_count;
t += k * green->table[i].other_value;
fprintf(stream, " + %g * <b>%s</b>", k, str_cget(&green->table[i].other_name));
}
}
- if(green->table[green->counts.desc_count].end_references_count) {
+ if(green->table[green->counts.desc_count].end_weight) {
double ww = 0, k;
/* Some paths end here */
if(fst) fprintf(stream, "<p>E(T) = ");
else fprintf(stream, " + ");
fst = 0;
ww = green->ambient_temp;
- k = (double)green->table[green->counts.desc_count].end_references_count
+ k = (double)green->table[green->counts.desc_count].end_weight
/ (double)green->counts.ok_count;
t += ww * k;
fprintf(stream, "%g * <b>Ambient</b>", k);
@@ -268,15 +304,8 @@ dump_green_info
CELL(g, sl->lambda);
CELL(g, sl->rho);
CELL(g, sl->cp);
- ASSERT(green->table[i].other_defined);
- MCELLif(g, green->table[i].other_references_weight,
- str_cget(&green->table[i].other_name), sl->vpower);
- if(sl->imposed_temperature >= 0) {
- ASSERT(green->table[i].end_defined);
- MCELL(g, green->table[i].end_references_count,
- str_cget(&green->table[i].end_name), sl->imposed_temperature);
- }
- else CELL(s, "Unknown");
+ VAR_CELL(i, other);
+ VAR_CELL(i, end);
fprintf(stream, "</tr>\n");
local_count++;
}
@@ -303,12 +332,7 @@ dump_green_info
CELL(s, str_cget(&fl->name));
CELL(g, fl->rho);
CELL(g, fl->cp);
- if(fl->imposed_temperature >= 0) {
- ASSERT(green->table[i].end_defined);
- MCELL(g, green->table[i].end_references_count,
- str_cget(&green->table[i].end_name), fl->imposed_temperature);
- }
- else CELL(s, "Unknown");
+ VAR_CELL(i, end);
fprintf(stream, "</tr>\n");
local_count++;
}
@@ -332,8 +356,7 @@ dump_green_info
fprintf(stream, "<tr>\n");
CELL(s, str_cget(&bd->name));
ASSERT(green->table[i].end_defined);
- MCELL(g, green->table[i].end_references_count,
- str_cget(&green->table[i].end_name), bd->imposed_temperature);
+ VAR_CELL(i, end);
fprintf(stream, "</tr>\n");
local_count++;
}
@@ -359,8 +382,7 @@ dump_green_info
fprintf(stream, "<tr>\n");
CELL(s, str_cget(&bd->name));
ASSERT(green->table[i].end_defined);
- MCELL(g, green->table[i].end_references_count,
- str_cget(&green->table[i].end_name), bd->imposed_temperature);
+ VAR_CELL(i, end);
CELL(g, bd->emissivity);
CELL(g, bd->specular_fraction);
CELL(g, bd->hc);
@@ -393,8 +415,7 @@ dump_green_info
CELL(g, bd->specular_fraction);
CELL(g, bd->hc);
ASSERT(green->table[i].end_defined);
- MCELL(g, green->table[i].end_references_count,
- str_cget(&green->table[i].end_name), bd->imposed_temperature);
+ VAR_CELL(i, end);
fprintf(stream, "</tr>\n");
local_count++;
}
@@ -424,8 +445,7 @@ dump_green_info
CELL(g, bd->hc);
ASSERT(green->table[i].end_defined);
ASSERT(green->table[i].end_defined);
- MCELL(g, green->table[i].end_references_count,
- str_cget(&green->table[i].end_name), bd->imposed_temperature);
+ VAR_CELL(i, end);
fprintf(stream, "</tr>\n");
local_count++;
}
@@ -449,8 +469,7 @@ dump_green_info
fprintf(stream, "<tr>\n");
CELL(s, str_cget(&bd->name));
ASSERT(green->table[i].other_defined);
- MCELL(g, green->table[i].other_references_weight,
- str_cget(&green->table[i].other_name), bd->imposed_flux);
+ VAR_CELL(i, other);
fprintf(stream, "</tr>\n");
local_count++;
}
@@ -466,9 +485,7 @@ dump_green_info
fprintf(stream, "<tr>\n");
CELL(s, "Ambient");
ASSERT(green->table[green->counts.desc_count].end_defined);
- MCELL(g, green->table[i].end_references_count,
- str_cget(&green->table[green->counts.desc_count].end_name),
- green->ambient_temp);
+ VAR_CELL(green->counts.desc_count, end);
fprintf(stream, "</tr>\n");
fprintf(stream, "<tr>\n");
CELL(s, "Linearization");
@@ -482,5 +499,4 @@ dump_green_info
}
#undef CELL
-#undef MCELL
-#undef MCELLif
-\ No newline at end of file
+#undef VAR_CELL
+\ No newline at end of file
diff --git a/src/green-types.h b/src/green-types.h
@@ -180,13 +180,11 @@ release_sample
*/
struct table_elt {
- struct str end_name;
- struct str other_name;
- double end_value;
- double other_value;
- int end_defined, other_defined;
- int end_references_count;
- double other_references_weight;
+ struct str end_name, other_name;
+ double end_value, other_value;
+ int end_defined, other_defined, end_unknown, other_unknown;
+ unsigned end_weight;
+ double other_weight;
};
static INLINE void
@@ -201,8 +199,10 @@ init_table_elt
elt->other_value = 0;
elt->end_defined = 0;
elt->other_defined = 0;
- elt->end_references_count = 0;
- elt->other_references_weight = 0;
+ elt->end_unknown = 0;
+ elt->other_unknown = 0;
+ elt->end_weight = 0;
+ elt->other_weight = 0;
}
static INLINE void
@@ -217,6 +217,7 @@ release_table_elt
struct variable_data {
double* value;
int used;
+ int unknown;
};
#define HTABLE_NAME variable_ptr
@@ -242,7 +243,7 @@ struct green {
double ambient_temp, ref_temp;
struct table_elt* table;
struct sample* samples;
- int references_checked, unused_variables;
+ int references_checked, unused_variables, unknown_variables;
struct htable_variable_ptr variable_ptrs;
};
@@ -264,6 +265,7 @@ green_init
green->ref_temp = 0;
green->references_checked = 0;
green->unused_variables = 0;
+ green->unknown_variables = 0;
htable_variable_ptr_init(alloc, &green->variable_ptrs);
}