LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
ldndc::EcHy Class Reference

Hydrology model EcHy. More...

#include <models/watercycle/echy/echy.h>

Private Member Functions

lerr_t EcHyGroundwaterStorageExchange ()
 Exchange with a prescribed groundwater table based on profile water storage.
 
lerr_t EcHyIrrigation ()
 Irrigation.
 
lerr_t EcHyFlood ()
 sets hydrologic conditions during flooding events, e.g.,
 
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 EcHyCapillaryRise (double const &, double const &, size_t const &, double const &, double &)
 ...
 
lerr_t EcHyBalanceCheck (double &)
 ...
 
void EcHyreset ()
 ...
 
lerr_t EcHyGroundwater ()
 ...
 
lerr_t EcHyIntegration ()
 ...
 
lerr_t EcHyStepInit ()
 ...
 
lerr_t EcHyStepExit ()
 ...
 
double EcHyGetInterceptionCapacity ()
 ...
 
lerr_t EcHyCalculateLeafWaterDistribution (lvector_t< double > &, 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 EcHyGetGroundRadiationFraction ()
 Fraction of shortwave radiation absorbed at the ground surface (below the canopy)
 
double EcHyDistributeWaterUptake (double)
 Distributes the water uptake target across the rooted soil layers (trwl_sl), limited by the available water of each layer, and returns the actual uptake [m].
 
double EcHySoilWaterChange (size_t)
 

Private Attributes

double kst_bottom
 
double gw_depth_static
 
double gw_recharge_potential
 
double accumulated_potentialtranspiration_old
 
double accumulated_irrigation_old
 
lvector< double > trwl_sl
 
lvector< double > wlfl_sl
 
lvector< double > cr_fill_sl
 
lvector< double > gw_fill_sl
 
lvector< double > bypass_fill_sl
 
double ev_surfacewater
 
lvector< double > evsws_sl
 
lvector< double > kst_sl
 
lvector< double > wl_sl
 
lvector< double > wlfc_sl
 
lvector< double > wlwp_sl
 
double ev_leaf
 
double gw_fill_surface
 
double cr_fill_groundwater
 
double runoff
 
double throughfall_snow
 
double throughfall_water
 
double canopy_snowmelt
 
double canopy_water
 
double thornthwaite_heat_index
 
double daily_potential_evapotranspiration
 
bool pet_limit_daily
 
double pet_day_remaining
 
double potential_evapotranspiration_ts
 
lvector< double > rad_pet_ts
 
lvector< double > f_pet_ts
 
double potential_transpiration_ts
 
double transpiration_ts
 
WaterCycleSnowDNDC::IceContentStateIn m_icecontent_in
 
cbm::string_t evapotranspiration_method
 
cbm::string_t runoff_method
 
bool have_gw_exchange_storage
 
bool have_gw_exchange_layerwise
 
double gw_exchange_tau
 

Detailed Description

Hydrology model EcHy.

Author
David Kraus

Member Function Documentation

◆ EcHyBalanceCheck()

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

...

Checks balance between all incoming and outgoing water fluxes.

616{
617 double balance( canopy_water + surface_water + canopy_snow + surface_snow);
618 for ( size_t sl = 0; sl < soillayers_in->soil_layer_cnt(); ++sl)
619 {
620 balance += wl_sl[sl] + wc_.ice_sl[sl] * sc_.h_sl[sl];
621 }
622
623 if ( _balance > 0.0)
624 {
625 balance += wlfl_sl[soillayers_in->soil_layer_cnt()]
626 + ev_leaf + ev_surfacewater + evsws_sl.sum() + trwl_sl.sum() + runoff
628 - irrigation - throughfall_water - throughfall_snow;
629
630 double const balance_delta( std::abs( _balance - balance));
631 if ( cbm::flt_greater( balance_delta, 1.0e-4))
632 {
633 KLOGWARN( " Water leakage in: ", name(),
634 " Difference: ", balance - _balance);
635 return LDNDC_ERR_FAIL;
636 }
637 }
638 else
639 {
640 _balance = balance;
641 }
642
643 return LDNDC_ERR_OK;
644}
double gw_fill_surface
Definition echy.h:136
lvector< double > wl_sl
Definition echy.h:124
double runoff
Definition echy.h:142
double ev_surfacewater
Definition echy.h:114
double throughfall_water
Definition echy.h:148
double cr_fill_groundwater
Definition echy.h:139
lvector< double > evsws_sl
Definition echy.h:117
double throughfall_snow
Definition echy.h:145
lvector< double > trwl_sl
Definition echy.h:92
double canopy_water
Definition echy.h:155
double ev_leaf
Definition echy.h:133
lvector< double > gw_fill_sl
Definition echy.h:108
lvector< double > wlfl_sl
Definition echy.h:100

References canopy_water, cr_fill_groundwater, ev_leaf, ev_surfacewater, evsws_sl, gw_fill_sl, gw_fill_surface, runoff, throughfall_snow, throughfall_water, trwl_sl, wl_sl, and wlfl_sl.

Referenced by EcHyBypassFlow().

Here is the caller graph for this function:

◆ EcHyCapillaryRise()

lerr_t ldndc::EcHy::EcHyCapillaryRise ( double const & _cp,
double const & _delta_z,
size_t 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

@documentation Chapter 15 in documentation WOFOST Version 4.1 (1988)

430{
431 //calculation of pf from matrix head
432 double pf( std::log10( _cp));
433
434 //in case of small matric head (high water contents)
435 if ( cbm::flt_greater( 1.0, pf))
436 {
437 _flow = 0.0;
438 return LDNDC_ERR_OK;
439 }
440
441 double elog10( 2.302585);
442 double logst4( 2.518514);
443
444 double start[4] = {0.0, 45.0, 170.0, 330.0};
445
446 //number and width of integration intervals
447 int iint( 0);
448 double del[4] = { 0.0, 0.0, 0.0, 0.0};
449 for (int i1 = 0; i1 < 4; i1++)
450 {
451 if (i1 < 3)
452 {
453 del[i1] = std::min( start[i1+1], _cp) - start[i1];
454 }
455 else
456 {
457 del[i1] = pf - logst4;
458 }
459 if (del[i1] <= 0.0)
460 {
461 break;
462 }
463 iint += 1;
464 }
465
466 //preparation of three-point gaussian integration
467 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};
468 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};
469 for (int i1 = 0; i1 < iint; i1++)
470 {
471 for (int i2 = 0; i2 < 3; i2++)
472 {
473 double pgau[3] = {0.1127016654, 0.5, 0.8872983346};
474 double wgau[3] = {0.2777778, 0.4444444, 0.2777778};
475
476 int i3( 3 * i1 + i2);
477
478 //the three points in the full-width intervals are standard
479 double pfstan[9] = {0.705143, 1.352183, 1.601282, 1.771497, 2.031409, 2.192880, 2.274233, 2.397940, 2.494110};
480 double pfgau( pfstan[i3]);
481
482 //the three points in the last interval are calculated
483 if ( i1 == (iint-1))
484 {
485 if ( iint < 4)
486 {
487 pfgau = std::log10( start[iint-1] + pgau[i2] * del[iint-1]);
488 }
489 else
490 {
491 pfgau = logst4 + pgau[i2] * del[iint-1];
492 }
493 }
494
495 double const wcl_loc( ldndc::hydrology::water_content( std::exp(elog10 * pfgau), wc_.vga_sl[_sl], wc_.vgn_sl[_sl], wc_.vgm_sl[_sl], _saturation, 0.1));
496 conduc[i3] = ldndc::hydraulic_conductivity( wcl_loc, wc_.vgm_sl[_sl], wc_.mvg_tau_sl[_sl],
497 _saturation, wc_.wc_wp_sl[_sl], kst_sl[_sl] * cbm::CM_IN_M);
498 hulp[i3] = del[i1] * wgau[i2] * conduc[i3];
499 if (i3 > 8)
500 {
501 hulp[i3] = hulp[i3] * elog10 * std::exp( elog10 * pfgau);
502 }
503 }
504 }
505
506 //setting upper and lower limit
507 double const wcl_loc( ldndc::hydrology::water_content( _cp, wc_.vga_sl[_sl], wc_.vgn_sl[_sl], wc_.vgm_sl[_sl], _saturation, 0.1));
508 double const kms( ldndc::hydraulic_conductivity( wcl_loc, wc_.vgm_sl[_sl], wc_.mvg_tau_sl[_sl],
509 _saturation, wc_.wc_wp_sl[_sl], kst_sl[_sl] * cbm::CM_IN_M));
510 double fu( (_cp <= _delta_z) ? 0.0 : 1.27);
511 double fl( (_cp >= _delta_z) ? 0.0 : -kms);
512
513 if ( !cbm::flt_equal( _cp, _delta_z))
514 {
515 //iteration loop
516 int imax( 3 * iint);
517 for ( int i1 = 0; i1 < 14; i1++)
518 {
519 double flw( (fu + fl) / 2.0);
520 double df( (fu - fl) / 2.0);
521 if ( (df < 0.01) &&
522 ((df / std::abs(flw)) < 0.1))
523 {
524 break;
525 }
526
527 double z( 0.0);
528 for ( int i2 = 0; i2 < imax; i2++)
529 {
530 z = z + hulp[i2] / (conduc[i2] + flw);
531 }
532 if (z >= _delta_z)
533 {
534 fl = flw;
535 }
536 if (z <= _delta_z)
537 {
538 fu = flw;
539 }
540 }
541 }
542
543 //flow output in mm
544 _flow = 10.0 * (fu + fl) / 2.0;
545
546 return LDNDC_ERR_OK;
547}
lvector< double > kst_sl
Definition echy.h:120

