extend_to_exergy: Extend an ECC in PSUT format from energy to exergy

View source: R/energy_to_exergy.R

extend_to_exergyR Documentation

Extend an ECC in PSUT format from energy to exergy

Description

An energy conversion chain can be represented in energy or exergy quantifications of energy. This function moves from an energy quantification to an exergy quantification, given the matrices for the energy quantification and phi (exergy-to-energy ratio) vectors.

Usage

extend_to_exergy(
  .sutmats = NULL,
  clean_up_df = TRUE,
  R = Recca::psut_cols$R,
  U = Recca::psut_cols$U,
  U_feed = Recca::psut_cols$U_feed,
  U_eiou = Recca::psut_cols$U_eiou,
  r_eiou = Recca::psut_cols$r_eiou,
  V = Recca::psut_cols$V,
  Y = Recca::psut_cols$Y,
  phi = Recca::psut_cols$phi,
  .exergy_suffix = "_exergy",
  mat_piece = "all",
  phi_piece = "all",
  notation = RCLabels::bracket_notation,
  prepositions = RCLabels::prepositions_list,
  R_name = Recca::psut_cols$R,
  U_name = Recca::psut_cols$U,
  U_feed_name = Recca::psut_cols$U_feed,
  U_eiou_name = Recca::psut_cols$U_eiou,
  r_eiou_name = Recca::psut_cols$r_eiou,
  V_name = Recca::psut_cols$V,
  Y_name = Recca::psut_cols$Y,
  phi_name = Recca::psut_cols$phi,
  energy_type = Recca::psut_cols$energy_type,
  S_units = Recca::psut_cols$S_units,
  energy = Recca::energy_types$e,
  exergy = Recca::energy_types$x
)

Arguments

.sutmats

An optional data frame of energy conversion chain matrices.

clean_up_df

When .sutmats is a data frame, tells whether to tidyr::pivot_longer() the result, remove no-longer-needed input column phi, and fill the energy_type column with "X" for the exergy versions of the ECC matrices. Default is TRUE.

R, U, U_feed, U_eiou, r_eiou, V, Y, phi

Names of columns in .sutmats or single matrices. See Recca::psut_cols.

.exergy_suffix

The string suffix to be appended to exergy versions of ECC matrices.

mat_piece

The piece of matrix row and column names for R, U, U_feed, U_EIOU, V, and Y matrices which are to be matched against names in the phi vector. Default is "all", meaning that entire names are to be matched.

phi_piece

The piece of names in the phi vector against which row and column names for matrices R, U, U_feed, U_EIOU, V, and Y matrices is to be matched. Default is "all", meaning that entire names are to be matched.

notation

The nomenclature for the row and column labels. Default is RCLabels::bracket_notation.

prepositions

The prepositions to be used row and column notation. Default is RCLabels::prepositions_list.

R_name, U_name, U_feed_name, U_eiou_name, r_eiou_name, V_name, Y_name, phi_name, energy_type, S_units

Names of output matrices

energy, exergy

See Recca::energy_types.

Details

Internally, this function uses matsindf::apply(), so the ECC matrices can be provided as individual matrices, in a named list, or or in a data frame (in which case the arguments should given the string names of columns in the .sutmats data frame, the default).

The vector phi is considered to be a store of values to be applied to each type of energy carrier. To determine which entry in the phi vector is matched against which energy carrier, mat_piece and phi_piece are consulted. mat_piece and phi_piece can be any of "all", "pref", "suff", "noun", or one of many prepositions given in suffixes

Value

A data frame or list of matrices that represents the exergy version of the ECC.

Examples

sutmats <- UKEnergy2000mats %>%
  # Put in wide-by-matrix format.
  tidyr::spread(key = matrix.name, value = matrix) %>%
  # Eliminate services ECCs.
  dplyr::filter(Last.stage %in% c("Final", "Useful")) %>%
  dplyr::mutate(
    phi = RCLabels::make_list(Recca::phi_vec, n = nrow(.), lenx = 1)
  )
extend_to_exergy(sutmats)

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