LandscapeDNDC  1.36.0
ldndc::EcHy Class Reference

Watercycle model EcosystemHydrology - EcHy. More...

Inherits ldndc::MBE_LegacyModel.

Public Member Functions

lerr_t solve ()
 

Private Member Functions

lerr_t EcHyIrrigation ()
 Irrigation.
 
lerr_t EcHyFlood ()
 sets hydrologic conditions during flooding events, e.g., More...
 
lerr_t EcHyPercolation (size_t, size_t)
 Calculates water percolation within the soil profile.
 
lerr_t EcHyBypassFlow (double, double &)
 Calculates water percolation within the soil profile.
 
lerr_t EcHyEvapotranspiration ()
 Calculates evapotranspiration within the soil profile.
 
lerr_t EcHySubsl2 (double const &, double const &, int const &, double const &, double &)
 ... More...
 
lerr_t EcHyBalanceCheck (double &)
 ... More...
 
void EcHyreset ()
 ...
 
lerr_t EcHyGroundwater ()
 ... More...
 
lerr_t EcHyIntegration ()
 ... More...
 
lerr_t EcHyStepInit ()
 ...
 
lerr_t EcHyStepExit ()
 ...
 
double EcHyGetInterceptionCapacity ()
 ...
 
lerr_t EcHyCalculateLeafWaterDistribution (lvector_t< double > &)
 ...
 
lerr_t EcHyPotentialEvapotranspiration ()
 Calculates potential evapotranspiration. Specific concept can be given as model option.
 
lerr_t EcHySnowIce ()
 Calls SnowDNDC for the calculation of snowpack and soil ice formation.
 
double EcHyGetMinimumWater (size_t)
 ...
 
double EcHyGetWiltingPoint (size_t)
 ...
 
double EcHyGetAvailableWaterTranspiration (size_t)
 ...
 
double EcHyGetAvailableWaterEvaporation (size_t)
 ...
 
double EcHyGetRootLimitation (double)
 ...
 
double EcHyGetWaterLimitationTranspiration (double, size_t)
 ...
 
double EcHySoilWaterChange (size_t)
 

Private Attributes

double kst_bottom
 
double gw_depth_static
 
double accumulated_potentialtranspiration_old
 
double accumulated_irrigation_old
 
lvector_t< double > trwl_sl
 
lvector_t< double > wlfl_sl
 
lvector_t< double > cr_fill_sl
 
lvector_t< double > gw_fill_sl
 
lvector_t< double > bypass_fill_sl
 
lvector_t< double > wc_max_sl
 
lvector_t< double > wc_min_sl
 
lvector_t< double > evsws_sl
 
lvector_t< double > kst_sl
 
lvector_t< double > wl_sl
 
lvector_t< double > wlfc_sl
 
lvector_t< double > wlwp_sl
 
lvector_t< double > wlst_sl
 
double ev_leaf
 
double gw_fill_surface
 
double cr_fill_groundwater
 
double runoff
 
double snowfall
 
double throughfall
 
double interception_water
 
double thornthwaite_heat_index
 
double daily_potential_evapotranspiration
 
double daily_potential_leaf_evaporation
 
double daily_potential_soil_evaporation
 
double daily_potential_transpiration
 
WaterCycleSnowDNDC::IceContentStateIn m_icecontent_in
 
cbm::string_t evapotranspiration_method
 
cbm::string_t runoff_method
 

Detailed Description

Watercycle model EcosystemHydrology - EcHy.

Member Function Documentation

◆ EcHyBalanceCheck()

lerr_t ldndc::EcHy::EcHyBalanceCheck ( double &  _balance)
private

...

Checks balance between all incoming and outgoing water fluxes.

References cr_fill_groundwater, ev_leaf, evsws_sl, gw_fill_sl, gw_fill_surface, interception_water, runoff, snowfall, throughfall, trwl_sl, wl_sl, and wlfl_sl.

Referenced by solve().

449 {
450  double balance( interception_water + surface_water + surface_ice);
451  for ( size_t sl = 0; sl < soillayers_in->soil_layer_cnt(); ++sl)
452  {
453  balance += wl_sl[sl] + wc_.ice_sl[sl] * sc_.h_sl[sl];
454  }
455 
456  if ( _balance > 0.0)
457  {
458  balance += wlfl_sl[soillayers_in->soil_layer_cnt()]
459  + ev_leaf + evsws_sl.sum() + trwl_sl.sum() + runoff
461  - irrigation - throughfall - snowfall;
462 
463  double const balance_delta( std::abs( _balance - balance));
464  if ( cbm::flt_greater( balance_delta, 1.0e-4))
465  {
466  KLOGWARN( "Water leakage in: ", name(),
467  " Difference: ", balance - _balance);
468  return LDNDC_ERR_FAIL;
469  }
470  }
471  else
472  {
473  _balance = balance;
474  }
475 
476  return LDNDC_ERR_OK;
477 }
double gw_fill_surface
Definition: echy.h:127
double ev_leaf
Definition: echy.h:124
lvector_t< double > evsws_sl
Definition: echy.h:106
double cr_fill_groundwater
Definition: echy.h:130
double interception_water
Definition: echy.h:142
lvector_t< double > gw_fill_sl
Definition: echy.h:94
lvector_t< double > wl_sl
Definition: echy.h:112
double snowfall
Definition: echy.h:136
double runoff
Definition: echy.h:133
lvector_t< double > wlfl_sl
Definition: echy.h:88
double throughfall
Definition: echy.h:139
lvector_t< double > trwl_sl
Definition: echy.h:80
Here is the caller graph for this function:

