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

Watercycle model WatercycleDNDC. More...

#include <models/watercycle/dndc/watercycle-dndc.h>

Public Member Functions

lerr_t solve ()
 Kicks off computation for one time step.
 

Private Member Functions

lerr_t event_irrigate ()
 considers water input due to irrigation and/or liquid manure evetns
 
lerr_t event_flood ()
 sets hydrologic conditions during flooding events, e.g.,
 
double balance_check (double *)
 checks each time step for correct water balance
 
void CalcRaining (unsigned int)
 apportion daily rainfall to subdaily rainfall
 
double rainfall_intensity ()
 
void CalcIrrigation (unsigned int)
 apportion daily irrigation to subdaily irrigation
 
lerr_t CalcIceContent ()
 Call of ice-content related processes.
 
lerr_t CalcPotEvapoTranspiration (size_t)
 Potential evaporation.
 
void CalcInterception ()
 Calculates water quantity that is retained on leaf and stem bark surfaces.
 
double get_leaf_water ()
 Collects leaf water from all canopy layers.
 
double get_impedance_factor (size_t)
 Reduces water fluxes out of a layer if ice lenses have formed.
 
lerr_t CalcTranspiration ()
 
lerr_t CalcTranspirationCouvreur (double const &, double &)
 
void CalcSnowEvaporation ()
 
void CalcSurfaceWaterEvaporation ()
 
void CalcSurfaceFlux ()
 
void WatercycleDNDC_preferential_flow ()
 
void CalcSoilEvapoPercolation ()
 
void SoilWaterEvaporation (size_t)
 
double WaterFlowCapillaryRise (size_t, double const &)
 Similar to WaterFlowBelowFieldCapacity(...) but restricts water flow by water availability from soil layer below.
 
double WaterFlowAboveFieldCapacity (size_t, double const &)
 
double get_fsl (size_t)
 Returns factor accounting for soil layer depth. Originally, a constant soil layer depth of 0.02 m has been assumed. Due to flexible layer depth, an additional factor has been introduced that accounts for a higher resistance of larger layers.
 
double substep_day_fraction ()
 Length of a substep as fraction of a day.
 
double get_clay_limitation (size_t _sl, double _water_avail, double _water_ref)
 Restrains water availability due to clay content.
 
double hours_per_time_step ()
 

Private Attributes

double thornthwaite_heat_index
 heat index for potential evaporation using approach after Thornthwaite
 
double rainfall_intensity_cache
 

Detailed Description

Watercycle model WatercycleDNDC.

Member Function Documentation

◆ balance_check()

double ldndc::WatercycleDNDC::balance_check ( double * _balance)
private

checks each time step for correct water balance

Balance check of water.

2652{
2653 double balance = get_leaf_water() + wc_.surface_ice + wc_.surface_water;
2654 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
2655 {
2656 balance += (wc_.wc_sl[sl] + wc_.ice_sl[sl]) * sc_.h_sl[sl];
2657 }
2658 balance += ( - m_wc.accumulated_irrigation_event_executed
2659 - wc_.accumulated_irrigation_automatic
2660 - wc_.accumulated_irrigation_ggcmi
2661 - wc_.accumulated_irrigation_reservoir_withdrawal
2662 - wc_.accumulated_precipitation
2663 - wc_.accumulated_groundwater_access
2664 + wc_.accumulated_percolation
2665 + wc_.accumulated_runoff
2666 + wc_.accumulated_wateruptake_sl.sum()
2667 + wc_.accumulated_interceptionevaporation
2668 + wc_.accumulated_soilevaporation
2669 + wc_.accumulated_surfacewaterevaporation);
2670
2671 if ( _balance)
2672 {
2673 double const balance_delta( std::abs( *_balance - balance));
2674 if ( balance_delta > cbm::DIFFMAX)
2675 {
2676 KLOGWARN( "Water leakage: difference is ", balance - *_balance);
2677 }
2678 }
2679
2680 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
2681 {
2682 if ( cbm::flt_less( wc_.wc_sl[sl], 0.0))
2683 {
2684 KLOGWARN( "Negative water content of: ", wc_.wc_sl[sl], " in layer: ", sl, ". Water content set to zero.");
2685 wc_.wc_sl[sl] = 0.0;
2686 }
2687 if ( cbm::flt_less( wc_.ice_sl[sl], 0.0))
2688 {
2689 KLOGWARN( "Negative ice content of: ", wc_.ice_sl[sl], " in layer: ", sl, ". Ice content set to zero.");
2690 wc_.ice_sl[sl] = 0.0;
2691 }
2692 }
2693
2694 return balance;
2695}
double get_leaf_water()
Collects leaf water from all canopy layers.
Definition watercycle-dndc.cpp:1210

References balance_check(), and get_leaf_water().

Referenced by balance_check(), and solve().

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

◆ CalcInterception()

void ldndc::WatercycleDNDC::CalcInterception ( )
private

Calculates water quantity that is retained on leaf and stem bark surfaces.

  • Rainfall and interception are assumed to happen at the end of the timestep and evaporation is realised at once at the start of the timestep.
  • The model assumes a homogeneous horizontal distribution of LAI although a non-linear dependency to crown cover (relative foliage clumping) has been reported (e.g. Teklehaimanot et al. 1991).
  • The default water-interception for foliage almost equal to the largest species specific value

References get_impedance_factor(), and get_leaf_water().

Referenced by solve().

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

◆ CalcIrrigation()

void ldndc::WatercycleDNDC::CalcIrrigation ( unsigned int _substep)
private

apportion daily irrigation to subdaily irrigation

Automatic irrigation to prevent water stress

GGCMI style irrigation

  • fill up the water content of each soil layer to field capacity at the start of each day
  • water supplied just injected into soil layer
  • no interception, no run off, no surface-water
  • only irrigate if a crop is present

Irrigation due to flooding

irrigation triggered by flooding management

Irrigation due to explicit irrigation event

