Confirm that an SUT-style data frame conserves energy.
Source:R/energy_balance.R
verify_SUT_energy_balance.Rd
Energy balances are confirmed by Product (within tol
) for every row in .sutmats
.
Usage
verify_SUT_energy_balance(
.sutmats = NULL,
R = "R",
U = "U",
V = "V",
Y = "Y",
tol = 1e-06,
SUT_energy_balance = ".SUT_energy_balance"
)
Arguments
- .sutmats
an SUT-style data frame with columns of matrices, including
U
,V
, andY
columns.- R
resources (
R
) matrix or name of the column in.sutmats
that contains same. Default is "R".- U
use (
U
) matrix or name of the column in.sutmats
that contains same. Default is "U".- V
make (
V
) matrix or name of the column in.sutmats
that contains same. Default is "V".- Y
final demand (
Y
) matrix or name of the column in.sutmats
that contains same. Default is "Y".- tol
the maximum amount by which Supply and Consumption can be out of balance. Default is
1e-6
.- SUT_energy_balance
the name for booleans telling if energy is in balance. Default is ".SUT_energy_balance".
Details
If energy is in balance for every row, .sutmats
is returned with an additional column, and
execution returns to the caller.
If energy balance is not observed for one or more of the rows,
a warning is emitted, and
the additional column (SUT_energy_blance
)
indicates where the problem occurred, with FALSE
showing where energy is not in balance.
Examples
library(dplyr)
library(tidyr)
verify_SUT_energy_balance(UKEnergy2000mats %>%
dplyr::filter(Last.stage %in% c("Final", "Useful")) %>%
tidyr::spread(key = matrix.name, value = matrix),
tol = 1e-4)
#> # A tibble: 2 × 13
#> Country Year Energy.type Last.stage R S_units U U_EIOU
#> <chr> <dbl> <chr> <chr> <list> <list> <list> <list>
#> 1 GBR 2000 E Final <dbl [2 × 2]> <dbl[…]> <dbl[…]> <dbl[…]>
#> 2 GBR 2000 E Useful <dbl [2 × 2]> <dbl[…]> <dbl[…]> <dbl[…]>
#> # ℹ 5 more variables: U_feed <list>, V <list>, Y <list>, r_EIOU <list>,
#> # .SUT_energy_balance <lgl>