Alpine3D 20241222.625fd38
SolarPanel.h
Go to the documentation of this file.
1#ifndef SOLARPANEL_H
2#define SOLARPANEL_H
3
4
5#include <meteoio/MeteoIO.h>
7#include <meteoio/dataClasses/Grid2DObject.h>
8
10
12
13 public:
15
16 SolarPanel(const mio::Config& cfg, const mio::DEMObject &dem_in, const std::vector<std::vector<double> > &pv_pts);
17
18 void setSP(const mio::Date timestamp, const double solarAzimuth, const double solarElevation);
19 void setGridRadiation(const mio::Array2D<double>& in_albedo, const mio::Array2D<double>& in_direct,
20 const mio::Array2D<double>& in_diffuse, const mio::Array2D<double>&
21 in_direct_unshaded_horizontal, const double solarAzimuth, const double solarElevation);
22
23 void initTerrain(size_t N_terrain_in, size_t M_terrain_in);
24 void setTLists(mio::Array4D<double> TList1, mio::Array4D<double> TList2, mio::Array4D<double> TList3, mio::Array4D<double> TList4);
25 void writeSP(const unsigned int max_steps);
26
27 private:
28 typedef double (SolarPanel::*minfun)(size_t, size_t, double, std::vector<double>);
29
30
31 // Initialisation Functions Functions
32 void getRadfield();
33 void writeHeader();
34
35 void initBasicSetHorizontal();
36 void initBasicSetRotated();
37 void initViewListPanel();
38 void initViewListTerrain();
39 void initShadelist();
40
41
42 // Essential Functions
43 size_t vectorToSPixel(std::vector<double> vec_in, size_t N, size_t M);
44 size_t vectorToSPixel(std::vector<double> vec_in, size_t number_pvp, size_t N, size_t M);
45 size_t vectorToSPixel(std::vector<double> vec_in, double inclination_panel, double azimuth_panel, size_t N, size_t M);
46 size_t vectorToSPixel(std::vector<double> vec_in, size_t ii_dem, size_t jj_dem, size_t which_triangle, size_t N, size_t M);
47
48 double IntersectionRayTriangle(std::vector<double> ray, size_t ii_PVP, size_t jj_PVP, double offset_PVP, size_t ii_dem, size_t jj_dem, int which_triangle);
49 bool doesPanelShadowPixel(std::vector<double> v_sun, size_t number_pvp, size_t number_solidangle);
50 double getLandViewFactor(size_t name_pvp);
51 double getSkyViewFactor(size_t name_pvp);
52
53
54 // Sum & Tracker Functions
55 void initSumPVP();
56 void readSumPVP();
57 mio::Array2D<double> initSListSumPVP(size_t ii, size_t jj, double height, std::vector<std::vector<double> > SVector_temp);
58
59 std::vector<double> projectSum(size_t ii, size_t jj, double height, double azimuth, double inclination);
60
61 std::vector<double> projectTracker(size_t ii, size_t jj, double height, double azimuth, double inclination);
62
63 std::vector<double> optimize(size_t ii, size_t jj, double height, size_t rounds, minfun f_min);
64 double minfun_MonoTracker(size_t ii, size_t jj, double height, std::vector<double> x);
65 double minfun_MonoStatic(size_t ii, size_t jj, double height, std::vector<double> x);
66
67
68 // auxiliary functions
69 std::vector<double> listindexToAngles(size_t index);
70 std::vector<double> NormalVectorToRotationAngles(std::vector<double> normal);
71 std::vector<double> RotationAnglesToNormalVector(double azimuth, double phi);
72 int get_ii(int number_pvp);
73 int get_jj(int number_pvp);
74 std::vector<double> TriangleNormal(size_t ii_dem, size_t jj_dem, int which_triangle);
75 std::vector<double> getVectorSun(const double solarAzimuth, const double solarElevation);
76
77
78 // Elementary functions
79 double AngleBetween2Vectors(std::vector<double> vec1, std::vector<double> vec2);
80 double NormOfVector(std::vector<double> vec1);
81 std::vector<double> normalizeVector(std::vector<double> vec1);
82 std::vector<double> ProjectVectorToPlane(std::vector<double> vec1, std::vector<double> plane_normal);
83 double VectorScalarProduct(std::vector<double> vec1, std::vector<double> vec2);
84 std::vector<double> VectorCrossProduct(std::vector<double> vec1, std::vector<double> vec2);
85
86 std::vector<double> VectorSum(std::vector<double> vec1, std::vector<double> vec2);
87 std::vector<double> VectorDifference(std::vector<double> vec1, std::vector<double> vec2);
88 std::vector<double> VectorStretch(std::vector<double> vec1, double factor);
89
90 std::vector<double> RotX(std::vector<double> vec_in, double rad);
91 std::vector<double> RotY(std::vector<double> vec_in, double rad);
92 std::vector<double> RotZ(std::vector<double> vec_in, double rad);
93 std::vector<double> RotN(std::vector<double> axis, std::vector<double> vec_in, double rad);
94
95
96 // Output functions for testing
97 void PrintVector(std::vector<double> vec1);
98 void RadiationMap(size_t ii, size_t jj, double elevation);
99 void GridRadiationMap(double offset);
100 void WriteOptimumTrackerRadiation(size_t number_pvp, std::string filename, const mio::Date timestamp);
101 void WriteSunTrackerRadiation(size_t number_pvp, std::string filename, const mio::Date timestamp);
102
103
104 size_t dimx, dimy;
105 size_t M_epsilon_panel, M_phi_panel; // sperical pixelcoordinates
106 size_t S_panel;
107 size_t M_epsilon_terrain, M_phi_terrain;
108 size_t S_terrain;
109 bool Terrain_complex_mode=false;
110 std::vector<double> v_globalsun;
111
112 mio::DEMObject dem;
113 std::vector<std::vector<double> > pv_points;
114 SnowBRDF BRDFobject;
115 mio::Timer timer;
116 mio::Array3D<size_t> Shadelist;
117 bool generate_PVP_sum;
118 bool sun_tracker;
119 bool optimal_tracker;
120
121 std::vector<std::vector<double> > BasicSet_horizontal; //Spherical-pixel vectors horizontal case
122 std::vector<std::vector<std::vector<double> > > BasicSet_rotated; //For each PVP a set of Spherical-pixel vectors according to inclination and azimuth of Pannel
123 std::vector<std::vector<std::vector<double> > > ViewList_panel; //For each Spherical-pixel (and for all PVP's), the ii.jj of the DEM-grid are assigned as well as the distance
124
125
126 std::vector<double> direct, diffuse, terrain_iso, terrain_aniso, terrain_ms, terrain_ms_noshadow, direct_beam;
127 mio::Array4D<double> TList_direct, TList_sky_iso, TList_sky_aniso, TList_ms;
128 mio::Array4D<double> TList_sum;
129 mio::Array3D<double> Direct_sum;
130 mio::Array2D<double> Diffuse_sum;
131
132 mio::Array2D<double> albedo;
133 mio::Array2D<double> d_direct_A, d_direct_B, d_diffuse, d_direct_unshaded_horizontal;
134 const mio::Date* dateobject;
135 std::vector<std::string> filenames;
136
137 bool if_shadowing=true;
138 size_t alpine_steps=0;
139
140};
141
142#endif
Definition: SnowBRDF.h:6
Definition: SolarPanel.h:11
void initTerrain(size_t N_terrain_in, size_t M_terrain_in)
Initializing interface between TerrainRadiationComplex and SolarPanel.
Definition: SolarPanel.cc:90
void writeSP(const unsigned int max_steps)
Writes unprojected average radiation to files.
Definition: SolarPanel.cc:377
void setGridRadiation(const mio::Array2D< double > &in_albedo, const mio::Array2D< double > &in_direct, const mio::Array2D< double > &in_diffuse, const mio::Array2D< double > &in_direct_unshaded_horizontal, const double solarAzimuth, const double solarElevation)
Updates grid Radiation (incoming SWR for all grid points): preparing TerrainRadiation if TerrainRadia...
Definition: SolarPanel.cc:113
SolarPanel()
Definition: SolarPanel.h:14
void setTLists(mio::Array4D< double > TList1, mio::Array4D< double > TList2, mio::Array4D< double > TList3, mio::Array4D< double > TList4)
Called by TerrainRadiationComplex, updates Terrain Lists. A Terrain List (TList) stores Radiance in a...
Definition: SolarPanel.cc:74
void setSP(const mio::Date timestamp, const double solarAzimuth, const double solarElevation)
Writes output for SolarPanels (PVP files), and updates the sum if generate_PVP_sum==true.
Definition: SolarPanel.cc:170