◆ EcHyFlood()

lerr_t ldndc::EcHy::EcHyFlood ( )
private

sets hydrologic conditions during flooding events, e.g.,

Flooding.

  • surface water table
  • bund height

References kst_bottom, and kst_sl.

Referenced by solve().

18 {
19  lerr_t rc = m_eventflood.solve();
20  if ( rc != LDNDC_ERR_OK){ return rc; }
21 
22  bund_height = m_eventflood.get_bund_height();
23 
24  /* todo */
25  //irrigation_amount = m_eventflood.get_irrigation_amount();
26 
27  /* todo */
28  //double const irrigation_height = m_eventflood.get_irrigation_height();
29  double const max_percolation = m_eventflood.get_maximum_percolation();
30  double const water_table_flooding = m_eventflood.get_water_table();
31 
32 
33  irrigation_switch = NONE;
34  minimum_watertable_height = 0.0;
35  if ( cbm::is_valid( water_table_flooding))
36  {
37  if ( cbm::flt_greater_zero( water_table_flooding))
38  {
39  irrigation_switch = CONSTANT_POSITIVE_WATER_TABLE;
40  minimum_watertable_height = water_table_flooding;
41  bund_height = water_table_flooding;
42  }
43  else
44  {
45  irrigation_switch = CONSTANT_NEGATIVE_WATER_TABLE;
46  minimum_watertable_height = water_table_flooding;
47  bund_height = 0.0;
48  }
49  }
50 
51 
52  size_t sl_max( soillayers_in->soil_layer_cnt()-1);
53  if ( cbm::is_valid( max_percolation))
54  {
55  kst_sl[sl_max] = max_percolation / lclock()->time_resolution();
56  }
57  else
58  {
59  double const time_rate( 0.1 / lclock()->time_resolution());
60  kst_sl[sl_max] -= (kst_sl[sl_max] - kst_bottom) * time_rate;
61  }
62 
63  return LDNDC_ERR_OK;
64 }
lvector_t< double > kst_sl
Definition: echy.h:109
double kst_bottom
Definition: echy.h:67
Here is the caller graph for this function:

◆ EcHyGroundwater()

lerr_t ldndc::EcHy::EcHyGroundwater ( )
private

...

Negative groundwater table represents water on the soil surface

Negative groundwater table represents water on the soil surface

References cr_fill_groundwater, cr_fill_sl, EcHySoilWaterChange(), gw_depth_static, gw_fill_sl, gw_fill_surface, kst_sl, wc_max_sl, wc_min_sl, wl_sl, and wlst_sl.

Referenced by solve().

