Skip to contents

Top-level driver that traces the nitrogen, carbon and volatile solids in realised feed intake (the redistribute_feed() result) through livestock excretion, manure management and application to soil by land use and crop, plus the management-loss side-streams. It chains estimate_n_excretion(), split_manure_management(), apply_management_losses() and allocate_manure_to_land(); at the "subnational" resolution it additionally spills each cell's un-placeable surplus to neighbouring cells with allocate_manure_transport() before local disposal. Every method choice is recorded in a method_* provenance column and the nitrogen balance (excreted = applied + management losses) is conserved.

Usage

build_livestock_nutrient_flows(
  intake,
  resolution = "national",
  methods = list(),
  gridded = NULL
)

Arguments

intake

A tibble of realised feed intake (the redistribute_feed() result); see estimate_n_excretion() for the required columns. At "subnational" resolution sub_territory is the "lon_lat" cell id.

resolution

One of "global", "national" (default) or "subnational". Transport between cells runs only at "subnational".

methods

A named list of per-stage option lists, any of excretion, split, losses, allocation and transport, each forwarded to the matching pipeline function's options.

gridded

The land-surface layer (crops and optional grass tibbles) passed to allocate_manure_to_land(); required for the default "potential_uptake" cap. NULL is treated as an empty list. The crop column of crops is a code: as.character(item_prod_code) from items_prod_full. That is the one contract, honoured by both consumers of this function's applied stream (the carbon balance and the nitrogen balance); a crop name is still resolved by the nitrogen path but is deprecated and warns.

Value

A named list with applied (manure applied per land_use x crop (x cell) with manure_type ("Excreta"/"Solid"/ "Liquid") and all method_* provenance columns), losses (management-loss side-streams per polity) and excretion (the per-category excretion totals).

Examples

intake <- tibble::tribble(
  ~year, ~territory, ~sub_territory, ~livestock_category,
  ~item_cbs_code, ~feed_quality, ~intake_dm_t,
  2020L, "203", NA, "Cattle_milk", 2513L, "high_quality", 200,
  2020L, "203", NA, "Cattle_milk", NA, "grass", 600
)
gridded <- list(
  crops = tibble::tribble(
    ~year, ~territory, ~sub_territory, ~crop, ~manure_n_receptivity, ~crop_n_cap,
    2020L, "203", NA, "44", 6, 200,
    2020L, "203", NA, "15", 4, 200
  )
)
build_livestock_nutrient_flows(intake, gridded = gridded)
#> $applied
#> # A tibble: 5 × 20
#>    year territory sub_territory land_use  crop  source_stream manure_type
#>   <int> <chr>     <lgl>         <chr>     <chr> <chr>         <chr>      
#> 1  2020 203       NA            Cropland  44    collected     Solid      
#> 2  2020 203       NA            Cropland  44    collected     Liquid     
#> 3  2020 203       NA            Cropland  15    collected     Solid      
#> 4  2020 203       NA            Cropland  15    collected     Liquid     
#> 5  2020 203       NA            Grassland NA    grazing       Excreta    
#> # ℹ 13 more variables: applied_n <dbl>, applied_c <dbl>, applied_vs <dbl>,
#> #   over_cap <lgl>, method_allocation <chr>, method_cap <chr>,
#> #   disposal_method <chr>, resolution <chr>, method_n_excretion <chr>,
#> #   method_vs <chr>, method_mms <chr>, method_losses <chr>,
#> #   method_transport <chr>
#> 
#> $losses
#> # A tibble: 1 × 10
#>    year territory sub_territory n_volatilized n_leached n2o_direct_n   n2_n
#>   <int> <chr>     <lgl>                 <dbl>     <dbl>        <dbl>  <dbl>
#> 1  2020 203       NA                     2.08    0.0755       0.0289 0.0868
#> # ℹ 3 more variables: n2o_indirect_n <dbl>, c_lost <dbl>, vs_destroyed <dbl>
#> 
#> $excretion
#> # A tibble: 1 × 10
#>    year territory sub_territory livestock_category n_intake n_excretion
#>   <int> <chr>     <lgl>         <chr>                 <dbl>       <dbl>
#> 1  2020 203       NA            Cattle_milk            15.7        12.6
#> # ℹ 4 more variables: c_excretion <dbl>, vs_excretion <dbl>,
#> #   method_n_excretion <chr>, method_vs <chr>
#>