902{
903 //reset irrigation
904 m_wc.irrigation = 0.0;
905
909 if (cbm::flt_in_range_lu(0.0, m_cfg.automaticirrigation, 1.0))
910 {
911 if (m_veg->size() > 0) //check crop is present
912 {
913 if (cbm::flt_greater(mc_.nd_airtemperature,10.0)) // only add water if temperature > 10C)
914 {
915 for (size_t l = 0; l < m_soillayers->soil_layer_cnt(); ++l)
916 {
917 if (cbm::flt_greater_zero(m_veg->mfrt_sl(l))) //only count water need for soil layers that contain roots
918 {
919 // trigger irrigation events as soon as drought stress appears
920 double const wc_target(wc_.wc_wp_sl[l] + m_cfg.automaticirrigation * (wc_.wc_fc_sl[l] - wc_.wc_wp_sl[l]));
921 if (cbm::flt_less(wc_.wc_sl[l], wc_target) &&
922 cbm::flt_equal_zero(wc_.ice_sl[l])) //only add water if no ice is present
923 {
924 // irrigation assumed until target water content
925 double const irrigate_layer((wc_target - wc_.wc_sl[l]) * sc_.h_sl[l]);
926 m_wc.irrigation += irrigate_layer;
927 wc_.accumulated_irrigation_automatic += irrigate_layer;
928 }
929 }
930 }
931
932 }
933 else
934 {
935 }
936
937 }
938 }
939
940 if ( cbm::flt_in_range_lu( 0.0, m_eventflood.get_saturation_level(), 1.0) &&
941 cbm::is_valid( m_eventflood.get_irrigation_height()) &&
942 cbm::is_valid( m_eventflood.get_soil_depth()))
943 {
944 double wc_sum( 0.0);
945 double wc_fc_sum( 0.0);
946 double wc_wp_sum( 0.0);
947 for ( size_t l = 0; l < m_soillayers->soil_layer_cnt(); ++l)
948 {
949 wc_sum += wc_.wc_sl[l] * sc_.h_sl[l];
950 wc_fc_sum += wc_.wc_fc_sl[l] * sc_.h_sl[l];
951 wc_wp_sum += wc_.wc_wp_sl[l] * sc_.h_sl[l];
952
953 if ( cbm::flt_greater_equal( sc_.depth_sl[l], m_eventflood.get_soil_depth()))
954 {
955 break;
956 }
957 }
958
959 // trigger irrigation events as soon as drought stress appears
960 double const wc_target( wc_wp_sum + m_eventflood.get_saturation_level() * (wc_fc_sum - wc_wp_sum));
961 if ( cbm::flt_less( wc_sum, wc_target))
962 {
963 m_wc.irrigation += m_eventflood.get_irrigation_height();
964 wc_.accumulated_irrigation_automatic += m_eventflood.get_irrigation_height();
965 }
966 }
967
975 if ( m_cfg.ggcmi_irrigation)
976 {
977 if( (lclock()->subday() == 1) && (_substep == 0))
978 {
979 if( m_veg->size() > 0 ) //check crop is present
980 {
981 double water_supply( 0.0);
982 for ( size_t l = 0; l < m_soillayers->soil_layer_cnt(); ++l)
983 {
984 if ( cbm::flt_greater_zero( m_veg->mfrt_sl( l))) //only irrigate soil layers that contain roots
985 {
986 if( cbm::flt_less( wc_.wc_sl[l], wc_.wc_fc_sl[l]) &&
987 cbm::flt_equal_zero( wc_.ice_sl[l])) //only add water if no ice is present
988 {
989 water_supply += (wc_.wc_fc_sl[l] - wc_.wc_sl[l]) * sc_.h_sl[l]; //amount of water added (m)
990 wc_.wc_sl[l] = wc_.wc_fc_sl[l];
991 }
992 }
993 }
994 wc_.accumulated_irrigation_ggcmi += water_supply;
995 }
996 }
997 }
998
1002 if ( cbm::is_valid( m_eventflood.get_water_table()))
1003 {
1004 /* Dynamic flooding */
1005 if ( cbm::is_valid( m_eventflood.get_irrigation_height()))
1006 {
1007 bool irrigate( false);
1008
1009 /* Irrigate after surface water table drop */
1010 if ( cbm::flt_greater_equal_zero( m_eventflood.get_water_table()))
1011 {
1012 if ( cbm::flt_greater( m_eventflood.get_water_table(), wc_.surface_water))
1013 {
1014 irrigate = true;
1015 }
1016 }
1017 else
1018 {
1019 if ( !cbm::flt_greater_zero( wc_.surface_water))
1020 {
1021 double water_tot_sum( 0.0);
1022 double water_fc_sum( 0.0);
1023 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
1024 {
1025 water_tot_sum += wc_.wc_sl[sl] * sc_.h_sl[sl];
1026 water_fc_sum += wc_.wc_fc_sl[sl] * sc_.h_sl[sl];
1027 if ( cbm::flt_greater_equal( sc_.depth_sl[sl], -m_eventflood.get_water_table()))
1028 {
1029 break;
1030 }
1031 }
1032 // Note: The tipping bucket approach may block percolation into deeper soil layers
1033 // if the upper layers have higher water content. This can lead to water reduction
1034 // from evapotranspiration in deeper layers without replenishment from above.
1035 // Workaround: AWD is triggered when the integrated topsoil water drops below
1036 // 90% of the integrated topsoil field capacity.
1037 if ( cbm::flt_less( water_tot_sum, 0.9 * water_fc_sum))
1038 {
1039 irrigate = true;
1040 }
1041 }
1042 }
1043 // trigger AWD irrigation event
1044 if ( irrigate)
1045 {
1046 double water_supply( cbm::bound_min( 0.0, m_eventflood.get_irrigation_height() - wc_.surface_water));
1047 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
1048 {
1049 // set soil fully water saturated
1050 if ( cbm::flt_greater( sc_.poro_sl[sl], wc_.wc_sl[sl]))
1051 {
1052 water_supply += ((sc_.poro_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl]);
1053 }
1054 }
1055
1056 //remove rainfall (less irrigation water is supplied if it if raining)
1057 water_supply = cbm::bound_min( 0.0, water_supply - m_mc.precipitation_ts);
1058
1059 if ( m_eventflood.have_unlimited_water())
1060 {
1061 wc_.accumulated_irrigation_automatic += water_supply;
1062 }
1063 else
1064 {
1065 if ( cbm::flt_greater( wc_.irrigation_reservoir, water_supply))
1066 {
1067 wc_.irrigation_reservoir -= water_supply;
1068 }
1069 else
1070 {
1071 water_supply = wc_.irrigation_reservoir;
1072 wc_.irrigation_reservoir = 0.0;
1073 }
1074 wc_.accumulated_irrigation_reservoir_withdrawal += water_supply;
1075 }
1076 m_wc.irrigation += water_supply;
1077 }
1078 }
1079 /* Static flooding */
1080 else
1081 {
1082 if ( !cbm::flt_greater_zero( m_eventflood.get_water_table()))
1083 {
1084 double water_supply( 0.0);
1085 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
1086 {
1087 if ( cbm::flt_greater( sc_.depth_sl[sl], -m_eventflood.get_water_table()) &&
1088 cbm::flt_greater( sc_.poro_sl[sl], wc_.wc_sl[sl]))
1089 {
1090 double const scale( cbm::flt_less( sc_.depth_sl[sl] - sc_.h_sl[sl], -m_eventflood.get_water_table()) ?
1091 (-m_eventflood.get_water_table() - (sc_.depth_sl[sl] - sc_.h_sl[sl])) / sc_.h_sl[sl] :
1092 1.0);
1093
1094 water_supply += scale * (sc_.poro_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl];
1095 }
1096 }
1097
1098 //remove rainfall (less irrigation water is supplied if it is raining)
1099 //and limit by saturated water flow into the first soil layer during the substep
1100 water_supply = cbm::bound( 0.0, water_supply - m_mc.precipitation_ts,
1101 WaterFlowSaturated( 0, get_impedance_factor( 0)));
1102
1103 /* Surface water will be actively drained */
1104 if ( cbm::flt_greater_equal( wc_.surface_water, water_supply))
1105 {
1106 wc_.accumulated_runoff += wc_.surface_water - water_supply;
1107 wc_.surface_water = water_supply;
1108 water_supply = 0.0;
1109 }
1110 else if ( cbm::flt_greater_zero( wc_.surface_water))
1111 {
1112 water_supply -= wc_.surface_water;
1113 }
1114
1115 if ( m_eventflood.have_unlimited_water())
1116 {
1117 wc_.accumulated_irrigation_automatic += water_supply;
1118 }
1119 else
1120 {
1121 if ( cbm::flt_greater( wc_.irrigation_reservoir, water_supply))
1122 {
1123 wc_.irrigation_reservoir -= water_supply;
1124 }
1125 else
1126 {
1127 water_supply = wc_.irrigation_reservoir;
1128 wc_.irrigation_reservoir = 0.0;
1129 }
1130 wc_.accumulated_irrigation_reservoir_withdrawal += water_supply;
1131 }
1132
1133 m_wc.irrigation += water_supply;
1134 }
1138 else if ( cbm::flt_greater( m_eventflood.get_water_table(), wc_.surface_water))
1139 {
1140 //adjust surface and soil water in case of flooding event
1141 //water required to fill up surface water
1142 double water_supply( m_eventflood.get_water_table() - wc_.surface_water);
1143
1144 //add water required to fill top x layers up to saturation
1145 unsigned long no_layers(3);
1146 if( no_layers > m_soillayers->soil_layer_cnt())
1147 {
1148 no_layers = m_soillayers->soil_layer_cnt();
1149 }
1150
1151 for ( size_t sl = 0; sl < no_layers; ++sl)
1152 {
1153 water_supply += ((sc_.poro_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl]);
1154 }
1155
1156 //remove rainfall (less irrigation water is supplied if it if raining)
1157 water_supply = cbm::bound_min( 0.0, water_supply - m_mc.precipitation_ts);
1158
1159 if ( m_eventflood.have_unlimited_water())
1160 {
1161 wc_.accumulated_irrigation_automatic += water_supply;
1162 }
1163 else
1164 {
1165 if ( cbm::flt_greater( wc_.irrigation_reservoir, water_supply))
1166 {
1167 wc_.irrigation_reservoir -= water_supply;
1168 }
1169 else
1170 {
1171 water_supply = wc_.irrigation_reservoir;
1172 wc_.irrigation_reservoir = 0.0;
1173 }
1174 wc_.accumulated_irrigation_reservoir_withdrawal += water_supply;
1175 }
1176 m_wc.irrigation += water_supply;
1177 }
1178 }
1179 }
1180
1184 double const irrigation_scheduled( cbm::bound_min( 0.0, wc_.accumulated_irrigation - m_wc.accumulated_irrigation_event_executed));
1185
1186 // note: amounts are given per substep (substep_hours hours)
1187 if ( cbm::flt_greater( irrigation_scheduled, 24.0 * rainfall_intensity()))
1188 {
1189 m_wc.irrigation += irrigation_scheduled * substep_hours / 24.0;
1190 m_wc.accumulated_irrigation_event_executed += irrigation_scheduled * substep_hours / 24.0;
1191 }
1192 else if ( cbm::flt_greater( irrigation_scheduled, substep_hours * rainfall_intensity()))
1193 {
1194 m_wc.irrigation += substep_hours * rainfall_intensity();
1195 m_wc.accumulated_irrigation_event_executed += substep_hours * rainfall_intensity();
1196 }
1197 else
1198 {
1199 m_wc.irrigation += irrigation_scheduled;
1200 m_wc.accumulated_irrigation_event_executed += irrigation_scheduled;
1201 }
1202}
double rainfall_intensity()
Definition watercycle-dndc.cpp:109
double get_impedance_factor(size_t)
Reduces water fluxes out of a layer if ice lenses have formed.
Definition watercycle-dndc.cpp:2525

