LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
canopyecm.h
1/*
2 * SPDX-FileCopyrightText: Karlsruhe Institute of Technology (KIT)
3 * SPDX-License-Identifier: LicenseRef-LandscapeDNDC
4 * This file is part of LandscapeDNDC. See LICENSE.
5 */
15
16#ifndef LM_MICROCLIMATE_CANOPY_ECM_H_
17#define LM_MICROCLIMATE_CANOPY_ECM_H_
18
19#include <vector>
20#include "mbe_legacymodel.h"
21#include "state/mbe_state.h"
22
23namespace ldndc {
24
25
26class LDNDC_API MicroClimateCanopyECM : public MBE_LegacyModel
27{
28 LMOD_EXPORT_MODULE_INFO(MicroClimateCanopyECM,"microclimate:canopyecm","Microclimate CanopyECM");
29
33 static const double QMASSAREA;
35 static const double EXPW;
37 static const double ROUGH;
39 static const double FEXT_W;
40
42 static const double FLITALB;
44 static const double FSNOWALB;
46 static const double HSNOWALB;
47
49 static const size_t DEEP_NODES_MAX;
51 static const double DEEP_NODES_GROWTH;
52
53public:
54 MicroClimateCanopyECM(
55 MoBiLE_State *,
56 cbm::io_kcomm_t *,
57 timemode_e);
58
59 ~MicroClimateCanopyECM();
60
61
62 lerr_t configure( ldndc::config_file_t const *);
63
64 lerr_t initialize();
65
66 lerr_t solve();
67
68 lerr_t finalize() { return LDNDC_ERR_OK; }
69
70 lerr_t sleep() { return LDNDC_ERR_OK; }
71 lerr_t wake() { return LDNDC_ERR_OK; }
72
73private:
74 input_class_setup_t const & se_;
75 substate_watercycle_t const & wc_;
76 substate_microclimate_t & mc_;
77 substate_physiology_t const & ph_;
78
79 MoBiLE_PlantVegetation * m_veg;
80
81 input_class_climate_t const & climate_;
82 input_class_soillayers_t const & sl_;
83 substate_soilchemistry_t const & sc_;
84
85 substate_surfacebulk_t & sbl_;
86
87 solver_tridiagonal_t tdma_solver_;
88
89 /* pointer to daily or subdaily state items */
90 /* radiation per canopy layer (temporarly unit-converted) [W m-2] */
91 lvector_t< double > loc_lw_rad_down_fl;
92 lvector_t< double > loc_lw_rad_up_fl;
93 lvector_t< double > loc_sw_rad_fl;
94 lvector_t< double > loc_sw_rad_refl_fl;
95 double loc_sw_rad_refl_a;
96 /* short wave radiation absorbed per canopy layer [W m-2 ground] */
97 lvector_t< double > loc_sw_rad_abs_fl;
98 lvector_t< double > f_area_fl;
99 lvector_t< double > lai_fl;
100 lvector_t< double > loc_temp_fl;
101 lvector_t< double > loc_fsun_fl;
102 lvector_t< double > loc_parshd_fl;
103 lvector_t< double > loc_parsun_fl;
104 lvector_t< double > loc_vpd_fl;
105 lvector_t< double > loc_rh_fl;
106 lvector_t< double > loc_win_fl;
107
108 bool al_new; // if additional layers above soil occur the first time ala_new is true, else false;
109
110 double * temp_old_sl; // old soil temperature for soil layers
111 double * temp_old_sbl; // old soil temperature for bulk surface layers (snow or water)
112
113 double * hcap_sl; // volumetric heat capacity of the soil layer (J K-1 m-2)
114 double * lambda_sl; // heat conductivity (J K-1 m-1 s-1)
115
116 double * h_extended_sl; // extends the last soil layer for more realistic lower boundary condition of constant annual temp
117 double * som_extended_sl;
118 double * min_extended_sl;
119
120 bool dirichletboundarycondition;
121 double annual_average_temperature;
122
123 double domainextension;
124 bool energybalance;
125
126 /* heat conduction nodes below the soil profile (no water, no matter) */
127 double soilthermaldepth; // depth of the lower boundary (m)
128 std::vector< double > h_deep; // thickness of the nodes (m)
129 std::vector< double > temp_deep; // temperature of the nodes (oC)
130
131 double accumulated_evapotranspiration_canopy;
132 double accumulated_evapotranspiration_soil;
133
134 /* outgoing (reflected) short wave radiation [W m-2] */
135 double loc_sw_rad_out;
136
137 /* outgoing long wave radiation [W m-2] */
138 double loc_lw_rad_out;
139
140 /* outgoing sensible heat [W m-2] */
141 double loc_sensible_heat_out_top;
142 double loc_sensible_heat_out_bottom;
143
144 /* radiation above litter [W m-2] */
145 double loc_rad_a;
146 double loc_temp_a;
147 double loc_rad_sw;
148 double loc_rad_lw;
149 double loc_temp;
150 double loc_win;
151 double loc_vpd;
152 double loc_fdif;
153 double loc_sinb;
154
156 double lai_sum;
157
158 // parameter aggregation
159 double fdrag;
160
161
162 lerr_t CanopyECM_step_init();
163 lerr_t CanopyECM_step_out();
164
165 void CalcTemperature();
166
172 void SetupDeepNodes();
173 void SetLowerBoundary( size_t /* lowest soil layer */, size_t /* row in equation system */);
174 void GetDeepNodesSolution( size_t /* first row in equation system */);
175
176 lerr_t CalcSoilTemperature_implicite(
177 lvector_t< double > & /*soil temperatures*/,
178 double /*average temperature above canopy*/,
179 double &/*average temperature above litter*/);
180
181 lerr_t CalcSoilTemperature_implicite_extended(
182 lvector_t< double > & /*soil temperatures*/,
183 double /*average temperature above canopy*/,
184 double &/*average temperature above litter*/);
185
186
200 void CalcShortwaveRadiation();
201
206 void CalcShortwaveRadiation_instantaneous( double /* short wave radiation */,
207 double /* diffuse fraction */,
208 double /* sine of solar elevation */);
209
210
218 void CalcHumidity();
219
229 void CalcWindspeed();
230
236 void CalcAlbedo();
237
243 double foliage_layer_heat_capacity( size_t /* foliage layer*/);
244
250 double get_canopy_energy();
251
252 double get_surface_bulk_energy();
253
254 double get_soil_energy( lvector_t< double > & /* soil temperature */);
255
261 double get_lai_fraction( size_t /* foliage layer */,
262 size_t /* no of foliage layer */);
263
269 double get_sky_view( double const & /* lai*/);
270
275 double time_steps_per_day();
276
282 double get_lw_radiation_down( double const & /* open area fraction top */,
283 double const & /* open area fraction */,
284 double const & /* leaf area index */,
285 double const & /* incoming longwave radiation */);
286};
287} /*namespace ldndc*/
288
289#endif /* !LDNDC_MOD_MICROCLIMATE_CANOPY_ECM_H_ */
290
Spatially explicit groundwater model.
Definition airchemistryput.h:21