...
757 KLOGERROR(
"[BUG] ",
"root_system is NULL when not expected \"",_vt->name(),
"\"!");
758 return LDNDC_ERR_RUNTIME_ERROR;
761 bool const mulching = _attributes.get(
"/mulching",
false);
763 double const export_root = _attributes.get(
"/fraction-export-rootwood", 0.0);
764 double const rootlitter_c( (1.0 - export_root) * _vt->mFrt * cbm::CCDM);
765 double const rootlitter_n( (1.0 - export_root) * _vt->n_frt());
766 double const root_c_export( export_root * _vt->mFrt * cbm::CCDM);
767 double const root_n_export( export_root * _vt->mFrt * _vt->ncFrt);
769 double const straw_c( (_vt->mFol + _vt->dw_dfol + _vt->dw_lst+ _vt->dw_dst) * cbm::CCDM);
770 double const straw_n( _vt->n_fol() + _vt->n_dfol + _vt->n_lst + _vt->n_dst);
772 double const fru_c( _vt->mBud * cbm::CCDM);
773 double const fru_n( _vt->n_bud());
775 double fru_c_export( 0.0);
776 double fru_n_export( 0.0);
778 double straw_c_export( 0.0);
779 double straw_n_export( 0.0);
781 double mulching_c( 0.0);
782 double mulching_n( 0.0);
784 double stubble_c( 0.0);
785 double stubble_n( 0.0);
787 double gdd_sum( _vt->growing_degree_days );
788 double dvs_flush( _vt->dvsFlush );
790 double const height( _attributes.get(
"/height", invalid_flt));
791 double remains_relative( _attributes.get(
"/remains_relative", invalid_flt));
792 double remains_absolute( _attributes.get(
"/remains_absolute", invalid_flt));
793 if( cbm::is_valid( remains_absolute))
795 remains_absolute *= cbm::HA_IN_M2;
798 if ( !cbm::flt_greater_equal_zero( remains_relative)
799 && !cbm::flt_greater_equal_zero( remains_absolute)
800 && !cbm::flt_greater_equal_zero( height))
802 if ( _vt->is_covercrop)
804 remains_relative = 1.0;
808 KLOGWARN(
"harvest event attribute \"remains_relative\" and \"remains_absolute\" and \"height\" not set;",
809 " \"remains_relative\" set to zero and used [species=", _vt->name(),
"]");
812 else if ( (cbm::flt_greater_equal_zero( remains_relative) ||
813 cbm::flt_greater_equal_zero( remains_absolute))
814 && cbm::flt_greater_equal_zero( height))
816 KLOGWARN(
"harvest event attribute \"remains_(relative/absolute)\" and \"height\" both set;" 817 " attribute \"remains_relative\" used [species=", _vt->name(),
"]");
820 if ( cbm::flt_greater_equal_zero( remains_relative))
824 else if ( cbm::flt_greater_equal_zero( remains_absolute))
826 remains_relative = cbm::bound( 0.0,
827 remains_absolute / (_vt->mFol + _vt->dw_dfol + _vt->dw_lst+ _vt->dw_dst),
830 else if ( cbm::flt_equal_zero( height))
832 remains_relative = 0.0;
834 else if ( cbm::flt_greater_zero( height))
837 double remains_relative_fol = 0.0;
838 for (
int fl = 0; fl < m_setup->canopylayers(); ++fl)
840 remains_relative_fol += _vt->fFol_fl[fl];
841 h_cum += ph_.h_fl[fl];
842 if ( cbm::flt_greater_equal( h_cum, height))
849 double remains_relative_lst = 0.0;
850 double remains_relative_lst_total = 0.0;
851 for (
int fl = 0; fl < m_setup->canopylayers(); ++fl)
854 remains_relative_lst_total += pow( cbm::bound_min( 0.0, _vt->height_max - h_cum), 0.3);
855 if ( cbm::flt_less_equal( h_cum, height))
857 remains_relative_lst += pow( cbm::bound_min( 0.0, _vt->height_max - h_cum), 0.3);
859 h_cum += ph_.h_fl[fl];
861 remains_relative_lst /= remains_relative_lst_total;
863 remains_relative = (remains_relative_fol * (_vt->mFol + _vt->dw_dfol) +
864 remains_relative_lst * (_vt->dw_lst+ _vt->dw_dst)) /
865 (_vt->mFol + _vt->dw_dfol + _vt->dw_lst+ _vt->dw_dst);
869 KLOGERROR(
"[BUG] ",
"harvest event attribute \"remains_relative\" and \"height\" are invalid [species=", _vt->name(),
"]");
870 return LDNDC_ERR_FAIL;
873 stubble_c += remains_relative * straw_c;
874 stubble_n += remains_relative * straw_n;
877 mulching_c += (1.0-remains_relative) * straw_c;
878 mulching_n += (1.0-remains_relative) * straw_n;
882 straw_c_export += (1.0-remains_relative) * straw_c;
883 straw_n_export += (1.0-remains_relative) * straw_n;
886 if ( _vt->is_covercrop)
888 stubble_c += remains_relative * fru_c;
889 stubble_n += remains_relative * fru_n;
892 mulching_c += (1.0-remains_relative) * fru_c;
893 mulching_n += (1.0-remains_relative) * fru_n;
897 stubble_c += (1.0-remains_relative) * fru_c;
898 stubble_n += (1.0-remains_relative) * fru_n;
903 fru_c_export = fru_c;
904 fru_n_export = fru_n;
908 c_total_exported += straw_c_export + fru_c_export;
909 c_fruit_exported += fru_c_export;
910 n_total_exported += straw_n_export + fru_n_export;
911 n_fruit_exported += fru_n_export;
913 ph_.accumulated_c_export_harvest += straw_c_export + fru_c_export + root_c_export;
914 ph_.accumulated_n_export_harvest += straw_n_export + fru_n_export + root_n_export;
916 ph_.accumulated_c_fru_export_harvest += fru_c_export;
917 ph_.accumulated_n_fru_export_harvest += fru_n_export;
920 sc_.c_stubble_lit3 += stubble_c * (*_vt)->LIGNIN();
921 sc_.c_stubble_lit2 += stubble_c * (*_vt)->CELLULOSE();
922 sc_.c_stubble_lit1 += stubble_c * (1.0 - (*_vt)->LIGNIN() - (*_vt)->CELLULOSE());
923 sc_.accumulated_c_litter_stubble += stubble_c;
925 sc_.n_stubble_lit3 += stubble_n * (*_vt)->LIGNIN();
926 sc_.n_stubble_lit2 += stubble_n * (*_vt)->CELLULOSE();
927 sc_.n_stubble_lit1 += stubble_n * (1.0 - (*_vt)->LIGNIN() - (*_vt)->CELLULOSE());
928 sc_.accumulated_n_litter_stubble += stubble_n;
931 sc_.c_raw_lit_1_above += mulching_c * (1.0 - (*_vt)->CELLULOSE() - (*_vt)->LIGNIN());
932 sc_.c_raw_lit_2_above += mulching_c * (*_vt)->CELLULOSE();
933 sc_.c_raw_lit_3_above += mulching_c * (*_vt)->LIGNIN();
934 sc_.accumulated_c_litter_above += mulching_c;
936 sc_.n_raw_lit_1_above += mulching_n * (1.0 - (*_vt)->CELLULOSE() - (*_vt)->LIGNIN());
937 sc_.n_raw_lit_2_above += mulching_n * (*_vt)->CELLULOSE();
938 sc_.n_raw_lit_3_above += mulching_n * (*_vt)->LIGNIN();
939 sc_.accumulated_n_litter_above += mulching_n;
942 for (
size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
944 double const dw_rootlitter( rootlitter_c / cbm::CCDM * _vt->fFrt_sl[sl]);
945 double const n_rootlitter( dw_rootlitter * _vt->ncFrt);
947 sc_.c_raw_lit_1_sl[sl] += dw_rootlitter * (1.0 - (*_vt)->CELLULOSE() - (*_vt)->LIGNIN()) * cbm::CCDM;
948 sc_.c_raw_lit_2_sl[sl] += dw_rootlitter * (*_vt)->CELLULOSE() * cbm::CCDM;
949 sc_.c_raw_lit_3_sl[sl] += dw_rootlitter * (*_vt)->LIGNIN() * cbm::CCDM;
950 sc_.accumulated_c_litter_below_sl[sl] += dw_rootlitter * cbm::CCDM;
952 sc_.n_raw_lit_1_sl[sl] += n_rootlitter * (1.0 - (*_vt)->CELLULOSE() - (*_vt)->LIGNIN());
953 sc_.n_raw_lit_2_sl[sl] += n_rootlitter * (*_vt)->CELLULOSE();
954 sc_.n_raw_lit_3_sl[sl] += n_rootlitter * (*_vt)->LIGNIN();
955 sc_.accumulated_n_litter_below_sl[sl] += n_rootlitter;
958 cbm::state_scratch_t * mcom = io_kcomm->get_scratch();
959 std::string mcom_key;
961 char const * species_name = _attributes.get(
"/name",
"?");
963 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:daysOnField", species_name);
964 mcom->set( mcom_key.c_str(), (double)((lclock()->seconds() - seconds_crop_planting[_vt->slot]) / cbm::SEC_IN_DAY));
966 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:gddsum", species_name);
967 mcom->set( mcom_key.c_str(), gdd_sum);
969 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:dvsflush", species_name);
970 mcom->set( mcom_key.c_str(), dvs_flush);
972 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:c_fru", species_name);
973 mcom->set( mcom_key.c_str(), fru_c);
975 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:c_fru_export", species_name);
976 mcom->set( mcom_key.c_str(), fru_c_export);
978 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:n_fru", species_name);
979 mcom->set( mcom_key.c_str(), fru_n);
981 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:n_fru_export", species_name);
982 mcom->set( mcom_key.c_str(), fru_n_export);
984 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:c_straw", species_name);
985 mcom->set( mcom_key.c_str(), straw_c);
987 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:c_straw_export", species_name);
988 mcom->set( mcom_key.c_str(), straw_c_export);
990 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:n_straw", species_name);
991 mcom->set( mcom_key.c_str(), straw_n);
993 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:n_straw_export", species_name);
994 mcom->set( mcom_key.c_str(), straw_n_export);
996 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:c_stubble", species_name);
997 mcom->set( mcom_key.c_str(), stubble_c);
999 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:n_stubble", species_name);
1000 mcom->set( mcom_key.c_str(), stubble_n);
1002 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:c_frt", species_name);
1003 mcom->set( mcom_key.c_str(), rootlitter_c);
1005 cbm::state_scratch_t::make_item_key( &mcom_key,
"harvest:%s:n_frt", species_name);
1006 mcom->set( mcom_key.c_str(), rootlitter_n);
1008 for (
size_t sl = 0; sl < sl_.soil_layer_cnt(); ++sl)
1010 _vt->fFrt_sl[sl] = 0.0;
1014 _vt->rooting_depth = 0.0;
1016 days_after_emergence[_vt->slot] = -1;
1018 dw_retranslocation_stem[_vt->slot] = 0.0;
1019 dw_retranslocation_foliage[_vt->slot] = 0.0;
1021 dw_fol_old[_vt->slot] = 0.0;
1022 lai_dynamic[_vt->slot] = 0.0;
1036 _vt->mBudStart = 0.0;
1043 _vt->growing_degree_days = 0.0;
1045 _vt->dvsFlush = 0.0;
1046 _vt->dvsFlushOld = 0.0;
1048 n_plant[_vt->slot] = 0.0;
1051 _vt->height_max = 0.0;
1052 _vt->height_at_canopy_start = 0.0;
1055 for (
int fl = 0; fl < m_setup->canopylayers(); ++fl)
1057 _vt->fFol_fl[fl] = 0.0;
1058 _vt->lai_fl[fl] = 0.0;
1065 yearly_cuts[_vt->slot] = 0;
1072 m_fruit_maximum[_vt->slot] = -1.0;
1073 spikelets_sterility[_vt->slot] = 0.0;
1074 hypoxia[_vt->slot] = 0.0;
1079 return LDNDC_ERR_OK;
lvector_t< unsigned int > root_q_vt_
Largest soil layer index where roots exist [-].
Definition: plamox.h:338
lvector_t< double > allocation_factor_stems
Allocation factor of daily assimilated carbon to stem growth [-].
Definition: plamox.h:277
ldndc::growable_array< BaseRootSystemDNDC *, 1000, 1 > plamox_root_system
Root system.
Definition: plamox.h:145
lvector_t< double > allocation_factor_fruit
Allocation factor of daily assimilated carbon to fruit growth [-].
Definition: plamox.h:283
lvector_t< double > chill_factor
Factor that retards plant development if vernalization requirement is not fullfilled.
Definition: plamox.h:308
lvector_t< double > allocation_factor_roots
Allocation factor of daily assimilated carbon to root growth [-].
Definition: plamox.h:289
lvector_t< double > chill_units
Accumulated chilling units for vernalization;.
Definition: plamox.h:314
lvector_t< double > allocation_factor_leafs
Allocation factor of daily assimilated carbon to leaf growth [-].
Definition: plamox.h:271