References CalcIrrigation(), get_impedance_factor(), and rainfall_intensity().

Referenced by CalcIrrigation(), and solve().

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

◆ CalcPotEvapoTranspiration()

lerr_t ldndc::WatercycleDNDC::CalcPotEvapoTranspiration ( size_t _substep)
private

Potential evaporation.


there are two methods of calculating potential evaporation (choose via macro POTENTIAL_EVAPORATION above)

  • [0] Procedure according to Thornthwaite 1948 with modifications by Camargo et al. 1999 and Peireira and Pruitt 2004 (implemented from Pereira and Pruitt 2004) to better account for dry environments and daylength.
    NOTE:
    • monthly temperatures are assumed to be equal to daily average temperature of the middle of the month, calculated from continous equations equal to those used in the weather generator.
    • the model uses always daily average temperature as input even if it is run in sub-daily mode
    • the original PnET-N-DNDC code which contains modification that could not be found in the literature has been outcommented.
  • [1] uses the Priestley Taylor equation (Priestly and Taylor 1972) to calculate daily and hourly potential evapotranspiration (implemented from internet) vps calculation according to Allen et al. 1998, cit. in Cai et al. 2007
605{
606 // Daily evaportation demand is derived from the Thornthwaite, the Penman, or the Priestley-Taylor method (standard is 'thornthwaite).
607 day_potevapo = 0.0;
608 if ( m_cfg.potentialevapotranspiration_method == "thornthwaite")
609 {
610 if ( lclock()->is_position( TMODE_PRE_YEARLY))
611 {
613 lclock()->days_in_year(),
614 m_climate->annual_temperature_average(),
615 m_climate->annual_temperature_amplitude());
616 }
617
618 double const daylength(ldndc::meteo::daylength(m_setup->latitude(), lclock()->yearday()));
619 double const avg_dayl(12.0);
620
621 day_potevapo = m_sipar->WCDNDC_INCREASE_POT_EVAPOTRANS()
623 mc_.nd_airtemperature,
624 daylength, avg_dayl, lclock()->days_in_month(),
626 }
627 else if ( (m_cfg.potentialevapotranspiration_method == "penman") ||
628 (m_cfg.potentialevapotranspiration_method == "priestleytaylor") ||
629 (m_cfg.potentialevapotranspiration_method == "penmanmonteith"))
630 {
631 cbm::sclock_t const & clk( lclock_ref());
632
633 /* vapour pressure [10^3:Pa] */
634 double vps( 0.0);
635 ldndc::meteo::vps( mc_.nd_airtemperature, &vps);
636 double vp( vps - m_climate->vpd_day( clk));
637
638 if( m_cfg.potentialevapotranspiration_method == "priestleytaylor")
639 {
640 day_potevapo = m_sipar->WCDNDC_INCREASE_POT_EVAPOTRANS()
641 * ldndc::priestleytaylor( clk.yearday(),
642 clk.days_in_year(),
643 mc_.albedo,
644 m_setup->latitude(),
645 mc_.nd_airtemperature,
646 mc_.nd_shortwaveradiation_in,
647 vp,
648 m_sipar->PT_ALPHA(),
649 m_cfg.longwaveradiation_from_input ? mc_.nd_longwaveradiation_in * cbm::SEC_IN_DAY : -1.0);
650 }
651 else if( m_cfg.potentialevapotranspiration_method == "penman")
652 {
653 /* leaf area index */
654 double const lai( m_veg->lai());
655 ldndc::surface_type surface( cbm::flt_greater_zero( lai) ? short_grass : bare_soil);
656
657 day_potevapo = m_sipar->WCDNDC_INCREASE_POT_EVAPOTRANS()
658 * ldndc::penman( surface,
659 clk.yearday(),
660 clk.days_in_year(),
661 mc_.albedo,
662 m_setup->latitude(),
663 mc_.nd_shortwaveradiation_in * cbm::SEC_IN_DAY,
664 mc_.nd_airtemperature,
665 mc_.nd_windspeed,
666 vp,
667 m_cfg.longwaveradiation_from_input ? mc_.nd_longwaveradiation_in * cbm::SEC_IN_DAY : -1.0);
668 }
669 else if( m_cfg.potentialevapotranspiration_method == "penmanmonteith")
670 {
671 day_potevapo = m_sipar->WCDNDC_INCREASE_POT_EVAPOTRANS()
672 * ldndc::penman_monteith_fao56( clk.yearday(),
673 clk.days_in_year(),
674 m_setup->latitude(),
675 m_setup->elevation(),
676 mc_.nd_shortwaveradiation_in * cbm::SEC_IN_DAY,
677 mc_.nd_airtemperature,
678 mc_.nd_windspeed,
679 m_climate->windheight(),
680 vp,
681 m_cfg.longwaveradiation_from_input ? mc_.nd_longwaveradiation_in * cbm::SEC_IN_DAY : -1.0);
682 }
683 }
684 else
685 {
686 KLOGERROR("[BUG] huh : it seems that this potentialevapotranspiration method is not registered",
687 "tell the maintainers refering to this error message");
688 return LDNDC_ERR_FAIL;
689 }
690
691 // The daily evaporation demand is distributed throughout the day (standard is 'previouspattern)
692 // TODO: design a routine that distributes evaporation demand according to temperature or humidity
693 if ( m_cfg.evapotranspiration_method == "uniform")
694 {
695 // hourly evaporation demand is calculated from daily demand equally throughout the day
696 hr_pot_evapotrans = day_potevapo * substep_hours / cbm::HR_IN_DAY;
697 }
698 else if ( m_cfg.evapotranspiration_method == "previouspattern")
699 {
700 // evaporation demand of the time step is derived from the weighted expression of previous values
701 // and equally distributed over the substeps of the time step
702 hr_pot_evapotrans = day_potevapo * pot_evapotranspiration_ts[lclock()->subday()-1] / substeps_per_timestep;
703 }
704 else if (m_cfg.evapotranspiration_method == "daytimeonly")
705 {
706 // hourly evaporation demand is distributed throughout the sunlight hours only (similar as radiation)
707 // hour of the day at the end of the current substep
708 double const hour( double(lclock()->subday() - 1) * substep_hours * substeps_per_timestep + double(_substep + 1) * substep_hours);
709 double const day( lclock()->yearday());
710 double const hsun( 0.833 * cbm::PI / 180.0);
711 double const lat( m_setup->latitude() * cbm::PI / 180.0);
712 double const dec( -23.44 * (cbm::PI / 180.0) * std::cos(2.0 * cbm::PI * (day - 172.0) / lclock()->days_in_year()));
713 double const help( (std::sin(hsun) - std::sin(lat) * std::sin(dec)) / (std::cos(lat) * std::cos(dec)));
714 double dayl(0.0);
715 if (help < -0.999) dayl = 0.0;
716 else if (help > 0.999) dayl = 24.0;
717 else dayl = 24.0 - 24.0 / cbm::PI * std::acos((std::sin(hsun) - std::sin(lat) * std::sin(dec)) / (std::cos(lat) * std::cos(dec)));
718 if (dayl < 1.0) dayl = 0.0;
719 double const rise(12.0 - dayl * 0.5);
720
721 double factor(0.0);
722 if (dayl > 0.0) factor = (-std::cos(2.0 * cbm::PI * (hour - rise) / (cbm::HR_IN_DAY - 2.0 * rise)) + 1.0) / (cbm::HR_IN_DAY - 2.0 * rise);
723
724 double fday(0.0);
725 if (hour > rise && hour < (24.0 - rise)) fday = factor;
726
727 // fday is given per hour
728 hr_pot_evapotrans = day_potevapo * fday * substep_hours;
729 }
730 else
731 {
732 KLOGERROR("[BUG] huh : it seems that this evapotranspiration method option is not registered ",
733 "tell the maintainers refering to this error message");
734 return LDNDC_ERR_FAIL;
735 }
736
737 // the evaporation limit for all timesteps is the daily demand
738 wc_.accumulated_potentialevaporation += hr_pot_evapotrans;
739
740 return LDNDC_ERR_OK;
741}
double thornthwaite_heat_index
heat index for potential evaporation using approach after Thornthwaite
Definition watercycle-dndc.h:143
double LDNDC_API thornthwaite_heat_index(double, size_t, double, double)
Thornthwaite heat index.
Definition ld_thornthwaite.cpp:105
double penman_monteith_fao56(int, int, double, double, double, double, double, double, double, double=-1.0)
FAO-56 Penman-Monteith reference evapotranspiration [m d-1] (short grass, albedo 0....
Definition ld_penman.cpp:272
double LDNDC_API thornthwaite(double, double, double, double, double)
Potential evapotranspiration after thornthwaite:1948a.
Definition ld_thornthwaite.cpp:46

References CalcPotEvapoTranspiration(), ldndc::penman_monteith_fao56(), ldndc::thornthwaite(), ldndc::thornthwaite_heat_index(), and thornthwaite_heat_index.

Referenced by CalcPotEvapoTranspiration(), and solve().

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

◆ CalcSnowEvaporation()

void ldndc::WatercycleDNDC::CalcSnowEvaporation ( )
private
Parameters
[in]None
[out]None
Returns
None
2019{
2020 //Average limit of snowEvaporation is 0.00013m day-1 (Granger and Male 1978)
2021 double hr_potESnow( cbm::bound(0.0, hr_pot_evapotrans, 0.00013 * substep_hours/24.0));
2022
2023 if ( cbm::flt_greater_zero( wc_.surface_ice) &&
2024 cbm::flt_greater_zero( hr_potESnow))
2025 {
2026 //If there is a snowpack and there is a potential to evaporate
2027 if ( wc_.surface_ice > hr_potESnow)
2028 {
2029 //Partial evaporation from the snow
2030 //note: snow evaporation is booked as surface water evaporation (no separate state variable)
2031 hr_pot_evapotrans = cbm::bound_min( 0.0, hr_pot_evapotrans - hr_potESnow);
2032 wc_.accumulated_surfacewaterevaporation += hr_potESnow;
2033 wc_.surface_ice -= hr_potESnow;
2034 }
2035 else
2036 {
2037 //Total evaporation of the snowpack
2038 hr_pot_evapotrans = cbm::bound_min( 0.0, hr_pot_evapotrans - wc_.surface_ice);;
2039 wc_.accumulated_surfacewaterevaporation += wc_.surface_ice;
2040 wc_.surface_ice = 0.0;
2041 }
2042 }
2043}

References CalcSnowEvaporation().

Referenced by CalcSnowEvaporation(), CalcTranspiration(), and solve().

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

◆ CalcSoilEvapoPercolation()

void ldndc::WatercycleDNDC::CalcSoilEvapoPercolation ( )
private
Parameters
[in]None
[out]None
Returns
None
2151{
2152 // reset all water fluxes
2153 for (size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
2154 {
2155 m_wc.percolation_sl[sl] = 0.0;
2156 }
2157
2158 // fill groundwater layer with water
2159 for (int sl = m_soillayers->soil_layer_cnt() - 1; sl >= 0; --sl)
2160 {
2161 if (cbm::flt_greater(sc_.depth_sl[sl], ground_water_table))
2162 {
2163 // ice volume is excepted from groundwater
2164 double const ice_vol(wc_.ice_sl[sl] / cbm::DICE);
2165 if (cbm::flt_greater(sc_.poro_sl[sl], ice_vol))
2166 {
2167 // new water in the layer is generated from groundwater
2168 double const gw_access(cbm::bound_min(0.0, (sc_.poro_sl[sl] - ice_vol - wc_.wc_sl[sl]) * sc_.h_sl[sl] ));
2169 wc_.wc_sl[sl] += gw_access / sc_.h_sl[sl];
2170 wc_.accumulated_groundwater_access += gw_access;
2171 }
2172 }
2173 else
2174 {
2175 break;
2176 }
2177 }
2178
2179 for (size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
2180 {
2181 // the first soil (litter) layer is filled with surface water up to its capacity
2182 if (sl == 0)
2183 {
2184 double delta_wc(0.0);
2185 double const wc_old(wc_.wc_sl[sl]);
2186 double const wc_cap( (sc_.poro_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl]); // uptake capacity in first soil layer [mm]
2187
2188 if (cbm::flt_greater(wc_.surface_water, wc_cap))
2189 {
2190 wc_.wc_sl[sl] = sc_.poro_sl[sl];
2191 delta_wc = cbm::bound_max(wc_.surface_water, (cbm::bound_min(0.0, wc_.wc_sl[sl] - wc_old) * sc_.h_sl[sl]));
2192 wc_.surface_water -= delta_wc;
2193 }
2194 else
2195 {
2196 wc_.wc_sl[sl] = (wc_.wc_sl[sl] * sc_.h_sl[sl] + wc_.surface_water) / sc_.h_sl[sl];
2197 delta_wc = cbm::bound_max(wc_.surface_water, (cbm::bound_min(0.0, wc_.wc_sl[sl] - wc_old) * sc_.h_sl[sl]));
2198 wc_.surface_water = 0.0;
2199 }
2200
2201 wc_.accumulated_infiltration += delta_wc;
2202 }
2203 // other soil layers get updated by percolation rates from the layer above
2204 else
2205 {
2206 wc_.wc_sl[sl] += m_wc.percolation_sl[sl - 1] / sc_.h_sl[sl];
2207 }
2208
2209 // percolation for all layers below groundwater
2210 if (cbm::flt_greater(sc_.depth_sl[sl], ground_water_table))
2211 {
2212
2213 // in case groundwater reaches the soil surface, only water exceeding the pore space leaves
2214 // the first layer; a saturated-flow outflux would be refilled by groundwater access in the
2215 // next time step and circulate through the whole profile
2216 if (sl == 0)
2217 {
2218 m_wc.percolation_sl[sl] = cbm::bound_min( 0.0, (wc_.wc_sl[sl] - sc_.poro_sl[sl]) * sc_.h_sl[sl]);
2219 }
2220 // other soil layers are assumed to percolate by the same rate as the last non-groundwater layer
2221 else
2222 {
2223 m_wc.percolation_sl[sl] = m_wc.percolation_sl[sl - 1];
2224 }
2225
2226 }
2227 // in all other cases percolation
2228 else if (sl + 1 == m_soillayers->soil_layer_cnt())
2229 {
2230 m_wc.percolation_sl[sl] = 0.0;
2231 if (cbm::flt_greater_zero(wc_.sks_sl[sl]))
2232 {
2233 if (cbm::flt_greater(wc_.wc_sl[sl], sc_.poro_sl[sl]) &&
2234 cbm::flt_greater(wc_.wc_sl[sl], wc_.wc_fc_sl[sl])) //security, should be always true if first condition is met
2235 {
2236 //maximum allowed flow until field capacity
2237 double const max_flow((wc_.wc_sl[sl] - wc_.wc_fc_sl[sl]) * sc_.h_sl[sl]);
2238 m_wc.percolation_sl[sl] = cbm::bound_max(WaterFlowSaturated(sl, get_impedance_factor(sl)), max_flow);
2239 }
2240
2241 //water flux above field capacity
2242 else if (cbm::flt_greater_equal(wc_.wc_sl[sl] + wc_.ice_sl[sl], wc_.wc_fc_sl[sl]))
2243 {
2244 m_wc.percolation_sl[sl] = WaterFlowAboveFieldCapacity(sl, get_impedance_factor(sl));
2245 }
2246
2247 //water flux below field capacity and above wilting point
2248 else if ((sl > 0) && cbm::flt_greater_zero(m_wc.percolation_sl[sl - 1]) &&
2249 cbm::flt_greater(wc_.wc_sl[sl], wc_.wc_wp_sl[sl]))
2250 {
2251 m_wc.percolation_sl[sl] = m_sipar->FPERCOL() * m_wc.percolation_sl[sl - 1];
2252 }
2253
2254 //bound water flux by defined maximal percolation rate (e.g., during flooding events)
2255 m_wc.percolation_sl[sl] = cbm::bound_max(m_wc.percolation_sl[sl], max_percolation);
2256 }
2257 }
2258
2259 //infiltrating water in current time step is exceeding available pore space of last time step
2260 //second condition: security, should be always true if first condition is met
2261 else if (cbm::flt_greater(wc_.wc_sl[sl], sc_.poro_sl[sl]) &&
2262 cbm::flt_greater(wc_.wc_sl[sl], wc_.wc_fc_sl[sl]))
2263 {
2264 //maximum allowed flow until field capacity
2265 double const max_flow((wc_.wc_sl[sl] - wc_.wc_fc_sl[sl]) * sc_.h_sl[sl]);
2266 m_wc.percolation_sl[sl] = cbm::bound_max(WaterFlowSaturated(sl, get_impedance_factor(sl)),
2267 max_flow);
2268 }
2269 else if (cbm::flt_greater_equal(wc_.wc_sl[sl] + wc_.ice_sl[sl], wc_.wc_fc_sl[sl]))
2270 {
2271 m_wc.percolation_sl[sl] = WaterFlowAboveFieldCapacity(sl, get_impedance_factor(sl));
2272 }
2273 else if (cbm::flt_greater(wc_.wc_sl[sl], wc_.wc_wp_sl[sl]))
2274 {
2275 m_wc.percolation_sl[sl] = WaterFlowCapillaryRise(sl, get_impedance_factor(sl));
2276 }
2277 else
2278 {
2279 m_wc.percolation_sl[sl] = 0.0;
2280 }
2281
2282
2283 // water content must be greater or equal wilting point
2284 if (cbm::flt_less((wc_.wc_sl[sl] + wc_.ice_sl[sl]) * sc_.h_sl[sl] - m_wc.percolation_sl[sl], wc_.wc_wp_sl[sl] * sc_.h_sl[sl]) &&
2285 cbm::flt_greater_zero(m_wc.percolation_sl[sl]))
2286 {
2287 m_wc.percolation_sl[sl] = cbm::bound(0.0,
2288 (wc_.wc_sl[sl] + wc_.ice_sl[sl] - wc_.wc_wp_sl[sl]) * sc_.h_sl[sl],
2289 m_wc.percolation_sl[sl]);
2290 }
2291
2292 // Update of the current soil layer water content
2293 wc_.wc_sl[sl] -= m_wc.percolation_sl[sl] / sc_.h_sl[sl];
2294
2296 }
2297
2298 /* Correct water content and percolation if water content is above porosity
2299 * If the layer below cannot take up all of the water assigned for percolation,
2300 * so if the air filled pore space is not sufficient,
2301 * the water remains in the upper layer.
2302 */
2303 for (size_t sl = m_soillayers->soil_layer_cnt() - 1; sl > 0; sl--)
2304 {
2305 double const ice_vol(wc_.ice_sl[sl] / cbm::DICE);
2306 if (cbm::flt_greater(wc_.wc_sl[sl] + ice_vol, sc_.poro_sl[sl]))
2307 {
2308 double delta_wc(wc_.wc_sl[sl] + ice_vol - sc_.poro_sl[sl]);
2309 if (cbm::flt_greater_equal(ice_vol, sc_.poro_sl[sl]))
2310 {
2311 delta_wc = wc_.wc_sl[sl];
2312 wc_.wc_sl[sl] = 0.0;
2313 }
2314 else
2315 {
2316 wc_.wc_sl[sl] = sc_.poro_sl[sl] - ice_vol;
2317 }
2318 m_wc.percolation_sl[sl - 1] -= delta_wc * sc_.h_sl[sl];
2319 wc_.wc_sl[sl - 1] += delta_wc * sc_.h_sl[sl] / sc_.h_sl[sl - 1];
2320 }
2321 }
2322
2323 double const ice_vol(wc_.ice_sl[0] / cbm::DICE);
2324 if (cbm::flt_greater(wc_.wc_sl[0] + ice_vol, sc_.poro_sl[0]))
2325 {
2326
2327 double delta_wc(wc_.wc_sl[0] + ice_vol - sc_.poro_sl[0]);
2328 if (cbm::flt_greater_equal(ice_vol, sc_.poro_sl[0]))
2329 {
2330 delta_wc = wc_.wc_sl[0];
2331 wc_.wc_sl[0] = 0.0;
2332 }
2333 else
2334 {
2335 wc_.wc_sl[0] = sc_.poro_sl[0] - ice_vol;
2336 }
2337 wc_.accumulated_infiltration -= delta_wc * sc_.h_sl[0];
2338 wc_.surface_water += delta_wc * sc_.h_sl[0];
2339 }
2340
2341 if (cbm::flt_greater_zero(wc_.surface_water))
2342 {
2344 }
2345
2346 wc_.accumulated_waterflux_sl += m_wc.percolation_sl;
2347 wc_.accumulated_percolation += m_wc.percolation_sl[ m_soillayers->soil_layer_cnt()-1];
2348}
double WaterFlowAboveFieldCapacity(size_t, double const &)
Definition watercycle-dndc.cpp:2368
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 SoilWaterEvaporation(size_t)
Definition watercycle-dndc.cpp:2079

References CalcSoilEvapoPercolation(), CalcSurfaceFlux(), get_impedance_factor(), SoilWaterEvaporation(), WaterFlowAboveFieldCapacity(), and WaterFlowCapillaryRise().

Referenced by CalcSoilEvapoPercolation(), CalcTranspiration(), and solve().

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

◆ CalcSurfaceFlux()

void ldndc::WatercycleDNDC::CalcSurfaceFlux ( )
private
Parameters
[in]None
[out]None
Returns
None
2575{
2576 if ( cbm::flt_greater_zero( m_eventflood.get_bund_height()))
2577 {
2578 if ( cbm::flt_greater( wc_.surface_water, m_eventflood.get_bund_height()))
2579 {
2580 wc_.accumulated_runoff += wc_.surface_water - m_eventflood.get_bund_height();
2581 wc_.surface_water = m_eventflood.get_bund_height();
2582 }
2583 }
2584 else
2585 {
2586 /* runoff fraction per time step equals RO fraction per hour * length of a time step */
2587 double const runoff_fraction(m_sipar->FRUNOFF() * substep_day_fraction());
2588
2589 // - not all surface water is removed within one timestep
2590 if ( cbm::flt_less( runoff_fraction, 1.0))
2591 {
2592 double const runoff( runoff_fraction * wc_.surface_water);
2593 wc_.surface_water -= runoff;
2594 wc_.accumulated_runoff += runoff;
2595 }
2596 // - all surface water is immediatly removed
2597 else
2598 {
2599 wc_.accumulated_runoff += wc_.surface_water;
2600 wc_.surface_water = 0.0;
2601 }
2602 }
2603}
double substep_day_fraction()
Length of a substep as fraction of a day.
Definition watercycle-dndc.cpp:2640

References CalcSurfaceFlux(), and substep_day_fraction().

Referenced by CalcSoilEvapoPercolation(), CalcSurfaceFlux(), and CalcTranspiration().

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

◆ CalcSurfaceWaterEvaporation()

void ldndc::WatercycleDNDC::CalcSurfaceWaterEvaporation ( )
private
Parameters
[in]None
[out]None
Returns
None
1986{
1987 if ( cbm::flt_greater_zero( wc_.surface_water) &&
1988 cbm::flt_greater_zero( hr_pot_evapotrans))
1989 {
1990 if ( hr_pot_evapotrans > wc_.surface_water)
1991 {
1992 wc_.accumulated_surfacewaterevaporation += wc_.surface_water;
1993 hr_pot_evapotrans -= wc_.surface_water;
1994 wc_.surface_water = 0.0;
1995 }
1996 else
1997 {
1998 wc_.surface_water -= hr_pot_evapotrans;
1999 wc_.accumulated_surfacewaterevaporation += hr_pot_evapotrans;
2000 hr_pot_evapotrans = 0.0;
2001 }
2002 }
2003}

References CalcSurfaceWaterEvaporation().

Referenced by CalcSurfaceWaterEvaporation(), CalcTranspiration(), and solve().

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

◆ CalcTranspiration()

lerr_t ldndc::WatercycleDNDC::CalcTranspiration ( )
private

◆ CalcTranspirationCouvreur()

lerr_t ldndc::WatercycleDNDC::CalcTranspirationCouvreur ( double const & _transpiration_possible,
double & _uptake )
private
Parameters
[in]None
[out]None
Returns
None
1861{
1862 _uptake = 0.0;
1863
1864 double const mfrt_total( m_veg->dw_frt());
1865 if ( !cbm::flt_greater_zero( mfrt_total))
1866 {
1867 return LDNDC_ERR_OK;
1868 }
1869
1870 /* TODO: include ice_water_ratio_critical as proper parameter */
1871 double const ice_water_ratio_critical( 0.1);
1872 size_t const sl_cnt( m_soillayers->soil_layer_cnt());
1873 lvector_t< double > head_sl( sl_cnt, 0.0);
1874 lvector_t< double > active_sl( sl_cnt, 0.0);
1875
1876 // Calculate the root water uptake and hence the transpiration for every plant individually
1877 for( PlantIterator vt = m_veg->begin(); vt != m_veg->end(); ++vt)
1878 {
1879 MoBiLE_Plant *p = *vt;
1880 if ( !cbm::flt_greater_zero( p->mFrt))
1881 {
1882 continue;
1883 }
1884 if ( !cbm::flt_greater_zero( vt->KRSINIT()) || !cbm::flt_greater_zero( vt->FRTMASSINIT()) || !cbm::flt_less( vt->HLEAFCRIT(), 0.0))
1885 {
1886 KLOGERROR( "ROOT_WATER_UPTAKE_COUVREUR requires species parameters KRSINIT > 0, FRTMASSINIT > 0 and HLEAFCRIT < 0 [species=",
1887 p->name(), ", KRSINIT=", vt->KRSINIT(), ", FRTMASSINIT=", vt->FRTMASSINIT(), ", HLEAFCRIT=", vt->HLEAFCRIT(), "]");
1888 return LDNDC_ERR_FAIL;
1889 }
1890
1891 // possible transpiration of this plant, split up by the fine root mass
1892 double const transpiration_possible_vt( cbm::bound_min( 0.0, _transpiration_possible) * p->mFrt / mfrt_total * cbm::CM_IN_M); // cm
1893
1894 // If some soil layers are frozen and contain only ice, no fluid water is present and the water potential diverges.
1895 // The uptake from these layers is prevented by considering only roots in layers with more water than ice,
1896 // and the root distribution is rescaled to the active layers.
1897 double active_root_fraction( 0.0);
1898 double eff_soil_water_potential( 0.0);
1899 size_t sl_rooted( 0);
1900 for( size_t sl = 0; sl < sl_cnt; ++sl)
1901 {
1902 active_sl[sl] = 0.0;
1903 if ( !cbm::flt_greater_zero( p->fFrt_sl[sl]))
1904 {
1905 // roots are not wireless ;-)
1906 break;
1907 }
1908 sl_rooted = sl + 1;
1909 if ( cbm::flt_greater_zero( wc_.wc_sl[sl]) &&
1910 cbm::flt_less( wc_.ice_sl[sl] / wc_.wc_sl[sl], ice_water_ratio_critical))
1911 {
1912 head_sl[sl] = Soillayerwaterhead( sl); // negative
1913 active_sl[sl] = p->fFrt_sl[sl];
1914 active_root_fraction += p->fFrt_sl[sl];
1915 eff_soil_water_potential += head_sl[sl] * p->fFrt_sl[sl];
1916 }
1917 }
1918 if ( !cbm::flt_greater_zero( active_root_fraction))
1919 {
1920 // all rooted layers frozen
1921 continue;
1922 }
1923 eff_soil_water_potential /= active_root_fraction;
1924
1925 // hydraulic conductivities of plant system
1926 double const k_rs( vt->KRSINIT() * p->mFrt / vt->FRTMASSINIT() * substep_hours); // cm(water)/cm(pressure head)/timestep
1927 double const k_comp( vt->KCOMPINIT() * p->mFrt / vt->FRTMASSINIT() * substep_hours); // cm(water)/cm(pressure head)/timestep
1928
1929 // water potential in the leaves, depending on the possible transpiration, bounded by stomatal closure
1930 double const leaf_water_potential( cbm::bound_min( vt->HLEAFCRIT(),
1931 eff_soil_water_potential - (transpiration_possible_vt / k_rs))); // cm
1932 // uptake driven by the gradient soil -> leaf; none without demand and none if the soil is drier than HLEAFCRIT
1933 double const effuptake( k_rs * cbm::bound_min( 0.0, eff_soil_water_potential - leaf_water_potential)); // cm/timestep
1934
1935 double uptake_vt( 0.0);
1936 for( size_t sl = 0; sl < sl_rooted; ++sl)
1937 {
1938 if ( !cbm::flt_greater_zero( active_sl[sl]))
1939 {
1940 continue;
1941 }
1942 double const compuptake( k_comp * (head_sl[sl] - eff_soil_water_potential));
1943 double uptake_layer( (effuptake + compuptake) * active_sl[sl] / active_root_fraction); // cm
1944
1945 // limits: no uptake below the residual water content, no release beyond the pore space
1946 double const avail( (wc_.wc_sl[sl] - wc_.wc_res_sl[sl]) * sc_.h_sl[sl] * cbm::CM_IN_M); // cm
1947 double const space( (wc_.wc_sat_sl[sl] - wc_.wc_sl[sl] - wc_.ice_sl[sl]) * sc_.h_sl[sl] * cbm::CM_IN_M); // cm
1948 uptake_layer = cbm::bound( -cbm::bound_min( 0.0, space), uptake_layer, cbm::bound_min( 0.0, avail));
1949
1950 wc_.accumulated_wateruptake_sl[sl] += uptake_layer * cbm::M_IN_CM;
1951 wc_.wc_sl[sl] -= uptake_layer * cbm::M_IN_CM / sc_.h_sl[sl];
1952 uptake_vt += uptake_layer;
1953 }
1954
1955 if ( cbm::flt_greater( uptake_vt, transpiration_possible_vt, 1.0e-10))
1956 {
1957 KLOGERROR( "Total water uptake ", uptake_vt, " cm larger than possible transpiration ", transpiration_possible_vt, " cm [species=", p->name(), "]");
1958 }
1959 _uptake += uptake_vt * cbm::M_IN_CM; // m for all species
1960 }
1961
1962 // total evaporation demand reduced to apply on other evaporating sources (ground, snow, surface water)
1963 hr_pot_evapotrans = cbm::bound_min( 0.0, hr_pot_evapotrans - _uptake);
1964
1965 return LDNDC_ERR_OK;
1966}

References CalcTranspirationCouvreur().

Referenced by CalcTranspiration(), and CalcTranspirationCouvreur().

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

◆ event_flood()

lerr_t ldndc::WatercycleDNDC::event_flood ( )
private

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

  • surface water table
  • bund height
872{
873 lerr_t rc = m_eventflood.solve();
874 if ( rc != LDNDC_ERR_OK)
875 {
876 KLOGERROR("Flooding event handler not successful!");
877 return rc;
878 }
879
880 /* max_percolation is gradually decreased after end of flooding event to inital value */
881 double const maximum_percolation = m_eventflood.get_maximum_percolation();
882 if ( cbm::is_valid( maximum_percolation))
883 {
884 if ( cbm::flt_greater_zero( maximum_percolation))
885 {
886 max_percolation = maximum_percolation * substep_hours / 24.0;
887 }
888 }
889 else
890 {
891 /* time rate for gradual recovery of max_percolation (called once per time step, i.e., substeps_per_timestep substeps) */
892 double const time_rate( substep_day_fraction() * double( substeps_per_timestep) * 0.1);
893 max_percolation -= (max_percolation - WaterFlowSaturated( m_soillayers->soil_layer_cnt()-1, 1.0)) * time_rate;
894 }
895
896 return LDNDC_ERR_OK;
897}

References event_flood(), and substep_day_fraction().

Referenced by event_flood(), and solve().

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

◆ get_leaf_water()

double ldndc::WatercycleDNDC::get_leaf_water ( )
private

Collects leaf water from all canopy layers.

Parameters
[in]None
[out]None
Returns
Leaf water
1211{
1212 /* note: intercepted water is also returned without vegetation. Water that is still on the
1213 * canopy when the vegetation is removed (e.g. harvest) reaches the ground as throughfall in
1214 * the next substep (interception capacity is zero then, see CalcInterception()). Until
1215 * 2026-11-28 it was dropped from the water balance (up to 2.7 mm per harvest). */
1216 return wc_.wc_fl.sum();
1217}

References get_leaf_water().

Referenced by balance_check(), CalcInterception(), and get_leaf_water().

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

◆ hours_per_time_step()

double ldndc::WatercycleDNDC::hours_per_time_step ( )
private

number of hours per time step

2700{
2701 return substep_hours * substeps_per_timestep;
2702}

References hours_per_time_step().

Referenced by CalcRaining(), CalcTranspiration(), and hours_per_time_step().

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

◆ rainfall_intensity()

double ldndc::WatercycleDNDC::rainfall_intensity ( )
private

rainfall intensity, i.e., maximum rainfall/irrigation per hour [m h-1]

110{
111 if ( rainfall_intensity_cache < 0.0)
112 {
113 if ( m_iokcomm->get_input_class< input_class_climate_t >())
114 {
115 rainfall_intensity_cache = m_iokcomm->get_input_class< climate::input_class_climate_t >()->station_info()->rainfall_intensity * cbm::M_IN_MM;
116 }
117 else
118 {
119 rainfall_intensity_cache = ldndc::climate::climate_info_defaults.rainfall_intensity * cbm::M_IN_MM;
120 }
121 }
123}
double rainfall_intensity_cache
Definition watercycle-dndc.h:177
double rainfall_intensity
Definition climatetypes.h:47

References rainfall_intensity(), and rainfall_intensity_cache.

Referenced by CalcIrrigation(), CalcRaining(), and rainfall_intensity().

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

◆ SoilWaterEvaporation()

void ldndc::WatercycleDNDC::SoilWaterEvaporation ( size_t _sl)
private
Parameters
[in]_slSoil layer
[out]None
Returns
None
2081{
2082 //percolation and direct evaporation from the (upper) soil
2083 //if there is snow cover, evaporation from soil will be set to 0, and only sublimation is allowed.
2084 double const wc_min_evaporation(m_sipar->WCDNDC_EVALIM_FRAC_WCMIN() * wc_.wc_wp_sl[_sl]);
2085 if ( cbm::flt_less( sc_.depth_sl[_sl] - sc_.h_sl[_sl], m_sipar->EVALIM()) &&
2086 cbm::flt_greater( wc_.wc_sl[_sl], wc_min_evaporation) &&
2087 cbm::flt_greater_zero( hr_pot_evapotrans))
2088 {
2089 //limiting factor for soil water infiltration
2090 double const f_clay( 1.0 + m_sipar->SLOPE_CLAYF() * std::min(1.0 - sc_.fcorg_sl[_sl] / cbm::CCORG, sc_.clay_sl[_sl]));
2091 double const f_water( cbm::bound( 0.0,
2092 pow( (wc_.wc_sl[_sl] - wc_min_evaporation) / wc_.wc_fc_sl[_sl], f_clay),
2093 1.0));
2094 double const h_rest( std::min( sc_.h_sl[_sl], m_sipar->EVALIM() - ( sc_.depth_sl[_sl] - sc_.h_sl[_sl])));
2095 double const f_depth( h_rest / m_sipar->EVALIM() * std::max(0.0,
2096 1.0 - std::min((double)m_sipar->EVALIM(),
2097 sc_.depth_sl[_sl] - ( 0.5 * sc_.h_sl[_sl]))
2098 / m_sipar->EVALIM()));
2099 double const soilevaporation_max( cbm::bound_max( f_water * wc_.wc_sl[_sl] * sc_.h_sl[_sl], hr_pot_evapotrans));
2100
2101 double const soilevaporation( cbm::bound( 0.0,
2102 hr_pot_evapotrans * f_depth * f_water,
2103 soilevaporation_max));
2104
2105 //update of the current soil layer water content
2106 wc_.wc_sl[_sl] -= soilevaporation / sc_.h_sl[_sl];
2107 wc_.accumulated_soilevaporation += soilevaporation;
2108 hr_pot_evapotrans = cbm::bound_min( 0.0, hr_pot_evapotrans - soilevaporation);
2109 }
2110}

References SoilWaterEvaporation().

Referenced by CalcSoilEvapoPercolation(), CalcTranspiration(), and SoilWaterEvaporation().

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

◆ substep_day_fraction()

double ldndc::WatercycleDNDC::substep_day_fraction ( )
private

Length of a substep as fraction of a day.

Length of a substep as fraction of a day (used to convert daily rates to rates per substep)

2641{
2642 return (substep_hours / 24.0);
2643}

References substep_day_fraction().

Referenced by CalcSurfaceFlux(), CalcTranspiration(), event_flood(), substep_day_fraction(), WatercycleDNDC_preferential_flow(), and WaterFlowAboveFieldCapacity().

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

◆ WatercycleDNDC_preferential_flow()

void ldndc::WatercycleDNDC::WatercycleDNDC_preferential_flow ( )
private
Parameters
[in]None
[out]None
Returns
None
2464{
2465 //BY_PASSF is defined as the fraction of surface water that passes per hour (0.0 by default)
2466 if ( cbm::flt_greater_zero(m_sipar->BY_PASSF()) &&
2467 cbm::flt_greater_zero( wc_.surface_water))
2468 {
2469
2470 double water_def_total( 0.0);
2471 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
2472 {
2473 //water flux that flow through macro pores can maximally store
2474 water_def_total += cbm::bound_min( 0.0, (wc_.wc_fc_sl[sl] - wc_.wc_sl[sl] - wc_.ice_sl[sl]) * sc_.h_sl[sl]);
2475 }
2476
2477 //duration of timestep (hr-1)
2478 double const fhr( substep_day_fraction());
2479
2480
2481 //fraction of surface water that is put into bypass flow (m timestep-1)
2482 double const bypass_fraction( cbm::bound_max(m_sipar->BY_PASSF() * fhr, 0.99));
2483 double const bypass_water( wc_.surface_water * bypass_fraction);
2484 wc_.surface_water -= bypass_water;
2485 wc_.accumulated_infiltration += bypass_water;
2486
2487 if ( cbm::flt_greater_equal( water_def_total, bypass_water))
2488 {
2489
2490 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
2491 {
2492 double const water_def( cbm::bound_min( 0.0, (wc_.wc_fc_sl[sl] - wc_.wc_sl[sl] - wc_.ice_sl[sl]) * sc_.h_sl[sl]));
2493 double const water_add( water_def / water_def_total * bypass_water);
2494
2495 wc_.wc_sl[sl] += water_add / sc_.h_sl[sl];
2496 }
2497 }
2498 else
2499 {
2500 for ( size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
2501 {
2502 double const water_def( cbm::bound_min( 0.0, (wc_.wc_fc_sl[sl] - wc_.wc_sl[sl] - wc_.ice_sl[sl]) * sc_.h_sl[sl]));
2503 wc_.wc_sl[sl] += water_def / sc_.h_sl[sl];
2504 }
2505 /* add surplus to percolation out of last soil layer */
2506 wc_.accumulated_percolation += bypass_water - water_def_total;
2507 wc_.accumulated_waterflux_sl[m_soillayers->soil_layer_cnt()-1] += bypass_water - water_def_total;
2508 }
2509 }
2510}

References substep_day_fraction(), and WatercycleDNDC_preferential_flow().

Referenced by CalcTranspiration(), solve(), and WatercycleDNDC_preferential_flow().

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

◆ WaterFlowAboveFieldCapacity()

double ldndc::WatercycleDNDC::WaterFlowAboveFieldCapacity ( size_t _sl,
double const & _fact_impedance )
private

factor accounting for different water travelling characteristics in litter and mineral soil

2371{
2372 double const sks( WaterFlowSaturated( _sl, _fact_impedance));
2373 double const fsl( get_fsl( _sl));
2374 double const fhr( substep_day_fraction());
2375
2377 double slope(( _sl < m_soillayers->soil_layers_in_litter_cnt()) ? m_sipar->SLOPE_FF() : m_sipar->SLOPE_MS());
2378
2379 double const travel_time( 1.0 - log10( wc_.sks_sl[_sl] * cbm::M_IN_CM * cbm::MIN_IN_DAY * fhr));
2380 double const travel_time_factor( cbm::flt_greater_zero( travel_time) ? (1.0 - exp(-1.0 / travel_time)) : 1.0);
2381 return cbm::bound_max( cbm::sqr(1.0 - (wc_.wc_fc_sl[_sl] / ((wc_.wc_sl[_sl] + wc_.ice_sl[_sl]) * slope)))
2382 * wc_.wc_sl[_sl] * sc_.h_sl[_sl] * fsl * travel_time_factor * _fact_impedance,
2383 sks);
2384}
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

References get_fsl(), substep_day_fraction(), and WaterFlowAboveFieldCapacity().

Referenced by CalcSoilEvapoPercolation(), CalcTranspiration(), and WaterFlowAboveFieldCapacity().

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

Member Data Documentation

◆ rainfall_intensity_cache

double ldndc::WatercycleDNDC::rainfall_intensity_cache
private

rainfall intensity (constant during a run), cached on first use (negative: not yet read) [m h-1]

Referenced by rainfall_intensity().