19 {
20  cbm::invalidate( kst_bottom_gw);
21  size_t sl_down( soillayers_in->soil_layer_cnt()-1);
22  if ( cbm::flt_greater( sc_.depth_sl[sl_down], gw_depth_static))
23  {
28  if ( cbm::flt_greater( -gw_depth_static, surface_water))
29  {
30  gw_fill_surface = -gw_depth_static - surface_water;
31  }
32 
33  //groundwater access
34  {
35  size_t sl( 0);
36  double const layer_midpoint_depth( 0.5 * sc_.h_sl[sl]);
37  if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
38  {
39  gw_fill_sl[sl] = cbm::bound_min( 0.0,
40  wlst_sl[sl] - (wl_sl[sl] + EcHySoilWaterChange( sl)));
41  wc_.accumulated_groundwater_access += gw_fill_sl[sl];
42  }
43  else
44  {
45  double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
46  double const wc_new( cbm::bound( wc_min_sl[sl], wl_new / sc_.h_sl[sl], wc_max_sl[sl]));
47  kst_bottom_gw = cbm::bound_min( 0.0,
48  ldndc::hydrology::hydraulic_conductivity(
49  wc_new,
50  sc_.vgm_sl[sl],
51  wc_max_sl[sl],
52  wc_min_sl[sl],
53  kst_sl[sl]));
54  gw_fill_sl[sl] = 0.0;
55  }
56  }
57 
58  for (size_t sl = 1; sl < soillayers_in->soil_layer_cnt()-1; sl++)
59  {
60  double const layer_midpoint_depth( sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl]);
61  if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
62  {
63  gw_fill_sl[sl] = cbm::bound_min( 0.0,
64  wlst_sl[sl] - (wl_sl[sl] + EcHySoilWaterChange( sl)));
65  wc_.accumulated_groundwater_access += gw_fill_sl[sl];
66  }
67  else
68  {
69  double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
70  double const wc_new( cbm::bound( wc_min_sl[sl], wl_new / sc_.h_sl[sl], wc_max_sl[sl]));
71  kst_bottom_gw = cbm::bound_min( 0.0,
72  ldndc::hydrology::hydraulic_conductivity(
73  wc_new,
74  sc_.vgm_sl[sl],
75  wc_max_sl[sl],
76  wc_min_sl[sl],
77  kst_sl[sl]));
78  gw_fill_sl[sl] = 0.0;
79  }
80  }
81 
82  {
83  size_t sl( soillayers_in->soil_layer_cnt()-1);
84  double const layer_midpoint_depth( sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl]);
85  if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
86  {
87  gw_fill_sl[sl] = cbm::bound_min( 0.0,
88  wlst_sl[sl] - (wl_sl[sl] + EcHySoilWaterChange( sl)));
89  wc_.accumulated_groundwater_access += gw_fill_sl[sl];
90  }
91  else
92  {
93  double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
94  double const wc_new( cbm::bound( wc_min_sl[sl], wl_new / sc_.h_sl[sl], wc_max_sl[sl]));
95  kst_bottom_gw = cbm::bound_min( 0.0,
96  ldndc::hydrology::hydraulic_conductivity(
97  wc_new,
98  sc_.vgm_sl[sl],
99  wc_max_sl[sl],
100  wc_min_sl[sl],
101  kst_sl[sl]));
102  gw_fill_sl[sl] = 0.0;
103  }
104  }
105  }
106 
107  //capillary rise
108  if ( m_param->WCDNDC_HAVE_CAPILLARY_ACTION())
109  {
110  size_t const STEPS( 10);
111  for (size_t steps = 0; steps < STEPS; steps++)
112  {
113  for (size_t sl = 0; sl < soillayers_in->soil_layer_cnt()-1; sl++)
114  {
115  double const layer_midpoint_depth( sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl]);
116  if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
117  {
118  break;
119  }
120 
121  /* Water contents with until now calculated water balance */
122  double const wl_new_0( wl_sl[sl] + EcHySoilWaterChange( sl));
123  double const wl_new_1( wl_sl[sl+1] + EcHySoilWaterChange( sl+1));
124 
125  double const wc_vg_0( cbm::bound( wc_min_sl[sl], wl_new_0 / sc_.h_sl[sl], wc_max_sl[sl]));
126  double const wc_vg_1( cbm::bound( wc_min_sl[sl+1], wl_new_1 / sc_.h_sl[sl+1], wc_max_sl[sl+1]));
127 
128  /* Unsaturated hydraulic conductivity with until now calculated water balance */
129  double const kust_0( cbm::bound_min( 0.0,
130  ldndc::hydrology::hydraulic_conductivity(
131  wc_vg_0, sc_.vgm_sl[sl],
132  wc_max_sl[sl], wc_min_sl[sl], 1.0/double(STEPS)*kst_sl[sl])));
133  double const kust_1( cbm::bound_min( 0.0,
134  ldndc::hydrology::hydraulic_conductivity(
135  wc_vg_1, sc_.vgm_sl[sl+1],
136  wc_max_sl[sl+1], wc_min_sl[sl+1], 1.0/double(STEPS)*kst_sl[sl+1])));
137 
138  double const capillary_pressure_0( ldndc::hydrology::capillary_pressure(
139  wl_new_0/sc_.h_sl[sl], sc_.vga_sl[sl], sc_.vgn_sl[sl], sc_.vgm_sl[sl],
140  wc_max_sl[sl], wc_min_sl[sl]));
141  double const capillary_pressure_1( ldndc::hydrology::capillary_pressure(
142  wl_new_1/sc_.h_sl[sl+1], sc_.vga_sl[sl+1], sc_.vgn_sl[sl+1], sc_.vgm_sl[sl+1],
143  wc_max_sl[sl], wc_min_sl[sl+1]));
144 
145  double const kust( cbm::flt_greater( capillary_pressure_0, capillary_pressure_1) ? kust_1 : kust_0 );
146  double const flow( (capillary_pressure_1 - capillary_pressure_0) / (0.5 * (sc_.h_sl[sl] + sc_.h_sl[sl+1])) * kust);
147 
148  /* downward flow*/
149  if ( cbm::flt_greater_zero( flow))
150  {
151  double const left( wl_sl[sl] + EcHySoilWaterChange( sl) - (wc_min_sl[sl] * sc_.h_sl[sl]));
152  double const space( wlst_sl[sl+1] - (wl_sl[sl+1] + EcHySoilWaterChange( sl+1)));
153 
154  if ( cbm::flt_greater_zero( left) &&
155  cbm::flt_greater_zero( space))
156  {
157  double const bound_flow( 1.0 / static_cast<double>(STEPS) * cbm::bound_max( flow, std::min( left, space)));
158  cr_fill_sl[sl] -= bound_flow;
159  cr_fill_sl[sl+1] += bound_flow;
160  }
161  }
162  /* upward flow */
163  else if ( cbm::flt_less( flow, 0.0))
164  {
165  double const left( wl_sl[sl+1] + EcHySoilWaterChange( sl+1) - (wc_min_sl[sl+1] * sc_.h_sl[sl+1]));
166  double const space( wlst_sl[sl] - (wl_sl[sl] + EcHySoilWaterChange( sl)));
167 
168  if ( cbm::flt_greater_zero( left) &&
169  cbm::flt_greater_zero( space))
170  {
171  double const bound_flow( cbm::bound_max( -flow, 1.0 / static_cast<double>(STEPS) * std::min( left, space)));
172  cr_fill_sl[sl] += bound_flow;
173  cr_fill_sl[sl+1] -= bound_flow;
174  }
175  }
176  }
177 
178  size_t sl( soillayers_in->soil_layer_cnt()-1);
179  double const layer_midpoint_depth( sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl]);
180  if ( cbm::flt_greater( gw_depth_static, layer_midpoint_depth))
181  {
182  /* Water contents with until now calculated water balance */
183  double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
184 
185  double const wc_vg( cbm::bound( wc_min_sl[sl], wl_new / sc_.h_sl[sl], wc_max_sl[sl]));
186 
187  /* Unsaturated hydraulic conductivity with until now calculated water balance */
188  double const kust( cbm::bound_min( 0.0,
189  ldndc::hydrology::hydraulic_conductivity(
190  wc_vg, sc_.vgm_sl[sl],
191  wc_max_sl[sl], wc_min_sl[sl], 1.0/double(STEPS)*kst_sl[sl])));
192 
193  double const capillary_pressure( ldndc::hydrology::capillary_pressure(
194  wl_new/sc_.h_sl[sl], sc_.vga_sl[sl], sc_.vgn_sl[sl], sc_.vgm_sl[sl],
195  wc_max_sl[sl], wc_min_sl[sl]));
196 
197  /* upward flow */
198  double const flow( -capillary_pressure / (gw_depth_static - layer_midpoint_depth) * kust);
199  if ( cbm::flt_less( flow, 0.0))
200  {
201  double const space( wlst_sl[sl] - (wl_sl[sl] + EcHySoilWaterChange( sl)));
202  if ( cbm::flt_greater_zero( space))
203  {
204  double const bound_flow( cbm::bound_max( -flow, 1.0 / static_cast<double>(STEPS) * space));
205  cr_fill_sl[sl] += bound_flow;
206  cr_fill_groundwater += bound_flow;
207  }
208  }
209  }
210  }
211  }
212 
213  return LDNDC_ERR_OK;
214 }
double gw_fill_surface
Definition: echy.h:127
double gw_depth_static
Definition: echy.h:71
lvector_t< double > kst_sl
Definition: echy.h:109
double cr_fill_groundwater
Definition: echy.h:130
lvector_t< double > wc_max_sl
Definition: echy.h:100
lvector_t< double > gw_fill_sl
Definition: echy.h:94
lvector_t< double > wl_sl
Definition: echy.h:112
lvector_t< double > wc_min_sl
Definition: echy.h:103
double EcHySoilWaterChange(size_t)
Definition: echy.cpp:411
lvector_t< double > wlst_sl
Definition: echy.h:121
lvector_t< double > cr_fill_sl
Definition: echy.h:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EcHyIntegration()