References kst_sl.

Referenced by EcHyBypassFlow().

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
23{
24 lerr_t rc = m_eventflood.solve();
25 if ( rc != LDNDC_ERR_OK){ return rc; }
26
27 bund_height = m_eventflood.get_bund_height();
28
29 /* todo */
30 //irrigation_amount = m_eventflood.get_irrigation_amount();
31
32 /* todo */
33 //double const irrigation_height = m_eventflood.get_irrigation_height();
34 double const max_percolation = m_eventflood.get_maximum_percolation();
35 double const water_table_flooding = m_eventflood.get_water_table();
36
37 irrigation_switch = NONE;
38 minimum_watertable_height = 0.0;
39 if ( cbm::is_valid( water_table_flooding))
40 {
41 if ( cbm::flt_greater_zero( water_table_flooding))
42 {
43 irrigation_switch = CONSTANT_POSITIVE_WATER_TABLE;
44 minimum_watertable_height = water_table_flooding;
45 bund_height = water_table_flooding;
46 }
47 else
48 {
49 irrigation_switch = CONSTANT_NEGATIVE_WATER_TABLE;
50 minimum_watertable_height = water_table_flooding;
51 bund_height = 0.0;
52 }
53 }
54
55 bool cracked( false);
56 for (size_t sl = 0; sl < soillayers_in->soil_layer_cnt()-1; sl++)
57 {
58 if ( cbm::flt_greater_equal( sc_.depth_sl[sl], 0.3))
59 {
60 if ( cbm::is_valid( max_percolation))
61 {
62 /* the percolation rate of a flooding event (puddled soil) limits the conductivity,
63 * it does not raise it above the conductivity of the undisturbed soil */
64 if ((kst_eq_sl[sl] > max_percolation / lclock()->time_resolution()))
65 {
66 kst_sl[sl] = max_percolation / lclock()->time_resolution();
67 }
68 }
69 /* after flooding the conductivity recovers as soon as the layer dries below 80 % of its
70 * pore space (cracking of the puddled layer). Until 2026-11-28 the condition read
71 * wl < -0.8 * pore space, which is never true, so the percolation rate of a single
72 * flooding event limited the conductivity for the rest of the simulation. */
73 else if ( wl_sl[sl] < 0.8 * pore_space( sl))
74 {
75 cracked = true;
76 }
77
78 if ( cracked)
79 {
80 double const time_rate( 0.1 / lclock()->time_resolution());
81 kst_sl[sl] = cbm::bound_min( 0.0,
82 kst_sl[sl] - (kst_sl[sl] - kst_eq_sl[sl]) * time_rate);
83 }
84 break;
85 }
86 }
87
88 return LDNDC_ERR_OK;
89}

