management.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. ////////////////////////////////////////////////////////////////
  2. ////////////////////////////////////////////////
  3. /// \file management.h
  4. /// \brief Harvest functions for cropland, managed forest and pasture
  5. /// \author Mats Lindeskog
  6. /// $Date: 2018-12-21 08:30:58 +0100 (Fri, 21 Dec 2018) $
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  8. #ifndef LPJ_GUESS_MANAGEMENT_H
  9. #define LPJ_GUESS_MANAGEMENT_H
  10. // Forward declaration
  11. struct Harvest_CN;
  12. /// Harvest function for cropland, including true crops, intercrop grass
  13. void harvest_crop(Harvest_CN& indiv_cp, Pft& pft, bool alive, bool isintercropgrass);
  14. /// Harvest function for cropland, including true crops, intercrop grass
  15. void harvest_crop(Individual& indiv, Pft& pft, bool alive, bool isintercropgrass, bool harvest_grs);
  16. /// Set forest management intensity for all stands this year
  17. void cut_fractions(Gridcell& gridcell);
  18. /// Harvest function used for managed forest and for clearing natural vegetation at land use change.
  19. void harvest_wood(Harvest_CN& indiv_cp,Pft& pft, bool alive, double frac_cut, double harv_eff, double res_outtake_twig = 0.0, double res_outtake_coarse_root = 0.0);
  20. /// Harvest function used for managed forest and for clearing natural vegetation at land use change.
  21. void harvest_wood(Individual& indiv, double frac_cut, double harv_eff, double res_outtake_twig = 0.0, double res_outtake_coarse_root = 0.0, bool lc_change = false);
  22. /// Harvest function for pasture, representing grazing.
  23. void harvest_pasture(Harvest_CN& indiv_cp, Pft& pft, bool alive);
  24. /// Harvest function for pasture, representing grazing.
  25. void harvest_pasture(Individual& indiv, Pft& pft, bool alive);
  26. /// Harvest function for managed forest
  27. void harvest_forest(Individual& indiv, Pft& pft, bool alive, double anpp, bool& killed);
  28. /// Transfers all carbon and nitrogen from living tissue to litter.
  29. void kill_remaining_vegetation(Harvest_CN& indiv_cp, Pft& pft, bool alive, bool istruecrop_or_intercropgrass, bool burn = false);
  30. /// Transfers all carbon and nitrogen from living tissue to litter.
  31. void kill_remaining_vegetation(Individual& indiv, bool burn = false, bool lc_change = false);
  32. /// Scaling of last year's or harvest day individual carbon and nitrogen member values in stands that have increased their area fraction this year.
  33. void scale_indiv(Individual& indiv, bool scale_grsC);
  34. /// Yearly function for harvest of all land covers. Should only be called from growth()
  35. bool harvest_year(Individual& indiv);
  36. /// Yield function for true crops and intercrop grass
  37. void yield_crop(Individual& indiv);
  38. /// Yield function for pasture grass grown in cropland landcover
  39. void yield_pasture(Individual& indiv, double cmass_leaf_inc);
  40. /// Determines amount of nitrogen applied today
  41. void nfert(Patch& patch);
  42. /// Updates crop rotation status
  43. void crop_rotation(Stand& stand);
  44. /// Determines cutting intensity before wood harvest
  45. double cut_fraction(Patch& patch);
  46. /// Struct for copies of carbon and nitrogen of an individual and associated litter and fluxes resulting from harvest
  47. /// This is needed if we want to harvest only part of a stand, as during land cover change.
  48. struct Harvest_CN {
  49. double cmass_leaf;
  50. double cmass_root;
  51. double cmass_sap;
  52. double cmass_heart;
  53. double cmass_debt;
  54. double cmass_ho;
  55. double cmass_agpool;
  56. double cmass_stem;
  57. double cmass_dead_leaf;
  58. double debt_excess;
  59. double nmass_leaf;
  60. double nmass_root;
  61. double nmass_sap;
  62. double nmass_heart;
  63. double nmass_ho;
  64. double nmass_agpool;
  65. double nmass_dead_leaf;
  66. double nstore_longterm;
  67. double nstore_labile;
  68. double max_n_storage;
  69. double litter_leaf;
  70. double litter_root;
  71. double litter_sap;
  72. double litter_heart;
  73. double nmass_litter_leaf;
  74. double nmass_litter_root;
  75. double nmass_litter_sap;
  76. double nmass_litter_heart;
  77. double acflux_harvest;
  78. double anflux_harvest;
  79. double harvested_products_slow;
  80. double harvested_products_slow_nmass;
  81. double dcflux_harvest_crop;
  82. double dcflux_harvest_pasture;
  83. double dcflux_harvest_wood;
  84. double dcflux_product_crop;
  85. double dcflux_product_pasture;
  86. double dcflux_product_any;
  87. double dcflux_product_grass;
  88. double dcflux_product_wood;
  89. double dcflux_harvest_res;
  90. double dcflux_harvest_wood_res;
  91. double dnflux_product;
  92. Harvest_CN() {
  93. cmass_leaf = cmass_root = cmass_sap = cmass_heart = cmass_debt = cmass_ho = cmass_agpool = cmass_stem = cmass_dead_leaf = debt_excess = 0.0;
  94. nmass_leaf = nmass_root = nmass_sap = nmass_heart = nmass_ho = nmass_agpool = nmass_dead_leaf = nstore_longterm = nstore_labile = max_n_storage = 0.0;
  95. litter_leaf = litter_root = litter_sap = litter_heart = 0.0;
  96. nmass_litter_leaf = nmass_litter_root = nmass_litter_sap = nmass_litter_heart = 0.0;
  97. acflux_harvest = anflux_harvest = dcflux_harvest_crop = dcflux_harvest_pasture = dcflux_harvest_wood = 0.0;
  98. harvested_products_slow = harvested_products_slow_nmass = 0.0;
  99. dcflux_product_crop = dcflux_product_pasture = dcflux_product_any = dcflux_product_grass = dcflux_product_wood = dnflux_product = 0.0;
  100. dcflux_harvest_res = dcflux_harvest_wood_res = 0.0;
  101. }
  102. /// Copies C and N values from individual and patchpft tp struct.
  103. void copy_from_indiv(Individual& indiv, bool copy_grsC = false, bool copy_dead_C = true) {
  104. Patch& patch = indiv.vegetation.patch;
  105. Patchpft& ppft = patch.pft[indiv.pft.id];
  106. if(copy_grsC) {
  107. if(indiv.cropindiv) {
  108. cmass_leaf = indiv.cropindiv->grs_cmass_leaf;
  109. cmass_root = indiv.cropindiv->grs_cmass_root;
  110. if(indiv.pft.landcover == CROPLAND) {
  111. cmass_ho = indiv.cropindiv->grs_cmass_ho;
  112. cmass_agpool = indiv.cropindiv->grs_cmass_agpool;
  113. cmass_stem = indiv.cropindiv->grs_cmass_stem;
  114. cmass_dead_leaf = indiv.cropindiv->grs_cmass_dead_leaf;
  115. }
  116. }
  117. }
  118. else {
  119. cmass_leaf = indiv.cmass_leaf;
  120. cmass_root = indiv.cmass_root;
  121. cmass_sap = indiv.cmass_sap;
  122. cmass_heart = indiv.cmass_heart;
  123. cmass_debt = indiv.cmass_debt;
  124. if(indiv.pft.landcover == CROPLAND && indiv.cropindiv) { // ecev3 - added indiv.cropindiv check)
  125. cmass_ho = indiv.cropindiv->cmass_ho;
  126. cmass_agpool = indiv.cropindiv->cmass_agpool;
  127. // cmass_stem = indiv.cropindiv->grs_cmass_stem; // We can't use grs_cmass here !
  128. // cmass_dead_leaf = indiv.cropindiv->grs_cmass_dead_leaf;
  129. }
  130. }
  131. nmass_leaf = indiv.nmass_leaf;
  132. nmass_root = indiv.nmass_root;
  133. nmass_sap = indiv.nmass_sap;
  134. nmass_heart = indiv.nmass_heart;
  135. nstore_longterm = indiv.nstore_longterm;
  136. nstore_labile = indiv.nstore_labile;
  137. max_n_storage = indiv.max_n_storage;
  138. if(indiv.pft.landcover == CROPLAND && indiv.cropindiv) { // ecev3 - added indiv.cropindiv check
  139. nmass_ho = indiv.cropindiv->nmass_ho;
  140. nmass_agpool = indiv.cropindiv->nmass_agpool;
  141. nmass_dead_leaf = indiv.cropindiv->nmass_dead_leaf;
  142. }
  143. if(copy_dead_C) {
  144. litter_leaf = ppft.litter_leaf;
  145. litter_root = ppft.litter_root;
  146. litter_sap = ppft.litter_sap;
  147. litter_heart = ppft.litter_heart;
  148. nmass_litter_leaf = ppft.nmass_litter_leaf;
  149. nmass_litter_root = ppft.nmass_litter_root;
  150. nmass_litter_sap = ppft.nmass_litter_sap;
  151. nmass_litter_heart = ppft.nmass_litter_heart;
  152. // acflux_harvest and anflux_harvest only for output
  153. harvested_products_slow = ppft.harvested_products_slow;
  154. harvested_products_slow_nmass = ppft.harvested_products_slow_nmass;
  155. }
  156. }
  157. /// Copies C and N values from struct to individual, patchpft and patch (fluxes).
  158. void copy_to_indiv(Individual& indiv, bool copy_grsC = false, bool lc_change = false) {
  159. Patch& patch = indiv.vegetation.patch;
  160. Patchpft& ppft = patch.pft[indiv.pft.id];
  161. if(copy_grsC) {
  162. indiv.cropindiv->grs_cmass_leaf = cmass_leaf;
  163. indiv.cropindiv->grs_cmass_root = cmass_root;
  164. if(indiv.pft.landcover == CROPLAND) {
  165. indiv.cropindiv->grs_cmass_ho = cmass_ho;
  166. indiv.cropindiv->grs_cmass_agpool = cmass_agpool;
  167. indiv.cropindiv->grs_cmass_dead_leaf = cmass_dead_leaf;
  168. indiv.cropindiv->grs_cmass_stem = cmass_stem;
  169. }
  170. }
  171. else {
  172. indiv.cmass_leaf = cmass_leaf;
  173. indiv.cmass_root = cmass_root;
  174. indiv.cmass_sap = cmass_sap;
  175. indiv.cmass_heart = cmass_heart;
  176. indiv.cmass_debt = cmass_debt;
  177. if(indiv.pft.landcover == CROPLAND) {
  178. indiv.cropindiv->cmass_ho = cmass_ho;
  179. indiv.cropindiv->cmass_agpool = cmass_agpool;
  180. // indiv.cropindiv->grs_cmass_dead_leaf = cmass_dead_leaf; // We can't use grs_cmass here !
  181. // indiv.cropindiv->grs_cmass_stem = cmass_stem;
  182. }
  183. }
  184. indiv.nmass_leaf = nmass_leaf;
  185. indiv.nmass_root = nmass_root;
  186. indiv.nmass_sap = nmass_sap;
  187. indiv.nmass_heart = nmass_heart;
  188. indiv.nstore_longterm = nstore_longterm;
  189. indiv.nstore_labile = nstore_labile;
  190. if(indiv.pft.landcover == CROPLAND) {
  191. indiv.cropindiv->nmass_ho = nmass_ho;
  192. indiv.cropindiv->nmass_agpool = nmass_agpool;
  193. indiv.cropindiv->nmass_dead_leaf = nmass_dead_leaf;
  194. }
  195. ppft.litter_leaf = litter_leaf;
  196. ppft.litter_root = litter_root;
  197. ppft.litter_sap = litter_sap;
  198. ppft.litter_heart = litter_heart;
  199. ppft.nmass_litter_leaf = nmass_litter_leaf;
  200. ppft.nmass_litter_root = nmass_litter_root;
  201. ppft.nmass_litter_sap = nmass_litter_sap;
  202. ppft.nmass_litter_heart = nmass_litter_heart;
  203. if(!lc_change) {
  204. patch.fluxes.report_flux(Fluxes::HARVESTC, acflux_harvest); // Put into gridcell.acflux_landuse_change instead at land use change
  205. patch.fluxes.report_flux(Fluxes::HARVESTN, anflux_harvest); // Put into gridcell.anflux_landuse_change instead at land use change
  206. }
  207. patch.fluxes.report_flux(Fluxes::HARVCROPC, dcflux_harvest_crop);
  208. patch.fluxes.report_flux(Fluxes::HARVGRAZC, dcflux_harvest_pasture);
  209. patch.fluxes.report_flux(Fluxes::HARVWOODC, dcflux_harvest_wood);
  210. patch.fluxes.report_flux(Fluxes::DEFORPRODC, dcflux_product_wood);
  211. patch.fluxes.report_flux(Fluxes::PRODUCTN, dnflux_product);
  212. patch.fluxes.report_flux(Fluxes::HARVRESC, dcflux_harvest_res);
  213. patch.fluxes.report_flux(Fluxes::DEFORRESC, dcflux_harvest_wood_res);
  214. // indiv.report_flux(Fluxes::NPP, debt_excess);
  215. // indiv.report_flux(Fluxes::RA, -debt_excess);
  216. ppft.harvested_products_slow = harvested_products_slow;
  217. ppft.harvested_products_slow_nmass = harvested_products_slow_nmass;
  218. }
  219. };
  220. #endif // LPJ_GUESS_MANAGEMENT_H