lerr_t ldndc::EcHy::EcHyIntegration ( )
private

...

Integrates all water state variables.

References bypass_fill_sl, EcHySoilWaterChange(), gw_fill_surface, runoff, throughfall, wc_max_sl, wc_min_sl, wl_sl, and wlfl_sl.

Referenced by solve().

425 {
426  surface_water = cbm::bound_min( 0.0,
427  surface_water +
428  (throughfall + gw_fill_surface + irrigation - wlfl_sl[0] - runoff - bypass_fill_sl.sum()));
429 
430  for (size_t sl = 0; sl < soillayers_in->soil_layer_cnt(); sl++)
431  {
432  wl_sl[sl] = cbm::bound_min( 0.0, wl_sl[sl] + EcHySoilWaterChange( sl));
433  wc_.mskpa_sl[sl] = ldndc::hydrology::capillary_pressure( wl_sl[sl]/sc_.h_sl[sl], sc_.vga_sl[sl],
434  sc_.vgn_sl[sl], sc_.vgm_sl[sl], wc_max_sl[sl], wc_min_sl[sl]);
435  }
436 
437  return LDNDC_ERR_OK;
438 }
double gw_fill_surface
Definition: echy.h:127
lvector_t< double > wc_max_sl
Definition: echy.h:100
lvector_t< double > wl_sl
Definition: echy.h:112
lvector_t< double > wc_min_sl
Definition: echy.h:103
double runoff
Definition: echy.h:133
lvector_t< double > wlfl_sl
Definition: echy.h:88
double throughfall
Definition: echy.h:139
double EcHySoilWaterChange(size_t)
Definition: echy.cpp:411
lvector_t< double > bypass_fill_sl
Definition: echy.h:97
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EcHySoilWaterChange()

