solarCalculator.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2017 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::solarCalculator
28 
29 Description
30  The solar calculator model provides information about the Sun direction
31  and Sun load model. The available models are:
32 
33  For the Sun direction:
34  1) SunDirConstant : the direction is given in 'sunDirection'
35  2) SunDirTracking : the direction is calculated from the following
36  parameters:
37  localStandardMeridian : GMT (Local Zone Meridian) in hours
38  startDay : day from 1 to 365)
39  startTime: in hours
40  longitude: in degrees
41  latitude: in degrees
42  gridUp: grid orientation upwards
43  gridEast grid orientation eastwards
44 
45  This model should be use in transient calculations.
46  The keyword 'sunTrackingUpdateInterval' (in hours) specifies on which
47  interval is the Sun direction updated.
48 
49 
50  Solar Load models available:
51  1) SunLoadConstant: direct and diffusive heat fluxes are provided by the
52  entries 'directSolarRad' and 'diffuseSolarRad'
53 
54  2) SunLoadFairWeatherConditions: The solar fluxes are calculated following
55  the Fair Weather Conditions Method from the ASHRAE Handbook. The entries
56  are:
57  skyCloudCoverFraction: Fraction of sky covered by clouds (0-1)
58  A : Apparent solar irradiation at air mass m = 0
59  B : Atmospheric extinction coefficient
60  beta: Solar altitude (in degrees) above the horizontal. This
61  can be read or calculated providing the respective parameters
62  for Sun position explained above.
63  groundReflectivity : ground reflectivity
64 
65  In this model the flux is calculated as:
66 
67  directSolarRad =
68  (1 - 0.75*skyCloudCoverFraction^3)*A/exp(B/sin(beta));
69 
70  3) SunLoadTheoreticalMaximum: The entries are:
71  Setrn
72  SunPrime:
73  groundReflectivity : ground reflectivity
74 
75  In this model the flux is calculated as:
76 
77  directSolarRad = Setrn*SunPrime;
78 
79  The diffuse on vertical/horizontal walls and ground-reflected radiation are
80  calculated following the ASHRAE Handbook.
81 
82 
83 SourceFiles
84  solarCalculator.C
85 
86 \*---------------------------------------------------------------------------*/
87 
88 #ifndef solarCalculator_H
89 #define solarCalculator_H
90 
91 #include "fvMesh.H"
92 #include "meshTools.H"
93 #include "DynamicField.H"
94 #include "HashSet.H"
95 #include "coordinateSystem.H"
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 namespace Foam
100 {
101 
102 /*---------------------------------------------------------------------------*\
103  Class solarCalculator Declaration
104 \*---------------------------------------------------------------------------*/
105 
106 class solarCalculator
107 {
108 public:
109 
110  // Public enumeration
111 
112  //- Sun direction models
113  enum sunDirModel
114  {
117  };
118 
119  //- Direct sun load models
120  enum sunLModel
121  {
125  };
126 
127 
128 protected:
129 
130  //- Sun direction models
132 
133  //- Sun load models
135 
136 
137 private:
138 
139  // Private data
140 
141 
142  //- Reference to mesh
143  const fvMesh& mesh_;
144 
145  //- Dictionary
146  dictionary dict_;
147 
148  //- Direction
149  vector direction_;
150 
151  //- Direct solar irradiation
152  scalar directSolarRad_;
153 
154  //- Diffuse solar irradiation on vertical surfaces
155  scalar diffuseSolarRad_;
156 
157  //- Ground reflectivity
158  scalar groundReflectivity_;
159 
160  //- Fair weather direct solar load model parameters
161  scalar A_;
162  scalar B_;
163  scalar beta_;
164  scalar theta_;
165 
166  //- Sky cloud cover fraction [0-1]
167  scalar skyCloudCoverFraction_;
168 
169 
170  //- Maximum theoretical direct solar load model parameters
171  scalar Setrn_;
172  scalar SunPrime_;
173 
174 
175  //- Diffusive solar load model parameters
176  scalar C_;
177 
178  //- Sun direction model
179  sunDirModel sunDirectionModel_;
180 
181  //- Sun load model
182  sunLModel sunLoadModel_;
183 
184  //- Grid coordinate system
186 
187  //- East grid orientation
188  vector eastDir_;
189 
190  //- Up grid orientation
191  vector gridUp_;
192 
193  //- Interval in decimal hours to update Sun direction for SunDirTracking
194  scalar sunTrackingUpdateInterval_;
195 
196  //- Start time for the Sun position (decimal hours)
197  scalar startTime_;
198 
199 
200  //- No copy construct
201  solarCalculator(const solarCalculator&) = delete;
202 
203  //- No copy assignment
204  void operator=(const solarCalculator&) = delete;
205 
206 
207  // Private members
208 
209  //- Init
210  void init();
211 
212  //- Calculate beta and theta angles
213  void calculateBetaTheta();
214 
215  //- Calculate Sun direction
216  void calculateSunDirection();
217 
218 
219 public:
220 
221  // Declare name of the class and its debug switch
222  ClassName("solarCalculator");
223 
224 
225  // Constructors
226 
227  //- Construct from dictionary
228  solarCalculator(const dictionary&, const fvMesh&);
229 
230 
231  //- Destructor
232  ~solarCalculator() = default;
233 
234 
235  // Member Functions
236 
237  // Access
238 
239  //- const access to direction
240  const vector& direction() const
241  {
242  return direction_;
243  }
244 
245  //- Non-const access to direction
246  vector& direction()
247  {
248  return direction_;
249  }
250 
251  //- Return direct solar irradiation
252  scalar& directSolarRad()
253  {
254  return directSolarRad_;
255  }
256 
257  //- Return const access to direct solar irradiation
258  const scalar& directSolarRad() const
259  {
260  return directSolarRad_;
261  }
262 
263  //- Return diffuse solar irradiation
264  scalar& diffuseSolarRad()
265  {
266  return diffuseSolarRad_;
267  }
268 
269  //- Return diffuse solar irradiation
270  const scalar& diffuseSolarRad() const
271  {
272  return diffuseSolarRad_;
273  }
274 
275  //- Return C constant
276  scalar C()
277  {
278  return C_;
279  }
280 
281  //- Return beta
282  scalar beta()
283  {
284  return beta_;
285  }
286 
287  //- Return theta
288  scalar theta()
289  {
290  return theta_;
291  }
292 
293  //- Return Sun direction model
295  {
296  return sunDirectionModel_;
297  }
298 
299  //- Return Sun load model
300  sunLModel sunLoadModel() const
301  {
302  return sunLoadModel_;
303  }
304 
305  //- Return groundReflectivity
306  scalar groundReflectivity()
307  {
308  return groundReflectivity_;
309  }
310 
311  //- Return coordinateSystem
312  const coordinateSystem& coord()
313  {
314  return *coord_;
315  }
316 
317  //- Return sunTrackingUpdateInterval
319  {
320  return sunTrackingUpdateInterval_;
321  }
322 
323  //- Return startTime
324  scalar startTime()
325  {
326  return startTime_;
327  }
328 
329 
330  //- Recalculate
331  void correctSunDirection();
332 };
333 
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 } // End namespace Foam
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #endif
342 
343 // ************************************************************************* //
meshTools.H
Foam::Enum< sunDirModel >
Foam::solarCalculator::sunTrackingUpdateInterval
scalar sunTrackingUpdateInterval()
Return sunTrackingUpdateInterval.
Definition: solarCalculator.H:317
Foam::solarCalculator::diffuseSolarRad
const scalar & diffuseSolarRad() const
Return diffuse solar irradiation.
Definition: solarCalculator.H:269
Foam::solarCalculator::directSolarRad
scalar & directSolarRad()
Return direct solar irradiation.
Definition: solarCalculator.H:251
Foam::solarCalculator::coord
const coordinateSystem & coord()
Return coordinateSystem.
Definition: solarCalculator.H:311
Foam::solarCalculator::~solarCalculator
~solarCalculator()=default
Destructor.
Foam::solarCalculator::directSolarRad
const scalar & directSolarRad() const
Return const access to direct solar irradiation.
Definition: solarCalculator.H:257
Foam::solarCalculator::mSunLoadFairWeatherConditions
Definition: solarCalculator.H:122
Foam::solarCalculator::startTime
scalar startTime()
Return startTime.
Definition: solarCalculator.H:323
coordinateSystem.H
Foam::solarCalculator::groundReflectivity
scalar groundReflectivity()
Return groundReflectivity.
Definition: solarCalculator.H:305
Foam::solarCalculator
The solar calculator model provides information about the Sun direction and Sun load model....
Definition: solarCalculator.H:105
Foam::solarCalculator::sunLModel
sunLModel
Direct sun load models.
Definition: solarCalculator.H:119
Foam::solarCalculator::C
scalar C()
Return C constant.
Definition: solarCalculator.H:275
Foam::solarCalculator::sunDirectionModel
sunDirModel sunDirectionModel() const
Return Sun direction model.
Definition: solarCalculator.H:293
HashSet.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::solarCalculator::mSunDirConstant
Definition: solarCalculator.H:114
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::solarCalculator::ClassName
ClassName("solarCalculator")
Foam::solarCalculator::correctSunDirection
void correctSunDirection()
Recalculate.
Definition: solarCalculator.C:271
DynamicField.H
Foam::solarCalculator::direction
vector & direction()
Non-const access to direction.
Definition: solarCalculator.H:245
Foam::solarCalculator::sunDirectionModelTypeNames_
static const Enum< sunDirModel > sunDirectionModelTypeNames_
Sun direction models.
Definition: solarCalculator.H:130
Foam::solarCalculator::mSunLoadTheoreticalMaximum
Definition: solarCalculator.H:123
Foam::Vector< scalar >
Foam::solarCalculator::direction
const vector & direction() const
const access to direction
Definition: solarCalculator.H:239
Foam::solarCalculator::theta
scalar theta()
Return theta.
Definition: solarCalculator.H:287
Foam::solarCalculator::beta
scalar beta()
Return beta.
Definition: solarCalculator.H:281
Foam::solarCalculator::sunDirModel
sunDirModel
Sun direction models.
Definition: solarCalculator.H:112
Foam::solarCalculator::sunLoadModelTypeNames_
static const Enum< sunLModel > sunLoadModelTypeNames_
Sun load models.
Definition: solarCalculator.H:133
Foam::solarCalculator::mSunDirTracking
Definition: solarCalculator.H:115
Foam::coordinateSystem
Base class for coordinate system specification, the default coordinate system type is cartesian .
Definition: coordinateSystem.H:122
Foam::solarCalculator::diffuseSolarRad
scalar & diffuseSolarRad()
Return diffuse solar irradiation.
Definition: solarCalculator.H:263
Foam::solarCalculator::sunLoadModel
sunLModel sunLoadModel() const
Return Sun load model.
Definition: solarCalculator.H:299
Foam::solarCalculator::mSunLoadConstant
Definition: solarCalculator.H:121