LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
watercycle-dndc.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 */
6
7#ifndef LM_WATERCYCLE_DNDC_H_
8#define LM_WATERCYCLE_DNDC_H_
9
10#include "mbe_legacymodel.h"
11#include "state/mbe_state.h"
12#include "ld_shared.h"
13
14#include "ld_eventqueue.h"
15#include "eventhandler/flood/flood.h"
16
17#include "watercycle/ld_icesnow.h"
18
19namespace ldndc {
20
25class LDNDC_API WatercycleDNDC : public MBE_LegacyModel
26{
27 LMOD_EXPORT_MODULE_INFO(WatercycleDNDC,"watercycle:watercycledndc","WatercycleDNDC");
28
29public:
30 WatercycleDNDC( MoBiLE_State *,
31 cbm::io_kcomm_t *,
32 timemode_e);
33
34 ~WatercycleDNDC();
35
36 lerr_t configure( ldndc::config_file_t const *);
37 lerr_t register_ports( cbm::io_kcomm_t *);
38 lerr_t initialize();
39
40 lerr_t solve();
41
42 lerr_t unregister_ports( cbm::io_kcomm_t *);
43 lerr_t finalize();
44
45 lerr_t sleep();
46 lerr_t wake();
47
48private:
49 cbm::io_kcomm_t * m_iokcomm;
50
51 input_class_groundwater_t const * m_groundwater;
52 input_class_climate_t const * m_climate;
53 input_class_setup_t const * m_setup;
54 input_class_siteparameters_t const * m_sipar;
55 input_class_soillayers_t const * m_soillayers;
56
57 MoBiLE_PlantVegetation * m_veg;
58
59 substate_soilchemistry_t & sc_;
60 substate_watercycle_t & wc_;
61 substate_microclimate_t & mc_;
62 substate_physiology_t & ph_;
63
64 struct cfg_t
65 {
66 bool snowpack:1;
67 bool icecontent:1;
68 cbm::string_t potentialevapotranspiration_method;
69 cbm::string_t evapotranspiration_method;
70 bool longwaveradiation_from_input:1; // take incoming long-wave radiation from the climate input
71 double automaticirrigation; // automatically triggers irrigation in order to avoid drought stress
72 bool ggcmi_irrigation; //at the start of each day magically reset water level to field capacity (if below)
73 };
74 struct cfg_t m_cfg;
75
76 struct StateMicroclimate
77 {
78 /*in*/
79 double air_temperature_below_canopy;
81 double precipitation;
83 double precipitation_ts;
84
85 /*in/out*/
86 CBM_Vector<double> soil_temperature_sl;
87 };
88 StateMicroclimate m_mc;
89
90 struct StateWatercycle
91 {
92 double accumulated_irrigation_event_executed;
93 double irrigation;
94
95 CBM_Vector<double> percolation_sl;
96 };
97 StateWatercycle m_wc;
98
99private:
100
101 lerr_t receive_state();
102 lerr_t send_state();
103
104 WaterCycleSnowDNDC m_snowdndc;
105 WaterCycleSnowDNDC::IceContentStateIn m_icecontent_in;
106 WaterCycleSnowDNDC::IceContentStateOut m_icecontent_out;
107
108 EventHandlerFlood m_eventflood;
109
110 SubscribedEvent<LD_EventHandlerQueue> m_ManureEvents;
111 SubscribedEvent<LD_EventHandlerQueue> m_IrrigationEvents;
112
113private:
114
115 /* each model time step is calculated in substeps of (at most) one hour.
116 * note: variables with prefix "hr_" refer to the current substep
117 * (which equals one hour only for hourly or daily time resolution)
118 */
119 size_t substeps_per_timestep; // number of substeps per model time step
120 double substep_hours; // length of a substep [h]
121
122 /* water fluxes */
123 double day_potevapo; // daily potential evapotranspiration from air demand [m]
124 double hr_pot_evapotrans; // potential evapotranspiration of the current substep (derived from daily potential evapotranspiration) [m]
125 double hr_throughfall;
126 double potentialtranspiration; // hourly potential transpiration (derived from differently calculated potential demand considering also plant conductance) [m]
127 double accumulated_potentialtranspiration_ts_old; // accumulated potential transpiration at the last time step [m]
128 double accumulated_potentialtranspiration_nd_old; // accumulated potential transpiration at the last day [m]
129
130 double max_percolation; // maximum water percolation rate during flooding event
131
132 /* state variables */
133 double leaf_dryfraction; // fraction of leaves uncovered with water
134 double ground_water_table; // ground water table depth below the soil surface [m]
135
136 CBM_Vector<double> transpiration_ts;
137 CBM_Vector<double> pot_evapotranspiration_ts;
138
144
145 /********************/
146 /* member functions */
147 /********************/
148
153 lerr_t event_irrigate();
154
161 lerr_t event_flood();
162
167 double balance_check( double * /*old balance (in=NULL, out!=NULL)*/);
168
173 void CalcRaining( unsigned int);
174
175 double rainfall_intensity();
178
183 void CalcIrrigation( unsigned int);
184
185 lerr_t CalcSnowPack();
186
187 lerr_t CalcIceContent();
188
223 lerr_t CalcPotEvapoTranspiration( size_t /* substep */);
224
246
252 double get_leaf_water();
253
258 double get_impedance_factor( size_t /* soil layer */);
259
266
272 lerr_t CalcTranspirationCouvreur( double const & /* possible transpiration [m] */, double & /* actual root water uptake [m] */);
273
279 void CalcSnowEvaporation();
280
287
293 void CalcSurfaceFlux();
294
301
308
314 void SoilWaterEvaporation( size_t);
315
320 double WaterFlowBelowFieldCapacity( size_t /* layer */,
321 double const & /* impedance factor */);
322
328 double WaterFlowCapillaryRise( size_t /* layer */,
329 double const & /* impedance factor */);
330
335 double WaterFlowAboveFieldCapacity( size_t /* layer */,
336 double const & /* impedance factor */);
337
342 double WaterFlowSaturated( size_t /* layer */,
343 double const & /* impedance factor */);
344
349 double Soillayerwaterhead( size_t /* soil layer */);
350
355 double get_fsl( size_t /* soil layer */);
356
361 double substep_day_fraction();
362
367 double
368 get_clay_limitation( size_t _sl,
369 double _water_avail,
370 double _water_ref);
371
373 double hours_per_time_step();
374
375};
376} /*namespace ldndc*/
377
378#endif /* !LM_WATERCYCLE_DNDC_H_ */
double get_fsl(size_t)
Returns factor accounting for soil layer depth. Originally, a constant soil layer depth of 0....
Definition watercycle-dndc.cpp:2546
lerr_t solve()
Kicks off computation for one time step.
Definition watercycle-dndc.cpp:509
void CalcSnowEvaporation()
Definition watercycle-dndc.cpp:2018
double rainfall_intensity_cache
Definition watercycle-dndc.h:177
double WaterFlowAboveFieldCapacity(size_t, double const &)
Definition watercycle-dndc.cpp:2368
lerr_t CalcTranspirationCouvreur(double const &, double &)
Definition watercycle-dndc.cpp:1860
double rainfall_intensity()
Definition watercycle-dndc.cpp:109
double WaterFlowCapillaryRise(size_t, double const &)
Similar to WaterFlowBelowFieldCapacity(...) but restricts water flow by water availability from soil ...
Definition watercycle-dndc.cpp:2419
void CalcSurfaceFlux()
Definition watercycle-dndc.cpp:2574
void CalcRaining(unsigned int)
apportion daily rainfall to subdaily rainfall
Definition watercycle-dndc.cpp:767
double hours_per_time_step()
Definition watercycle-dndc.cpp:2699
void SoilWaterEvaporation(size_t)
Definition watercycle-dndc.cpp:2079
lerr_t CalcIceContent()
Call of ice-content related processes.
Definition watercycle-dndc.cpp:1442
double get_leaf_water()
Collects leaf water from all canopy layers.
Definition watercycle-dndc.cpp:1210
void CalcInterception()
Calculates water quantity that is retained on leaf and stem bark surfaces.
void CalcSurfaceWaterEvaporation()
Definition watercycle-dndc.cpp:1985
lerr_t event_irrigate()
considers water input due to irrigation and/or liquid manure evetns
Definition watercycle-dndc.cpp:805
double balance_check(double *)
checks each time step for correct water balance
Definition watercycle-dndc.cpp:2651
double thornthwaite_heat_index
heat index for potential evaporation using approach after Thornthwaite
Definition watercycle-dndc.h:143
void CalcIrrigation(unsigned int)
apportion daily irrigation to subdaily irrigation
Definition watercycle-dndc.cpp:900
lerr_t event_flood()
sets hydrologic conditions during flooding events, e.g.,
Definition watercycle-dndc.cpp:871
double substep_day_fraction()
Length of a substep as fraction of a day.
Definition watercycle-dndc.cpp:2640
lerr_t CalcPotEvapoTranspiration(size_t)
Potential evaporation.
Definition watercycle-dndc.cpp:604
void CalcSoilEvapoPercolation()
Definition watercycle-dndc.cpp:2150
double get_impedance_factor(size_t)
Reduces water fluxes out of a layer if ice lenses have formed.
Definition watercycle-dndc.cpp:2525
double get_clay_limitation(size_t _sl, double _water_avail, double _water_ref)
Restrains water availability due to clay content.
Definition watercycle-dndc.cpp:2710
void WatercycleDNDC_preferential_flow()
Definition watercycle-dndc.cpp:2463
Spatially explicit groundwater model.
Definition airchemistryput.h:21