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 |
+ |
* version 2.6 (2021/01/29): dew point dependency added according to Perez publication 1990 (W -> atm_preci_water=exp(0.07*Td-0.075) ). by J. Wienold, EPFL |
9 |
|
*/ |
10 |
|
|
11 |
|
#define _USE_MATH_DEFINES |
105 |
|
|
106 |
|
double solar_sunset(int month, int day); |
107 |
|
double solar_sunrise(int month, int day); |
107 |
– |
double stadj(); |
108 |
– |
int jdate(int month, int day); |
108 |
|
|
109 |
|
const double AU = 149597890E3; |
110 |
|
const double solar_constant_e = 1367; /* solar constant W/m^2 */ |
121 |
|
|
122 |
|
|
123 |
|
/* required values */ |
124 |
+ |
int year = 0; /* year (optional) */ |
125 |
|
int month, day; /* date */ |
126 |
|
double hour; /* time */ |
127 |
|
int tsolar; /* 0=standard, 1=solar */ |
134 |
|
double skybrightness = 0; |
135 |
|
double solarradiance; |
136 |
|
double diffuseilluminance, directilluminance, diffuseirradiance, directirradiance, globalirradiance; |
137 |
< |
double sunzenith, daynumber, atm_preci_water=2; |
137 |
> |
double sunzenith, daynumber, atm_preci_water, Td=10.97353115; |
138 |
|
|
139 |
|
/*double sunaltitude_border = 0;*/ |
140 |
|
double diffnormalization = 0; |
200 |
|
for (i = 4; i < argc; i++) |
201 |
|
if (argv[i][0] == '-' || argv[i][0] == '+') |
202 |
|
switch (argv[i][1]) { |
203 |
+ |
case 'd': |
204 |
+ |
Td = atof(argv[++i]); |
205 |
+ |
if (Td < -40 || Td > 40) { |
206 |
+ |
Td=10.97353115; } |
207 |
+ |
break; |
208 |
|
case 's': |
209 |
|
cloudy = 0; |
210 |
|
dosun = argv[i][0] == '+'; |
211 |
|
break; |
212 |
+ |
case 'y': |
213 |
+ |
year = atoi(argv[++i]); |
214 |
+ |
break; |
215 |
|
case 'R': |
216 |
|
u_solar = argv[i][1] == 'R' ? -1 : 1; |
217 |
|
solarbr = atof(argv[++i]); |
329 |
|
{ fprintf(stderr,"Out of memory error in function main"); return 1; } |
330 |
|
|
331 |
|
|
332 |
+ |
atm_preci_water=exp(0.07*Td-0.075); |
333 |
|
printhead(argc, argv); |
334 |
|
computesky(); |
335 |
|
printsky(); |
356 |
|
/* compute solar direction */ |
357 |
|
|
358 |
|
if (month) { /* from date and time */ |
350 |
– |
int jd; |
359 |
|
double sd; |
360 |
|
|
361 |
< |
jd = jdate(month, day); /* Julian date */ |
362 |
< |
sd = sdec(jd); /* solar declination */ |
363 |
< |
if (tsolar) /* solar time */ |
364 |
< |
st = hour; |
365 |
< |
else |
366 |
< |
st = hour + stadj(jd); |
367 |
< |
|
368 |
< |
|
361 |
> |
st = hour; |
362 |
> |
if (year) { /* Michalsky algorithm? */ |
363 |
> |
double mjd = mjdate(year, month, day, hour); |
364 |
> |
if (tsolar) |
365 |
> |
sd = msdec(mjd, NULL); |
366 |
> |
else |
367 |
> |
sd = msdec(mjd, &st); |
368 |
> |
} else { |
369 |
> |
int jd = jdate(month, day); /* Julian date */ |
370 |
> |
sd = sdec(jd); /* solar declination */ |
371 |
> |
if (!tsolar) /* get solar time? */ |
372 |
> |
st = hour + stadj(jd); |
373 |
> |
} |
374 |
> |
|
375 |
|
if(timeinterval) { |
376 |
|
|
377 |
|
if(timeinterval<0) { |
707 |
|
|
708 |
|
printf("# Local solar time: %.2f\n", st); |
709 |
|
printf("# Solar altitude and azimuth: %.1f %.1f\n", altitude*180/M_PI, azimuth*180/M_PI); |
710 |
+ |
printf("# epsilon, delta, atmospheric precipitable water content : %.4f %.4f %.4f \n", skyclearness, skybrightness,atm_preci_water ); |
711 |
|
|
712 |
|
|
713 |
|
if (dosun&&(skyclearness>1)) |
796 |
|
{ |
797 |
|
if (msg != NULL) |
798 |
|
fprintf(stderr, "%s: Use error - %s\n\n", progname, msg); |
799 |
< |
fprintf(stderr, "Usage: %s month day hour [...]\n", progname); |
800 |
< |
fprintf(stderr, " or: %s -ang altitude azimuth [...]\n", progname); |
799 |
> |
fprintf(stderr, "Usage: %s month day hour [-y year] [...]\n", progname); |
800 |
> |
fprintf(stderr, " or: %s -ang altitude azimuth [...]\n", progname); |
801 |
|
fprintf(stderr, " followed by: -P epsilon delta [options]\n"); |
802 |
|
fprintf(stderr, " or: [-W|-L|-G] direct_value diffuse_value [options]\n"); |
803 |
< |
fprintf(stderr, " or: -E global_irradiance [options]\n\n"); |
804 |
< |
fprintf(stderr, " Description:\n"); |
803 |
> |
fprintf(stderr, " or: -E global_irradiance [options]\n\n"); |
804 |
> |
fprintf(stderr, " Description:\n"); |
805 |
|
fprintf(stderr, " -P epsilon delta (these are the Perez parameters) \n"); |
806 |
|
fprintf(stderr, " -W direct-normal-irradiance diffuse-horizontal-irradiance (W/m^2)\n"); |
807 |
|
fprintf(stderr, " -L direct-normal-illuminance diffuse-horizontal-illuminance (lux)\n"); |
1435 |
|
/* degrees into radians */ |
1436 |
|
double radians(double degres) |
1437 |
|
{ |
1438 |
< |
return degres*M_PI/180.0; |
1438 |
> |
return degres*(M_PI/180.); |
1439 |
|
} |
1440 |
|
|
1441 |
|
|
1442 |
|
/* radian into degrees */ |
1443 |
|
double degres(double radians) |
1444 |
|
{ |
1445 |
< |
return radians/M_PI*180.0; |
1445 |
> |
return radians*(180./M_PI); |
1446 |
|
} |
1447 |
|
|
1448 |
|
|
1473 |
|
buffer += (*(lv+i))*cos(radians(*(theta+i))); |
1474 |
|
} |
1475 |
|
|
1476 |
< |
return buffer*2*M_PI/144; |
1476 |
> |
return buffer*(2.*M_PI/145.); |
1477 |
|
} |
1478 |
|
|
1479 |
|
|