View source: R/final_to_useful.R
extend_to_useful | R Documentation |
This function uses a matrix method to move from final energy/exergy to useful energy/exergy as the last stage of an energy conversion chain.
extend_to_useful(
.sutdata = NULL,
tol = 0.1,
R = IEATools::psut_cols$R,
U_feed = IEATools::psut_cols$U_feed,
U_eiou = IEATools::psut_cols$U_eiou,
U = IEATools::psut_cols$U,
r_eiou = IEATools::psut_cols$r_eiou,
V = IEATools::psut_cols$V,
Y = IEATools::psut_cols$Y,
C_eiou = IEATools::template_cols$C_eiou,
C_Y = IEATools::template_cols$C_Y,
eta_fu = IEATools::template_cols$eta_fu,
phi_u = IEATools::template_cols$phi_u,
last_stage = IEATools::iea_cols$last_stage,
final = IEATools::last_stages$final,
useful = IEATools::last_stages$useful,
industry_type = IEATools::row_col_types$industry,
product_type = IEATools::row_col_types$product,
interface_ind = IEATools::interface_industries,
losses = IEATools::tfc_compare_flows$losses,
stat_diffs = IEATools::tfc_compare_flows$statistical_differences,
arrow_note = RCLabels::arrow_notation,
from_note = RCLabels::from_notation,
.add_to_U_f = ".add_to_U_f",
.add_to_U_eiou = ".add_to_U_eiou",
.add_to_V_f = ".add_to_V_f",
.add_to_dest = ".repl_dest",
details_fu = "details_fu",
.err = ".err",
.e_bal_ok = ".e_bal_ok",
.sep = "_",
U_feed_name = IEATools::psut_cols$U_feed,
U_eiou_name = IEATools::psut_cols$U_eiou,
U_name = IEATools::psut_cols$U,
r_eiou_name = IEATools::psut_cols$r_eiou,
V_name = IEATools::psut_cols$V,
Y_name = IEATools::psut_cols$Y,
Y_fu_details_name = IEATools::psut_cols$Y_fu_details,
U_eiou_fu_details_name = IEATools::psut_cols$U_eiou_fu_details
)
.sutdata |
A wide-by-matrices data frame of PSUT matrices that represent an energy conversion chain.
Each row of |
tol |
The allowable error in energy balances for the outgoing matrices (last stage useful).
Default is |
R , U_eiou , U_feed , U , r_eiou , V , Y |
See |
C_eiou , C_Y , eta_fu , phi_u |
See |
last_stage |
See |
final , useful |
See |
industry_type , product_type |
See |
interface_ind |
See |
losses |
See |
stat_diffs |
See |
arrow_note , from_note |
The row and column notation in the |
.add_to_U_f |
An internal matrix name for the a matrix to be added to the U_feed_f matrix to form the useful form of the U_feed matrix. Default is ".add_to_U_f". |
.add_to_U_eiou |
An internal matrix name for the a matrix to be added to the U_eiou_f matrix to form the useful form of the U_eiou matrix. Default is ".add_to_U_eiou". |
.add_to_V_f |
An internal matrix name for a matrix to add to the Y_f matrix. Default is ".add_to_V_f". |
.add_to_dest |
An internal matrix name for a matrix that replaces a previous energy destination. Default is ".repl_dest". |
details_fu |
An internal matrix name for a matrix that contains detailed information about the final-to-useful extension, namely, final energy product, destination sector, final-to-useful machine, and useful energy product. |
.err |
An internal matrix name for calculating energy balance errors. Default is ".err". |
.e_bal_ok |
An internal column name for assessing whether energy balance is within acceptable tolerances set by the |
.sep |
A separator between matrix names and |
U_eiou_name , U_feed_name , U_name , r_eiou_name , V_name , Y_name , Y_fu_details_name , U_eiou_fu_details_name |
See |
.sutdata
or individual matrices are always assumed to have final energy as its last stage.
Internally, this function uses matsindf::matsindf_apply()
to perform its calculations.
If .sutdata
is NULL
, and R
, U_eiou
, U_feed
, U
, r_eiou
, V
, and Y
are individual matrices,
the output is a named list of matrices containing new values for
U_eiou, U_feed, U, r_eiou, V, and Y matrices,
named with .sep
plus useful
appended to the variable names.
If .sutdata
is a named list of matrices,
output is a list of matrices with names appended to include .sep
and useful
,
where appropriate.
Note that output matrices are appended to the original list supplied to .sutdata
.
If .sutdata
is a data frame, arguments
R
, U_feed
, U_eiou
, U
, r_eiou
, V
, Y
, C_eiou
, C_Y
, eta_fu
, and phi_u
should all be strings (as the default)
identifying which columns in .sutdata
should be used for each matrix.
Output is a data frame with additional columns with names
appended with paste0(.sep, useful)
.
If final and useful versions of matrices are
desired to be stacked (rbind
ed),
call stack_final_useful_df()
subsequent to calling
extend_to_useful()
.
An energy balance check is performed on the useful matrices.
If the energy balance check fails, a warning is emitted and
additional diagnostic information will appear in the output: .err
and .e_bal_ok
.
If .sutdata
is a data frame with no rows or a list of length 0
,
NULL
is returned.
Output depends on input, roughly according to
conventions in matsindf::apply()
.
If .sutdata
is NULL
and individual matrices are supplied in
U_eiou
, U_feed
, U
, r_eiou
, V
, and Y
arguments,
output is a named list of individual matrices with .sep
and useful
appended.
If .sutdata
is a named list of individual matrices,
the output is a list of matrices with .sep
and final
or .sep
and useful
appended
to the names.
If .sutdata
is a data frame, output will be a data frame of matrices
with column names with with .sep
and final
or .sep
and useful
appended
to the names (when gather = FALSE
).
If .sutdata
is a data frame, output will be a data frame of matrices
with a last.stage
column containing final
or useful
and
columns named for matrices (when gather = TRUE
, the default).
C_data <- load_fu_allocation_data() %>%
form_C_mats()
eta_fu_data <- load_eta_fu_data() %>%
form_eta_fu_phi_u_vecs()
m_cols <- eta_fu_data %>%
IEATools::meta_cols(return_names = TRUE,
years_to_keep = IEATools::iea_cols$year,
not_meta = c(IEATools::template_cols$eta_fu,
IEATools::template_cols$phi_u))
psut_mats <- load_tidy_iea_df() %>%
specify_all() %>%
prep_psut()
extended_to_useful <- psut_mats |>
dplyr::full_join(C_data, by = m_cols) %>%
dplyr::full_join(eta_fu_data, by = m_cols) |>
extend_to_useful()
extended_to_useful %>%
head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.