double ldndc::EcHy::EcHySoilWaterChange ( size_t  _sl)
private

Integrates all water state variables.

References cr_fill_sl, evsws_sl, gw_fill_sl, trwl_sl, and wlfl_sl.

Referenced by EcHyGetAvailableWaterEvaporation(), EcHyGetAvailableWaterTranspiration(), EcHyGroundwater(), EcHyIntegration(), and EcHyIrrigation().

413 {
414  return wlfl_sl[_sl] - wlfl_sl[_sl+1] + cr_fill_sl[_sl] - trwl_sl[_sl] - evsws_sl[_sl] + gw_fill_sl[_sl];
415 }
lvector_t< double > evsws_sl
Definition: echy.h:106
lvector_t< double > gw_fill_sl
Definition: echy.h:94
lvector_t< double > wlfl_sl
Definition: echy.h:88
lvector_t< double > trwl_sl
Definition: echy.h:80
lvector_t< double > cr_fill_sl
Definition: echy.h:91
Here is the caller graph for this function:

◆ EcHySubsl2()

lerr_t ldndc::EcHy::EcHySubsl2 ( double const &  _cp,
double const &  _delta_z,
int const &  _sl,
double const &  _saturation,
double &  _flow 
)
private

...

This routine calculates the rate of capillary flow or percolation between groundwater table and root zone. The stationary flow is found by integration of dZL = K.d(MH)/(K + FLW), where Z= height above groundwater, MH= matric head, K= conductivity and FLW= chosen flow. In an iteration loop the correct flow is found. The integration goes at most over four intervals: [0,45], [45,170], [170,330] and [330,MH-rootzone] (last one on logarithmic scale).

Author
C. Rappoldt M. Wopereis
Date
January 1986, revised June 1990

Chapter 15 in documentation WOFOST Version 4.1 (1988)

References kst_sl.