References kst_sl, and wl_sl.

◆ EcHyGroundwater()

lerr_t ldndc::EcHy::EcHyGroundwater ( )
private

...

Negative groundwater table represents water on the soil surface

25{
26 cbm::invalidate( kst_bottom_gw_vertical);
27
28 // storage-based exchange replaces layer-wise filling/draining while the water table is below the surface
29 bool const use_storage_exchange( have_gw_exchange_storage &&
30 !cbm::flt_less( gw_depth_static, 0.0) &&
31 cbm::flt_greater( sc_.depth_sl[soillayers_in->soil_layer_cnt()-1], gw_depth_static));
32 if ( use_storage_exchange)
33 {
35 }
36
37 if ( !use_storage_exchange &&
38 cbm::flt_greater( sc_.depth_sl[soillayers_in->soil_layer_cnt()-1], gw_depth_static))
39 {
40 // negative groundwater table represents water above soil surface
41 double const surface_water_new( surface_water + throughfall_water + surface_snowmelt + irrigation
43 if ( cbm::flt_greater_zero( - gw_depth_static))
44 {
45 gw_fill_surface = - gw_depth_static - surface_water_new;
46 }
47 // remove surface water if static groundwater existed in previous time step
48 else if ( cbm::flt_greater_zero( - gw_depth_static_old))
49 {
50 gw_fill_surface = - cbm::bound_max( surface_water, surface_water_new);
51 }
52
53 // exchange of surface water with the groundwater is part of the water balance as well
54 // (until 2026-11-24 it was added to / removed from the surface water without being accounted for)
55 if ( cbm::flt_greater_zero( gw_fill_surface))
56 {
57 wc_.accumulated_groundwater_access += gw_fill_surface;
58 }
59 else
60 {
61 wc_.accumulated_groundwater_loss -= gw_fill_surface;
62 }
63
64 //groundwater access
65 {
66 size_t sl( 0);
67 double layer_midpoint_depth( 0.5 * sc_.h_sl[sl]);
68 if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
69 {
70 gw_fill_sl[sl] = cbm::bound_min( 0.0,
71 0.999 * pore_space( sl) - wc_.ice_sl[sl] * sc_.h_sl[sl]
72 - (wl_sl[sl] + EcHySoilWaterChange( sl)));
73 wc_.accumulated_groundwater_access += gw_fill_sl[sl];
74 wc_.accumulated_groundwater_exchange_sl[sl] += gw_fill_sl[sl];
75 }
76 else
77 {
78 double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
79 double const wc_new( cbm::bound( wc_.wc_res_sl[sl], wl_new / sc_.h_sl[sl], wc_.wc_sat_sl[sl]));
80 kst_bottom_gw_vertical = cbm::bound_min( 0.0,
81 ldndc::hydraulic_conductivity(
82 wc_new,
83 wc_.vgm_sl[sl],
84 wc_.mvg_tau_sl[sl],
85 wc_.wc_sat_sl[sl],
86 wc_.wc_res_sl[sl],
87 kst_sl[sl]));
88 gw_fill_sl[sl] = 0.0;
89 }
90
91 for ( sl = 1; sl < soillayers_in->soil_layer_cnt()-1; sl++)
92 {
93 layer_midpoint_depth = sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl];
94 if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
95 {
96 gw_fill_sl[sl] = cbm::bound_min( 0.0,
97 0.999 * pore_space( sl) - wc_.ice_sl[sl] * sc_.h_sl[sl]
98 - (wl_sl[sl] + EcHySoilWaterChange( sl)));
99 wc_.accumulated_groundwater_access += gw_fill_sl[sl];
100 wc_.accumulated_groundwater_exchange_sl[sl] += gw_fill_sl[sl];
101 }
102 else
103 {
104 double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
105 double const wc_new( cbm::bound( wc_.wc_res_sl[sl], wl_new / sc_.h_sl[sl], wc_.wc_sat_sl[sl]));
106 kst_bottom_gw_vertical = cbm::bound_min( 0.0,
107 ldndc::hydraulic_conductivity(
108 wc_new,
109 wc_.vgm_sl[sl],
110 wc_.mvg_tau_sl[sl],
111 wc_.wc_sat_sl[sl],
112 wc_.wc_res_sl[sl],
113 kst_sl[sl]));
114 gw_fill_sl[sl] = 0.0;
115 }
116 }
117
118 sl = soillayers_in->soil_layer_cnt()-1;
119 layer_midpoint_depth = sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl];
120 if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
121 {
122 gw_fill_sl[sl] = cbm::bound_min( 0.0,
123 0.999 * pore_space( sl) - wc_.ice_sl[sl] * sc_.h_sl[sl]
124 - (wl_sl[sl] + EcHySoilWaterChange( sl)));
125 wc_.accumulated_groundwater_access += gw_fill_sl[sl];
126 wc_.accumulated_groundwater_exchange_sl[sl] += gw_fill_sl[sl];
127 }
128 else
129 {
130 double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
131 double const wc_new( cbm::bound( wc_.wc_res_sl[sl], wl_new / sc_.h_sl[sl], wc_.wc_sat_sl[sl]));
132 kst_bottom_gw_vertical = cbm::bound_min( 0.0,
133 ldndc::hydraulic_conductivity(
134 wc_new,
135 wc_.vgm_sl[sl],
136 wc_.mvg_tau_sl[sl],
137 wc_.wc_sat_sl[sl],
138 wc_.wc_res_sl[sl],
139 kst_sl[sl]));
140 gw_fill_sl[sl] = 0.0;
141 }
142 }
143 }
144
145 //groundwater removal
146 for (size_t sl = 1; !use_storage_exchange && sl < soillayers_in->soil_layer_cnt()-1; sl++)
147 {
148 double const layer_midpoint_depth( sc_.depth_sl[sl]);
149 if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static_old) &&
150 cbm::flt_less( layer_midpoint_depth, gw_depth_static) &&
151 cbm::flt_greater( wl_sl[sl] + EcHySoilWaterChange( sl), wc_.wc_fc_sl[sl] * sc_.h_sl[sl]))
152 {
153 double wl_reduce( wl_sl[sl] + EcHySoilWaterChange( sl) - wc_.wc_fc_sl[sl] * sc_.h_sl[sl]);
154 gw_fill_sl[sl] -= wl_reduce;
155 // water drained with the falling groundwater table leaves the domain
156 wc_.accumulated_groundwater_loss += wl_reduce;
157 wc_.accumulated_groundwater_exchange_sl[sl] -= wl_reduce;
158 }
159 }
160
161 //capillary rise
162 if ( have_capillary_flow)
163 {
164 size_t const STEPS( 10);
165 for (size_t steps = 0; steps < STEPS; steps++)
166 {
167 for (size_t sl = 0; sl < soillayers_in->soil_layer_cnt()-1; sl++)
168 {
169 double const layer_midpoint_depth( sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl]);
170 if ( cbm::flt_greater_equal( layer_midpoint_depth, gw_depth_static))
171 {
172 break;
173 }
174
175 /* Water contents with until now calculated water balance */
176 double const wl_new_0( wl_sl[sl] + EcHySoilWaterChange( sl));
177 double const wl_new_1( wl_sl[sl+1] + EcHySoilWaterChange( sl+1));
178
179 double const wc_vg_0( cbm::bound( wc_.wc_res_sl[sl], wl_new_0 / sc_.h_sl[sl], wc_.wc_sat_sl[sl]));
180 double const wc_vg_1( cbm::bound( wc_.wc_res_sl[sl+1], wl_new_1 / sc_.h_sl[sl+1], wc_.wc_sat_sl[sl+1]));
181
182 /* Unsaturated hydraulic conductivity with until now calculated water balance */
183 double const kust_0( cbm::bound_min( 0.0,
184 ldndc::hydraulic_conductivity(
185 wc_vg_0, wc_.vgm_sl[sl], wc_.mvg_tau_sl[sl],
186 wc_.wc_sat_sl[sl], wc_.wc_res_sl[sl],
187 1.0/double(STEPS)*kst_sl[sl])));
188 double const kust_1( cbm::bound_min( 0.0,
189 ldndc::hydraulic_conductivity(
190 wc_vg_1, wc_.vgm_sl[sl+1], wc_.mvg_tau_sl[sl+1],
191 wc_.wc_sat_sl[sl+1], wc_.wc_res_sl[sl+1],
192 1.0/double(STEPS)*kst_sl[sl+1])));
193
194 double const capillary_pressure_0( ldndc::capillary_pressure(
195 wl_new_0/sc_.h_sl[sl], wc_.vga_sl[sl],
196 wc_.vgn_sl[sl], wc_.vgm_sl[sl],
197 wc_.wc_sat_sl[sl], wc_.wc_res_sl[sl]));
198 /* saturated and residual water content of the LOWER layer; until 2026-11-20
199 * the saturation of the upper layer was passed here, which biased the pressure
200 * gradient wherever two neighbouring layers differ in porosity - in peat
201 * profiles that is every boundary */
202 double const capillary_pressure_1( ldndc::capillary_pressure(
203 wl_new_1/sc_.h_sl[sl+1], wc_.vga_sl[sl+1],
204 wc_.vgn_sl[sl+1], wc_.vgm_sl[sl+1],
205 wc_.wc_sat_sl[sl+1], wc_.wc_res_sl[sl+1]));
206
207 double const kust( cbm::flt_greater( capillary_pressure_0, capillary_pressure_1) ? kust_1 : kust_0 );
208 double const flow( (capillary_pressure_1 - capillary_pressure_0) / (0.5 * (sc_.h_sl[sl] + sc_.h_sl[sl+1])) * kust);
209
210 /* downward flow*/
211 if ( cbm::flt_greater_zero( flow))
212 {
213 double const left( wl_sl[sl] + EcHySoilWaterChange( sl) - (wc_.wc_res_sl[sl] * sc_.h_sl[sl]));
214 double const space( 0.999 * pore_space( sl+1) - wc_.ice_sl[sl+1] * sc_.h_sl[sl+1]
215 - (wl_sl[sl+1] + EcHySoilWaterChange( sl+1)));
216
217 if ( cbm::flt_greater_zero( left) &&
218 cbm::flt_greater_zero( space))
219 {
220 double const bound_flow( cbm::bound_max( flow, std::min( left, space)) / static_cast<double>(STEPS));
221 cr_fill_sl[sl] -= bound_flow;
222 cr_fill_sl[sl+1] += bound_flow;
223 cr_down_sl[sl] += bound_flow;
224 }
225 }
226 /* upward flow */
227 else if ( cbm::flt_less( flow, 0.0))
228 {
229 double const left( wl_sl[sl+1] + EcHySoilWaterChange( sl+1) - (wc_.wc_res_sl[sl+1] * sc_.h_sl[sl+1]));
230 double const space( 0.999 * pore_space( sl) - wc_.ice_sl[sl] * sc_.h_sl[sl]
231 - (wl_sl[sl] + EcHySoilWaterChange( sl)));
232
233 if ( cbm::flt_greater_zero( left) &&
234 cbm::flt_greater_zero( space))
235 {
236 double const bound_flow( cbm::bound_max( -flow, std::min( left, space)) / static_cast<double>(STEPS));
237 cr_fill_sl[sl] += bound_flow;
238 cr_fill_sl[sl+1] -= bound_flow;
239 cr_up_sl[sl] += bound_flow;
240 }
241 }
242 }
243
244 size_t sl( soillayers_in->soil_layer_cnt()-1);
245 double const layer_midpoint_depth( sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl]);
246 if ( have_capillary_rise &&
247 //groundwater table below discretized soil
248 cbm::flt_greater( gw_depth_static, layer_midpoint_depth) &&
249 //groundwater not more than 10m below discretized soil
250 cbm::flt_less( gw_depth_static, layer_midpoint_depth + 10))
251 {
252 /* Water contents with until now calculated water balance */
253 double const wl_new( wl_sl[sl] + EcHySoilWaterChange( sl));
254
255 double const wc_vg( cbm::bound( wc_.wc_res_sl[sl], wl_new / sc_.h_sl[sl], wc_.wc_sat_sl[sl]));
256
257 /* Unsaturated hydraulic conductivity with until now calculated water balance */
258 double const kust( cbm::bound_min( 0.0,
259 ldndc::hydraulic_conductivity(
260 wc_vg, wc_.vgm_sl[sl], wc_.mvg_tau_sl[sl],
261 wc_.wc_sat_sl[sl], wc_.wc_res_sl[sl],
262 1.0/double(STEPS)*kst_sl[sl])));
263
264 double const capillary_pressure( ldndc::capillary_pressure(
265 wl_new/sc_.h_sl[sl], wc_.vga_sl[sl],
266 wc_.vgn_sl[sl], wc_.vgm_sl[sl],
267 wc_.wc_sat_sl[sl], wc_.wc_res_sl[sl]));
268
269 /* upward flow */
270 double const flow( -capillary_pressure / (gw_depth_static - layer_midpoint_depth) * kust);
271 if ( cbm::flt_less( flow, 0.0))
272 {
273 double const space( 0.999 * pore_space( sl) - wc_.ice_sl[sl] * sc_.h_sl[sl]
274 - (wl_sl[sl] + EcHySoilWaterChange( sl)));
275 if ( cbm::flt_greater_zero( space))
276 {
277 double const bound_flow( cbm::bound_max( -flow, 1.0 / static_cast<double>(STEPS) * space));
278 cr_fill_sl[sl] += bound_flow;
279 cr_fill_groundwater += bound_flow;
280 cr_up_sl[sl] += bound_flow;
281 }
282 }
283 }
284 }
285 }
286
287 return LDNDC_ERR_OK;
288}
lvector< double > bypass_fill_sl
Definition echy.h:111
bool have_gw_exchange_storage
Definition echy.h:236
lerr_t EcHyGroundwaterStorageExchange()
Exchange with a prescribed groundwater table based on profile water storage.
Definition echy-groundwater.cpp:308
double EcHySoilWaterChange(size_t)
Definition echy.cpp:557
lvector< double > cr_fill_sl
Definition echy.h:103
double gw_depth_static
Definition echy.h:79

