Skip to content

Commit

Permalink
Fix load assignment in thermal rate compute module and cashloan_heat …
Browse files Browse the repository at this point in the history
…ready for initial testing
  • Loading branch information
sjanzou committed Nov 4, 2024
1 parent 5b7a910 commit 3bffdaa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
31 changes: 24 additions & 7 deletions ssc/cmod_cashloan_heat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static var_info vtab_cashloan_heat[] = {
{ SSC_OUTPUT, SSC_NUMBER, "total_cost", "Total installed cost", "$", "", "Financial Metrics", "*", "", "" },


{ SSC_OUTPUT, SSC_ARRAY, "cf_energy_net", "Electricity net generation", "kWh", "", "Cash Flow Electricity", "*", "LENGTH_EQUAL=cf_length", "" },
{ SSC_OUTPUT, SSC_ARRAY, "cf_energy_net", "Thermal energy", "kWht", "", "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", "" },
Expand All @@ -125,6 +125,8 @@ static var_info vtab_cashloan_heat[] = {
{ SSC_OUTPUT, SSC_ARRAY, "cf_om_opt_fuel_1_expense", "Feedstock biomass expense", "$", "", "Cash Flow", "*", "LENGTH_EQUAL=cf_length", "" },
{ SSC_OUTPUT, SSC_ARRAY, "cf_om_opt_fuel_2_expense", "Feedstock coal expense", "$", "", "Cash Flow", "*", "LENGTH_EQUAL=cf_length", "" },

{ SSC_OUTPUT, SSC_ARRAY, "cf_om_elec_price_for_heat_techs", "Electricity expense in heat models", "$", "", "Cash Flow Expenses", "*", "LENGTH_EQUAL=cf_length", "" },


{ SSC_OUTPUT, SSC_ARRAY, "cf_property_tax_assessed_value","Property tax net assessed value", "$", "", "Cash Flow", "*", "LENGTH_EQUAL=cf_length", "" },
{ SSC_OUTPUT, SSC_ARRAY, "cf_property_tax_expense", "Property tax expense", "$", "", "Cash Flow", "*", "LENGTH_EQUAL=cf_length", "" },
Expand Down Expand Up @@ -195,7 +197,7 @@ var_info_invalid };
extern var_info
vtab_standard_financial[],
vtab_standard_loan[],
vtab_oandm[],
vtab_oandm_heat[],
vtab_depreciation[],
vtab_battery_replacement_cost[],
vtab_fuelcell_replacement_cost[],
Expand Down Expand Up @@ -301,6 +303,9 @@ enum {
CF_om_production2_expense,
CF_om_capacity2_expense,
CF_om_fuel_expense,
CF_om_elec_price_for_heat_techs,


CF_energy_charged_grid,
CF_energy_charged_pv,
CF_energy_discharged,
Expand Down Expand Up @@ -358,7 +363,7 @@ class cm_cashloan_heat : public compute_module
{
add_var_info( vtab_standard_financial );
add_var_info( vtab_standard_loan );
add_var_info( vtab_oandm );
add_var_info( vtab_oandm_heat );
add_var_info( vtab_depreciation );
add_var_info( vtab_tax_credits );
add_var_info( vtab_payment_incentives );
Expand Down Expand Up @@ -581,10 +586,16 @@ class cm_cashloan_heat : public compute_module

// precompute expenses from annual schedules or value+escalation
escal_or_annual( CF_om_fixed_expense, nyears, "om_fixed", inflation_rate, 1.0, false, as_double("om_fixed_escal")*0.01 );
escal_or_annual( CF_om_production_expense, nyears, "om_production", inflation_rate, 0.001, false, as_double("om_production_escal")*0.01 );
escal_or_annual( CF_om_capacity_expense, nyears, "om_capacity", inflation_rate, 1.0, false, as_double("om_capacity_escal")*0.01 );
escal_or_annual( CF_om_production_expense, nyears, "om_production_heat", inflation_rate, 0.001, false, as_double("om_production_escal")*0.01 );
escal_or_annual( CF_om_capacity_expense, nyears, "om_capacity_heat", inflation_rate, 1.0, false, as_double("om_capacity_escal")*0.01 );
escal_or_annual( CF_om_fuel_expense, nyears, "om_fuel_cost", inflation_rate, as_double("system_heat_rate")*0.001, false, as_double("om_fuel_cost_escal")*0.01 );

arrp = as_array("utility_bill_wo_sys", &count);
for (i = 0; i < count && i <= nyears; i++)
cf.at(CF_om_elec_price_for_heat_techs, i) = arrp[i];



// additional o and m sub types (e.g. batteries and fuel cells)
int add_om_num_types = as_integer("add_om_num_types");
ssc_number_t nameplate1 = 0;
Expand Down Expand Up @@ -971,6 +982,7 @@ class cm_cashloan_heat : public compute_module
+ cf.at(CF_om_production2_expense, i)
+ cf.at(CF_om_capacity2_expense, i)
+ cf.at(CF_om_fuel_expense,i)
+ cf.at(CF_om_elec_price_for_heat_techs, i)
+ cf.at(CF_om_opt_fuel_1_expense,i)
+ cf.at(CF_om_opt_fuel_2_expense,i)
+ cf.at(CF_property_tax_expense,i)
Expand Down Expand Up @@ -1422,6 +1434,9 @@ class cm_cashloan_heat : public compute_module
save_cf(CF_om_production2_expense, nyears, "cf_om_production2_expense");
save_cf(CF_om_capacity2_expense, nyears, "cf_om_capacity2_expense");
}

save_cf(CF_om_elec_price_for_heat_techs, nyears, "cf_om_elec_price_for_heat_techs");

save_cf( CF_om_fuel_expense, nyears, "cf_om_fuel_expense" );
save_cf( CF_om_opt_fuel_1_expense, nyears, "cf_om_opt_fuel_1_expense" );
save_cf( CF_om_opt_fuel_2_expense, nyears, "cf_om_opt_fuel_2_expense" );
Expand Down Expand Up @@ -1521,13 +1536,15 @@ class cm_cashloan_heat : public compute_module
double pvFixedOandM = npv(CF_om_capacity_expense, nyears, nom_discount_rate);
double pvVariableOandM = npv(CF_om_production_expense, nyears, nom_discount_rate);
double pvFuelOandM = npv(CF_om_fuel_expense, nyears, nom_discount_rate);
double pvElec_price_for_heat_techs = npv(CF_om_elec_price_for_heat_techs, nyears, nom_discount_rate);

double pvOptFuel1OandM = npv(CF_om_opt_fuel_1_expense, nyears, nom_discount_rate);
double pvOptFuel2OandM = npv(CF_om_opt_fuel_2_expense, nyears, nom_discount_rate);
// double pvWaterOandM = NetPresentValue(sv[svNominalDiscountRate], cf[cfAnnualWaterCost], analysis_period);

assign( "present_value_oandm", var_data((ssc_number_t)(pvAnnualOandM + pvFixedOandM + pvVariableOandM + pvFuelOandM))); // + pvWaterOandM);
assign( "present_value_oandm", var_data((ssc_number_t)(pvAnnualOandM + pvFixedOandM + pvVariableOandM + pvFuelOandM + pvElec_price_for_heat_techs))); // + pvWaterOandM);

assign( "present_value_oandm_nonfuel", var_data((ssc_number_t)(pvAnnualOandM + pvFixedOandM + pvVariableOandM)));
assign( "present_value_oandm_nonfuel", var_data((ssc_number_t)(pvAnnualOandM + pvFixedOandM + pvVariableOandM + pvElec_price_for_heat_techs)));
assign( "present_value_fuel", var_data((ssc_number_t)(pvFuelOandM + pvOptFuel1OandM + pvOptFuel2OandM)));

// present value of insurance and property tax
Expand Down
31 changes: 18 additions & 13 deletions ssc/cmod_thermalrate_iph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static var_info vtab_thermal_rate_iph[] = {

// First year or lifetime hourly or subhourly
// load and gen expected to be > 0
{ SSC_INPUT, SSC_ARRAY, "gen_heat", "Thermal power generated", "kW-t", "", "Thermal Rate", "*", "", "" },
{ SSC_INPUT, SSC_ARRAY, "gen_heat", "Thermal power generated", "kWt", "", "Thermal Rate", "*", "", "" },

// input from user as MMBtu/hr and output as MMBtu/hr
{ SSC_INOUT, SSC_ARRAY, "thermal_load_heat_btu", "Thermal load (year 1)", "MMBtu/hr", "", "Thermal Rate", "", "", "" },
Expand All @@ -72,9 +72,11 @@ static var_info vtab_thermal_rate_iph[] = {


{ SSC_OUTPUT, SSC_ARRAY, "annual_thermal_value", "Thermal value", "$", "", "Annual", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "thermal_revenue_with_system", "Thermal revenue with system", "$", "", "Time Series", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "thermal_revenue_without_system", "Thermal revenue without system", "$", "", "Time Series", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "thermal_load_year1", "Thermal load (year 1)", "$", "", "", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "thermal_revenue_with_system", "Thermal revenue with system", "$", "", "Time Series", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "thermal_revenue_without_system", "Thermal revenue without system", "$", "", "Time Series", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "thermal_cost_with_system", "Thermal cost with system", "$", "", "Time Series", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "thermal_cost_without_system", "Thermal cost without system", "$", "", "Time Series", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "thermal_load_year1", "Thermal load total", "MMBtu/hr", "", "", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "thermal_savings_year1", "Thermal savings (year 1)", "$", "", "", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "thermal_cost_with_system_year1", "Thermal cost with sytem (year 1)", "$", "", "", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "thermal_cost_without_system_year1", "Thermal cost without system (year 1)", "$", "", "", "*", "", "" },
Expand Down Expand Up @@ -217,6 +219,18 @@ class cm_thermalrate_iph : public compute_module
ssc_number_t ts_hour_gen = 1.0f / step_per_hour_gen;
m_num_rec_yearly = nrec_gen_per_year;


// prepare timestep arrays for load and grid values
std::vector<ssc_number_t>
e_sys_cy(m_num_rec_yearly), p_sys_cy(m_num_rec_yearly),
p_load(m_num_rec_yearly), // to handle no load, or num load != num gen resets above assignment
p_buyrate(m_num_rec_yearly),
p_sellrate(m_num_rec_yearly),
e_grid_cy(m_num_rec_yearly), p_grid_cy(m_num_rec_yearly),
e_load_cy(m_num_rec_yearly), p_load_cy(m_num_rec_yearly); // current year load (accounts for escal)



if (is_assigned("thermal_load_heat_btu"))
{ // hourly or sub hourly loads for single year

Expand All @@ -237,15 +251,6 @@ class cm_thermalrate_iph : public compute_module



// prepare timestep arrays for load and grid values
std::vector<ssc_number_t>
e_sys_cy(m_num_rec_yearly), p_sys_cy(m_num_rec_yearly),
p_load(m_num_rec_yearly), // to handle no load, or num load != num gen
p_buyrate(m_num_rec_yearly),
p_sellrate(m_num_rec_yearly),
e_grid_cy(m_num_rec_yearly), p_grid_cy(m_num_rec_yearly),
e_load_cy(m_num_rec_yearly), p_load_cy(m_num_rec_yearly); // current year load (accounts for escal)




Expand Down

0 comments on commit 3bffdaa

Please sign in to comment.