245 {
246  //calculation of pf from matrix head
247  double pf( std::log10( _cp));
248 
249  //in case of small matric head (high water contents)
250  if ( cbm::flt_greater( 1.0, pf))
251  {
252  _flow = 0.0;
253  return LDNDC_ERR_OK;
254  }
255 
256  double elog10( 2.302585);
257  double logst4( 2.518514);
258 
259  double start[4] = {0.0, 45.0, 170.0, 330.0};
260 
261  //number and width of integration intervals
262  int iint( 0);
263  double del[4] = { 0.0, 0.0, 0.0, 0.0};
264  for (int i1 = 0; i1 < 4; i1++)
265  {
266  if (i1 < 3)
267  {
268  del[i1] = std::min( start[i1+1], _cp) - start[i1];
269  }
270  else
271  {
272  del[i1] = pf - logst4;
273  }
274  if (del[i1] <= 0.0)
275  {
276  break;
277  }
278  iint += 1;
279  }
280 
281  //preparation of three-point gaussian integration
282  double hulp[12] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
283  double conduc[12] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
284  for (int i1 = 0; i1 < iint; i1++)
285  {
286  for (int i2 = 0; i2 < 3; i2++)
287  {
288  double pgau[3] = {0.1127016654, 0.5, 0.8872983346};
289  double wgau[3] = {0.2777778, 0.4444444, 0.2777778};
290 
291  int i3( 3 * i1 + i2);
292 
293  //the three points in the full-width intervals are standard
294  double pfstan[9] = {0.705143, 1.352183, 1.601282, 1.771497, 2.031409, 2.192880, 2.274233, 2.397940, 2.494110};
295  double pfgau( pfstan[i3]);
296 
297  //the three points in the last interval are calculated
298  if ( i1 == (iint-1))
299  {
300  if ( iint < 4)
301  {
302  pfgau = std::log10( start[iint-1] + pgau[i2] * del[iint-1]);
303  }
304  else
305  {
306  pfgau = logst4 + pgau[i2] * del[iint-1];
307  }
308  }
309 
310  double const wcl_loc( ldndc::hydrology::water_content( std::exp(elog10 * pfgau), sc_.vga_sl[_sl], sc_.vgn_sl[_sl], sc_.vgm_sl[_sl], _saturation, 0.1));
311  conduc[i3] = ldndc::hydrology::hydraulic_conductivity(wcl_loc, sc_.vgm_sl[_sl], _saturation, sc_.wcmin_sl[_sl], kst_sl[_sl] * cbm::CM_IN_M);
312  hulp[i3] = del[i1] * wgau[i2] * conduc[i3];
313  if (i3 > 8)
314  {
315  hulp[i3] = hulp[i3] * elog10 * std::exp( elog10 * pfgau);
316  }
317  }
318  }
319 
320 
321  //setting upper and lower limit
322  double const wcl_loc( ldndc::hydrology::water_content( _cp, sc_.vga_sl[_sl], sc_.vgn_sl[_sl], sc_.vgm_sl[_sl], _saturation, 0.1));
323  double const kms( ldndc::hydrology::hydraulic_conductivity(wcl_loc, sc_.vgm_sl[_sl], _saturation, sc_.wcmin_sl[_sl], kst_sl[_sl] * cbm::CM_IN_M));
324  double fu( (_cp <= _delta_z) ? 0.0 : 1.27);
325  double fl( (_cp >= _delta_z) ? 0.0 : -kms);
326 
327 
328  if ( !cbm::flt_equal( _cp, _delta_z))
329  {
330  //iteration loop
331  int imax( 3 * iint);
332  for ( int i1 = 0; i1 < 14; i1++)
333  {
334  double flw( (fu + fl) / 2.0);
335  double df( (fu - fl) / 2.0);
336  if ( (df < 0.01) &&
337  ((df / std::abs(flw)) < 0.1))
338  {
339  break;
340  }
341 
342  double z( 0.0);
343  for ( int i2 = 0; i2 < imax; i2++)
344  {
345  z = z + hulp[i2] / (conduc[i2] + flw);
346  }
347  if (z >= _delta_z)
348  {
349  fl = flw;
350  }
351  if (z <= _delta_z)
352  {
353  fu = flw;
354  }
355  }
356  }
357 
358  //flow output in mm
359  _flow = 10.0 * (fu + fl) / 2.0;
360 
361  return LDNDC_ERR_OK;
362 }
lvector_t< double > kst_sl
Definition: echy.h:109

◆ solve()

lerr_t ldndc::EcHy::solve ( )

Kicks off computation for one time step.

References EcHyBalanceCheck(), EcHyBypassFlow(), EcHyEvapotranspiration(), EcHyFlood(), EcHyGroundwater(), EcHyIntegration(), EcHyIrrigation(), EcHyPercolation(), EcHyreset(), EcHySnowIce(), EcHyStepExit(), EcHyStepInit(), kst_bottom, kst_sl, runoff, runoff_method, throughfall, and wlfl_sl.

