verify_SUT_energy_balance_with_units: Confirm that an SUT-style data frame conserves energy.

View source: R/energy_balance.R

verify_SUT_energy_balance_with_unitsR Documentation

Confirm that an SUT-style data frame conserves energy.

Description

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".

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.

Value

.sutmats with additional columns.

Examples

library(tidyr)
verify_SUT_energy_balance_with_units(UKEnergy2000mats %>%
                                       tidyr::spread(key = matrix.name, value = matrix),
                                       tol = 1e-3)

MatthewHeun/Recca documentation built on Feb. 9, 2024, 6:18 p.m.