LandscapeDNDC 1.37.0
watercycle-dndc.h
1
2#ifndef LM_WATERCYCLE_DNDC_H_
3#define LM_WATERCYCLE_DNDC_H_
4
5#include "mbe_legacymodel.h"
6#include "state/mbe_state.h"
7#include "ld_shared.h"
8
9#include "ld_eventqueue.h"
10#include "eventhandler/flood/flood.h"
11
12#include "watercycle/ld_icesnow.h"
13
14namespace ldndc {
15
20class LDNDC_API WatercycleDNDC : public MBE_LegacyModel
21{
22 LMOD_EXPORT_MODULE_INFO(WatercycleDNDC,"watercycle:watercycledndc","WatercycleDNDC");
23
24public:
26 static const unsigned int IMAX_W;
27
28public:
29 WatercycleDNDC( MoBiLE_State *,
30 cbm::io_kcomm_t *,
31 timemode_e);
32
34
35 lerr_t configure( ldndc::config_file_t const *);
36 lerr_t register_ports( cbm::io_kcomm_t *);
37 lerr_t initialize();
38
39 lerr_t solve();
40
41 lerr_t unregister_ports( cbm::io_kcomm_t *);
42 lerr_t finalize();
43
44 lerr_t sleep();
45 lerr_t wake();
46
47private:
48 cbm::io_kcomm_t * m_iokcomm;
49
50 input_class_groundwater_t const * m_groundwater;
51 input_class_climate_t const * m_climate;
52 input_class_setup_t const * m_setup;
53 input_class_siteparameters_t const * m_sipar;
54 input_class_soillayers_t const * m_soillayers;
55
56 MoBiLE_PlantVegetation * m_veg;
57
58 substate_soilchemistry_t & sc_;
59 substate_watercycle_t & wc_;
60 substate_microclimate_t & mc_;
61 substate_physiology_t & ph_;
62
63 struct cfg_t
64 {
65 bool snowpack:1;
66 bool icecontent:1;
67 cbm::string_t potentialevapotranspiration_method;
68 cbm::string_t evapotranspiration_method;
69 double automaticirrigation; // automatically triggers irrigation in order to avoid drought stress
70 bool ggcmi_irrigation; //at the start of each day magically reset water level to field capacity (if below)
71 };
72 struct cfg_t m_cfg;
73
74 struct StateMicroclimate
75 {
76 /*in*/
77 double air_temperature_below_canopy;
78 double precipitation;
79
80 /*in/out*/
81 CBM_Vector<double> soil_temperature_sl;
82 };
83 StateMicroclimate m_mc;
84
85 struct StateWatercycle
86 {
87 double accumulated_irrigation_event_executed;
88 double irrigation;
89
90 CBM_Vector<double> percolation_sl;
91 };
92 StateWatercycle m_wc;
93
94private:
95
96 lerr_t receive_state();
97 lerr_t send_state();
98
99 WaterCycleSnowDNDC m_snowdndc;
100 WaterCycleSnowDNDC::IceContentStateIn m_icecontent_in;
101 WaterCycleSnowDNDC::IceContentStateOut m_icecontent_out;
102
103 EventHandlerFlood m_eventflood;
104
105 SubscribedEvent<LD_EventHandlerQueue> m_ManureEvents;
106 SubscribedEvent<LD_EventHandlerQueue> m_IrrigationEvents;
107
108private:
109
110 size_t nwc; // number of loops per time step
111 double nhr; // number of hours per internal loop
112
113 /* water fluxes */
114 double day_potevapo; // daily potential evapotranspiration from air demand [m]
115 double hr_pot_evapotrans; // hourly potential evapotranspiration (derived from daily potential evapotranspiration) [m]
116 double hr_throughfall;
117 double potentialtranspiration; // hourly potential transpiration (derived from differently calculated potential demand considering also plant conductance) [m]
118 double accumulated_potentialtranspiration_ts_old; // accumulated potential transpiration at the last time step [m]
119 double accumulated_potentialtranspiration_nd_old; // accumulated potential transpiration at the last day [m]
120
121 double max_percolation; // maximum water percolation rate during flooding event
122
123 /* state variables */
124 double leaf_dryfraction; // fraction of leaves uncovered with water
125 double ground_water_table; // ground water table depth below the soil surface [m]
126
127 CBM_Vector<double> transpiration_ts;
128 CBM_Vector<double> pot_evapotranspiration_ts;
129
135
136 /********************/
137 /* member functions */
138 /********************/
139
144 lerr_t event_irrigate();
145
152 lerr_t event_flood();
153
158 double balance_check( double * /*old balance (in=NULL, out!=NULL)*/);
159
164 void CalcRaining( unsigned int);
165
166 double rainfall_intensity();
167
172 void CalcIrrigation( unsigned int);
173
174 lerr_t CalcSnowPack();
175
176 lerr_t CalcIceContent();
177
212 lerr_t CalcPotEvapoTranspiration( );
213
235
241 double get_leaf_water();
242
247 double get_impedance_factor( size_t /* soil layer */);
248
255
261 lerr_t CalcTranspirationCouvreur( double const &hr_potTransinm /* potential transpiration */);
262
268 void CalcSnowEvaporation();
269
275 void CalcSurfaceWaterEvaporation();
276
282 void CalcSurfaceFlux();
283
289 void WatercycleDNDC_preferential_flow();
290
296 void CalcSoilEvapoPercolation();
297
303 void SoilWaterEvaporation( size_t);
304
309 double WaterFlowBelowFieldCapacity( size_t /* layer */,
310 double const & /* impedance factor */);
311
317 double WaterFlowCapillaryRise( size_t /* layer */,
318 double const & /* impedance factor */);
319
324 double WaterFlowAboveFieldCapacity( size_t /* layer */,
325 double const & /* impedance factor */);
326
331 double WaterFlowSaturated( size_t /* layer */,
332 double const & /* impedance factor */);
333
338 double Soillayerwaterhead( size_t /* soil layer */);
339
344 double get_fsl( size_t /* soil layer */);
345
350 double get_time_step_duration();
351
352 size_t hours_per_time_step();
353
354};
355} /*namespace ldndc*/
356
357#endif /* !LM_WATERCYCLE_DNDC_H_ */
Watercycle model WatercycleDNDC.
Definition: watercycle-dndc.h:21
static const unsigned int IMAX_W
Definition: watercycle-dndc.h:26
void CalcInterception()
Calculates water quantity that is retained on leaf and stem bark surfaces.
double thornthwaite_heat_index
heat index for potential evaporation using approach after Thornthwaite
Definition: watercycle-dndc.h:134
Spatially explicit groundwater model.
Definition: airchemistryput.h:15