Skip to content

Commit

Permalink
Update names from generic to custom generation, update test script to
Browse files Browse the repository at this point in the history
skip generic system
  • Loading branch information
mjprilliman committed Oct 9, 2024
1 parent 2f4437e commit d8e32f4
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 66 deletions.
4 changes: 2 additions & 2 deletions deploy/runtime/cashflow.lk
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function cf_production()
cfline( 'wind_cf_energy_net',0);
}
if ( technology() == 'CustomGeneration PVWatts Wind FuelCell Battery Hybrid') {
cfline( 'generic_cf_energy_net',0);
cfline( 'customgeneration_cf_energy_net',0);
cfline( 'pvwatts_cf_energy_net',0);
cfline( 'wind_cf_energy_net',0);
}
Expand Down Expand Up @@ -298,7 +298,7 @@ function cf_om_expenses()
}
if ( technology() == 'CustomGeneration PVWatts Wind FuelCell Battery Hybrid'){
cfline( 'Subsystem Costs', -1, 0 );
cfline( 'generic_cf_om_fixed,generic_cf_om_production,generic_cf_om_capacity,generic_cf_om_fuel_cost',0);
cfline( 'customgeneration_cf_om_fixed,customgeneration_cf_om_production,customgeneration_cf_om_capacity,customgeneration_cf_om_fuel_cost',0);
if (fin == 'Single Owner')
cfline( 'pvwatts_cf_om_fixed,pvwatts_cf_om_production,pvwatts_cf_om_capacity,pvwatts_cf_om_land_lease',0);
else
Expand Down
12 changes: 6 additions & 6 deletions deploy/runtime/metrics.lk
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,9 @@ metrics{ 'CustomGeneration PVWatts Wind FuelCell Battery Hybrid|Single Owner'}
so_metrics();

metric_table('SubsystemTable', {'headers'='Year 1 Generation by Subsystem,Value'});
metric_row( 'generic_annual_energy', {'label'='Generic', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh', 'tableName'='SubsystemTable' } );
metric_row( 'generic_capacity_factor', {'label'='Generic AC capacity factor', 'mode'='f', 'deci'='1', 'thousep'='true', 'post'='%', 'tableName'='SubsystemTable'} );
metric_row( 'generic_kwh_per_kw', {'label'='Generic energy yield', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh/kW', 'tableName'='SubsystemTable' } );
metric_row( 'customgeneration_annual_energy', {'label'='Custom generation', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh', 'tableName'='SubsystemTable' } );
metric_row( 'customgeneration_capacity_factor', {'label'='Custom generation AC capacity factor', 'mode'='f', 'deci'='1', 'thousep'='true', 'post'='%', 'tableName'='SubsystemTable'} );
metric_row( 'customgeneration_kwh_per_kw', {'label'='Custom generation energy yield', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh/kW', 'tableName'='SubsystemTable' } );
metric_row( 'pvwatts_annual_energy', {'label'='PVWatts', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh', 'tableName'='SubsystemTable' } );
metric_row( 'pvwatts_capacity_factor', {'label'='PVWatts DC capacity factor', 'mode'='f', 'deci'='1', 'thousep'='true', 'post'='%', 'tableName'='SubsystemTable'} );
metric_row( 'pvwatts_kwh_per_kw', {'label'='PVWatts energy yield', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh/kW', 'tableName'='SubsystemTable' } );
Expand All @@ -723,9 +723,9 @@ metrics{ 'CustomGeneration PVWatts Wind FuelCell Battery Hybrid|Host Developer'}
host_developer_metrics();

metric_table('SubsystemTable', {'headers'='Year 1 Generation by Subsystem,Value'});
metric_row( 'generic_annual_energy', {'label'='Generic', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh', 'tableName'='SubsystemTable' } );
metric_row( 'generic_capacity_factor', {'label'='Generic AC capacity factor', 'mode'='f', 'deci'='1', 'thousep'='true', 'post'='%', 'tableName'='SubsystemTable'} );
metric_row( 'generic_kwh_per_kw', {'label'='Generic energy yield', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh/kW', 'tableName'='SubsystemTable' } );
metric_row( 'customgeneration_annual_energy', {'label'='Custom generation', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh', 'tableName'='SubsystemTable' } );
metric_row( 'customgeneration_capacity_factor', {'label'='Custom generation AC capacity factor', 'mode'='f', 'deci'='1', 'thousep'='true', 'post'='%', 'tableName'='SubsystemTable'} );
metric_row( 'customgeneration_kwh_per_kw', {'label'='Custom generation energy yield', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh/kW', 'tableName'='SubsystemTable' } );
metric_row( 'pvwatts_annual_energy', {'label'='PVWatts', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh', 'tableName'='SubsystemTable' } );
metric_row( 'pvwatts_capacity_factor', {'label'='PVWatts DC capacity factor', 'mode'='f', 'deci'='1', 'thousep'='true', 'post'='%', 'tableName'='SubsystemTable'} );
metric_row( 'pvwatts_kwh_per_kw', {'label'='PVWatts energy yield', 'mode'='f', 'deci'='0', 'thousep'='true', 'post'=' kWh/kW', 'tableName'='SubsystemTable' } );
Expand Down
2 changes: 1 addition & 1 deletion deploy/runtime/startup.lk
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ addconfig( 'Solar Water Heating', ['Residential', 'Commercial', 'LCOE Calculator
addconfig( 'Biopower', ['Single Owner', 'Merchant Plant', 'Leveraged Partnership Flip', 'All Equity Partnership Flip', 'Sale Leaseback', 'LCOE Calculator', 'None']);
// Generic System
addconfig( 'Custom Generation Profile', ['Residential', 'Commercial', 'Third Party', 'Host Developer', 'Single Owner', 'Merchant Plant', 'Leveraged Partnership Flip', 'All Equity Partnership Flip', 'Sale Leaseback', 'LCOE Calculator', 'None']);
addconfig( 'Generic System', ['Residential', 'Commercial', 'Third Party', 'Host Developer', 'Single Owner', 'Merchant Plant', 'Leveraged Partnership Flip', 'All Equity Partnership Flip', 'Sale Leaseback', 'LCOE Calculator', 'None']);
addconfig( 'Generic System', ['None']);

addconfig( 'Retired', ['None']);
// Hybrid Power
Expand Down
1 change: 1 addition & 0 deletions deploy/test_script_ow.lk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ for (t=0; t<#technologies; t++)
&& (technologies[t] != "Dish Stirling")
&& (technologies[t] != "ISCC")
&& (technologies[t] != "Retired")
&& (technologies[t] != "Generic System")
&& (technologies[t] != "MSPTV2"))
// && (technologies[t] != "PVWatts Wind Battery Hybrid"))
{
Expand Down
108 changes: 54 additions & 54 deletions src/combinecases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ CombineCasesDialog::CombineCasesDialog(wxWindow* parent, const wxString& title,
{
// Initializations
m_result_code = -1;
m_generic_case = SamApp::Window()->GetCurrentCase();
m_generic_case_name = SamApp::Window()->Project().GetCaseName(m_generic_case);
m_generic_case_window = SamApp::Window()->GetCaseWindow(m_generic_case);
if (m_generic_case->Values(0).Get("generic_degradation")) {
m_generic_degradation = m_generic_case->Values(0).Get("generic_degradation")->Array(); // name in generic-battery cases
m_custom_generation_case = SamApp::Window()->GetCurrentCase();
m_custom_generation_case_name = SamApp::Window()->Project().GetCaseName(m_custom_generation_case);
m_custom_generation_case_window = SamApp::Window()->GetCaseWindow(m_custom_generation_case);
if (m_custom_generation_case->Values(0).Get("generic_degradation")) {
m_generic_degradation = m_custom_generation_case->Values(0).Get("generic_degradation")->Array(); // name in generic-battery cases
}
else if (m_generic_case->Values(0).Get("degradation")) {
m_generic_degradation = m_generic_case->Values(0).Get("degradation")->Array(); // name in other cases, if defined
else if (m_custom_generation_case->Values(0).Get("degradation")) {
m_generic_degradation = m_custom_generation_case->Values(0).Get("degradation")->Array(); // name in other cases, if defined
}
else {
m_generic_degradation.push_back(0.); // no value defined for LCOE and None financial models, set to zero
Expand Down Expand Up @@ -150,17 +150,17 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e)

// Get analysis period and inflation from generic case
// TODO: Move some of this to constructor?
wxString technology_name = m_generic_case->GetTechnology();
wxString financial_name = m_generic_case->GetFinancing();
wxString technology_name = m_custom_generation_case->GetTechnology();
wxString financial_name = m_custom_generation_case->GetFinancing();
double analysis_period = 0.;
double inflation = 0.;
if (financial_name == "LCOE Calculator" || financial_name == "LCOH Calculator") {
analysis_period = m_generic_case->Values(0).Get("c_lifetime")->Value();
inflation = m_generic_case->Values(0).Get("c_inflation")->Value();
analysis_period = m_custom_generation_case->Values(0).Get("c_lifetime")->Value();
inflation = m_custom_generation_case->Values(0).Get("c_inflation")->Value();
}
else if (financial_name != "None") {
analysis_period = m_generic_case->Values(0).Get("analysis_period")->Value();
inflation = m_generic_case->Values(0).Get("inflation_rate")->Value();
analysis_period = m_custom_generation_case->Values(0).Get("analysis_period")->Value();
inflation = m_custom_generation_case->Values(0).Get("inflation_rate")->Value();
}

// Allocate and initialize variables to run through the cases to combine
Expand Down Expand Up @@ -219,7 +219,7 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e)
// check that the case ran
if (!ok) {
m_result_code = 1;
m_generic_case_window->UpdateResults();
m_custom_generation_case_window->UpdateResults();
case_window->SwitchToPage("results:notices");
wxArrayString messages = current_case->BaseCase().GetAllMessages();
wxMessageBox("Error in " + case_name + "\n\n"
Expand Down Expand Up @@ -276,9 +276,9 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e)
}
else if (hourly_energy_this.ncells() > 8760 * analysis_period_this) {
m_result_code = 1;
m_generic_case_window->UpdateResults();
SamApp::Window()->SwitchToCaseWindow(m_generic_case_name);
m_generic_case_window->SwitchToInputPage("Power Plant");
m_custom_generation_case_window->UpdateResults();
SamApp::Window()->SwitchToCaseWindow(m_custom_generation_case_name);
m_custom_generation_case_window->SwitchToInputPage("Power Plant");
wxMessageBox("Subhourly simulations unsupported\n\n"
"The subhourly simulation for case " + technology_name + " is not supported.",
"Combine Cases Message", wxOK, this);
Expand Down Expand Up @@ -405,72 +405,72 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e)
}

// Set the generic system performance parameters
m_generic_case->Values(0).Get("system_capacity_combined")->Set(nameplate); // the shown and editable 'Nameplate capacity' widget that also
m_custom_generation_case->Values(0).Get("system_capacity_combined")->Set(nameplate); // the shown and editable 'Nameplate capacity' widget that also
// sets the hidden 'Nameplate capacity' widget value
m_generic_case->Values(0).Get("system_capacity")->Set(nameplate); // the actual used system_capacity, which corresponds to the
m_custom_generation_case->Values(0).Get("system_capacity")->Set(nameplate); // the actual used system_capacity, which corresponds to the
// 'Nameplate capacity' widget that is hidden when combining cases
m_generic_case->Values(0).Get("spec_mode")->Set(2); // specify the third radio button
m_generic_case->Values(0).Get("derate")->Set(0); // no additional losses- losses were computed in the individual models
m_generic_case->Values(0).Get("heat_rate")->Set(0); // no fuel costs- accounted for in O&M fuel costs from subsystem cash flows
m_generic_case->Values(0).Get("energy_output_array")->Set(hourly_energy.data(), hourly_energy.ncells());
m_generic_case->VariableChanged("energy_output_array",0); // triggers UI update
m_custom_generation_case->Values(0).Get("spec_mode")->Set(2); // specify the third radio button
m_custom_generation_case->Values(0).Get("derate")->Set(0); // no additional losses- losses were computed in the individual models
m_custom_generation_case->Values(0).Get("heat_rate")->Set(0); // no fuel costs- accounted for in O&M fuel costs from subsystem cash flows
m_custom_generation_case->Values(0).Get("energy_output_array")->Set(hourly_energy.data(), hourly_energy.ncells());
m_custom_generation_case->VariableChanged("energy_output_array",0); // triggers UI update

bool overwrite_capital = m_chkOverwriteCapital->IsChecked();
if (financial_name == "LCOE Calculator" || financial_name == "LCOH Calculator") {
if (!constant1) {
m_result_code = 1;
m_generic_case_window->UpdateResults();
SamApp::Window()->SwitchToCaseWindow(m_generic_case_name);
m_generic_case_window->SwitchToInputPage("Power Plant");
m_custom_generation_case_window->UpdateResults();
SamApp::Window()->SwitchToCaseWindow(m_custom_generation_case_name);
m_custom_generation_case_window->SwitchToInputPage("Power Plant");
wxMessageBox("LCOE calculator error\n\n"
"Single annualized fixed operating costs must be used.\n\n"
"Check O&M inputs in case " + technology_name,
"Combine Cases Message", wxOK, this);
return;
}
else if (overwrite_capital) {
m_generic_case->Values(0).Get("fixed_operating_cost")->Set(om_fixed);
m_custom_generation_case->Values(0).Get("fixed_operating_cost")->Set(om_fixed);
}
}

// Set installation and operating costs
if (financial_name != "None" && financial_name != "Third Party" && overwrite_capital) {
// Installation Costs
m_generic_case->Values(0).Get("fixed_plant_input")->Set(total_installed_cost);
m_generic_case->Values(0).Get("genericsys.cost.per_watt")->Set(0.);
m_generic_case->Values(0).Get("genericsys.cost.contingency_percent")->Set(0.);
m_generic_case->Values(0).Get("genericsys.cost.epc.percent")->Set(0.);
m_generic_case->Values(0).Get("genericsys.cost.epc.fixed")->Set(0.);
m_generic_case->Values(0).Get("genericsys.cost.plm.percent")->Set(0.);
m_generic_case->Values(0).Get("genericsys.cost.plm.fixed")->Set(0.);
m_generic_case->Values(0).Get("genericsys.cost.sales_tax.percent")->Set(0.);
m_custom_generation_case->Values(0).Get("fixed_plant_input")->Set(total_installed_cost);
m_custom_generation_case->Values(0).Get("genericsys.cost.per_watt")->Set(0.);
m_custom_generation_case->Values(0).Get("genericsys.cost.contingency_percent")->Set(0.);
m_custom_generation_case->Values(0).Get("genericsys.cost.epc.percent")->Set(0.);
m_custom_generation_case->Values(0).Get("genericsys.cost.epc.fixed")->Set(0.);
m_custom_generation_case->Values(0).Get("genericsys.cost.plm.percent")->Set(0.);
m_custom_generation_case->Values(0).Get("genericsys.cost.plm.fixed")->Set(0.);
m_custom_generation_case->Values(0).Get("genericsys.cost.sales_tax.percent")->Set(0.);

// Operating Costs - all zero except fixed (see explanation above)
m_generic_case->Values(0).Get("om_fixed")->Set(om_fixed);
m_generic_case->Values(0).Get("om_capacity")->Set(new double[1]{0.}, 1);
m_generic_case->Values(0).Get("om_production")->Set(new double[1]{0.}, 1);
m_custom_generation_case->Values(0).Get("om_fixed")->Set(om_fixed);
m_custom_generation_case->Values(0).Get("om_capacity")->Set(new double[1]{0.}, 1);
m_custom_generation_case->Values(0).Get("om_production")->Set(new double[1]{0.}, 1);
//O&M escalation rates are also zeroed because they are accounted for in the fixed O&M costs
m_generic_case->Values(0).Get("om_fixed_escal")->Set(0.);
m_generic_case->Values(0).Get("om_capacity_escal")->Set(0.);
m_generic_case->Values(0).Get("om_production_escal")->Set(0.);
m_custom_generation_case->Values(0).Get("om_fixed_escal")->Set(0.);
m_custom_generation_case->Values(0).Get("om_capacity_escal")->Set(0.);
m_custom_generation_case->Values(0).Get("om_production_escal")->Set(0.);

if (m_generic_case->Values(0).Get("om_fuel_cost")) {
m_generic_case->Values(0).Get("om_fuel_cost")->Set(new double[1]{0.}, 1);
m_generic_case->Values(0).Get("om_fuel_cost_escal")->Set(0.);
if (m_custom_generation_case->Values(0).Get("om_fuel_cost")) {
m_custom_generation_case->Values(0).Get("om_fuel_cost")->Set(new double[1]{0.}, 1);
m_custom_generation_case->Values(0).Get("om_fuel_cost_escal")->Set(0.);
}

if (m_generic_case->Values(0).Get("om_replacement_cost1")) {
m_generic_case->Values(0).Get("om_replacement_cost1")->Set(new double[1]{0.}, 1);
m_generic_case->Values(0).Get("om_replacement_cost_escal")->Set(0.);
if (m_custom_generation_case->Values(0).Get("om_replacement_cost1")) {
m_custom_generation_case->Values(0).Get("om_replacement_cost1")->Set(new double[1]{0.}, 1);
m_custom_generation_case->Values(0).Get("om_replacement_cost_escal")->Set(0.);
}
}

// Update UI with results
m_result_code = 0; // 0=success
SamApp::Window()->SwitchToCaseWindow(m_generic_case_name);
int result = m_generic_case->RecalculateAll(0,false);
m_generic_case_window->UpdateResults();
m_generic_case_window->SwitchToInputPage("Power Plant");
SamApp::Window()->SwitchToCaseWindow(m_custom_generation_case_name);
int result = m_custom_generation_case->RecalculateAll(0,false);
m_custom_generation_case_window->UpdateResults();
m_custom_generation_case_window->SwitchToInputPage("Power Plant");
if (is_notices) {
wxMessageBox("Notices\n\n"
"At least one of the models generated notices.\n\n"
Expand All @@ -487,7 +487,7 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e)

// 'Press' Edit array... button to show energy output array
ActiveInputPage* aip = 0;
wxUIObject* energy_output_array = m_generic_case_window->FindObject("energy_output_array", &aip);
wxUIObject* energy_output_array = m_custom_generation_case_window->FindObject("energy_output_array", &aip);
if (AFDataArrayButton* btn_energy_output_array = energy_output_array->GetNative<AFDataArrayButton>()) {
btn_energy_output_array->OnPressed(e);
}
Expand Down Expand Up @@ -515,7 +515,7 @@ void CombineCasesDialog::RefreshList(size_t first_item)
for (size_t i = 0; i < m_cases.size(); i++)
{
// Exclude generic case from displaying in case list
if (m_cases[i].display_name != m_generic_case_name) {
if (m_cases[i].display_name != m_custom_generation_case_name) {
int ndx = m_chlCases->Append(m_cases[i].display_name);
if (m_cases[i].is_selected) {
m_chlCases->Check(ndx, true);
Expand Down
6 changes: 3 additions & 3 deletions src/combinecases.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class CombineCasesDialog : public wxDialog
bool HasContingency(Simulation& bcsim);

int m_result_code;
Case* m_generic_case;
wxString m_generic_case_name;
CaseWindow* m_generic_case_window;
Case* m_custom_generation_case;
wxString m_custom_generation_case_name;
CaseWindow* m_custom_generation_case_window;
std::vector<double> m_generic_degradation;
std::vector<CaseInfo> m_cases;
wxCheckListBox* m_chlCases;
Expand Down

0 comments on commit d8e32f4

Please sign in to comment.