bifacial-radiance 0.5.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. bifacial_radiance/HPCScripts/BasicSimulations/addNewModule.py +15 -0
  2. bifacial_radiance/HPCScripts/BasicSimulations/dask_on_node.sh +11 -0
  3. bifacial_radiance/HPCScripts/BasicSimulations/run_sbatch.sbatch +51 -0
  4. bifacial_radiance/HPCScripts/BasicSimulations/simulate_fixedtilt_gencumsky.py +110 -0
  5. bifacial_radiance/HPCScripts/BasicSimulations/simulate_fixedtilt_gendaylit.py +102 -0
  6. bifacial_radiance/HPCScripts/BasicSimulations/simulate_tracking_gendaylit.py +126 -0
  7. bifacial_radiance/HPCScripts/Other Examples (unorganized)/PuertoRico.py +168 -0
  8. bifacial_radiance/HPCScripts/Other Examples (unorganized)/PuertoRico_2.py +166 -0
  9. bifacial_radiance/HPCScripts/Other Examples (unorganized)/PuertoRico_Original.py +195 -0
  10. bifacial_radiance/HPCScripts/Other Examples (unorganized)/basic_module_sampling.py +154 -0
  11. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_B.py +162 -0
  12. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_Cases.py +122 -0
  13. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_CasesMonth.py +142 -0
  14. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_PRNew.py +91 -0
  15. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_PRNewP2.py +95 -0
  16. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_TreeResults.py +108 -0
  17. bifacial_radiance/HPCScripts/Other Examples (unorganized)/compile_basic_module_sampling.py +103 -0
  18. bifacial_radiance/HPCScripts/Other Examples (unorganized)/simulate_JackHourly.py +160 -0
  19. bifacial_radiance/HPCScripts/Other Examples (unorganized)/simulate_improvedArray_Oct2127.py +623 -0
  20. bifacial_radiance/TEMP/.gitignore +4 -0
  21. bifacial_radiance/__init__.py +24 -0
  22. bifacial_radiance/data/CEC Modules.csv +16860 -0
  23. bifacial_radiance/data/default.ini +65 -0
  24. bifacial_radiance/data/falsecolor.exe +0 -0
  25. bifacial_radiance/data/gencumsky/License.txt +54 -0
  26. bifacial_radiance/data/gencumsky/Makefile +17 -0
  27. bifacial_radiance/data/gencumsky/README.txt +9 -0
  28. bifacial_radiance/data/gencumsky/Solar Irradiation Modelling.doc +0 -0
  29. bifacial_radiance/data/gencumsky/Sun.cpp +118 -0
  30. bifacial_radiance/data/gencumsky/Sun.h +45 -0
  31. bifacial_radiance/data/gencumsky/average_val.awk +3 -0
  32. bifacial_radiance/data/gencumsky/cPerezSkyModel.cpp +238 -0
  33. bifacial_radiance/data/gencumsky/cPerezSkyModel.h +57 -0
  34. bifacial_radiance/data/gencumsky/cSkyVault.cpp +536 -0
  35. bifacial_radiance/data/gencumsky/cSkyVault.h +86 -0
  36. bifacial_radiance/data/gencumsky/climateFile.cpp +312 -0
  37. bifacial_radiance/data/gencumsky/climateFile.h +37 -0
  38. bifacial_radiance/data/gencumsky/cumulative.cal +177 -0
  39. bifacial_radiance/data/gencumsky/cumulative.rad +14 -0
  40. bifacial_radiance/data/gencumsky/cumulativesky_rotated.rad +2 -0
  41. bifacial_radiance/data/gencumsky/gencumulativesky +0 -0
  42. bifacial_radiance/data/gencumsky/gencumulativesky.cpp +269 -0
  43. bifacial_radiance/data/gencumsky/make_gencumskyexe.py +107 -0
  44. bifacial_radiance/data/gencumsky/paths.h +62 -0
  45. bifacial_radiance/data/gencumulativesky +0 -0
  46. bifacial_radiance/data/gencumulativesky.exe +0 -0
  47. bifacial_radiance/data/ground.rad +83 -0
  48. bifacial_radiance/data/module.json +103 -0
  49. bifacial_radiance/gui.py +1696 -0
  50. bifacial_radiance/images/fig1_fixed_small.gif +0 -0
  51. bifacial_radiance/images/fig2_tracked_small.gif +0 -0
  52. bifacial_radiance/load.py +1156 -0
  53. bifacial_radiance/main.py +5673 -0
  54. bifacial_radiance/mismatch.py +461 -0
  55. bifacial_radiance/modelchain.py +299 -0
  56. bifacial_radiance/module.py +1427 -0
  57. bifacial_radiance/performance.py +466 -0
  58. bifacial_radiance/spectral_utils.py +555 -0
  59. bifacial_radiance-0.5.1.dist-info/METADATA +129 -0
  60. bifacial_radiance-0.5.1.dist-info/RECORD +63 -0
  61. bifacial_radiance-0.5.1.dist-info/WHEEL +6 -0
  62. bifacial_radiance-0.5.1.dist-info/licenses/LICENSE +30 -0
  63. bifacial_radiance-0.5.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,65 @@
