4 |
|
* Centre de Valbonne, 500 route des Lucioles, 06565 Sophia Antipolis Cedex, France |
5 |
|
* *BOUYGUES |
6 |
|
* 1 Avenue Eugene Freyssinet, Saint-Quentin-Yvelines, France |
7 |
+ |
* print colored output if activated in command line (-C). Based on model from A. Diakite, TU-Berlin. Implemented by J. Wienold, August 26 2018 |
8 |
|
*/ |
9 |
|
|
10 |
+ |
#define _USE_MATH_DEFINES |
11 |
|
#include <stdio.h> |
12 |
|
#include <string.h> |
13 |
|
#include <math.h> |
18 |
|
#include "paths.h" |
19 |
|
|
20 |
|
#define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) |
19 |
– |
#define _USE_MATH_DEFINES |
21 |
|
|
22 |
|
double normsc(); |
23 |
|
|
54 |
|
90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 0, 20, 40, 60, |
55 |
|
80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 0, 30, 60, 90, 120, 150, 180, 210, |
56 |
|
240, 270, 300, 330, 0, 60, 120, 180, 240, 300, 0}; |
57 |
+ |
/* default values for Berlin */ |
58 |
+ |
float locus[] = { |
59 |
+ |
-4.843e9,2.5568e6,0.24282e3,0.23258,-4.843e9,2.5568e6,0.24282e3,0.23258,-1.2848,1.7519,-0.093786}; |
60 |
|
|
61 |
|
|
62 |
|
|
107 |
|
double stadj(); |
108 |
|
int jdate(int month, int day); |
109 |
|
|
106 |
– |
|
107 |
– |
/* sun calculation constants */ |
108 |
– |
extern double s_latitude; |
109 |
– |
extern double s_longitude; |
110 |
– |
extern double s_meridian; |
111 |
– |
|
110 |
|
const double AU = 149597890E3; |
111 |
|
const double solar_constant_e = 1367; /* solar constant W/m^2 */ |
112 |
|
const double solar_constant_l = 127500; /* solar constant lux */ |
144 |
|
int output=0; /* define the unit of the output (sky luminance or radiance): */ |
145 |
|
/* visible watt=0, solar watt=1, lumen=2 */ |
146 |
|
int input=0; /* define the input for the calulation */ |
147 |
< |
|
147 |
> |
int color_output=0; |
148 |
|
int suppress_warnings=0; |
149 |
|
|
150 |
|
/* default values */ |
155 |
|
double gprefl = 0.2; |
156 |
|
int S_INTER=0; |
157 |
|
|
158 |
+ |
|
159 |
|
/* computed values */ |
160 |
|
double sundir[3]; |
161 |
|
double groundbr = 0; |
212 |
|
cloudy = argv[i][0] == '+' ? 2 : 1; |
213 |
|
dosun = 0; |
214 |
|
break; |
215 |
+ |
case 'C': |
216 |
+ |
if (argv[i][2] == 'I' && argv[i][3] == 'E' ) { |
217 |
+ |
locus[0] = -4.607e9; |
218 |
+ |
locus[1] = 2.9678e6; |
219 |
+ |
locus[2] = 0.09911e3; |
220 |
+ |
locus[3] = 0.244063; |
221 |
+ |
locus[4] = -2.0064e9; |
222 |
+ |
locus[5] = 1.9018e6; |
223 |
+ |
locus[6] = 0.24748e3; |
224 |
+ |
locus[7] = 0.23704; |
225 |
+ |
locus[8] = -3.0; |
226 |
+ |
locus[9] = 2.87; |
227 |
+ |
locus[10] = -0.275; |
228 |
+ |
}else{ color_output = 1; |
229 |
+ |
} |
230 |
+ |
break; |
231 |
+ |
case 'l': |
232 |
+ |
locus[0] = atof(argv[++i]); |
233 |
+ |
locus[1] = atof(argv[++i]); |
234 |
+ |
locus[2] = atof(argv[++i]); |
235 |
+ |
locus[3] = atof(argv[++i]); |
236 |
+ |
locus[4] = locus[0]; |
237 |
+ |
locus[5] = locus[1]; |
238 |
+ |
locus[6] = locus[2]; |
239 |
+ |
locus[7] = locus[3]; |
240 |
+ |
locus[8] = atof(argv[++i]); |
241 |
+ |
locus[9] = atof(argv[++i]); |
242 |
+ |
locus[10] = atof(argv[++i]); |
243 |
+ |
break; |
244 |
+ |
|
245 |
|
case 't': |
246 |
|
betaturbidity = atof(argv[++i]); |
247 |
|
break; |
711 |
|
printf("0\n0\n"); |
712 |
|
printf("4 %f %f %f %f\n", sundir[0], sundir[1], sundir[2], 2*half_sun_angle); |
713 |
|
} |
714 |
< |
|
715 |
< |
|
716 |
< |
printf("\nvoid brightfunc skyfunc\n"); |
717 |
< |
printf("2 skybright perezlum.cal\n"); |
714 |
> |
/* print colored output if activated in command line (-C). Based on model from A. Diakite, TU-Berlin. Implemented by J. Wienold, August 26 2018 */ |
715 |
> |
if (color_output==1 && skyclearness < 4.5 && skyclearness >1.065 ) |
716 |
> |
{ |
717 |
> |
fprintf(stderr, " warning: sky clearness(epsilon)= %f \n",skyclearness); |
718 |
> |
fprintf(stderr, " warning: intermediate sky!! \n"); |
719 |
> |
fprintf(stderr, " warning: color model for intermediate sky pending \n"); |
720 |
> |
fprintf(stderr, " warning: no color output ! \n"); |
721 |
> |
color_output=0; |
722 |
> |
} |
723 |
> |
if (color_output==1) |
724 |
> |
{ |
725 |
> |
printf("\nvoid colorfunc skyfunc\n"); |
726 |
> |
printf("4 skybright_r skybright_g skybright_b perezlum_c.cal\n"); |
727 |
|
printf("0\n"); |
728 |
< |
printf("10 %.3e %.3e %lf %lf %lf %lf %lf %f %f %f \n", diffnormalization, groundbr, |
728 |
> |
printf("22 %.3e %.3e %lf %lf %lf %lf %lf %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", diffnormalization, groundbr, |
729 |
|
*(c_perez+0),*(c_perez+1),*(c_perez+2),*(c_perez+3),*(c_perez+4), |
730 |
< |
sundir[0], sundir[1], sundir[2]); |
730 |
> |
sundir[0], sundir[1], sundir[2],skyclearness,locus[0],locus[1],locus[2],locus[3],locus[4],locus[5],locus[6],locus[7],locus[8],locus[9],locus[10]); |
731 |
> |
}else{ |
732 |
> |
printf("\nvoid brightfunc skyfunc\n"); |
733 |
> |
printf("2 skybright perezlum.cal\n"); |
734 |
> |
printf("0\n"); |
735 |
> |
printf("10 %.3e %.3e %lf %lf %lf %lf %lf %f %f %f \n", diffnormalization, groundbr, |
736 |
> |
*(c_perez+0),*(c_perez+1),*(c_perez+2),*(c_perez+3),*(c_perez+4), |
737 |
> |
sundir[0], sundir[1], sundir[2]); |
738 |
> |
} |
739 |
|
|
740 |
|
} |
741 |
|
|
794 |
|
fprintf(stderr, " -E global-horizontal-irradiance (W/m^2)\n\n"); |
795 |
|
fprintf(stderr, " Output specification with option:\n"); |
796 |
|
fprintf(stderr, " -O [0|1|2] (0=output in W/m^2/sr visible, 1=output in W/m^2/sr solar, 2=output in candela/m^2), default is 0 \n"); |
797 |
< |
fprintf(stderr, " gendaylit version 2.4 (2013/09/04) \n\n"); |
797 |
> |
fprintf(stderr, " gendaylit version 2.5 (2018/04/18) \n\n"); |
798 |
|
exit(1); |
799 |
|
} |
800 |
|
|