References bypass_fill_sl, cr_fill_groundwater, cr_fill_sl, EcHyGroundwaterStorageExchange(), EcHySoilWaterChange(), ev_surfacewater, gw_depth_static, gw_fill_sl, gw_fill_surface, have_gw_exchange_storage, kst_sl, runoff, throughfall_water, wl_sl, and wlfl_sl.

Referenced by EcHyBypassFlow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EcHyGroundwaterStorageExchange()

lerr_t ldndc::EcHy::EcHyGroundwaterStorageExchange ( )
private

Exchange with a prescribed groundwater table based on profile water storage.

The target storage is the hydrostatic equilibrium profile for the prescribed water table (saturated below, van Genuchten water content at the height above the water table above). Only the difference between target storage and the storage resulting from all vertical fluxes of the time step (infiltration, evapotranspiration, percolation) is exchanged with the groundwater, relaxed with the time constant gwexchangetau. A falling water table caused by evapotranspiration therefore does not drain the profile a second time, and a rising water table caused by rainfall is not refilled from groundwater. Inflow is distributed to layers in proportion to their deficit, outflow in proportion to their surplus relative to the target.

309{
310 size_t const S( soillayers_in->soil_layer_cnt());
311
312 double s_target( 0.0);
313 double s_actual( 0.0);
314 double deficit( 0.0);
315 double surplus( 0.0);
316 lvector_t< double > delta_sl( S, 0.0);
317 for ( size_t sl = 0; sl < S; ++sl)
318 {
319 gw_fill_sl[sl] = 0.0;
320
321 double const z_mid( sc_.depth_sl[sl] - 0.5 * sc_.h_sl[sl]);
322 double const h_above( gw_depth_static - z_mid); // height above water table [m]
323 double const wc_max( 0.999 * pore_space( sl) / sc_.h_sl[sl] - wc_.ice_sl[sl]);
324 double wc_eq( wc_max);
325 if ( cbm::flt_greater_zero( h_above))
326 {
327 wc_eq = std::min( wc_max, ldndc::hydrology::water_content( h_above, wc_.vga_sl[sl], wc_.vgn_sl[sl], wc_.vgm_sl[sl],
328 wc_.wc_sat_sl[sl], wc_.wc_res_sl[sl]));
329 }
330 double const wl_actual( wl_sl[sl] + EcHySoilWaterChange( sl));
331 double const wl_target( wc_eq * sc_.h_sl[sl]);
332
333 s_target += wl_target;
334 s_actual += wl_actual;
335 delta_sl[sl] = wl_target - wl_actual;
336 if ( cbm::flt_greater_zero( delta_sl[sl]))
337 {
338 // inflow limited by available pore space
339 delta_sl[sl] = std::min( delta_sl[sl], cbm::bound_min( 0.0, wc_max * sc_.h_sl[sl] - wl_actual));
340 deficit += delta_sl[sl];
341 }
342 else
343 {
344 // outflow limited by water above residual water content
345 delta_sl[sl] = -std::min( -delta_sl[sl], cbm::bound_min( 0.0, wl_actual - wc_.wc_res_sl[sl] * sc_.h_sl[sl]));
346 surplus -= delta_sl[sl];
347 }
348 }
349
350 double const dt( 1.0 / lclock()->time_resolution()); // [d]
351 double const relax( cbm::bound_max( dt / std::max( gw_exchange_tau, dt), 1.0));
352 double const exchange( relax * (s_target - s_actual));
353
355 {
356 // every layer relaxes towards its equilibrium water content (no netting of deficit and surplus)
357 for ( size_t sl = 0; sl < S; ++sl)
358 {
359 gw_fill_sl[sl] = relax * delta_sl[sl];
360 if ( cbm::flt_greater_zero( gw_fill_sl[sl]))
361 {
362 wc_.accumulated_groundwater_access += gw_fill_sl[sl];
363 wc_.accumulated_groundwater_exchange_sl[sl] += gw_fill_sl[sl];
364 }
365 else
366 {
367 wc_.accumulated_groundwater_loss -= gw_fill_sl[sl];
368 wc_.accumulated_groundwater_exchange_sl[sl] += gw_fill_sl[sl];
369 }
370 }
371 }
372 else if ( cbm::flt_greater_zero( exchange) && cbm::flt_greater_zero( deficit))
373 {
374 double const scale( std::min( exchange, deficit) / deficit);
375 for ( size_t sl = 0; sl < S; ++sl)
376 {
377 if ( cbm::flt_greater_zero( delta_sl[sl]))
378 {
379 gw_fill_sl[sl] = scale * delta_sl[sl];
380 wc_.accumulated_groundwater_access += gw_fill_sl[sl];
381 wc_.accumulated_groundwater_exchange_sl[sl] += gw_fill_sl[sl];
382 }
383 }
384 }
385 else if ( cbm::flt_less( exchange, 0.0) && cbm::flt_greater_zero( surplus))
386 {
387 double const scale( std::min( -exchange, surplus) / surplus);
388 for ( size_t sl = 0; sl < S; ++sl)
389 {
390 if ( cbm::flt_less( delta_sl[sl], 0.0))
391 {
392 gw_fill_sl[sl] = scale * delta_sl[sl];
393 wc_.accumulated_groundwater_loss -= gw_fill_sl[sl];
394 wc_.accumulated_groundwater_exchange_sl[sl] += gw_fill_sl[sl];
395 }
396 }
397 }
398
399 return LDNDC_ERR_OK;
400}
bool have_gw_exchange_layerwise
Definition echy.h:238
double gw_exchange_tau
Definition echy.h:240