46 {
47  /* reset of all fluxes */
48  EcHyreset();
49 
50  /* flooding events */
51  lerr_t rc = EcHyFlood();
52  if ( rc != LDNDC_ERR_OK)
53  {
54  KLOGERROR("Handling flooding event failed in: ", name());
55  return rc;
56  }
57 
58  /* tasks:
59  * - update internal state (e.g., throughfall, ...)
60  * - calculate evapotranspiration on demand
61  */
62  rc = EcHyStepInit();
63  if ( rc != LDNDC_ERR_OK)
64  { return rc; }
65 
66  /* begin water balance */
67  double balance( -1.0);
68  EcHyBalanceCheck( balance);
69 
70  /* snow and ice calculated */
71  EcHySnowIce();
72 
73  /*
74  * apply irrigation triggered by
75  * - irrigation events
76  * - flooding events
77  */
79 
80  double const potential_infiltration( surface_water + irrigation + throughfall);
81  double bypass_flow( m_param->CRACK_FRACTION() * potential_infiltration);
82 
83  /* bypass flow */
84  EcHyBypassFlow( m_param->CRACK_DEPTH(), bypass_flow);
85  double const infiltration( potential_infiltration - bypass_flow);
86 
87  /* downward water flow */
88  wlfl_sl[0] = cbm::bound_max( infiltration, kst_sl[0]);
89  for ( size_t sl = 0; sl < soillayers_in->soil_layer_cnt(); ++sl)
90  {
91  EcHyPercolation( 1, sl);
92  }
93 
94  if ( cbm::flt_equal_zero( kst_bottom))
95  {
96  wlfl_sl[soillayers_in->soil_layer_cnt()] = 0.0;
97  }
98  else if ( cbm::is_valid( kst_bottom_gw))
99  {
100  wlfl_sl[soillayers_in->soil_layer_cnt()] = kst_bottom_gw;
101  }
102 
104 
105  /* upward water flow */
106  for ( int sl = soillayers_in->soil_layer_cnt()-1; sl >= 0; --sl)
107  {
108  EcHyPercolation( 2, sl);
109  }
110 
111  /* runoff */
112  if ( runoff_method == "curvenumber")
113  {
114  double const surface_water_in_mm( surface_water * cbm::MM_IN_M);
115  double const curvenumber( 70.0);
116 
117  //retention parameter [mm]
118  double const retention_factor( 25.4 * (1000.0 / curvenumber - 10));
119 
120  //runoff [mm]
121  double const q_surf( cbm::sqr( surface_water_in_mm) /
122  ((surface_water_in_mm + retention_factor) * lclock()->time_resolution()));
123 
124  runoff = cbm::bound( 0.0,
125  q_surf * cbm::M_IN_MM,
126  0.99 * (surface_water + throughfall + irrigation - wlfl_sl[0] - bypass_flow));
127  }
128  else
129  {
130  double const f_runoff( cbm::bound_max( m_param->FRUNOFF() / lclock()->time_resolution(), 1.0));
131  runoff = cbm::bound_min( 0.0, f_runoff * (surface_water + throughfall + irrigation - wlfl_sl[0] - bypass_flow - bund_height));
132  }
133 
134  /* groundwater interaction:
135  * - set soil layers water-saturated
136  * - capillary rise
137  */
138  EcHyGroundwater();
139 
140  /* integration of state variables */
141  EcHyIntegration();
142 
143  /* update external state */
144  EcHyStepExit();
145 
146  /* perform water balance */
147  rc = EcHyBalanceCheck( balance);
148  if ( rc){ return rc; }
149 
150  rc = EcHy_check_for_negative_value("exit");
151  if ( rc){ return rc; }
152 
153  return LDNDC_ERR_OK;
154 }
lvector_t< double > kst_sl
Definition: echy.h:109
lerr_t EcHySnowIce()
Calls SnowDNDC for the calculation of snowpack and soil ice formation.
lerr_t EcHyFlood()
sets hydrologic conditions during flooding events, e.g.,
Definition: echy-management.cpp:17
void EcHyreset()
...
Definition: echy.cpp:163
lerr_t EcHyBypassFlow(double, double &)
Calculates water percolation within the soil profile.
lerr_t EcHyStepInit()
...
Definition: echy.cpp:195
lerr_t EcHyIntegration()
...
Definition: echy.cpp:424
lerr_t EcHyEvapotranspiration()
Calculates evapotranspiration within the soil profile.
cbm::string_t runoff_method
Definition: echy.h:193
double kst_bottom
Definition: echy.h:67
double runoff
Definition: echy.h:133
lvector_t< double > wlfl_sl
Definition: echy.h:88
double throughfall
Definition: echy.h:139
lerr_t EcHyGroundwater()
...
Definition: echy-groundwater.cpp:18
lerr_t EcHyStepExit()
...
Definition: echy.cpp:301
lerr_t EcHyPercolation(size_t, size_t)
Calculates water percolation within the soil profile.
lerr_t EcHyBalanceCheck(double &)
...
Definition: echy.cpp:447
lerr_t EcHyIrrigation()
Irrigation.
Definition: echy-management.cpp:73
Here is the call graph for this function:

Member Data Documentation

◆ accumulated_irrigation_old

double ldndc::EcHy::accumulated_irrigation_old
private

Accumulated irrigation of last time step [m]

Referenced by EcHyIrrigation().

◆ accumulated_potentialtranspiration_old

double ldndc::EcHy::accumulated_potentialtranspiration_old
private

Accumulated potential transpiration of last time step [m]

Referenced by EcHyPotentialEvapotranspiration().

◆ bypass_fill_sl

lvector_t< double > ldndc::EcHy::bypass_fill_sl
private

Soillayer water input due to bypass flow

Referenced by EcHyIntegration(), and EcHyreset().

◆ cr_fill_groundwater

double ldndc::EcHy::cr_fill_groundwater
private

Water addition to last soil layer from groundwater water by cappillary rise (only used for water balance calculation)

Referenced by EcHyBalanceCheck(), EcHyGroundwater(), and EcHyreset().

◆ cr_fill_sl

lvector_t< double > ldndc::EcHy::cr_fill_sl
private

Soillayer water input due to capillary rise

Referenced by EcHyGroundwater(), EcHyreset(), and EcHySoilWaterChange().

◆ daily_potential_evapotranspiration

double ldndc::EcHy::daily_potential_evapotranspiration
private

◆ daily_potential_leaf_evaporation

double ldndc::EcHy::daily_potential_leaf_evaporation
private

◆ daily_potential_soil_evaporation

