From d8e32f45b3c18a74d4287ea4e0a2b1eae760b941 Mon Sep 17 00:00:00 2001 From: Matt Prilliman <54449384+mjprilliman@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:27:24 -0500 Subject: [PATCH] Update names from generic to custom generation, update test script to skip generic system --- deploy/runtime/cashflow.lk | 4 +- deploy/runtime/metrics.lk | 12 ++--- deploy/runtime/startup.lk | 2 +- deploy/test_script_ow.lk | 1 + src/combinecases.cpp | 108 ++++++++++++++++++------------------- src/combinecases.h | 6 +-- 6 files changed, 67 insertions(+), 66 deletions(-) diff --git a/deploy/runtime/cashflow.lk b/deploy/runtime/cashflow.lk index ffce2df6cf..c4c8757870 100644 --- a/deploy/runtime/cashflow.lk +++ b/deploy/runtime/cashflow.lk @@ -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); } @@ -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 diff --git a/deploy/runtime/metrics.lk b/deploy/runtime/metrics.lk index e569cb1b3b..cf853f3f66 100644 --- a/deploy/runtime/metrics.lk +++ b/deploy/runtime/metrics.lk @@ -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' } ); @@ -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' } ); diff --git a/deploy/runtime/startup.lk b/deploy/runtime/startup.lk index f7a88a98b5..dd23a3f5e9 100644 --- a/deploy/runtime/startup.lk +++ b/deploy/runtime/startup.lk @@ -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 diff --git a/deploy/test_script_ow.lk b/deploy/test_script_ow.lk index 05fb4ec2fb..7c2aed1f68 100644 --- a/deploy/test_script_ow.lk +++ b/deploy/test_script_ow.lk @@ -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")) { diff --git a/src/combinecases.cpp b/src/combinecases.cpp index d4efd0dd30..48fec8fbd4 100644 --- a/src/combinecases.cpp +++ b/src/combinecases.cpp @@ -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 @@ -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 @@ -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" @@ -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); @@ -405,23 +405,23 @@ 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, @@ -429,48 +429,48 @@ void CombineCasesDialog::OnEvt(wxCommandEvent& e) 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" @@ -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()) { btn_energy_output_array->OnPressed(e); } @@ -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); diff --git a/src/combinecases.h b/src/combinecases.h index 09fea3f59c..61e50b0221 100644 --- a/src/combinecases.h +++ b/src/combinecases.h @@ -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 m_generic_degradation; std::vector m_cases; wxCheckListBox* m_chlCases;