References EcHySoilWaterChange(), gw_depth_static, gw_exchange_tau, gw_fill_sl, have_gw_exchange_layerwise, and wl_sl.

Referenced by EcHyGroundwater().

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.

570{
571 canopy_snow = cbm::bound_min( 0.0,
572 canopy_snow - canopy_snowmelt);
573 surface_snow = cbm::bound_min( 0.0,
574 surface_snow
576 - surface_snowmelt);
577 if ( cbm::flt_less( surface_snow, 1.0e-9))
578 {
579 surface_snow = 0.0;
580 }
581 canopy_water = cbm::bound_min( 0.0,
584 if ( cbm::flt_less( canopy_water, 1.0e-9))
585 {
586 canopy_water = 0.0;
587 }
588 surface_water = cbm::bound_min( 0.0,
589 surface_water
590 + throughfall_water + surface_snowmelt + gw_fill_surface + irrigation
592 if ( cbm::flt_less( surface_water, 1.0e-9))
593 {
594 surface_water = 0.0;
595 }
596
597 for (size_t sl = 0; sl < soillayers_in->soil_layer_cnt(); sl++)
598 {
599 wl_sl[sl] = cbm::bound_min( 0.0, wl_sl[sl] + EcHySoilWaterChange( sl));
600 wc_.mskpa_sl[sl] = ldndc::hydrology::capillary_pressure( wl_sl[sl]/sc_.h_sl[sl], wc_.vga_sl[sl],
601 wc_.vgn_sl[sl], wc_.vgm_sl[sl],
602 wc_.wc_sat_sl[sl], wc_.wc_res_sl[sl]);
603 }
604
605 return LDNDC_ERR_OK;
606}
double canopy_snowmelt
Definition echy.h:151

References bypass_fill_sl, canopy_snowmelt, canopy_water, EcHySoilWaterChange(), ev_surfacewater, gw_fill_surface, runoff, throughfall_snow, throughfall_water, wl_sl, and wlfl_sl.

Referenced by EcHyBypassFlow().

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.

559{
560 return wlfl_sl[_sl] - wlfl_sl[_sl+1] + cr_fill_sl[_sl] - trwl_sl[_sl] - evsws_sl[_sl] + gw_fill_sl[_sl];
561}

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

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

Here is the caller 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]

◆ bypass_fill_sl

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

Soillayer water input due to bypass flow

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

◆ canopy_snowmelt

double ldndc::EcHy::canopy_snowmelt
private

Snow melting

Referenced by EcHyIntegration(), and EcHySnowIce().

◆ canopy_water

double ldndc::EcHy::canopy_water
private

◆ 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(), EcHyreset(), and EcHyStepExit().

◆ cr_fill_sl

lvector< 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

...

◆ ev_leaf

double ldndc::EcHy::ev_leaf
private

Evaporation from plant surface

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

◆ ev_surfacewater

double ldndc::EcHy::ev_surfacewater
private

◆ evapotranspiration_method

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

...

◆ evsws_sl

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

◆ f_pet_ts

lvector< double > ldndc::EcHy::f_pet_ts
private

Share of the daily potential evapotranspiration per time step [-], sums to one.

◆ gw_depth_static

double ldndc::EcHy::gw_depth_static
private

Depth of groundwater table [m]

Referenced by EcHyGroundwater(), EcHyGroundwaterStorageExchange(), EcHyStepExit(), and EcHyStepInit().

◆ gw_exchange_tau

double ldndc::EcHy::gw_exchange_tau
private

time constant of storage-based groundwater exchange [d]

Referenced by EcHyGroundwaterStorageExchange().

◆ gw_fill_sl

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

Soillayer water input due to groundwater flow

Referenced by EcHyBalanceCheck(), EcHyGroundwater(), EcHyGroundwaterStorageExchange(), 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().

◆ gw_recharge_potential

double ldndc::EcHy::gw_recharge_potential
private

Water flow at the bottom of the profile before it is limited in the vicinity of the groundwater table [m]

Referenced by EcHyStepExit().

◆ have_gw_exchange_layerwise

bool ldndc::EcHy::have_gw_exchange_layerwise
private

storage-based exchange per layer instead of net profile storage (option gwexchange = storagelayer)

Referenced by EcHyGroundwaterStorageExchange().

◆ have_gw_exchange_storage

bool ldndc::EcHy::have_gw_exchange_storage
private

storage-based exchange with prescribed groundwater table (option gwexchange = storage)

Referenced by EcHyGroundwater().

◆ kst_bottom

double ldndc::EcHy::kst_bottom
private

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

Referenced by EcHyStepInit().

◆ kst_sl

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

Saturated hydraulic conductivity

Referenced by EcHyCapillaryRise(), EcHyFlood(), EcHyGroundwater(), and EcHyIrrigation().

◆ m_icecontent_in

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

...

Referenced by EcHySnowIce().

◆ pet_day_remaining

double ldndc::EcHy::pet_day_remaining
private

Remaining daily potential evapotranspiration [m]

Referenced by EcHyEvapotranspiration().

◆ pet_limit_daily

bool ldndc::EcHy::pet_limit_daily
private

Transpiration limited by remaining daily instead of time step potential evapotranspiration

Referenced by EcHyEvapotranspiration().

◆ potential_evapotranspiration_ts

double ldndc::EcHy::potential_evapotranspiration_ts
private

Potential evapotranspiration of the time step [m]

Referenced by EcHyEvapotranspiration(), and EcHyStepExit().

◆ potential_transpiration_ts

double ldndc::EcHy::potential_transpiration_ts
private

Potential transpiration of the time step (given by the physiology module) [m]

Referenced by EcHyEvapotranspiration().

◆ rad_pet_ts

lvector< double > ldndc::EcHy::rad_pet_ts
private

Short-wave radiation of each time step of the running day [W:m^-2].

Used to build the shares below at the beginning of the following day, so that the distribution of the daily potential evapotranspiration over the time steps is normalized with the radiation that actually occurred (see Normalization of the distribution).

◆ runoff

double ldndc::EcHy::runoff
private

◆ runoff_method

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

...

◆ thornthwaite_heat_index

double ldndc::EcHy::thornthwaite_heat_index
private

...

◆ throughfall_snow

double ldndc::EcHy::throughfall_snow
private

◆ throughfall_water

double ldndc::EcHy::throughfall_water
private

◆ transpiration_ts

double ldndc::EcHy::transpiration_ts
private

Actual transpiration of the time step [m] (equal to water uptake trwl_sl unless a plant water deficit is considered)

Referenced by EcHyEvapotranspiration(), and EcHyStepExit().

◆ trwl_sl

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

Water withdrawl by transpiration [m d−1]

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

◆ wl_sl

◆ wlfc_sl

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

Amount of water in soil layer at field capacity

Referenced by EcHyIrrigation().

◆ wlfl_sl

lvector< 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(), EcHyEvapotranspiration(), EcHyGroundwater(), EcHyIntegration(), EcHyreset(), EcHySoilWaterChange(), and EcHyStepExit().

◆ wlwp_sl

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

Amount of water in soil layer at wilting point

Referenced by EcHyGetWiltingPoint().