7. N leaching isn't multiplied by area

Leaching (out3, R/nitrogen_balance.R:249-253) is calculated per hectare but added to farm totals, and it uses the farm-total organic N. Gaseous loss (out4), on the next line, is multiplied by area_total.

Feed Area (ha) Current leaching (kg N) Fixed leaching (kg N)
Naturally occuring pasture - green fodder 109.05 2.6 3.1
Pennisetum purpureum - forage 1.80 2.6 0.1

The fix leaves the leaching coefficient 0.021 * (P - 3.9) unchanged, because I couldn't verify the published form (see the fix log).

--- a/R/nitrogen_balance.R	2026-09-29 10:31:58
+++ b/R/nitrogen_balance.R	2026-09-29 10:31:58
@@ -246,9 +246,9 @@
 
   n_balance_all <- n_balance_all %>%
     dplyr::mutate(
-      out3a = (n_mineralized_kg_ha_year + fertilizer_rate + in2) * (0.021 * (annual_precipitation - 3.9) / 100),
-      out3b = (n_mineralized_kg_ha_year + fertilizer_rate + in2) * (0.014 * annual_precipitation + 0.71) / 100,
-      out3c = (n_mineralized_kg_ha_year + fertilizer_rate + in2) * (0.0071 * annual_precipitation + 5.4) / 100,
+      out3a = (n_mineralized_kg_ha_year + fertilizer_rate + organic_n_kg_per_ha) * (0.021 * (annual_precipitation - 3.9) / 100) * area_total,
+      out3b = (n_mineralized_kg_ha_year + fertilizer_rate + organic_n_kg_per_ha) * (0.014 * annual_precipitation + 0.71) / 100 * area_total,
+      out3c = (n_mineralized_kg_ha_year + fertilizer_rate + organic_n_kg_per_ha) * (0.0071 * annual_precipitation + 5.4) / 100 * area_total,
       out3 = ifelse(soil_clay < 35, out3a, ifelse(soil_clay >= 55, out3c, out3b)),
       out4 = (n_mineralized_kg_ha_year + fertilizer_rate + organic_n_kg_per_ha) *
         (-9.4 + 0.13 * soil_clay + 0.01 * annual_precipitation) / 100 * area_total,
Reproduce this Open in Colab (R runtime; section 7)
Rscript reproduce_critical_issues.R 7 using reproduce_critical_issues.R (installs what it needs into its own library and cleaned @ 800d53a). Add CLEANED_FIXES=proposed_fixes.R with proposed_fixes.R for the fixed column.
Test: test-critical-07-n-leaching-area.R · Proposed change: F07.diff · Open an issue in CIAT/cleaned

Comments

Comments are GitHub Discussions on peetmate/cleaned-review; sign in with GitHub to post.