management.cpp 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /// \file management.cpp
  3. /// \brief Harvest functions for cropland, managed forest and pasture
  4. /// \author Mats Lindeskog
  5. /// $Date: $
  6. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  7. #include "landcover.h"
  8. #include "management.h"
  9. /// Harvest function used for managed forest and for clearing natural vegetation at land use change
  10. /** A fraction of trees is cut down (frac_cut)
  11. * A fraction of wood is harvested (pft.harv_eff) and returned as acflux_harvest
  12. * A fraction of harvested wood (pft.harvest_slow_frac) is returned as harvested_products_slow
  13. * The rest, including leaves and roots, is returned as litter, unless a fraction of twigs or roots removed.
  14. * Called from landcover_dynamics() first day of the year if any natural vegetation is transferred to another land use.
  15. * INPUT PARAMETER
  16. * \param frac_cut fraction of trees cut
  17. * \param harv_eff harvest efficiency
  18. * \param res_outtake_twig removed twig fraction
  19. * \param res_outtake_coarse_root removed course root fraction
  20. * INPUT/OUTPUT PARAMETERS
  21. * \param Harvest_CN& i struct containing the following indiv-specific public members:
  22. * - cmass_leaf leaf C biomass (kgC/m2)
  23. * - cmass_root fine root C biomass (kgC/m2)
  24. * - cmass_sap sapwood C biomass (kgC/m2)
  25. * - cmass_heart heartwood C biomass (kgC/m2)
  26. * - cmass_debt C "debt" (retrospective storage) (kgC/m2)
  27. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  28. * - nmass_root fine root nitrogen biomass (kgN/m2)
  29. * - nmass_sap sapwood nitrogen biomass (kgC/m2)
  30. * - nmass_heart heartwood nitrogen biomass (kgC/m2)
  31. * - nstore_labile labile nitrogen storage (kgC/m2)
  32. * - nstore_longterm longterm nitrogen storage (kgC/m2)
  33. * OUTPUT PARAMETERS
  34. * \param Harvest_CN& i struct containing the following patchpft-specific public members:
  35. * - litter_leaf new leaf C litter (kgC/m2)
  36. * - litter_root new root C litter (kgC/m2)
  37. * - litter_sap new sapwood C litter (kgC/m2)
  38. * - litter_heart new heartwood C litter (kgC/m2)
  39. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  40. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  41. * - nmass_litter_sap new sapwood nitrogen litter (kgN/m2)
  42. * - nmass_litter_heart new heartwood nitrogen litter (kgN/m2)
  43. * ,and the following patch-level public members:
  44. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  45. * - harvested_products_slow harvest products to slow pool (kgC/m2)
  46. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  47. * - harvested_products_slow_nmass harvest nitrogen products to slow pool (kgC/m2)
  48. */
  49. void harvest_wood(Harvest_CN& i, Pft& pft, bool alive, double frac_cut, double harv_eff, double res_outtake_twig, double res_outtake_coarse_root) {
  50. double harvest = 0.0;
  51. i.dcflux_harvest_wood = 0.0;
  52. double residue_outtake = 0.0;
  53. /// Fraction of wood cmass that are stems
  54. double stem_frac = 0.65; // Temporary values, should be pft-specific
  55. /// Fraction of wood cmass that are twigs
  56. double twig_frac = 0.13;
  57. /// Fraction of wood cmass that are coarse roots
  58. double coarse_root_frac = 1.0 - stem_frac - twig_frac; // 0.22 with default stem_frac and twig_frac values
  59. /// Fraction of leaves adhering to twigs at the time of removal
  60. double adhering_leaf_frac = 0.75;
  61. // only harvest trees
  62. if (pft.lifeform == GRASS)
  63. return;
  64. // all root carbon and nitrogen goes to litter
  65. if (alive) {
  66. i.litter_root += i.cmass_root * frac_cut;
  67. i.dcflux_harvest_wood_res += i.cmass_root * frac_cut;
  68. i.cmass_root *= (1.0 - frac_cut);
  69. }
  70. i.nmass_litter_root += i.nmass_root * frac_cut;
  71. i.nmass_litter_root += (i.nstore_labile + i.nstore_longterm) * frac_cut;
  72. i.nmass_root *= (1.0 - frac_cut);
  73. i.nstore_labile *= (1.0 - frac_cut);
  74. i.nstore_longterm *= (1.0 - frac_cut);
  75. if (alive) {
  76. // Carbon:
  77. if (i.cmass_debt <= i.cmass_sap + i.cmass_heart) {
  78. // harvested stem wood
  79. harvest += harv_eff * stem_frac * (i.cmass_sap + i.cmass_heart - i.cmass_debt) * frac_cut;
  80. // harvested products not consumed (oxidised) this year put into harvested_products_slow
  81. if (ifslowharvestpool) {
  82. i.harvested_products_slow += harvest * pft.harvest_slow_frac;
  83. if (harvest * pft.harvest_slow_frac > 0.0)
  84. i.dcflux_product_wood = harvest * pft.harvest_slow_frac;
  85. harvest = harvest * (1.0 - pft.harvest_slow_frac);
  86. }
  87. // harvested products consumed (oxidised) this year put into acflux_harvest
  88. i.acflux_harvest += harvest;
  89. i.dcflux_harvest_wood += harvest;
  90. // removed leaves adhering to twigs
  91. residue_outtake += res_outtake_twig * adhering_leaf_frac * i.cmass_leaf * frac_cut;
  92. // removed twigs
  93. residue_outtake += res_outtake_twig * twig_frac * (i.cmass_sap + i.cmass_heart - i.cmass_debt) * frac_cut;
  94. // removed coarse roots
  95. residue_outtake += res_outtake_coarse_root * coarse_root_frac * (i.cmass_sap + i.cmass_heart - i.cmass_debt) * frac_cut;
  96. // removed residues are oxidised
  97. i.acflux_harvest += residue_outtake;
  98. // not removed residues are put into litter
  99. i.litter_leaf += i.cmass_leaf * (1.0 - res_outtake_twig * adhering_leaf_frac) * frac_cut;
  100. i.dcflux_harvest_wood_res += i.cmass_leaf * (1.0 - res_outtake_twig * adhering_leaf_frac) * frac_cut;
  101. double to_partition_sap = 0.0;
  102. double to_partition_heart = 0.0;
  103. if (i.cmass_heart >= i.cmass_debt) {
  104. to_partition_sap = i.cmass_sap;
  105. to_partition_heart = i.cmass_heart - i.cmass_debt;
  106. }
  107. else {
  108. to_partition_sap = i.cmass_sap + i.cmass_heart - i.cmass_debt;
  109. // dprintf("ATTENTION: pft %s: cmass_debt > cmass_heart; difference=%f\n", (char*)pft.name, i.cmass_debt-i.cmass_heart);
  110. }
  111. i.litter_sap += to_partition_sap * (1.0 - res_outtake_twig * twig_frac - res_outtake_coarse_root * coarse_root_frac - harv_eff * stem_frac) * frac_cut;
  112. i.litter_heart += to_partition_heart * (1.0 - res_outtake_twig * twig_frac - res_outtake_coarse_root * coarse_root_frac - harv_eff * stem_frac) * frac_cut;
  113. i.dcflux_harvest_wood_res += (to_partition_sap + to_partition_heart) * (1.0 - res_outtake_twig * twig_frac - res_outtake_coarse_root * coarse_root_frac - harv_eff * stem_frac) * frac_cut;
  114. }
  115. // debt larger than existing wood biomass
  116. else {
  117. double debt_excess = i.cmass_debt - (i.cmass_sap + i.cmass_heart);
  118. dprintf("ATTENTION: cmass_debt > i.cmass_sap + i.cmass_heart; debt_excess=%f\n", debt_excess);
  119. // i.debt_excess += debt_excess * frac_cut; // debt_excess currently not dealt with during wood harvest
  120. }
  121. // unharvested trees:
  122. i.cmass_leaf *= (1.0 - frac_cut);
  123. i.cmass_sap *= (1.0 - frac_cut);
  124. i.cmass_heart *= (1.0 - frac_cut);
  125. i.cmass_debt *= (1.0 - frac_cut);
  126. //Nitrogen:
  127. harvest = 0.0;
  128. // harvested products
  129. harvest += harv_eff * stem_frac * (i.nmass_sap + i.nmass_heart) * frac_cut;
  130. // harvested products not consumed this year put into harvested_products_slow_nmass
  131. if (ifslowharvestpool) {
  132. i.harvested_products_slow_nmass += harvest * pft.harvest_slow_frac;
  133. if (harvest * pft.harvest_slow_frac > 0.0)
  134. i.dnflux_product += harvest * pft.harvest_slow_frac;
  135. harvest = harvest * (1.0 - pft.harvest_slow_frac);
  136. }
  137. // harvested products consumed this year put into anflux_harvest
  138. i.anflux_harvest += harvest;
  139. residue_outtake = 0.0;
  140. // removed leaves adhering to twigs
  141. residue_outtake += res_outtake_twig * adhering_leaf_frac * i.nmass_leaf * frac_cut;
  142. // removed twigs
  143. residue_outtake += res_outtake_twig * twig_frac * (i.nmass_sap + i.nmass_heart) * frac_cut;
  144. // removed coarse roots
  145. residue_outtake += res_outtake_coarse_root * coarse_root_frac * (i.nmass_sap + i.nmass_heart) * frac_cut;
  146. // removed residues are oxidised
  147. i.anflux_harvest += residue_outtake;
  148. // not removed residues are put into litter
  149. i.nmass_litter_leaf += i.nmass_leaf * (1.0 - res_outtake_twig * adhering_leaf_frac) * frac_cut;
  150. i.nmass_litter_sap += i.nmass_sap * (1.0 - res_outtake_twig * twig_frac - res_outtake_coarse_root * coarse_root_frac - harv_eff * stem_frac) * frac_cut;
  151. i.nmass_litter_heart += i.nmass_heart * (1.0 - res_outtake_twig * twig_frac - res_outtake_coarse_root * coarse_root_frac - harv_eff * stem_frac) * frac_cut;
  152. // unharvested trees:
  153. i.nmass_leaf *= (1.0 - frac_cut);
  154. i.nmass_sap *= (1.0 - frac_cut);
  155. i.nmass_heart *= (1.0 - frac_cut);
  156. }
  157. }
  158. /// Harvest function used for managed forest and for clearing natural vegetation at land use change
  159. /** A fraction of trees is cut down (frac_cut)
  160. * A fraction of wood is harvested (pft.harv_eff) and returned as acflux_harvest
  161. * A fraction of harvested wood (pft.harvest_slow_frac) is returned as harvested_products_slow
  162. * The rest, including leaves and roots, is returned as litter.
  163. * Called from landcover_dynamics() first day of the year if any natural vegetation is transferred to another land use.
  164. *
  165. * This function copies variables from an individual and it's associated patchpft and patch to
  166. * a Harvest_CN struct, which is then passed on to the main harvest_crop function.
  167. * After the execution of the main harvest_crop function, the output variables are copied
  168. * back to the individual and patchpft and the patch-level fluxes are updated.
  169. *
  170. * INPUT PARAMETER
  171. * \param frac_cut fraction of trees cut
  172. * \param harv_eff harvest efficiency
  173. * \param res_outtake_twig removed twig fraction
  174. * \param res_outtake_coarse_root removed course root fraction
  175. * \param lc_change whether to save harvest in gridcell-level luc variable
  176. * INPUT/OUTPUT PARAMETERS
  177. * \param indiv reference to an Individual containing the following indiv-specific public members:
  178. * - cmass_leaf leaf C biomass (kgC/m2)
  179. * - cmass_root fine root C biomass (kgC/m2)
  180. * - cmass_sap sapwood C biomass (kgC/m2)
  181. * - cmass_heart heartwood C biomass (kgC/m2)
  182. * - cmass_debt C "debt" (retrospective storage) (kgC/m2)
  183. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  184. * - nmass_root fine root nitrogen biomass (kgN/m2)
  185. * - nmass_sap sapwood nitrogen biomass (kgC/m2)
  186. * - nmass_heart heartwood nitrogen biomass (kgC/m2)
  187. * - nstore_labile labile nitrogen storage (kgC/m2)
  188. * - nstore_longterm longterm nitrogen storage (kgC/m2)
  189. * OUTPUT PARAMETERS
  190. * \param indiv reference to an Individual containing the following patchpft-specific public members:
  191. * - litter_leaf new leaf C litter (kgC/m2)
  192. * - litter_root new root C litter (kgC/m2)
  193. * - litter_sap new sapwood C litter (kgC/m2)
  194. * - litter_heart new heartwood C litter (kgC/m2)
  195. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  196. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  197. * - nmass_litter_sap new sapwood nitrogen litter (kgN/m2)
  198. * - nmass_litter_heart new heartwood nitrogen litter (kgN/m2)
  199. * ,and the following patch-level public members:
  200. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  201. * - harvested_products_slow harvest products to slow pool (kgC/m2)
  202. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  203. * - harvested_products_slow_nmass harvest nitrogen products to slow pool (kgC/m2)
  204. */
  205. void harvest_wood(Individual& indiv, double frac_cut, double harv_eff, double res_outtake_twig,
  206. double res_outtake_coarse_root, bool lc_change) {
  207. Harvest_CN indiv_cp;
  208. indiv_cp.copy_from_indiv(indiv);
  209. harvest_wood(indiv_cp, indiv.pft, indiv.alive, frac_cut, harv_eff, res_outtake_twig, res_outtake_coarse_root);
  210. indiv_cp.copy_to_indiv(indiv, false, lc_change);
  211. if (!lc_change) {
  212. return;
  213. }
  214. Stand& stand = indiv.vegetation.patch.stand;
  215. Landcover& lc = stand.get_gridcell().landcover;
  216. lc.dcflux_landuse_change += stand.get_gridcell_fraction() * indiv_cp.acflux_harvest / (double)stand.nobj; // ecev3 - reset to 0 each day
  217. lc.acflux_landuse_change += stand.get_gridcell_fraction() * indiv_cp.acflux_harvest / (double)stand.nobj;
  218. lc.acflux_landuse_change_lc[stand.origin] += stand.get_gridcell_fraction() * indiv_cp.acflux_harvest / (double)stand.nobj;
  219. lc.anflux_landuse_change += stand.get_gridcell_fraction() * indiv_cp.anflux_harvest / (double)stand.nobj;
  220. lc.anflux_landuse_change_lc[stand.origin] += stand.get_gridcell_fraction() * indiv_cp.anflux_harvest / (double)stand.nobj;
  221. }
  222. /// Use for normal forest management in calls from growth(). For clearcut during landcover change, use harvest_wood() and kill_remaining_vegetation()
  223. void clearcut(Individual& indiv, double anpp, bool& killed) {
  224. Patch& patch = indiv.vegetation.patch;
  225. Patchpft& ppft = patch.pft[indiv.pft.id];
  226. if (indiv.pft.lifeform == TREE) {
  227. if(indiv.alive)
  228. ppft.litter_sap += anpp;
  229. harvest_wood(indiv, 1.0, indiv.pft.harv_eff, indiv.pft.res_outtake); // frac_cut=1, harv_eff=pft.harv_eff, res_outtake_twig=pft.res_outtake, res_outtake_coarse_root=0
  230. indiv.kill();
  231. indiv.vegetation.killobj();
  232. killed = true;
  233. }
  234. patch.age = 0; //important for results
  235. patch.managed = true;
  236. patch.plant_this_year = true;
  237. }
  238. /// Set forest management intensity for all stands this year
  239. void cut_fractions(Gridcell& gridcell) {
  240. Gridcell::iterator gc_itr = gridcell.begin();
  241. while (gc_itr != gridcell.end()) {
  242. Stand& stand = *gc_itr;
  243. stand.firstobj();
  244. while (stand.isobj) {
  245. Patch& patch = stand.getobj();
  246. patch.man_strength = cut_fraction(patch);
  247. stand.nextobj();
  248. }
  249. ++gc_itr;
  250. }
  251. }
  252. // The following two functions are simplified adaptations (continous cutting) from Swedish forest management code by Fredrik Lagergren and should be
  253. // developed further. Specifically, the productivity values, which should ideally be observed values for each gridcell, are set to a static value.
  254. // Also, the calculated diameter limits and rotation times (which are dependent on productivity) are for Swedish forests.
  255. /// Determines whether this patch should be cut this year.
  256. double cut_fraction(Patch& patch) {
  257. if(!run_landcover)
  258. return 0.0;
  259. Stand& stand = patch.stand;
  260. xtring harvest_system = stlist[stand.stid].get_management(stand.current_rot).harvest_system;
  261. if(harvest_system == "")
  262. return 0.0;
  263. int first_cutyear = nyear_spinup; // Simulation year when forestry harvesting starts; default is directly after spinup.
  264. if(stlist[stand.stid].firstmanageyear < 100000) // Initialised to 100000; other values set in instruction file.
  265. first_cutyear = stlist[stand.stid].firstmanageyear - date.first_calendar_year;
  266. if(date.year < first_cutyear)
  267. return 0.0;
  268. const double minbon = 2.351; // The minimum average "bonitet" for a county in Sweden
  269. const double maxbon = 11.311; // The maximum average "bonitet" for a county in Sweden
  270. const double bonitet = 10.0; // Temporary static value (gives cut_int=17)
  271. double cut_fraction = 0.0;
  272. if(harvest_system == "CLEARCUT") {
  273. // First attempt to calculate optimum rotation age for clearcut
  274. if(patch.cmass_wood() / patch.age > patch.get_cmass_wood_inc_5() && patch.age > 20)
  275. cut_fraction = 1.0;
  276. }
  277. else if(harvest_system == "CONTINUOUS") {
  278. // Continuous forestry
  279. int cut_int; //Interval between cuttings
  280. int patch_order; //Which year in a cutting interval the patch belongs to
  281. // cut_int=30-(int)(15.0*(stand.bonitet-minbon)/(maxbon-minbon));
  282. cut_int=30-(int)(15.0*(bonitet-minbon)/(maxbon-minbon));
  283. patch_order = (int)(patch.id * cut_int * 1.0 / (1.0 * stand.npatch()));
  284. if (!((date.year - first_cutyear - patch_order) % cut_int)) // rule needs to be corrected
  285. cut_fraction = 0.40;
  286. }
  287. return cut_fraction;
  288. }
  289. /// Determines if and how much of this (average) individual is to be cut.
  290. /* Individual is cut by a fraction, determined by cut_fraction(), if diameter is above a calculated limit and
  291. * by 90 % if above a calculated maximum diameter.
  292. * If clearcut is selected (depending on result from cut_fraction()), individual is killed
  293. */
  294. void harvest_forest(Individual& indiv, Pft& pft, bool alive, double anpp, bool& killed) {
  295. Patch& patch = indiv.vegetation.patch;
  296. Patchpft& ppft = patch.pft[indiv.pft.id];
  297. const double minbon=2.351; // The minimum average "bonitet" for a county in Sweden
  298. const double maxbon=11.311; // The maximum average "bonitet" for a county in Sweden
  299. const double bonitet = 10.0; // Temporary static value
  300. int age_class = 0;
  301. double man_strength = patch.man_strength;
  302. if (pft.lifeform==TREE && man_strength > 0.00) {
  303. double diam = pow(indiv.height / indiv.pft.k_allom2, 1.0 / indiv.pft.k_allom3);
  304. if (man_strength == 1.00) {
  305. clearcut(indiv, anpp, killed);
  306. }
  307. else {
  308. double diam_limit=0.13+0.07*(bonitet-minbon)/(maxbon-minbon); // Harvest of trees > 19 cm
  309. double diam_max = diam_limit * 2.0;
  310. if (diam>diam_limit) {
  311. if (diam > diam_max)
  312. man_strength = 0.9;
  313. harvest_wood(indiv, man_strength, indiv.pft.harv_eff, indiv.pft.res_outtake); // frac_cut=man_strength, harv_eff=pft.harv_eff, res_outtake_twig=pft.res_outtake, res_outtake_coarse_root=0
  314. indiv.densindiv *= (1.0 - man_strength);
  315. }
  316. }
  317. // Will tell the program to skip establishment and mortality if management has been performed on this patch,
  318. patch.managed_this_year = true;
  319. patch.managed = true;
  320. }
  321. }
  322. /// Harvest function for pasture, representing grazing (previous year).
  323. /* Function for balancing carbon and nitrogen fluxes from last year's growth
  324. * A fraction of leaves is harvested (pft.harv_eff) and returned as acflux_harvest
  325. * This represents grazing minus return as manure.
  326. * The rest is handled like natural grass in turnover().
  327. * Called from growth() last day of the year for normal harvest/grazing.
  328. * Also called from landcover_dynamics() first day of the year if any natural vegetation
  329. * is transferred to another land use.
  330. * This calls for a scaling factor, when the pasture area has increased.
  331. *
  332. * INPUT/OUTPUT PARAMETERS
  333. * \param Harvest_CN& i struct containing the following indiv-specific public members:
  334. * - cmass_leaf leaf C biomass (kgC/m2)
  335. * - cmass_root fine root C biomass (kgC/m2)
  336. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  337. * - nmass_root fine root nitrogen biomass (kgN/m2)
  338. * OUTPUT PARAMETERS
  339. * \param Harvest_CN& i struct containing the following patchpft-specific public members:
  340. * - litter_leaf new leaf C litter (kgC/m2)
  341. * - litter_root new root C litter (kgC/m2)
  342. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  343. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  344. * ,and the following patch-level public members:
  345. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  346. * - harvested_products_slow harvest products to slow pool (kgC/m2)
  347. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  348. * - harvested_products_slow_nmass harvest nitrogen products to slow pool (kgC/m2)
  349. */
  350. void harvest_pasture(Harvest_CN& i, Pft& pft, bool alive) {
  351. double harvest;
  352. i.dcflux_harvest_pasture = 0.0;
  353. // harvest of leaves (grazing)
  354. // Carbon:
  355. harvest = pft.harv_eff * i.cmass_leaf;
  356. if (ifslowharvestpool) {
  357. i.harvested_products_slow += harvest * pft.harvest_slow_frac;
  358. if (harvest * pft.harvest_slow_frac > 0.0)
  359. i.dcflux_product_pasture = harvest * pft.harvest_slow_frac;
  360. harvest = harvest * (1 - pft.harvest_slow_frac);
  361. }
  362. if (alive) {
  363. i.acflux_harvest += harvest;
  364. i.dcflux_harvest_pasture += harvest;
  365. }
  366. i.cmass_leaf -= harvest;
  367. // Nitrogen
  368. // Reduced removal of N relative to C during grazing.
  369. double N_harvest_scale = 0.25; // Value that works. Needs to be verified in literature.
  370. harvest = pft.harv_eff * i.nmass_leaf * N_harvest_scale;
  371. if (ifslowharvestpool) {
  372. i.harvested_products_slow_nmass += harvest * pft.harvest_slow_frac;
  373. if (harvest * pft.harvest_slow_frac > 0.0)
  374. i.dnflux_product += harvest * pft.harvest_slow_frac;
  375. harvest = harvest * (1 - pft.harvest_slow_frac);
  376. }
  377. i.anflux_harvest += harvest;
  378. i.nmass_leaf -= harvest;
  379. if (grassforcrop && alive) {
  380. // Carbon:
  381. double residue_outtake = pft.res_outtake * i.cmass_leaf; // res_outtake currently set to 0.0,
  382. i.acflux_harvest += residue_outtake; // could be used for burning
  383. i.dcflux_harvest_pasture += residue_outtake;
  384. i.cmass_leaf -= residue_outtake;
  385. // Nitrogen:
  386. residue_outtake = pft.res_outtake * i.nmass_leaf;
  387. i.anflux_harvest += residue_outtake;
  388. i.nmass_leaf -= residue_outtake;
  389. }
  390. }
  391. /// Harvest function for pasture, representing grazing (previous year).
  392. /* Function for balancing carbon and nitrogen fluxes from last year's growth
  393. * A fraction of leaves is harvested (pft.harv_eff) and returned as acflux_harvest
  394. * This represents grazing minus return as manure.
  395. * The rest is handled like natural grass in turnover().
  396. * Called from growth() last day of the year for normal harvest/grazing.
  397. * Also called from landcover_dynamics() first day of the year if any natural vegetation
  398. * is transferred to another land use.
  399. * This calls for a scaling factor, when the pasture area has increased.
  400. *
  401. * This function copies variables from an individual and it's associated patchpft and patch to
  402. * a Harvest_CN struct, which is then passed on to the main harvest_crop function.
  403. * After the execution of the main harvest_crop function, the output variables are copied
  404. * back to the individual and patchpft and the patch-level fluxes are updated.
  405. *
  406. * INPUT/OUTPUT PARAMETERS
  407. * \param indiv reference to an Individual containing the following indiv-specific public members:
  408. * - cmass_leaf leaf C biomass (kgC/m2)
  409. * - cmass_root fine root C biomass (kgC/m2)
  410. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  411. * - nmass_root fine root nitrogen biomass (kgN/m2)
  412. * OUTPUT PARAMETERS
  413. * \param indiv reference to an Individual containing the following patchpft-specific public members:
  414. * - litter_leaf new leaf C litter (kgC/m2)
  415. * - litter_root new root C litter (kgC/m2)
  416. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  417. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  418. * ,and the following patch-level public members:
  419. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  420. * - harvested_products_slow harvest products to slow pool (kgC/m2)
  421. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  422. * - harvested_products_slow_nmass harvest nitrogen products to slow pool (kgC/m2)
  423. */
  424. void harvest_pasture(Individual& indiv, Pft& pft, bool alive) {
  425. Harvest_CN indiv_cp;
  426. indiv_cp.copy_from_indiv(indiv);
  427. harvest_pasture(indiv_cp, pft, alive);
  428. indiv_cp.copy_to_indiv(indiv);
  429. }
  430. /// Harvest function for cropland, including true crops, intercrop grass
  431. /** and pasture grass grown in cropland.
  432. * Function for balancing carbon and nitrogen fluxes from this year's harvested carbon and nitrogen.
  433. * A fraction of harvestable organs (grass:leaves) is harvested (pft.harv_eff) and returned as acflux_harvest.
  434. * A fraction of leaves is removed (pft.res_outtake) and returned as acflux_harvest
  435. * The rest, including roots, is returned as litter, leaving NO carbon or nitrogen in living tissue.
  436. * Called from growth() last day of the year for old-style harvest/grazing or, alternatively, from crop_growth_daily() at harvest day
  437. * (hdate) or last intercrop day (eicdate).
  438. * Also called from landcover_dynamics() first day of the year if any natural vegetation
  439. * is transferred to another land use.
  440. * This calls for a scaling factor, when the pasture area has increased.
  441. *
  442. * This function takes a Harvest_CN struct as an input parameter, copied from an individual and it's associated patchpft and patch.
  443. *
  444. * INPUT PARAMETERS
  445. * \param alive whether individual has survived the first year
  446. * \param isintercropgrass whether individual is cover crop grass
  447. *
  448. * INPUT/OUTPUT PARAMETERS
  449. * \param Harvest_CN& i struct containing the following indiv-specific public members:
  450. * - cmass_leaf leaf C biomass (kgC/m2)
  451. * - cmass_root fine root C biomass (kgC/m2)
  452. * - cmass_ho harvestable organ C biomass (kgC/m2)
  453. * - cmass_agpool above-ground pool C biomass (kgC/m2)
  454. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  455. * - nmass_root fine root nitrogen biomass (kgN/m2)
  456. * - param nmass_ho harvestable organ nitrogen biomass (kgC/m2)
  457. * - param nmass_agpool above-ground pool nitrogen biomass (kgC/m2)
  458. * - nstore_labile labile nitrogen storage (kgC/m2)
  459. * - nstore_longterm longterm nitrogen storage (kgC/m2)
  460. * OUTPUT PARAMETERS
  461. * \param Harvest_CN& i struct containing the following patchpft-specific public members:
  462. * - litter_leaf new leaf C litter (kgC/m2)
  463. * - litter_root new root C litter (kgC/m2)
  464. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  465. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  466. * ,and the following patch-level public members:
  467. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  468. * - harvested_products_slow harvest products to slow pool (kgC/m2)
  469. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  470. * - harvested_products_slow_nmass harvest nitrogen products to slow pool (kgC/m2)
  471. */
  472. void harvest_crop(Harvest_CN& i, Pft& pft, bool alive, bool isintercropgrass) {
  473. double residue_outtake, harvest;
  474. i.dcflux_harvest_crop = 0.0;
  475. if (pft.phenology==CROPGREEN) {
  476. // all root carbon and nitrogen goes to litter
  477. if (i.cmass_root > 0.0) {
  478. i.litter_root += i.cmass_root;
  479. i.dcflux_harvest_res += i.cmass_root;
  480. }
  481. i.cmass_root = 0.0;
  482. if (i.nmass_root > 0.0)
  483. i.nmass_litter_root += i.nmass_root;
  484. if (i.nstore_labile > 0.0)
  485. i.nmass_litter_root += i.nstore_labile;
  486. if (i.nstore_longterm > 0.0)
  487. i.nmass_litter_root += i.nstore_longterm;
  488. i.nmass_root = 0.0;
  489. i.nstore_labile = 0.0;
  490. i.nstore_longterm = 0.0;
  491. // harvest of harvestable organs
  492. // Carbon:
  493. if (i.cmass_ho > 0.0) {
  494. // harvested products
  495. harvest = pft.harv_eff * i.cmass_ho;
  496. // not removed harvestable organs are put into litter
  497. if (pft.aboveground_ho)
  498. i.litter_leaf += (i.cmass_ho - harvest);
  499. else
  500. i.litter_root += (i.cmass_ho - harvest);
  501. i.dcflux_harvest_res += (i.cmass_ho - harvest);
  502. // harvested products not consumed (oxidised) this year put into harvested_products_slow
  503. if (ifslowharvestpool) {
  504. i.harvested_products_slow += harvest * pft.harvest_slow_frac;
  505. if (harvest * pft.harvest_slow_frac > 0.0)
  506. i.dcflux_product_crop = harvest * pft.harvest_slow_frac;
  507. harvest = harvest * (1 - pft.harvest_slow_frac);
  508. }
  509. // harvested products consumed (oxidised) this year put into acflux_harvest
  510. i.acflux_harvest += harvest;
  511. i.dcflux_harvest_crop += harvest;
  512. }
  513. i.cmass_ho = 0.0;
  514. // Nitrogen:
  515. if (i.nmass_ho > 0.0) {
  516. // harvested products
  517. harvest = pft.harv_eff * i.nmass_ho;
  518. // not removed harvestable organs are put into litter
  519. if (pft.aboveground_ho)
  520. i.nmass_litter_leaf += (i.nmass_ho - harvest);
  521. else
  522. i.nmass_litter_root += (i.nmass_ho - harvest);
  523. // harvested products not consumed this year put into harvested_products_slow_nmass
  524. if (ifslowharvestpool) {
  525. i.harvested_products_slow_nmass += harvest * pft.harvest_slow_frac;
  526. if (harvest * pft.harvest_slow_frac > 0.0)
  527. i.dnflux_product += harvest * pft.harvest_slow_frac;
  528. harvest = harvest * (1 - pft.harvest_slow_frac);
  529. }
  530. // harvested products consumed this year put into anflux_harvest
  531. i.anflux_harvest += harvest;
  532. }
  533. i.nmass_ho = 0.0;
  534. // residues
  535. // Carbon
  536. if ((i.cmass_leaf + i.cmass_agpool + i.cmass_dead_leaf + i.cmass_stem) > 0.0) {
  537. // removed residues are oxidised
  538. residue_outtake = pft.res_outtake * (i.cmass_leaf + i.cmass_agpool + i.cmass_dead_leaf + i.cmass_stem);
  539. i.acflux_harvest += residue_outtake;
  540. i.dcflux_harvest_crop += residue_outtake;
  541. // not removed residues are put into litter
  542. i.litter_leaf += i.cmass_leaf + i.cmass_agpool + i.cmass_dead_leaf + i.cmass_stem - residue_outtake;
  543. i.dcflux_harvest_res += i.cmass_leaf + i.cmass_agpool + i.cmass_dead_leaf + i.cmass_stem - residue_outtake;
  544. }
  545. i.cmass_leaf = 0.0;
  546. i.cmass_agpool = 0.0;
  547. i.cmass_dead_leaf = 0.0;
  548. i.cmass_stem = 0.0;
  549. // Nitrogen:
  550. if ((i.nmass_leaf + i.nmass_agpool + i.nmass_dead_leaf) > 0.0) {
  551. // removed residues are oxidised
  552. residue_outtake = pft.res_outtake * (i.nmass_leaf + i.nmass_agpool + i.nmass_dead_leaf);
  553. i.nmass_litter_leaf += i.nmass_leaf + i.nmass_agpool + i.nmass_dead_leaf - residue_outtake;
  554. // not removed residues are put into litter
  555. i.anflux_harvest += residue_outtake;
  556. }
  557. i.nmass_leaf = 0.0;
  558. i.nmass_agpool = 0.0;
  559. i.nmass_dead_leaf = 0.0;
  560. }
  561. else if (pft.phenology == ANY) {
  562. // Intercrop grass
  563. if (isintercropgrass) {
  564. // roots
  565. // all root carbon and nitrogen goes to litter
  566. if (i.cmass_root > 0.0) {
  567. i.litter_root += i.cmass_root;
  568. i.dcflux_harvest_res += i.cmass_root;
  569. }
  570. if (i.nmass_root > 0.0)
  571. i.nmass_litter_root += i.nmass_root;
  572. if (i.nstore_labile > 0.0)
  573. i.nmass_litter_root += i.nstore_labile;
  574. if (i.nstore_longterm > 0.0)
  575. i.nmass_litter_root += i.nstore_longterm;
  576. i.cmass_root = 0.0;
  577. i.nmass_root = 0.0;
  578. i.nstore_labile = 0.0;
  579. i.nstore_longterm = 0.0;
  580. // leaves
  581. // Carbon:
  582. if (i.cmass_leaf > 0.0) {
  583. // Harvest/Grazing of leaves:
  584. harvest = pft.harv_eff_ic * i.cmass_leaf; // currently no harvest of intercrtop grass
  585. // not removed grass is put into litter
  586. i.litter_leaf += i.cmass_leaf - harvest;
  587. i.dcflux_harvest_res += i.cmass_leaf - harvest;
  588. if (ifslowharvestpool) {
  589. i.harvested_products_slow += harvest * pft.harvest_slow_frac; // no slow harvest for grass
  590. if (harvest * pft.harvest_slow_frac > 0.0)
  591. i.dcflux_product_any = harvest * pft.harvest_slow_frac;
  592. harvest = harvest * (1 - pft.harvest_slow_frac);
  593. }
  594. i.acflux_harvest += harvest;
  595. i.dcflux_harvest_crop += harvest;
  596. }
  597. i.cmass_leaf = 0.0;
  598. i.cmass_ho = 0.0;
  599. i.cmass_agpool = 0.0;
  600. // Nitrogen:
  601. if (i.nmass_leaf > 0.0) {
  602. // Harvest/Grazing of leaves:
  603. harvest = pft.harv_eff_ic * i.nmass_leaf; // currently no harvest of intercrtop grass
  604. // not removed grass is put into litter
  605. i.nmass_litter_leaf += i.nmass_leaf - harvest;
  606. if (ifslowharvestpool) {
  607. i.harvested_products_slow_nmass += harvest * pft.harvest_slow_frac; // no slow harvest for grass
  608. if (harvest * pft.harvest_slow_frac > 0.0)
  609. i.dnflux_product += harvest * pft.harvest_slow_frac;
  610. harvest = harvest * (1 - pft.harvest_slow_frac);
  611. }
  612. i.anflux_harvest += harvest;
  613. }
  614. i.nmass_leaf = 0.0;
  615. i.nmass_ho = 0.0;
  616. i.nmass_agpool = 0.0;
  617. }
  618. else { // pasture grass
  619. // harvest of leaves (grazing)
  620. // Carbon:
  621. harvest = pft.harv_eff * i.cmass_leaf;
  622. if (ifslowharvestpool) {
  623. i.harvested_products_slow += harvest * pft.harvest_slow_frac;
  624. if (harvest * pft.harvest_slow_frac > 0.0)
  625. i.dcflux_product_grass = harvest * pft.harvest_slow_frac;
  626. harvest = harvest * (1 - pft.harvest_slow_frac);
  627. }
  628. if (alive) {
  629. i.acflux_harvest += harvest;
  630. i.dcflux_harvest_crop += harvest;
  631. }
  632. i.cmass_leaf -= harvest;
  633. i.cmass_ho = 0.0;
  634. i.cmass_agpool = 0.0;
  635. // Nitrogen:
  636. // Reduced removal of N relative to C during grazing.
  637. double N_harvest_scale = 0.25; // Value that works. Needs to be verified in literature.
  638. harvest = pft.harv_eff * i.nmass_leaf * N_harvest_scale;
  639. if (ifslowharvestpool) {
  640. i.harvested_products_slow_nmass += harvest * pft.harvest_slow_frac;
  641. if (harvest * pft.harvest_slow_frac > 0.0)
  642. i.dnflux_product += harvest * pft.harvest_slow_frac;
  643. harvest = harvest * (1 - pft.harvest_slow_frac);
  644. }
  645. i.anflux_harvest += harvest;
  646. i.nmass_leaf -= harvest;
  647. i.nmass_ho=0.0;
  648. i.nmass_agpool=0.0;
  649. }
  650. }
  651. }
  652. /// Harvest function for cropland, including true crops, intercrop grass
  653. /** and pasture grass grown in cropland.
  654. * Function for balancing carbon and nitrogen fluxes from this year's harvested carbon and nitrogen.
  655. * A fraction of harvestable organs (grass:leaves) is harvested (pft.harv_eff) and returned as acflux_harvest.
  656. * A fraction of leaves is removed (pft.res_outtake) and returned as acflux_harvest
  657. * The rest, including roots, is returned as litter, leaving NO carbon or nitrogen in living tissue.
  658. * Called from growth() last day of the year for old-style harvest/grazing or, alternatively, from crop_growth_daily() at harvest day
  659. * (hdate) or last intercrop day (eicdate).
  660. * Also called from landcover_dynamics() first day of the year if any natural vegetation
  661. * is transferred to another land use.
  662. * This calls for a scaling factor, when the pasture area has increased.
  663. *
  664. * This function copies variables from an individual and it's associated patchpft and patch to
  665. * a Harvest_CN struct, which is then passed on to the main harvest_crop() function.
  666. * After the execution of the main harvest_crop function, the output variables are copied
  667. * back to the individual and patchpft and the patch-level fluxes are updated.
  668. *
  669. * INPUT PARAMETERS
  670. * \param alive whether individual has survived the first year
  671. * \param isintercropgrass whether individual is cover crop grass
  672. * \param harvest_grsC whether harvest daily carbon values are harvested
  673. *
  674. * INPUT/OUTPUT PARAMETERS
  675. * \param indiv reference to an Individual containing the following indiv-specific public members:
  676. * - cmass_leaf leaf C biomass (kgC/m2)
  677. * - cmass_root fine root C biomass (kgC/m2)
  678. * - cmass_ho harvestable organ C biomass (kgC/m2)
  679. * - cmass_agpool above-ground pool C biomass (kgC/m2)
  680. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  681. * - nmass_root fine root nitrogen biomass (kgN/m2)
  682. * - param nmass_ho harvestable organ nitrogen biomass (kgC/m2)
  683. * - param nmass_agpool above-ground pool nitrogen biomass (kgC/m2)
  684. * - nstore_labile labile nitrogen storage (kgC/m2)
  685. * - nstore_longterm longterm nitrogen storage (kgC/m2)
  686. * OUTPUT PARAMETERS
  687. * \param indiv reference to an Individual containing the following patchpft-specific public members:
  688. * - litter_leaf new leaf C litter (kgC/m2)
  689. * - litter_root new root C litter (kgC/m2)
  690. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  691. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  692. * ,and the following patch-level public members:
  693. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  694. * - harvested_products_slow harvest products to slow pool (kgC/m2)
  695. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  696. * - harvested_products_slow_nmass harvest nitrogen products to slow pool (kgC/m2)
  697. */
  698. void harvest_crop(Individual& indiv, Pft& pft, bool alive, bool isintercropgrass, bool harvest_grsC) {
  699. Harvest_CN indiv_cp;
  700. indiv_cp.copy_from_indiv(indiv, harvest_grsC);
  701. harvest_crop(indiv_cp, pft, alive, isintercropgrass);
  702. indiv_cp.copy_to_indiv(indiv, harvest_grsC);
  703. }
  704. /// Transfers all carbon and nitrogen from living tissue to litter
  705. /** Mainly used at land cover change when remaining vegetation after harvest (grass) is
  706. * killed by tillage, following an optional burning.
  707. *
  708. * This function takes a Harvest_CN struct as an input parameter, copied from an individual and it's associated patchpft and patch.
  709. *
  710. * INPUT PARAMETERS
  711. * \param alive whether individual has survived the first year
  712. * \param isintercropgrass whether individual is cover crop grass
  713. * \param burn whether above-ground vegetation C & N is sent to the atmosphere
  714. * rather than to litter
  715. * INPUT/OUTPUT PARAMETERS
  716. * \param Harvest_CN& i struct containing the following indiv-specific public members:
  717. * - cmass_leaf leaf C biomass (kgC/m2)
  718. * - cmass_root fine root C biomass (kgC/m2)
  719. * - cmass_ho harvestable organ C biomass (kgC/m2)
  720. * - cmass_agpool above-ground pool C biomass (kgC/m2)
  721. * - cmass_sap sapwood C biomass (kgC/m2)
  722. * - cmass_heart heartwood C biomass (kgC/m2)
  723. * - cmass_debt C "debt" (retrospective storage) (kgC/m2)
  724. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  725. * - nmass_root fine root nitrogen biomass (kgN/m2)
  726. * - nmass_sap sapwood nitrogen biomass (kgC/m2)
  727. * - nmass_heart heartwood nitrogen biomass (kgC/m2)
  728. * - param nmass_ho harvestable organ nitrogen biomass (kgC/m2)
  729. * - param nmass_agpool above-ground pool nitrogen biomass (kgC/m2)
  730. * - nstore_labile labile nitrogen storage (kgC/m2)
  731. * - nstore_longterm longterm nitrogen storage (kgC/m2)
  732. * OUTPUT PARAMETERS
  733. * \param Harvest_CN& i struct containing the following patchpft-specific public members:
  734. * - litter_leaf new leaf C litter (kgC/m2)
  735. * - litter_root new root C litter (kgC/m2)
  736. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  737. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  738. * ,and the following patch-level public members:
  739. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  740. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  741. */
  742. void kill_remaining_vegetation(Harvest_CN& cp, Pft& pft, bool alive, bool istruecrop_or_intercropgrass, bool burn) {
  743. if (alive || istruecrop_or_intercropgrass) {
  744. cp.litter_root += cp.cmass_root;
  745. if (burn) {
  746. cp.acflux_harvest += cp.cmass_leaf;
  747. cp.acflux_harvest += cp.cmass_sap;
  748. cp.acflux_harvest += cp.cmass_heart - cp.cmass_debt;
  749. }
  750. else {
  751. cp.litter_leaf += cp.cmass_leaf;
  752. cp.litter_sap += cp.cmass_sap;
  753. cp.litter_heart += cp.cmass_heart - cp.cmass_debt;
  754. }
  755. }
  756. cp.nmass_litter_root += cp.nmass_root;
  757. cp.nmass_litter_root += cp.nstore_longterm;
  758. cp.nmass_litter_root += cp.nstore_labile;
  759. if (burn) {
  760. cp.anflux_harvest += cp.nmass_leaf;
  761. cp.anflux_harvest += cp.nmass_sap;
  762. cp.anflux_harvest += cp.nmass_heart;
  763. }
  764. else {
  765. cp.nmass_litter_leaf += cp.nmass_leaf;
  766. cp.nmass_litter_sap += cp.nmass_sap;
  767. cp.nmass_litter_heart += cp.nmass_heart;
  768. }
  769. if (pft.landcover == CROPLAND) {
  770. if (pft.aboveground_ho) {
  771. if (burn) {
  772. cp.acflux_harvest += cp.cmass_ho;
  773. cp.anflux_harvest += cp.nmass_ho;
  774. }
  775. else {
  776. cp.litter_leaf += cp.cmass_ho;
  777. cp.nmass_litter_leaf += cp.nmass_ho;
  778. }
  779. }
  780. else {
  781. cp.litter_root += cp.cmass_ho;
  782. cp.nmass_litter_root += cp.nmass_ho;
  783. }
  784. if (burn) {
  785. cp.acflux_harvest += cp.cmass_agpool;
  786. cp.anflux_harvest += cp.nmass_agpool;
  787. }
  788. else {
  789. cp.litter_leaf += cp.cmass_agpool;
  790. cp.nmass_litter_leaf += cp.nmass_agpool;
  791. }
  792. }
  793. cp.cmass_leaf = 0.0;
  794. cp.cmass_root = 0.0;
  795. cp.cmass_sap = 0.0;
  796. cp.cmass_heart = 0.0;
  797. cp.cmass_debt = 0.0;
  798. cp.cmass_ho = 0.0;
  799. cp.cmass_agpool = 0.0;
  800. cp.nmass_leaf = 0.0;
  801. cp.nmass_root = 0.0;
  802. cp.nstore_longterm = 0.0;
  803. cp.nstore_labile = 0.0;
  804. cp.nmass_sap = 0.0;
  805. cp.nmass_heart = 0.0;
  806. cp.nmass_ho = 0.0;
  807. cp.nmass_agpool = 0.0;
  808. }
  809. /// Transfers all carbon and nitrogen from living tissue to litter
  810. /** Mainly used at land cover change when remaining vegetation after harvest (grass) is
  811. * killed by tillage, following an optional burning.
  812. *
  813. * This function copies variables from an individual and it's associated patchpft and patch to
  814. * a Harvest_CN struct, which is then passed on to the main harvest_crop() function.
  815. * After the execution of the main harvest_crop function, the output variables are copied
  816. * back to the individual and patchpft and the patch-level fluxes are updated.
  817. *
  818. * INPUT PARAMETERS
  819. * \param alive whether individual has survived the first year
  820. * \param isintercropgrass whether individual is cover crop grass
  821. * \param burn whether above-ground vegetation C & N is sent to the atmosphere
  822. * rather than to litter
  823. * INPUT/OUTPUT PARAMETERS
  824. * \param Harvest_CN& i struct containing the following indiv-specific public members:
  825. * - cmass_leaf leaf C biomass (kgC/m2)
  826. * - cmass_root fine root C biomass (kgC/m2)
  827. * - cmass_ho harvestable organ C biomass (kgC/m2)
  828. * - cmass_agpool above-ground pool C biomass (kgC/m2)
  829. * - cmass_sap sapwood C biomass (kgC/m2)
  830. * - cmass_heart heartwood C biomass (kgC/m2)
  831. * - cmass_debt C "debt" (retrospective storage) (kgC/m2)
  832. * - nmass_leaf leaf nitrogen biomass (kgN/m2)
  833. * - nmass_root fine root nitrogen biomass (kgN/m2)
  834. * - nmass_sap sapwood nitrogen biomass (kgC/m2)
  835. * - nmass_heart heartwood nitrogen biomass (kgC/m2)
  836. * - param nmass_ho harvestable organ nitrogen biomass (kgC/m2)
  837. * - param nmass_agpool above-ground pool nitrogen biomass (kgC/m2)
  838. * - nstore_labile labile nitrogen storage (kgC/m2)
  839. * - nstore_longterm longterm nitrogen storage (kgC/m2)
  840. * OUTPUT PARAMETERS
  841. * \param Harvest_CN& i struct containing the following patchpft-specific public members:
  842. * - litter_leaf new leaf C litter (kgC/m2)
  843. * - litter_root new root C litter (kgC/m2)
  844. * - nmass_litter_leaf new leaf nitrogen litter (kgN/m2)
  845. * - nmass_litter_root new root nitrogen litter (kgN/m2)
  846. * ,and the following patch-level public members:
  847. * - acflux_harvest harvest flux to atmosphere (kgC/m2)
  848. * - anflux_harvest harvest nitrogen flux out of system (kgC/m2)
  849. */
  850. void kill_remaining_vegetation(Individual& indiv, bool burn, bool lc_change) {
  851. Harvest_CN indiv_cp;
  852. indiv_cp.copy_from_indiv(indiv);
  853. kill_remaining_vegetation(indiv_cp, indiv.pft, indiv.alive, indiv.istruecrop_or_intercropgrass(), burn);
  854. indiv_cp.copy_to_indiv(indiv, false, lc_change);
  855. if (burn && lc_change) {
  856. Stand& stand = indiv.vegetation.patch.stand;
  857. Landcover& lc = stand.get_gridcell().landcover;
  858. lc.dcflux_landuse_change += stand.get_gridcell_fraction() * indiv_cp.acflux_harvest / (double)stand.nobj; // ecev3 - reset to 0 each day
  859. lc.acflux_landuse_change += stand.get_gridcell_fraction() * indiv_cp.acflux_harvest / (double)stand.nobj;
  860. lc.acflux_landuse_change_lc[stand.origin] += stand.get_gridcell_fraction() * indiv_cp.acflux_harvest / (double)stand.nobj;
  861. lc.anflux_landuse_change += stand.get_gridcell_fraction() * indiv_cp.anflux_harvest / (double)stand.nobj;
  862. lc.anflux_landuse_change_lc[stand.origin] += stand.get_gridcell_fraction() * indiv_cp.anflux_harvest / (double)stand.nobj;
  863. }
  864. }
  865. /// Scaling of last year's or harvest day individual carbon and nitrogen member values in stands that have increased their area fraction this year.
  866. /** Called immediately before harvest functions in growth() or allocation_crop_daily().
  867. */
  868. void scale_indiv(Individual& indiv, bool scale_grsC) {
  869. Stand& stand = indiv.vegetation.patch.stand;
  870. Gridcell& gridcell = stand.get_gridcell();
  871. if (stand.scale_LC_change >= 1.0) {
  872. return;
  873. }
  874. // Scale individual's C and N mass in stands that have increased in area
  875. // this year by (old area/new area):
  876. double scale = stand.scale_LC_change;
  877. if (scale_grsC) {
  878. if (indiv.pft.landcover == CROPLAND) {
  879. if (indiv.has_daily_turnover()) {
  880. indiv.cropindiv->grs_cmass_leaf -= indiv.cropindiv->grs_cmass_leaf_luc * (1.0 - scale);
  881. indiv.cropindiv->grs_cmass_root -= indiv.cropindiv->grs_cmass_root_luc * (1.0 - scale);
  882. indiv.cropindiv->grs_cmass_ho -= indiv.cropindiv->grs_cmass_ho_luc * (1.0 - scale);
  883. indiv.cropindiv->grs_cmass_agpool -= indiv.cropindiv->grs_cmass_agpool_luc * (1.0 - scale);
  884. indiv.cropindiv->grs_cmass_dead_leaf -= indiv.cropindiv->grs_cmass_dead_leaf_luc * (1.0 - scale);
  885. indiv.cropindiv->grs_cmass_stem -= indiv.cropindiv->grs_cmass_stem_luc * (1.0 - scale);
  886. indiv.check_C_mass();
  887. }
  888. else {
  889. indiv.cropindiv->grs_cmass_leaf *= scale;
  890. indiv.cropindiv->grs_cmass_root *= scale;
  891. indiv.cropindiv->grs_cmass_ho *= scale;
  892. indiv.cropindiv->grs_cmass_agpool *= scale;
  893. indiv.cropindiv->grs_cmass_plant *= scale; //grs_cmass_plant not used
  894. indiv.cropindiv->grs_cmass_dead_leaf *= scale;
  895. indiv.cropindiv->grs_cmass_stem *= scale;
  896. }
  897. }
  898. }
  899. else {
  900. indiv.cmass_root *= scale;
  901. indiv.cmass_leaf *= scale;
  902. indiv.cmass_heart *= scale;
  903. indiv.cmass_sap *= scale;
  904. indiv.cmass_debt *= scale;
  905. if (indiv.pft.landcover == CROPLAND) {
  906. indiv.cropindiv->cmass_agpool *= scale;
  907. indiv.cropindiv->cmass_ho *= scale;
  908. }
  909. }
  910. // Deduct individual N present day 0 this year in stands that have increased in area this year, scaled by (1 - old area/new area):
  911. indiv.nmass_root = indiv.nmass_root - indiv.nmass_root_luc * (1.0 - scale);
  912. indiv.nmass_leaf = indiv.nmass_leaf - indiv.nmass_leaf_luc * (1.0 - scale);
  913. indiv.nmass_heart = indiv.nmass_heart - indiv.nmass_heart_luc * (1.0 - scale);
  914. indiv.nmass_sap = indiv.nmass_sap - indiv.nmass_sap_luc * (1.0 - scale);
  915. if (indiv.pft.landcover == CROPLAND) {
  916. indiv.cropindiv->nmass_agpool = indiv.cropindiv->nmass_agpool - indiv.cropindiv->nmass_agpool_luc * (1.0 - scale);
  917. indiv.cropindiv->nmass_ho = indiv.cropindiv->nmass_ho - indiv.cropindiv->nmass_ho_luc * (1.0 - scale);
  918. indiv.cropindiv->nmass_dead_leaf =indiv.cropindiv->nmass_dead_leaf - indiv.cropindiv->nmass_dead_leaf_luc * (1.0 - scale);
  919. }
  920. if (indiv.nstore_labile > indiv.nstore_labile_luc * (1.0 - scale))
  921. indiv.nstore_labile -= indiv.nstore_labile_luc * (1.0 - scale);
  922. else
  923. indiv.nstore_longterm -= indiv.nstore_labile_luc * (1.0 - scale);
  924. indiv.nstore_longterm = indiv.nstore_longterm - indiv.nstore_longterm_luc * (1.0 - scale);
  925. indiv.check_N_mass();
  926. }
  927. /// Yearly function for harvest of all land covers that have yearly allocation, turnover and gridcell.expand_to_new_stand[lc] = false.
  928. /** Should only be called from growth().
  929. // Harvest functions are preceded by rescaling of living C.
  930. // Only affects natural stands if gridcell.expand_to_new_stand[NATURAL] is false.
  931. */
  932. bool harvest_year(Individual& indiv) {
  933. Stand& stand = indiv.vegetation.patch.stand;
  934. Landcover& landcover = stand.get_gridcell().landcover;
  935. bool killed = false;
  936. // Reduce individual's C and N mass in stands that have increased in area this year:
  937. if (landcover.updated && !indiv.has_daily_turnover()) {
  938. scale_indiv(indiv, false);
  939. }
  940. if (stand.landcover == CROPLAND) {
  941. if (!indiv.has_daily_turnover())
  942. harvest_crop(indiv, indiv.pft, indiv.alive, indiv.cropindiv->isintercropgrass, false);
  943. }
  944. else if (stand.landcover == PASTURE) {
  945. harvest_pasture(indiv, indiv.pft, indiv.alive);
  946. }
  947. else if(stand.landcover == FOREST || stand.landcover == NATURAL && run_landcover)
  948. harvest_forest(indiv, indiv.pft, indiv.alive, indiv.anpp, killed);
  949. return killed;
  950. }
  951. /// Yield function for true crops and intercrop grass.
  952. void yield_crop(Individual& indiv) {
  953. cropindiv_struct& cropindiv = *(indiv.get_cropindiv());
  954. if (indiv.pft.phenology == ANY) { // grass intercrop yield
  955. // Yield dry wieght of allocated harvestable organs this year; NB independent from harvest calculation in harvest_crop (different years)
  956. if (cropindiv.ycmass_leaf > 0.0)
  957. cropindiv.yield = cropindiv.ycmass_leaf * indiv.pft.harv_eff_ic * 2.0;
  958. else
  959. cropindiv.yield = 0.0;
  960. // Yield dry wieght of actually harvest products this year; NB as above
  961. if (cropindiv.harv_cmass_leaf > 0.0)
  962. cropindiv.harv_yield = cropindiv.harv_cmass_leaf * indiv.pft.harv_eff_ic * 2.0;
  963. else
  964. cropindiv.harv_yield = 0.0;
  965. }
  966. else if (indiv.pft.phenology == CROPGREEN) { //true crop yield
  967. // Yield dry wieght of allocated harvestable organs this year; NB independent from harvest calculation in harvest_crop (different years)
  968. if (cropindiv.ycmass_ho > 0.0)
  969. cropindiv.yield = cropindiv.ycmass_ho * indiv.pft.harv_eff * 2.0;// Should be /0.446 instead
  970. else
  971. cropindiv.yield = 0.0;
  972. // Yield dry wieght of actually harvest products this year; NB as above
  973. if (cropindiv.harv_cmass_ho > 0.0)
  974. cropindiv.harv_yield=cropindiv.harv_cmass_ho * indiv.pft.harv_eff * 2.0;
  975. else
  976. cropindiv.harv_yield = 0.0;
  977. // Yield dry wieght of actually harvest products this year; NB as above
  978. for (int i=0;i<2;i++) {
  979. if (cropindiv.cmass_ho_harvest[i] > 0.0)
  980. cropindiv.yield_harvest[i] = cropindiv.cmass_ho_harvest[i] * indiv.pft.harv_eff * 2.0;
  981. else
  982. cropindiv.yield_harvest[i]=0.0;
  983. }
  984. }
  985. return;
  986. }
  987. /// Yield function for pasture grass grown in cropland landcover
  988. void yield_pasture(Individual& indiv, double cmass_leaf_inc) {
  989. cropindiv_struct& cropindiv = *(indiv.get_cropindiv());
  990. // Normal CC3G/CC4G stand growth (Pasture)
  991. // OK if turnover_leaf==1.0, else (cmass_leaf+cmass_leaf_inc)*indiv.pft.harv_eff*2.0
  992. cropindiv.yield = max(0.0, cmass_leaf_inc) * indiv.pft.harv_eff * 2.0;
  993. // Although no specified harvest date, harv_yield is set for compatibility.
  994. cropindiv.harv_yield = cropindiv.yield;
  995. }
  996. /// Function that determines amount of nitrogen applied today. Crop-specific, pft-based.
  997. void nfert_crop(Patch& patch) {
  998. Gridcell& gridcell = patch.stand.get_gridcell();
  999. patch.dnfert = 0.0;
  1000. pftlist.firstobj();
  1001. // Loop through PFTs
  1002. while(pftlist.isobj) {
  1003. Pft& pft = pftlist.getobj();
  1004. Patchpft& patchpft = patch.pft[pft.id];
  1005. Gridcellpft& gridcellpft = gridcell.pft[pft.id];
  1006. if (patch.stand.pft[pft.id].active && pft.phenology == CROPGREEN) {
  1007. cropphen_struct& ppftcrop = *(patchpft.get_cropphen());
  1008. if(!ppftcrop.growingseason) {
  1009. pftlist.nextobj();
  1010. continue;
  1011. }
  1012. double nfert = pft.N_appfert;
  1013. if (gridcellpft.Nfert_read >= 0.0) {
  1014. nfert = gridcellpft.Nfert_read;
  1015. }
  1016. if (!ppftcrop.fertilised[0] && ppftcrop.dev_stage > 0.0){
  1017. // Fertiliser application at dev_stage = 0, sowing.
  1018. patch.dnfert = nfert * (1.0 - pft.fertrate[0] - pft.fertrate[1]);
  1019. ppftcrop.fertilised[0] = true;
  1020. }
  1021. else if (!ppftcrop.fertilised[1] && ppftcrop.dev_stage > pft.fert_stages[0]){
  1022. patch.dnfert = nfert * pft.fertrate[0];
  1023. ppftcrop.fertilised[1] = true;
  1024. }
  1025. else if (!ppftcrop.fertilised[2] && ppftcrop.dev_stage > pft.fert_stages[1]){
  1026. patch.dnfert = nfert * (pft.fertrate[1]);
  1027. ppftcrop.fertilised[2] = true;
  1028. }
  1029. }
  1030. pftlist.nextobj();
  1031. }
  1032. patch.anfert += patch.dnfert;
  1033. patch.fluxes.report_flux(Fluxes::NFERT, patch.dnfert);
  1034. }
  1035. /// Function that determines amount of nitrogen applied today.
  1036. void nfert(Patch& patch) {
  1037. Stand& stand = patch.stand;
  1038. StandType& st = stlist[stand.stid];
  1039. Gridcell& gridcell = stand.get_gridcell();
  1040. if(stand.landcover == CROPLAND) {
  1041. nfert_crop(patch);
  1042. return;
  1043. }
  1044. // General code for applying nitrogen to other land cover types, an equal amount every day.
  1045. double nfert;
  1046. if(gridcell.st[st.id].nfert >= 0.0) { // todo: management type variable (mt.nfert)
  1047. nfert = gridcell.st[st.id].nfert;
  1048. }
  1049. else {
  1050. nfert = 0.0;
  1051. }
  1052. patch.dnfert = nfert / (double)date.year_length();
  1053. patch.anfert += patch.dnfert;
  1054. patch.fluxes.report_flux(Fluxes::NFERT, patch.dnfert);
  1055. }
  1056. /// Updates crop rotation status
  1057. /** Sets new crop management variables, typically on harvest day
  1058. */
  1059. void crop_rotation(Stand& stand) {
  1060. if (stand.landcover != CROPLAND) {
  1061. return;
  1062. }
  1063. CropRotation& rotation = stlist[stand.stid].rotation;
  1064. stand.ndays_inrotation++;
  1065. if (rotation.ncrops < 2 || !stand.isrotationday) {
  1066. return;
  1067. }
  1068. int firstrotyear = rotation.firstrotyear - date.first_calendar_year;
  1069. bool postpone_rotation = false;
  1070. // Alternative uses of firstrotyear:
  1071. // 1. Before firstrotyear, grow only crop1:
  1072. // if(date.year < firstrotyear)
  1073. // postpone_rotation = true;
  1074. // 2. Synchronise rotation with firstrotyear:
  1075. // A. At the creation of the stand:
  1076. if (date.year < stand.first_year + 3)
  1077. // B. At firstrotyear
  1078. // if(date.year == firstrotyear - 1)
  1079. // C. Continuously:
  1080. {
  1081. if ((abs(firstrotyear - date.year) % rotation.ncrops) != stand.current_rot)
  1082. postpone_rotation = true;
  1083. }
  1084. if (!postpone_rotation) {
  1085. if(stand.infallow) {
  1086. stand.infallow = false;
  1087. stand.get_gridcell().pft[stand.pftid].sowing_restriction = false;
  1088. }
  1089. int old_pftid = stand.pftid;
  1090. stand.rotate();
  1091. for (unsigned int p=0; p<stand.nobj; p++) {
  1092. cropphen_struct& previous = *(stand[p].pft[old_pftid].get_cropphen());
  1093. cropphen_struct& current = *(stand[p].pft[stand.pftid].get_cropphen());
  1094. previous.bicdate = -1;
  1095. if(!previous.intercropseason)
  1096. current.bicdate = stepfromdate(date.day, 15);
  1097. previous.eicdate = -1;
  1098. current.eicdate = -1;
  1099. previous.hdate = -1;
  1100. current.intercropseason = previous.intercropseason;
  1101. }
  1102. // Adds sowing and harvest dates for the second crop in a double cropping system
  1103. if (stlist[stand.stid].get_management(stand.current_rot).multicrop && rotation.ncrops == 2 && stand.current_rot == 1) {
  1104. if (stand.pft[stand.pftid].sdate_force < 0)
  1105. stand.pft[stand.pftid].sdate_force = stepfromdate(date.day, 10);
  1106. if (stand.pft[stand.pftid].hdate_force < 0) {
  1107. stand.pft[stand.pftid].hdate_force = stepfromdate(stand.pft[old_pftid].sdate_force, -10);
  1108. }
  1109. }
  1110. if(stlist[stand.stid].get_management(stand.current_rot).fallow) {
  1111. stand.infallow = true;
  1112. stand.get_gridcell().pft[stand.pftid].sowing_restriction = true;
  1113. }
  1114. }
  1115. stand.isrotationday = false;
  1116. }