1.3.64
 
Loading...
Searching...
No Matches
EnergyBalanceModel.h
Go to the documentation of this file.
1
16#ifndef ENERGYBALANCEMODEL
17#define ENERGYBALANCEMODEL
18
19#include "Context.h"
20
21// -- constants -- //
22
24constexpr float cp_air_mol = 29.25f;
26constexpr float lambda_mol = 44000.f;
28constexpr float von_Karman_constant = 0.41f;
30constexpr float R = 8.314462618f;
31
32inline float esat_Pa(float T_K) {
33 float Tc = T_K - 273.15f;
34 // This is Clausius-Clapeyron equation (See Campbell and Norman pp. 41 Eq. 3.8). Note that temperature must be in Kelvin, and result is in Pascals
35 return 611.0f * expf(17.502f * Tc / (Tc + 240.97f));
36}
37
39
41public:
43
47
49
52 static int selfTest(int argc = 0, char **argv = nullptr);
53
55 void enableMessages();
56
58 void disableMessages();
59
61 void run();
62
64
67 void run(float dt);
68
70
73 void run(const std::vector<uint> &UUIDs);
74
76
80 void run(const std::vector<uint> &UUIDs, float dt);
81
83
86 void addRadiationBand(const char *band);
87
89
92 void addRadiationBand(const std::vector<std::string> &bands);
93
95
101
103
108 void enableAirEnergyBalance(float canopy_height_m, float reference_height_m);
109
111
115 void evaluateAirEnergyBalance(float dt_sec, float time_advance_sec);
116
118
123 void evaluateAirEnergyBalance(const std::vector<uint> &UUIDs, float dt_sec, float time_advance_sec);
124
126
129 void optionalOutputPrimitiveData(const char *label);
130
131#ifdef HELIOS_CUDA_AVAILABLE
133
137 void enableGPUAcceleration();
138
140
144 void disableGPUAcceleration();
145
147
150 bool isGPUAccelerationEnabled() const;
151#endif
152
154 void printDefaultValueReport() const;
155
157
160 void printDefaultValueReport(const std::vector<uint> &UUIDs) const;
161
162private:
163 void evaluateSurfaceEnergyBalance(const std::vector<uint> &UUIDs, float dt);
164
165#ifdef HELIOS_CUDA_AVAILABLE
167 void evaluateSurfaceEnergyBalance_GPU(const std::vector<uint> &UUIDs, float dt);
168
170 void initializeGPUAcceleration();
171#endif
172
174 void evaluateSurfaceEnergyBalance_CPU(const std::vector<uint> &UUIDs, float dt);
175
177 helios::Context *context;
178
179#ifdef HELIOS_CUDA_AVAILABLE
181 bool gpu_acceleration_enabled = false;
182#endif
183
185 float temperature_default;
186
188 float wind_speed_default;
189
191 float air_temperature_default;
192
194 float air_humidity_default;
195
197 float pressure_default;
198
200 float gS_default;
201
203 float heatcapacity_default;
204
206 float Qother_default;
207
209 float surface_humidity_default;
210
211 bool air_energy_balance_enabled;
212
214 helios::vec3 canopy_dimensions;
215
216 float canopy_height_m;
217 float reference_height_m;
218
220 bool message_flag;
221
223 std::vector<std::string> radiation_bands;
224
226 std::vector<std::string> output_prim_data;
227};
228
229#endif