631 m_wc.irrigation = 0.0;
636 if ( cbm::flt_in_range_lu(0.0, m_cfg.automaticirrigation, 1.0))
638 for (
size_t l = 0; l < m_soillayers->soil_layer_cnt(); ++l)
641 double const wc_target( sc_.wcmin_sl[l] + m_cfg.automaticirrigation * (sc_.wcmax_sl[l] - sc_.wcmin_sl[l]));
642 if ( cbm::flt_less( wc_.wc_sl[l], wc_target))
645 double const irrigate_layer( (wc_target - wc_.wc_sl[l]) * sc_.h_sl[l]);
646 m_wc.irrigation += irrigate_layer;
647 wc_.accumulated_irrigation_automatic += irrigate_layer;
652 if ( cbm::flt_in_range_lu( 0.0, saturation_level, 1.0))
655 double wcmax_sum( 0.0);
656 double wcmin_sum( 0.0);
657 for (
size_t l = 0; l < m_soillayers->soil_layer_cnt(); ++l)
659 wc_sum += wc_.wc_sl[l] * sc_.h_sl[l];
660 wcmax_sum += sc_.wcmax_sl[l] * sc_.h_sl[l];
661 wcmin_sum += sc_.wcmin_sl[l] * sc_.h_sl[l];
663 if ( cbm::flt_greater_equal( sc_.depth_sl[l], soil_depth_flooding))
670 double const wc_target( wcmin_sum + saturation_level * (wcmax_sum - wcmin_sum));
671 if ( cbm::flt_less( wc_sum, wc_target))
673 m_wc.irrigation += irrigation_height;
674 wc_.accumulated_irrigation_automatic += irrigation_height;
685 if ( m_cfg.ggcmi_irrigation)
687 if( (lclock()->subday() == 1) && (_i == 0))
689 if( m_veg->size() > 0 )
691 double water_supply( 0.0);
692 for (
size_t l = 0; l < m_soillayers->soil_layer_cnt(); ++l)
694 if ( cbm::flt_greater_zero( m_veg->mfrt_sl( l)))
696 if( cbm::flt_less( wc_.wc_sl[l], sc_.wcmax_sl[l]) &&
697 cbm::flt_equal_zero( wc_.ice_sl[l]))
699 water_supply += (sc_.wcmax_sl[l] - wc_.wc_sl[l]) * sc_.h_sl[l];
700 wc_.wc_sl[l] = sc_.wcmax_sl[l];
704 wc_.accumulated_irrigation_ggcmi += water_supply;
712 if ( cbm::is_valid( water_table_flooding))
715 if ( cbm::is_valid( irrigation_height))
717 bool irrigate(
false);
720 if ( cbm::flt_greater_equal_zero( water_table_flooding))
722 if ( cbm::flt_greater( water_table_flooding, wc_.surface_water))
729 if ( !cbm::flt_greater_zero( wc_.surface_water))
731 for (
size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
733 if ( cbm::flt_greater_equal( sc_.depth_sl[sl], -water_table_flooding))
736 if ( cbm::flt_less( wc_.wc_sl[sl], 0.9 * sc_.poro_sl[sl]))
748 double water_supply( cbm::bound_min( 0.0, irrigation_height - wc_.surface_water));
749 for (
size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
752 if ( cbm::flt_greater( sc_.poro_sl[sl], wc_.wc_sl[sl]))
754 water_supply += ((sc_.poro_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl]);
759 water_supply = cbm::bound_min( 0.0, water_supply - m_mc.rainfall);
761 if ( !unlimited_water)
763 if ( cbm::flt_greater( wc_.irrigation_reservoir, water_supply))
765 wc_.irrigation_reservoir -= water_supply;
769 water_supply = wc_.irrigation_reservoir;
770 wc_.irrigation_reservoir = 0.0;
772 wc_.accumulated_irrigation_reservoir_withdrawal += water_supply;
776 wc_.accumulated_irrigation_automatic += water_supply;
778 m_wc.irrigation += water_supply;
784 if ( !cbm::flt_greater_zero( water_table_flooding))
786 double water_supply( 0.0);
787 for (
size_t sl = 0; sl < m_soillayers->soil_layer_cnt(); ++sl)
789 if ( cbm::flt_greater( -water_table_flooding, sc_.depth_sl[sl]) &&
790 cbm::flt_greater( sc_.wcmax_sl[sl], wc_.wc_sl[sl]))
792 water_supply += (sc_.wcmax_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl];
796 if ( cbm::flt_greater( sc_.poro_sl[sl], wc_.wc_sl[sl]))
798 water_supply += (sc_.poro_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl];
804 water_supply = cbm::bound_min( 0.0, water_supply - m_mc.rainfall);
807 if ( cbm::flt_greater( wc_.surface_water, water_supply))
809 wc_.accumulated_runoff += wc_.surface_water - water_supply;
810 wc_.surface_water = water_supply;
813 if ( !unlimited_water)
815 if ( cbm::flt_greater( wc_.irrigation_reservoir, water_supply))
817 wc_.irrigation_reservoir -= water_supply;
821 water_supply = wc_.irrigation_reservoir;
822 wc_.irrigation_reservoir = 0.0;
824 wc_.accumulated_irrigation_reservoir_withdrawal += water_supply;
828 wc_.accumulated_irrigation_automatic += water_supply;
830 m_wc.irrigation += water_supply;
835 else if ( cbm::flt_greater( water_table_flooding, wc_.surface_water))
839 double water_supply( water_table_flooding - wc_.surface_water);
842 unsigned long no_layers(3);
843 if( no_layers > m_soillayers->soil_layer_cnt())
845 no_layers = m_soillayers->soil_layer_cnt();
848 for (
size_t sl = 0; sl < no_layers; ++sl)
850 water_supply += ((sc_.poro_sl[sl] - wc_.wc_sl[sl]) * sc_.h_sl[sl]);
854 water_supply = cbm::bound_min( 0.0, water_supply - m_mc.rainfall);
856 if ( !unlimited_water)
858 if ( cbm::flt_greater( wc_.irrigation_reservoir, water_supply))
860 wc_.irrigation_reservoir -= water_supply;
864 water_supply = wc_.irrigation_reservoir;
865 wc_.irrigation_reservoir = 0.0;
867 wc_.accumulated_irrigation_reservoir_withdrawal += water_supply;
871 wc_.accumulated_irrigation_automatic += water_supply;
873 m_wc.irrigation += water_supply;
881 double const irrigation_scheduled( cbm::bound_min( 0.0, wc_.accumulated_irrigation - m_wc.accumulated_irrigation_event_executed));
885 m_wc.irrigation += irrigation_scheduled / 24.0;
886 m_wc.accumulated_irrigation_event_executed += irrigation_scheduled / 24.0;
888 else if ( cbm::flt_greater( irrigation_scheduled, (
double)hours_per_time_step() *
rainfall_intensity()))
891 m_wc.accumulated_irrigation_event_executed += (double)hours_per_time_step() *
rainfall_intensity();
895 m_wc.irrigation += irrigation_scheduled;
896 m_wc.accumulated_irrigation_event_executed += irrigation_scheduled;
double rainfall_intensity()
Definition: watercycle-dndc.cpp:128