double ldndc::EcHy::daily_potential_soil_evaporation
private

◆ daily_potential_transpiration

double ldndc::EcHy::daily_potential_transpiration
private

◆ ev_leaf

double ldndc::EcHy::ev_leaf
private

Evaporation from plant surface

Referenced by EcHyBalanceCheck(), EcHyPotentialEvapotranspiration(), and EcHyStepExit().

◆ evapotranspiration_method

cbm::string_t ldndc::EcHy::evapotranspiration_method
private

◆ evsws_sl

lvector_t< double > ldndc::EcHy::evsws_sl
private

◆ gw_depth_static

double ldndc::EcHy::gw_depth_static
private

Depth of groundwater table [m]

Referenced by EcHyGroundwater(), and EcHyStepInit().

◆ gw_fill_sl

lvector_t< double > ldndc::EcHy::gw_fill_sl
private

Soillayer water input due to groundwater flow

Referenced by EcHyBalanceCheck(), EcHyGroundwater(), EcHyreset(), and EcHySoilWaterChange().

◆ gw_fill_surface

double ldndc::EcHy::gw_fill_surface
private

Water addition to surface water from groundwater water boundary condition

Referenced by EcHyBalanceCheck(), EcHyGroundwater(), EcHyIntegration(), and EcHyreset().

◆ interception_water

double ldndc::EcHy::interception_water
private

◆ kst_bottom

double ldndc::EcHy::kst_bottom
private

Saturated hydraulic conductivity below last soil layer [cm:min-1]

Referenced by EcHyFlood(), EcHyStepInit(), and solve().

◆ kst_sl

lvector_t< double > ldndc::EcHy::kst_sl
private

Saturated hydraulic conductivity

Referenced by EcHyFlood(), EcHyGroundwater(), EcHyStepInit(), EcHySubsl2(), and solve().

◆ m_icecontent_in

WaterCycleSnowDNDC::IceContentStateIn ldndc::EcHy::m_icecontent_in
private

...

◆ runoff

double ldndc::EcHy::runoff
private

Lateral surface runoff

Referenced by EcHyBalanceCheck(), EcHyIntegration(), EcHyreset(), EcHyStepExit(), and solve().

◆ runoff_method

cbm::string_t ldndc::EcHy::runoff_method
private

...

Referenced by solve().

◆ snowfall

double ldndc::EcHy::snowfall
private

Snowfall

Referenced by EcHyBalanceCheck(), and EcHyreset().

◆ thornthwaite_heat_index

double ldndc::EcHy::thornthwaite_heat_index
private

◆ throughfall

double ldndc::EcHy::throughfall
private

Throughfall to soil

Referenced by EcHyBalanceCheck(), EcHyIntegration(), EcHyStepExit(), EcHyStepInit(), and solve().

◆ trwl_sl

lvector_t< double > ldndc::EcHy::trwl_sl
private

Water withdrawl by transpiration [m d−1]

Referenced by EcHyBalanceCheck(), EcHyPotentialEvapotranspiration(), EcHyreset(), EcHySoilWaterChange(), and EcHyStepExit().

◆ wc_max_sl

lvector_t< double > ldndc::EcHy::wc_max_sl
private

Maximum water content

Referenced by EcHyGroundwater(), and EcHyIntegration().

◆ wc_min_sl

lvector_t< double > ldndc::EcHy::wc_min_sl
private

Minimum water content

Referenced by EcHyGetMinimumWater(), EcHyGroundwater(), and EcHyIntegration().

◆ wl_sl

lvector_t< double > ldndc::EcHy::wl_sl
private

◆ wlfc_sl

lvector_t< double > ldndc::EcHy::wlfc_sl
private

Amount of water in soil layer at field capacity

Referenced by EcHyGetAvailableWaterTranspiration(), EcHyGetWaterLimitationTranspiration(), and EcHyIrrigation().

◆ wlfl_sl

lvector_t< double > ldndc::EcHy::wlfl_sl
private

Water flux at boundaries of soil layer [m d-1] the flux of water between soil layer is tracked by wlfl (mm d−1). in total, there are nl+1 flow rates, where nl is the number of soil layers, wlfl[1] is the flow rate between the ponded water layer and the soil surface, wlfl[2] is the flow rate between soil layer 1 and soil layer 2, etc.

Referenced by EcHyBalanceCheck(), EcHyIntegration(), EcHyreset(), EcHySoilWaterChange(), EcHyStepExit(), and solve().

◆ wlst_sl

lvector_t< double > ldndc::EcHy::wlst_sl
private

Amount of water in soil layer at saturation

Referenced by EcHyGroundwater(), and EcHyIrrigation().

◆ wlwp_sl

lvector_t< double > ldndc::EcHy::wlwp_sl
private

Amount of water in soil layer at wilting point

Referenced by EcHyGetWiltingPoint().