Skip to contents

If energy is in balance for every row, .sutmats is returned with two additional columns, and execution returns to the caller. If energy balance is not observed for one or more rows, a warning is emitted, and columns named SUT_prod_energy_blance and SUT_ind_energy_blance are added to .sutmats. FALSE indicates energy is not in balance.

Usage

verify_SUT_energy_balance_with_units(
  .sutmats = NULL,
  R = "R",
  U = "U",
  V = "V",
  Y = "Y",
  S_units = "S_units",
  tol = 1e-06,
  SUT_prod_energy_balance = ".SUT_prod_energy_balance",
  SUT_ind_energy_balance = ".SUT_ind_energy_balance"
)

Arguments

.sutmats

an SUT-style data frame containing columns R (optionally), U, V, Y, and S_units.

R

resource (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 .sutmatsthat contains same. Default is "V".

Y

final demand (Y) matrix or name of the column in .sutmats that contains same. Default is "Y".

S_units

S_units matrix or name of the column in .sutmats that contains same. Default is "S_units".

tol

the maximum amount by which energy can be out of balance. Default is 1e-6.

SUT_prod_energy_balance

the name for booleans telling if product energy is in balance. Default is ".SUT_prod_energy_balance".

SUT_ind_energy_balance

the name for booleans telling if product energy is in balance. Default is ".SUT_inds_energy_balance".

Value

.sutmats with additional columns.

Details

This function should be called for its side-effect of testing whether energy is in balance in .sutmats.

Both product and industry energy balance are verified. Units (as supplied by the S_units matrix) are respected.

Examples

library(tidyr)
verify_SUT_energy_balance_with_units(UKEnergy2000mats %>%
                                       tidyr::spread(key = matrix.name, value = matrix),
                                       tol = 1e-3)
#> # A tibble: 4 × 14
#>   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           Services   <dbl [2 × 2]> <dbl[…]> <dbl[…]> <dbl[…]>
#> 3 GBR      2000 E           Useful     <dbl [2 × 2]> <dbl[…]> <dbl[…]> <dbl[…]>
#> 4 GBR      2000 X           Services   <dbl [2 × 2]> <dbl[…]> <dbl[…]> <dbl[…]>
#> # ℹ 6 more variables: U_feed <list>, V <list>, Y <list>, r_EIOU <list>,
#> #   .SUT_prod_energy_balance <lgl>, .SUT_ind_energy_balance <lgl>