From b58cf62da9d7c9ecbe1841e3fd04d5c98757565d Mon Sep 17 00:00:00 2001 From: Taylor Brown <60201147+taylorbrown75@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:40:45 -0700 Subject: [PATCH] Add cash flow net heat output in MMBtu to IPH single owner and cashloan cmods. --- ssc/cmod_cashloan_heat.cpp | 9 ++++++++- ssc/cmod_singleowner_heat.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ssc/cmod_cashloan_heat.cpp b/ssc/cmod_cashloan_heat.cpp index 30f613980..2414ee124 100644 --- a/ssc/cmod_cashloan_heat.cpp +++ b/ssc/cmod_cashloan_heat.cpp @@ -102,6 +102,7 @@ static var_info vtab_cashloan_heat[] = { { SSC_OUTPUT, SSC_ARRAY, "cf_energy_net", "Thermal energy", "kWht", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, + { SSC_OUTPUT, SSC_ARRAY, "cf_energy_net_heat_btu", "Thermal energy", "MMBtu", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, { SSC_OUTPUT, SSC_ARRAY, "cf_energy_sales", "Electricity generation", "kWh", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, { SSC_OUTPUT, SSC_ARRAY, "cf_energy_purchases", "Electricity from grid to system", "kWh", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, { SSC_OUTPUT, SSC_ARRAY, "cf_energy_without_battery","Electricity generated without the battery or curtailment", "kWh", "", "Cash Flow Electricity", "", "LENGTH_EQUAL=cf_length", "" }, @@ -1563,7 +1564,13 @@ class cm_cashloan_heat : public compute_module save_cf(CF_itc_sta, nyears, "cf_itc_sta"); save_cf(CF_itc_total, nyears, "cf_itc_total"); - + // Save cf_energy_net_heat_btu (converted from cf_energy_net) + const double MMBTU_TO_KWh = 293.07107; // 1 MMBtu = 293.07107 kWh + std::vector cf_energy_net_vec = as_vector_double("cf_energy_net"); //[kWht] + int cf_energy_net_size = cf_energy_net_vec.size(); + ssc_number_t* cf_energy_net_heat_btu_arr = allocate("cf_energy_net_heat_btu", cf_energy_net_size); + for (int i = 0; i <= cf_energy_net_size; i++) + cf_energy_net_heat_btu_arr[i] = (ssc_number_t)(cf_energy_net_vec[i] / MMBTU_TO_KWh); //[MMBtu] } /* These functions can be placed in common financial library with matrix and constants passed? */ diff --git a/ssc/cmod_singleowner_heat.cpp b/ssc/cmod_singleowner_heat.cpp index e73f63d17..a739e1639 100644 --- a/ssc/cmod_singleowner_heat.cpp +++ b/ssc/cmod_singleowner_heat.cpp @@ -529,6 +529,7 @@ static var_info _cm_vtab_singleowner_heat[] = { /* Partial Income Statement: Project */ { SSC_OUTPUT, SSC_ARRAY, "cf_energy_net", "Thermal energy", "kWht", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, + { SSC_OUTPUT, SSC_ARRAY, "cf_energy_net_heat_btu", "Thermal energy", "MMBtu", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, { SSC_OUTPUT, SSC_ARRAY, "cf_energy_sales", "Thermal energy to grid", "kWht", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, { SSC_OUTPUT, SSC_ARRAY, "cf_energy_purchases", "Thermal energy from grid", "kWht", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" }, { SSC_OUTPUT, SSC_ARRAY, "cf_energy_without_battery", "Thermal energy generated without storage", "kWht", "", "Cash Flow Electricity", "", "LENGTH_EQUAL=cf_length", "" }, @@ -3988,6 +3989,13 @@ class cm_singleowner_heat : public compute_module save_cf(CF_itc_sta, nyears, "cf_itc_sta"); save_cf(CF_itc_total, nyears, "cf_itc_total"); + + // Save cf_energy_net_heat_btu (converted from cf_energy_net) + std::vector cf_energy_net_vec = as_vector_double("cf_energy_net"); //[kWht] + int cf_energy_net_size = cf_energy_net_vec.size(); + ssc_number_t* cf_energy_net_heat_btu_arr = allocate("cf_energy_net_heat_btu", cf_energy_net_size); + for (int i = 0; i <= cf_energy_net_size; i++) + cf_energy_net_heat_btu_arr[i] = (ssc_number_t)(cf_energy_net_vec[i] / MMBTU_TO_KWh); //[MMBtu] }