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

View source: R/energy_balance.R

verify_SUT_energy_balanceR Documentation

Confirm that an SUT-style data frame conserves energy.

Description

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, and Y 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 .sutmatsthat 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.

Value

a list or data frame saying whether .sutmats are 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)

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