private void Onremove_crop_biomass(RemoveCropBiomassType RemovalData) { // NOTE: It is responsability of the calling module to check that the amount of // herbage in each plant part is correct // No checking if the removing amount passed in are too much here // ATTENTION: The amounts passed should be in g/m^2 double fractionToRemove = 0.0; // get digestibility of DM being removed digestDefoliated = calcDigestibility(); for (int i = 0; i < RemovalData.dm.Length; i++) // for each pool (green or dead) { string plantPool = RemovalData.dm[i].pool; for (int j = 0; j < RemovalData.dm[i].dlt.Length; j++) // for each part (leaf or stem) { string plantPart = RemovalData.dm[i].part[j]; double amountToRemove = RemovalData.dm[i].dlt[j] * 10.0; // convert to kgDM/ha if (plantPool.ToLower() == "green" && plantPart.ToLower() == "leaf") { if (LeafGreenWt - amountToRemove > 0.0) { fractionToRemove = MathUtilities.Divide(amountToRemove, LeafGreenWt, 0.0); RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } else if (plantPool.ToLower() == "green" && plantPart.ToLower() == "stem") { if (StemGreenWt - amountToRemove > 0.0) { fractionToRemove = MathUtilities.Divide(amountToRemove, StemGreenWt, 0.0); RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } else if (plantPool.ToLower() == "dead" && plantPart.ToLower() == "leaf") { if (LeafDeadWt - amountToRemove > 0.0) { fractionToRemove = MathUtilities.Divide(amountToRemove, LeafDeadWt, 0.0); RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } else if (plantPool.ToLower() == "dead" && plantPart.ToLower() == "stem") { if (StemDeadWt - amountToRemove > 0.0) { fractionToRemove = MathUtilities.Divide(amountToRemove, StemDeadWt, 0.0); RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } } } RefreshAfterRemove(); }
private void Onremove_crop_biomass(RemoveCropBiomassType RemovalData) { // NOTE: It is responsability of the calling module to check that the amount of // herbage in each plant part is correct // No checking if the removing amount passed in are too much here // ATTENTION: The amounts passed should be in g/m^2 double fractionToRemove = 0.0; for (int i = 0; i < RemovalData.dm.Length; i++) // for each pool (green or dead) { string plantPool = RemovalData.dm[i].pool; for (int j = 0; j < RemovalData.dm[i].dlt.Length; j++) // for each part (leaf or stem) { string plantPart = RemovalData.dm[i].part[j]; double amountToRemove = RemovalData.dm[i].dlt[j] * 10.0; // convert to kgDM/ha if (plantPool.ToLower() == "green" && plantPart.ToLower() == "leaf") { for (int s = 0; s < numSpecies; s++) //for each mySpecies { if (LeafLiveWt - amountToRemove > 0.0) { fractionToRemove = amountToRemove / LeafLiveWt; mySward[s].RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } } else if (plantPool.ToLower() == "green" && plantPart.ToLower() == "stem") { for (int s = 0; s < numSpecies; s++) //for each mySpecies { if (StemLiveWt - amountToRemove > 0.0) { fractionToRemove = amountToRemove / StemLiveWt; mySward[s].RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } } else if (plantPool.ToLower() == "dead" && plantPart.ToLower() == "leaf") { for (int s = 0; s < numSpecies; s++) //for each mySpecies { if (LeafDeadWt - amountToRemove > 0.0) { fractionToRemove = amountToRemove / LeafDeadWt; mySward[s].RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } } else if (plantPool.ToLower() == "dead" && plantPart.ToLower() == "stem") { for (int s = 0; s < numSpecies; s++) //for each mySpecies { if (StemDeadWt - amountToRemove > 0.0) { fractionToRemove = amountToRemove / StemDeadWt; mySward[s].RemoveFractionDM(fractionToRemove, plantPool, plantPart); } } } } } // update digestibility and fractionToHarvest for (int s = 0; s < numSpecies; s++) mySward[s].RefreshAfterRemove(); }
private void Onremove_crop_biomass(RemoveCropBiomassType rm) { //Note: It is resposibility of the calling module to check the // amount of herbage in each pools of AbovegroundBiomassWt and set the // the correct amount in 'rm'. // No checking if the removing amount passed in are too much here const double gm2ha = 10; // constant for conversion of g/m^2 to kg/ha, // rm.dm.dlt should be in g/m^2 double dm_leaf_green = LeafLiveWt; double dm_stem_green = StemLiveWt; double dm_leaf_dead = LeafDeadWt; double dm_stem_dead = StemDeadWt; for (int s = 0; s < numSpecies; s++) // for accumulating the total DM & N removal of species from verious pools { SP[s].dmdefoliated = 0.0; SP[s].Ndefoliated = 0.0; } for (int i = 0; i < rm.dm.Length; i++) //for each pool { for (int j = 0; j < rm.dm[i].dlt.Length; j++) //for each part { if (rm.dm[i].pool == "green" && rm.dm[i].part[j] == "leaf") { for (int s = 0; s < numSpecies; s++) //for each species { if (dm_leaf_green != 0) //resposibility of other modules to check the amount { double rm_leaf = gm2ha * rm.dm[i].dlt[j] * SP[s].dmleaf_green / dm_leaf_green; double rm_leaf1 = rm_leaf * SP[s].dmleaf1 / SP[s].dmleaf_green; double rm_leaf2 = rm_leaf * SP[s].dmleaf2 / SP[s].dmleaf_green; double rm_leaf3 = rm_leaf * SP[s].dmleaf3 / SP[s].dmleaf_green; SP[s].dmleaf1 -= rm_leaf1; SP[s].dmleaf2 -= rm_leaf2; SP[s].dmleaf3 -= rm_leaf3; SP[s].dmdefoliated += rm_leaf1 + rm_leaf2 + rm_leaf3; SP[s].Nleaf1 -= SP[s].Ncleaf1 * rm_leaf1; SP[s].Nleaf2 -= SP[s].Ncleaf2 * rm_leaf2; SP[s].Nleaf3 -= SP[s].Ncleaf3 * rm_leaf3; SP[s].Ndefoliated += SP[s].Ncleaf1 * rm_leaf1 + SP[s].Ncleaf2 * rm_leaf2 + SP[s].Ncleaf3 * rm_leaf3; } } } else if (rm.dm[i].pool == "green" && rm.dm[i].part[j] == "stem") { for (int s = 0; s < numSpecies; s++) { if (dm_stem_green != 0) //resposibility of other modules to check the amount { double rm_stem = gm2ha * rm.dm[i].dlt[j] * SP[s].dmstem_green / dm_stem_green; double rm_stem1 = rm_stem * SP[s].dmstem1 / SP[s].dmstem_green; double rm_stem2 = rm_stem * SP[s].dmstem2 / SP[s].dmstem_green; double rm_stem3 = rm_stem * SP[s].dmstem3 / SP[s].dmstem_green; SP[s].dmstem1 -= rm_stem1; SP[s].dmstem2 -= rm_stem2; SP[s].dmstem3 -= rm_stem3; SP[s].dmdefoliated += rm_stem1 + rm_stem2 + rm_stem3; SP[s].Nstem1 -= SP[s].Ncstem1 * rm_stem1; SP[s].Nstem2 -= SP[s].Ncstem2 * rm_stem2; SP[s].Nstem3 -= SP[s].Ncstem3 * rm_stem3; SP[s].Ndefoliated += SP[s].Ncstem1 * rm_stem1 + SP[s].Ncstem2 * rm_stem2 + SP[s].Ncstem3 * rm_stem3; } } } else if (rm.dm[i].pool == "dead" && rm.dm[i].part[j] == "leaf") { for (int s = 0; s < numSpecies; s++) { if (dm_leaf_dead != 0) //resposibility of other modules to check the amount { double rm_leaf4 = gm2ha * rm.dm[i].dlt[j] * SP[s].dmleaf4 / dm_leaf_dead; SP[s].dmleaf4 -= rm_leaf4; SP[s].dmdefoliated += rm_leaf4; SP[s].Ndefoliated += SP[s].Ncleaf4 * rm_leaf4; SP[s].Nleaf4 -= SP[s].Ncleaf4 * rm_leaf4; } } } else if (rm.dm[i].pool == "dead" && rm.dm[i].part[j] == "stem") { for (int s = 0; s < numSpecies; s++) { if (dm_stem_dead != 0) //resposibility of other modules to check the amount { double rm_stem4 = gm2ha * rm.dm[i].dlt[j] * SP[s].dmstem4 / dm_stem_dead; SP[s].dmstem4 -= rm_stem4; SP[s].dmdefoliated += rm_stem4; SP[s].Nstem4 -= SP[s].Ncstem4 * rm_stem4; SP[s].Ndefoliated += SP[s].Ncstem4 * rm_stem4; } } } } } p_harvestDM = 0; p_harvestN = 0; for (int s = 0; s < numSpecies; s++) { p_harvestDM += SP[s].dmdefoliated; p_harvestN += SP[s].Ndefoliated; SP[s].updateAggregated(); } //In this routine of no selection among species, the removed tissue from different species //will be in proportion with exisisting mass of each species. //The digetibility below is an approximation (= that of pasture swards). //It is more reasonable to calculate it organ-by-organ for each species, then put them together. p_harvestDigest = HerbageDigestibility; }