1
+ #Version 0.3.0
2
+ [simulationParamsDict]
3
+ testfolder: C:\Users\cdeline\Documents\Python Scripts\Test2
4
+ weatherFile: C:\Users\cdeline\Documents\Python Scripts\Test2\EPWs\USA_VA_Richmond.Intl.AP.724010_TMY.epw
5
+ getEPW: True
6
+ simulationname: Demo1
7
+ moduletype: Longi
8
+ rewriteModule: True
9
+ cellLevelModule: False
10
+ axisofrotationTorqueTube: False
11
+ torqueTube: True
12
+ tracking: True
13
+ cumulativeSky: True
14
+ selectTimes: True
15
+ latitude: 37.5
16
+ longitude: -77.6st
17
+
18
+ [timeControlParamsDict]
19
+ starttime: 06_21_12_00
20
+ endtime: 06_21_12_00
21
+
22
+ [moduleParamsDict]
23
+ numpanels: 2
24
+ x: 0.98
25
+ y: 1.980
26
+ bifi: 0.90
27
+ xgap: 0.020
28
+ ygap: 0.150
29
+ zgap: 0.100
30
+
31
+ [sceneParamsDict]
32
+ gcrorpitch: pitch
33
+ gcr: 0.350
34
+ pitch: 10.0
35
+ albedo: 0.30
36
+ nMods: 20
37
+ nRows: 7
38
+ azimuth: 180
39
+ tilt: 30
40
+ clearance_height: 0.7
41
+ hub_height: 2.35
42
+ axis_azimuth: 180
43
+
44
+ [trackingParamsDict]
45
+ backtrack: True
46
+ limit_angle: 60
47
+ angle_delta: 30
48
+
49
+ [torquetubeParamsDict]
50
+ diameter: 0.10
51
+ tubetype: Hex
52
+ torqueTubeMaterial: Metal_Grey
53
+
54
+ [analysisParamsDict]
55
+ sensorsy: 9
56
+ modWanted: 10
57
+ rowWanted: 3
58
+
59
+ [cellLevelModuleParamsDict]
60
+ numcellsx: 12
61
+ numcellsy: 6
62
+ xcell: 0.150
63
+ ycell: 0.150
64
+ xcellgap: 0.100
65
+ ycellgap: 0.100
Binary file
@@ -0,0 +1,54 @@
1
+ The Radiance Software License, Version 1.0
2
+
3
+ Copyright (c) 1990 - 2018 The Regents of the University of California,
4
+ through Lawrence Berkeley National Laboratory. All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions
8
+ are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright
11
+ notice, this list of conditions and the following disclaimer.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in
15
+ the documentation and/or other materials provided with the
16
+ distribution.
17
+
18
+ 3. The end-user documentation included with the redistribution,
19
+ if any, must include the following acknowledgment:
20
+ "This product includes Radiance software
21
+ (http://radsite.lbl.gov/)
22
+ developed by the Lawrence Berkeley National Laboratory
23
+ (http://www.lbl.gov/)."
24
+ Alternately, this acknowledgment may appear in the software itself,
25
+ if and wherever such third-party acknowledgments normally appear.
26
+
27
+ 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
28
+ and "The Regents of the University of California" must
29
+ not be used to endorse or promote products derived from this
30
+ software without prior written permission. For written
31
+ permission, please contact radiance@radsite.lbl.gov.
32
+
33
+ 5. Products derived from this software may not be called "Radiance",
34
+ nor may "Radiance" appear in their name, without prior written
35
+ permission of Lawrence Berkeley National Laboratory.
36
+
37
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40
+ DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
41
+ ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48
+ SUCH DAMAGE.
49
+ ====================================================================
50
+
51
+ This software consists of voluntary contributions made by many
52
+ individuals on behalf of Lawrence Berkeley National Laboratory. For more
53
+ information on Lawrence Berkeley National Laboratory, please see
54
+ <http://www.lbl.gov/>.
@@ -0,0 +1,17 @@
1
+ CC = g++
2
+ CFLAGS = -D_XOPEN_SOURCE
3
+ INCLUDES = -lm
4
+ TARGET = gencumulativesky
5
+ SOURCES = *.cpp
6
+
7
+ all: $(TARGET)
8
+
9
+ $(TARGET): $(SOURCES)
10
+ $(CC) $(CFLAGS) $(SOURCES) $(INCLUDES) -o $(TARGET)
11
+
12
+ .PHONY : clean
13
+
14
+ clean:
15
+ rm -f $(TARGET) *.o
16
+
17
+
@@ -0,0 +1,9 @@
1
+ SOLAR RADIATION MAPPING
2
+ ========================
3
+ This is directory contains the source for the gencumulativesky program. To compile it using gcc:
4
+
5
+ g++ -D_XOPEN_SOURCE *.cpp -lm -o gencumulativesky
6
+
7
+ (The _XOPEN_SOURCE definition is required so that M_PI is defined when math.h is included - this will need changing depending on your compiler)
8
+
9
+ bifacial_radiance update Oct 2019: run python make_gencumskyexe.py from the command line to compile a platform-specific instance of gencumulativesky.exe
@@ -0,0 +1,118 @@
1
+ #include "Sun.h"
2
+
3
+ #define _USE_MATH_DEFINES
4
+ #include <math.h>
5
+ #include <stdio.h>
6
+
7
+ cSun::cSun (double latitude, int day, double hourangle, double meridian)
8
+ {
9
+ _latitude=latitude;
10
+ if (!this->SetDay(day))
11
+ this->SetDay(0);
12
+
13
+ if (!this->SetHourAngle(hourangle))
14
+ this->SetHourAngle(M_PI/2);
15
+ }
16
+
17
+ cSun::~cSun(void)
18
+ {
19
+ }
20
+
21
+ bool cSun::SetDay(int day)
22
+ {
23
+ if (day >=1 && day <=365)
24
+ {
25
+ _day=2.0*M_PI*(day-1.0)/365.0;
26
+ _declination = 0.006918 - 0.399912*cos(_day) + 0.070257*sin(_day)
27
+ - 0.006758*cos(2*_day) + 0.000907*sin(2*_day) - 0.002697*cos(3*_day)
28
+ + 0.00148*sin(3*_day);
29
+
30
+ CalculateSunrise();
31
+ return true;
32
+ }
33
+ else
34
+ return false;
35
+ }
36
+
37
+
38
+ bool cSun::SetLatitude(double latitude)
39
+ {
40
+ if (latitude >= -M_PI/2 && latitude <=M_PI/2)
41
+ {
42
+ _latitude = latitude;
43
+ CalculateSunrise();
44
+ return true;
45
+ }
46
+ else
47
+ return false;
48
+ }
49
+
50
+ bool cSun::SetHourAngle(double hourangle)
51
+ {
52
+ _hourangle=hourangle;
53
+ if (hourangle >= _sunrise && hourangle <= (2*M_PI - _sunrise))
54
+ {
55
+ return true;
56
+ }
57
+ else
58
+ return false;
59
+ }
60
+
61
+ void cSun::calculateAltitude()
62
+ {
63
+ _altitude=asin(sin(_latitude)*sin(_declination) - cos(_latitude)*cos(_declination)*cos(_hourangle));
64
+
65
+ }
66
+
67
+
68
+ void cSun::calculateAzimuth()
69
+ {
70
+ double temp;
71
+
72
+ temp = (-sin(_latitude)*sin(_altitude) + sin(_declination))/(cos(_latitude)*cos(_altitude));
73
+
74
+ if (temp > 1)
75
+ _azimuth=0;
76
+ else if (temp < -1)
77
+ _azimuth=M_PI;
78
+ else if (_hourangle < M_PI)
79
+ _azimuth=acos(temp);
80
+ else
81
+ _azimuth=2*M_PI - acos(temp);
82
+
83
+
84
+
85
+ }
86
+
87
+ void cSun::GetPosition(double &Alt, double &Az)
88
+ {
89
+ calculateAltitude();
90
+ calculateAzimuth();
91
+
92
+
93
+
94
+
95
+ Alt=_altitude;
96
+ Az=_azimuth;
97
+ }
98
+
99
+ void cSun::CalculateSunrise()
100
+ {
101
+ if (tan(_latitude)*tan(_declination)>=1)
102
+ _sunrise=0;
103
+ else if (tan(_latitude)*tan(_declination)<=-1)
104
+ _sunrise=M_PI;
105
+ else
106
+ _sunrise=acos(tan(_latitude)*tan(_declination));
107
+
108
+ }
109
+
110
+ double cSun::TimeDiff(double Longitude,double Meridian )
111
+ {
112
+ double Et;
113
+
114
+ Et = 229.2 * (0.000075 + 0.001868*cos(_day) - 0.032077*sin(_day) - 0.014615*cos(2*_day) - 0.04089*sin(2*_day));
115
+ return (-4*(Longitude-Meridian)*180./M_PI + Et)/60;
116
+
117
+
118
+ }
@@ -0,0 +1,45 @@
1
+ #define _USE_MATH_DEFINES
2
+ #include <math.h>
3
+ class cSun
4
+ {
5
+ public:
6
+ cSun (double latitude=54*2*M_PI/360, int day=1, double _hourangle=M_PI/2, double _meridian=0.0); // latitude in radians, day is integer 1-365
7
+ ~cSun(void);
8
+
9
+ bool SetDay(int day);
10
+ int GetDay() { return int((_day*365/(2*M_PI)) + 1); }
11
+
12
+ bool SetLatitude(double latitude);
13
+ double GetLatitude() { return _latitude; }
14
+
15
+ void SetMeridian(double meridian) { _meridian=meridian; }
16
+ double GetMeridian() { return _meridian; }
17
+
18
+ bool SetHourAngle(double hourangle);
19
+ double GetHourAngle() { return _hourangle; }
20
+
21
+ void GetPosition (double &Alt, double &Az);
22
+ double GetSunrise () { return _sunrise; }
23
+
24
+ // Difference between solar and clock time (add result to clock time to get solar)
25
+ // return value in hours, longitude in degrees(?)
26
+ double TimeDiff (double Longitude,double Meridian);
27
+
28
+ private:
29
+ // all of these angles stored in radians
30
+ double _altitude;
31
+ double _azimuth;
32
+ double _latitude;
33
+ double _hourangle;
34
+ double _declination;
35
+ double _sunrise;
36
+
37
+ double _meridian;
38
+
39
+ double _day;
40
+
41
+ void calculateAltitude();
42
+ void calculateAzimuth();
43
+ void CalculateSunrise();
44
+
45
+ };
@@ -0,0 +1,3 @@
1
+ BEGIN { sum=0; count =0; }
2
+ { sum=sum+$3; count=count+1 }
3
+ END {printf " %f\n",sum/count; }
@@ -0,0 +1,238 @@
1
+ #include "cPerezSkyModel.h"
2
+
3
+ #define _USE_MATH_DEFINES
4
+ #include <math.h>
5
+ #include <stdio.h>
6
+
7
+ // Perez all weather sky model coefficients
8
+ double cPerezSkyModel::m_a1[8]= {1.3525,-1.2219,-1.1000,-0.5484,-0.6000,-1.0156,-1.0000,-1.0500};
9
+ double cPerezSkyModel::m_a2[8]= {-0.2576,-0.7730,-0.2515,-0.6654,-0.3566,-0.3670,0.0211,0.0289};
10
+ double cPerezSkyModel::m_a3[8]= {-0.2690,1.4148,0.8952,-0.2672,-2.5000,1.0078,0.5025,0.4260};
11
+ double cPerezSkyModel::m_a4[8]= {-1.4366,1.1016,0.0156,0.7117,2.3250,1.4051,-0.5119,0.3590};
12
+ double cPerezSkyModel::m_b1[8]= {-0.7670,-0.2054,0.2782,0.7234,0.2937,0.2875,-0.3000,-0.3250};
13
+ double cPerezSkyModel::m_b2[8]= {0.0007,0.0367,-0.1812,-0.6219,0.0496,-0.5328,0.1922,0.1156};
14
+ double cPerezSkyModel::m_b3[8]= {1.2734,-3.9128,-4.5000,-5.6812,-5.6812,-3.8500,0.7023,0.7781};
15
+ double cPerezSkyModel::m_b4[8]= {-0.1233,0.9156,1.1766,2.6297,1.8415,3.3750,-1.6317,0.0025};
16
+ double cPerezSkyModel::m_c1[8]= {2.8000,6.9750,24.7219,33.3389,21.0000,14.0000,19.0000,31.0625};
17
+ double cPerezSkyModel::m_c2[8]= {0.6004,0.1774,-13.0812,-18.3000,-4.7656,-0.9999,-5.0000,-14.5000};
18
+ double cPerezSkyModel::m_c3[8]= {1.2375,6.4477,-37.7000,-62.2500,-21.5906,-7.1406,1.2438,-46.1148};
19
+ double cPerezSkyModel::m_c4[8]= {1.0000,-0.1239,34.8438,52.0781,7.2492,7.5469,-1.9094,55.3750};
20
+ double cPerezSkyModel::m_d1[8]= {1.8734,-1.5798,-5.0000,-3.5000,-3.5000,-3.4000,-4.0000,-7.2312};
21
+ double cPerezSkyModel::m_d2[8]= {0.6297,-0.5081,1.5218,0.0016,-0.1554,-0.1078,0.0250,0.4050};
22
+ double cPerezSkyModel::m_d3[8]= {0.9738,-1.7812,3.9229,1.1477,1.4062,-1.0750,0.3844,13.3500};
23
+ double cPerezSkyModel::m_d4[8]= {0.2809,0.1080,-2.6204,0.1062,0.3988,1.5702,0.2656,0.6234};
24
+ double cPerezSkyModel::m_e1[8]= {0.0356,0.2624,-0.0156,0.4659,0.0032,-0.0672,1.0468,1.5000};
25
+ double cPerezSkyModel::m_e2[8]= {-0.1246,0.0672,0.1597,-0.3296,0.0766,0.4016,-0.3788,-0.6426};
26
+ double cPerezSkyModel::m_e3[8]= {-0.5718,-0.2190,0.4199,-0.0876,-0.0656,0.3017,-2.4517,1.8564};
27
+ double cPerezSkyModel::m_e4[8]= {0.9938,-0.4285,-0.5562,-0.0329,-0.1294,-0.4844,1.4656,0.5636};
28
+ double cPerezSkyModel::m_PerezClearnessBin[8]={1.065,1.23,1.5,1.95,2.8,4.5,6.2,999999};
29
+
30
+ // Perez global luminous efficacy coefficients
31
+ double cPerezSkyModel::m_GlobLumEffya[8]={96.63,107.54,98.73,92.72,86.73,88.34,78.63,99.65};
32
+ double cPerezSkyModel::m_GlobLumEffyb[8]={-.47,.79,.7,.56,.98,1.39,1.47,1.86};
33
+ double cPerezSkyModel::m_GlobLumEffyc[8]={11.5,1.79,4.4,8.36,7.1,6.06,4.93,-4.46};
34
+ double cPerezSkyModel::m_GlobLumEffyd[8]={-9.16,-1.19,-6.95,-8.31,-10.94,-7.6,-11.37,-3.15};
35
+
36
+ // Perez diffuse luminous efficacy coefficients
37
+ double cPerezSkyModel::m_DiffLumEffya[8]={97.24,107.22,104.97,102.39,100.71,106.42,141.88,152.23};
38
+ double cPerezSkyModel::m_DiffLumEffyb[8]={-.46,1.15,2.96,5.59,5.94,3.83,1.90,.35};
39
+ double cPerezSkyModel::m_DiffLumEffyc[8]={12.0,.59,-5.53,-13.95,-22.75,-36.15,-53.24,-45.27};
40
+ double cPerezSkyModel::m_DiffLumEffyd[8]={-8.91,-3.95,-8.77,-13.9,-23.74,-28.83,-14.03,-7.98};
41
+
42
+ // Perez direct luminous efficacy coefficients
43
+ double cPerezSkyModel::m_BeamLumEffya[8]={57.2,98.99,109.83,110.34,106.36,107.19,105.75,101.18};
44
+ double cPerezSkyModel::m_BeamLumEffyb[8]={-4.55,-3.46,-4.90,-5.84,-3.97,-1.25,.77,1.58};
45
+ double cPerezSkyModel::m_BeamLumEffyc[8]={-2.98,-1.21,-1.71,-1.99,-1.75,-1.51,-1.26,-1.10};
46
+ double cPerezSkyModel::m_BeamLumEffyd[8]={117.12,12.38,-8.81,-4.56,-6.16,-26.73,-34.44,-8.29};
47
+
48
+ // TODO: check sunrise/sunset
49
+
50
+ cPerezSkyModel::cPerezSkyModel(void)
51
+ {
52
+ m_coefficientsset=false;
53
+ }
54
+
55
+ cPerezSkyModel::~cPerezSkyModel(void)
56
+ {
57
+ }
58
+
59
+ bool cPerezSkyModel::SetSkyConditions(double Idh, double Ibh, cSun *Sun)
60
+ {
61
+ double SolarZenith;
62
+ double Ibn;
63
+
64
+ double PerezBrightness, PerezClearness;
65
+ double E0,day_angle, AirMass;
66
+
67
+ int i, intClearness;
68
+
69
+ // if no sun, return no luminance
70
+ if (Idh <= 0)
71
+ {
72
+ m_a=0;
73
+ m_b=0;
74
+ m_c=0;
75
+ m_d=0;
76
+ m_e=0;
77
+ m_coefficientsset=true;
78
+ return false;
79
+ }
80
+
81
+ Sun->GetPosition(m_SolarAlt,m_SolarAz);
82
+
83
+ // store solar zenith
84
+ SolarZenith = M_PI/2 - m_SolarAlt;
85
+
86
+ // calculate clearness
87
+ if (m_SolarAlt > 0)
88
+ Ibn=Ibh/sin(m_SolarAlt);
89
+ else if (m_SolarAlt <=0 && Ibh>0)
90
+ {
91
+ // if there's direct horizontal radiation specified but sun is below horizon,
92
+ // lump it in with the diffuse
93
+ Idh=Idh+Ibh;
94
+ Ibn=0;
95
+ }
96
+ else
97
+ Ibn=0;
98
+
99
+ PerezClearness = ((Idh+Ibn)/Idh + 1.041*pow(SolarZenith,3))/(1+1.041*pow(SolarZenith,3));
100
+
101
+ // calculate brightness
102
+ // extra terrestrial radiation
103
+
104
+ // TODO: check IextraT and AirMass eqns with task 3 microclimate modelling paper
105
+ day_angle=Sun->GetDay()*2*M_PI/365;
106
+
107
+ E0 = 1367 * (1.00011+0.034221*cos(day_angle)+0.00128*sin(day_angle)
108
+ +0.000719*cos(2*day_angle)+0.000077*sin(2*day_angle));
109
+
110
+ // air optical mass
111
+ if (m_SolarAlt >= 10 * M_PI/180)
112
+ AirMass=1/sin(m_SolarAlt);
113
+ else
114
+ // AirMass=1/(sin(m_SolarAlt) + 0.15*pow(m_SolarAlt*180/M_PI + 3.885,-1.253));
115
+ AirMass=1/(sin(m_SolarAlt) + 0.50572*pow(180*m_SolarAlt/M_PI+6.07995,-1.6364));
116
+
117
+ // fix in case a very negative solar altitude is input
118
+ // if (m_SolarAlt*180/M_PI + 3.885 >=0)
119
+ if (m_SolarAlt*180/M_PI + 6.07995 >=0)
120
+ PerezBrightness=AirMass*Idh/E0;
121
+ else
122
+ {
123
+ // Idh is not zero, but sun altitude < 6 degrees, if Idh is very small (<10) neglect it
124
+ if (Idh <= 10)
125
+ {
126
+ m_a=0;
127
+ m_b=0;
128
+ m_c=0;
129
+ m_d=0;
130
+ m_e=0;
131
+ m_coefficientsset=true;
132
+ return false;
133
+ }
134
+
135
+ // Idh is > 10 and sun altitude v. low, flag up an error and blunder on anyway
136
+ fprintf(stderr,"Error! Solar altitude is %.0f < -6 degrees and Idh = %.0f > 10 W/m^2 on day %d !Ibn is %.0f. Attempting to continue!\n",m_SolarAlt*180/M_PI,Idh,Sun->GetDay(),Ibn);
137
+ PerezBrightness=0;
138
+ }
139
+
140
+ // TODO: Temporary bit!!!
141
+ if (PerezBrightness < 0.2 && (PerezClearness > 1.065 && PerezClearness < 2.8)) PerezBrightness=0.2;
142
+
143
+ // Now determine the model coefficients
144
+ // TODO: Error checking
145
+ if (PerezClearness <1)
146
+ {
147
+ //fprintf(stderr,"ERROR! CLEARNESS < 1\n");
148
+ return false;
149
+ }
150
+
151
+ // find which 'clearness bin' to use (note intClearness is set to one lower than the
152
+ // tradiational bin numbers (i.e. for clearness bin 1, intClearness=0)
153
+ for (i=7; i>=0; i--)
154
+ if (PerezClearness < m_PerezClearnessBin[i]) intClearness=i;
155
+
156
+ m_a = m_a1[intClearness] + m_a2[intClearness]*SolarZenith
157
+ + PerezBrightness*(m_a3[intClearness] + m_a4[intClearness]*SolarZenith);
158
+ m_b = m_b1[intClearness] + m_b2[intClearness]*SolarZenith
159
+ + PerezBrightness*(m_b3[intClearness] + m_b4[intClearness]*SolarZenith);
160
+ m_e = m_e1[intClearness] + m_e2[intClearness]*SolarZenith
161
+ + PerezBrightness*(m_e3[intClearness] + m_e4[intClearness]*SolarZenith);
162
+
163
+ if (intClearness > 0)
164
+ {
165
+ m_c = m_c1[intClearness] + m_c2[intClearness]*SolarZenith
166
+ + PerezBrightness*(m_c3[intClearness] + m_c4[intClearness]*SolarZenith);
167
+ m_d = m_d1[intClearness] + m_d2[intClearness]*SolarZenith
168
+ + PerezBrightness*(m_d3[intClearness] + m_d4[intClearness]*SolarZenith);
169
+ }
170
+ else
171
+ {
172
+ // different equations for c & d in clearness bin no. 1
173
+ m_c=exp(pow(PerezBrightness*(m_c1[intClearness] + m_c2[intClearness]*SolarZenith),m_c3[intClearness])) - 1;
174
+ m_d=-exp(PerezBrightness*(m_d1[intClearness] + m_d2[intClearness]*SolarZenith)) + m_d3[intClearness] + m_d4[intClearness]*PerezBrightness;
175
+ }
176
+
177
+ m_coefficientsset=true;
178
+ m_PerezClearness=PerezClearness;
179
+ m_IntPerezClearness=intClearness;
180
+ m_PerezBrightness=PerezBrightness;
181
+ return true;
182
+ }
183
+
184
+ double cPerezSkyModel::GetRelativeLuminance(double Alt, double Az)
185
+ {
186
+ double cosSkySunAngle;
187
+ double lv;
188
+
189
+ if (!m_coefficientsset)
190
+ {
191
+ // trying to use model without setting it up
192
+ printf("Attempt to use model before coefficients are set!\n");
193
+ return -1;
194
+ }
195
+
196
+ cosSkySunAngle= sin(Alt)*sin(m_SolarAlt) + cos(m_SolarAlt)*cos(Alt)*cos(fabs(Az-m_SolarAz));
197
+
198
+ lv=(1 + m_a*exp(m_b/sin(Alt))) * (1 + m_c*exp(m_d*acos(cosSkySunAngle)) + m_e*cosSkySunAngle*cosSkySunAngle);
199
+ if (lv < 0) lv=0;
200
+ return lv;
201
+ }
202
+
203
+ // TODO: Work out W properly!
204
+ // Td - three hourly surface dew point temp (degC)
205
+ double cPerezSkyModel::GetDiffuseLumEffy(double SolarAlt, double Td)
206
+ {
207
+ double W = 2.0;
208
+
209
+ return m_DiffLumEffya[m_IntPerezClearness] + m_DiffLumEffyb[m_IntPerezClearness]*W + m_DiffLumEffyc[m_IntPerezClearness]*sin(SolarAlt)
210
+ + m_DiffLumEffyd[m_IntPerezClearness]*log(m_PerezBrightness);
211
+ }
212
+
213
+ // Td - three hourly surface dew point temp (degC)
214
+ double cPerezSkyModel::GetBeamLumEffy(double SolarAlt, double Td)
215
+ {
216
+ double W = 2.0;
217
+ double BeamLumEffy=m_BeamLumEffya[m_IntPerezClearness] + m_BeamLumEffyb[m_IntPerezClearness]*W + m_BeamLumEffyc[m_IntPerezClearness]*exp(5.73*(M_PI/2-SolarAlt)-5)
218
+ + m_BeamLumEffyd[m_IntPerezClearness]*m_PerezBrightness;
219
+
220
+ if (BeamLumEffy>0)
221
+ return BeamLumEffy;
222
+ else
223
+ return 0;
224
+ }
225
+
226
+ // Td - three hourly surface dew point temp (degC)
227
+ double cPerezSkyModel::GetGlobalLumEffy(double SolarAlt, double Td)
228
+ {
229
+ double W = 2.0;
230
+ double GlobLumEffy=m_GlobLumEffya[m_IntPerezClearness] + m_GlobLumEffyb[m_IntPerezClearness]*W + m_GlobLumEffyc[m_IntPerezClearness]*sin(SolarAlt)
231
+ + m_GlobLumEffyd[m_IntPerezClearness]*log(m_PerezBrightness);
232
+ // careful we don't return a negative efficacy!
233
+
234
+ if (GlobLumEffy>0)
235
+ return GlobLumEffy;
236
+ else
237
+ return 0;
238
+ }
@@ -0,0 +1,57 @@
1
+ #include "Sun.h"
2
+ class cPerezSkyModel
3
+ {
4
+
5
+ public:
6
+ cPerezSkyModel(void);
7
+ virtual ~cPerezSkyModel(void);
8
+
9
+ // return whether or not it was succesful
10
+ // cSun object should be set up in the correct position before calling
11
+ virtual bool SetSkyConditions(double Idh, double Ibh, cSun *Sun);
12
+ virtual double GetRelativeLuminance(double Alt, double Az);
13
+ virtual double GetDiffuseLumEffy(double SolarAlt, double Td);
14
+ virtual double GetGlobalLumEffy(double SolarAlt, double Td);
15
+ virtual double GetBeamLumEffy(double SolarAlt, double Td);
16
+
17
+ double GetSkyClearness() { return m_PerezClearness; }
18
+
19
+ private:
20
+ double m_SolarAlt, m_SolarAz; // in radians
21
+
22
+ // used to make sure we don't return a luminance before model is set up
23
+ bool m_coefficientsset;
24
+
25
+ // model coefficients
26
+ // TODO: probably shouldn't declare these as static, but need to find a way
27
+ // to initialise them
28
+ static double m_a1[8], m_a2[8], m_a3[8], m_a4[8];
29
+ static double m_b1[8], m_b2[8], m_b3[8], m_b4[8];
30
+ static double m_c1[8], m_c2[8], m_c3[8], m_c4[8];
31
+ static double m_d1[8], m_d2[8], m_d3[8], m_d4[8];
32
+ static double m_e1[8], m_e2[8], m_e3[8], m_e4[8];
33
+ static double m_PerezClearnessBin[8];
34
+
35
+ // Perez global luminous efficacy coefficients
36
+ static double m_GlobLumEffya[8];
37
+ static double m_GlobLumEffyb[8];
38
+ static double m_GlobLumEffyc[8];
39
+ static double m_GlobLumEffyd[8];
40
+
41
+ // Perez diffuse luminous efficacy coefficients
42
+ static double m_DiffLumEffya[8];
43
+ static double m_DiffLumEffyb[8];
44
+ static double m_DiffLumEffyc[8];
45
+ static double m_DiffLumEffyd[8];
46
+
47
+ // Perez direct luminous efficacy coefficients
48
+ static double m_BeamLumEffya[8];
49
+ static double m_BeamLumEffyb[8];
50
+ static double m_BeamLumEffyc[8];
51
+ static double m_BeamLumEffyd[8];
52
+
53
+ double m_a,m_b,m_c,m_d,m_e;
54
+ double m_PerezClearness;
55
+ int m_IntPerezClearness;
56
+ double m_PerezBrightness;
57
+ };