From 00d4eb3070cd90f1abf18932ae6278e41bdbb91f Mon Sep 17 00:00:00 2001 From: Matt Prilliman Date: Fri, 2 Aug 2024 13:43:26 -0500 Subject: [PATCH 01/15] Start implementation of PV battery compare cases macro --- .../PV Battery/PV Battery Compare Cases.lk | 673 ++++++++++++++++++ 1 file changed, 673 insertions(+) create mode 100644 deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk diff --git a/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk new file mode 100644 index 0000000000..b9d03ba60b --- /dev/null +++ b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk @@ -0,0 +1,673 @@ +/*@ +This macro allows you to compare multiple PV Battery cases. +This may be helpful for modeling a variety of scenarios, including: + + +Instructions: +
    +
  1. Create the cases that you wish to compare. +
  2. Define the PV module, inverter, system design, battery system, losses, system cost, and financial parameters for all the created cases. +
  3. Simulate all the cases. +
  4. Open the PV Battery Compare Cases Macro and select a simulation option from the list. +
      +
    • You may choose all of the cases in the existing project to be compared, OR +
    • You may choose which cases to compare by typing their names into the input box, separated by ONLY a comma (no space). +
    +
  5. Click 'Run macro' at the top of the screen. +
  6. When prompted, confirm the cases that will be compared. +
  7. When the macro simulation is complete, view the results in your browser. +
+ +@*/ +//Macro user interface widgets +//@ name=mode;type=combo;label=Choose an option;value=1) Compare all cases,2) Compare only the cases listed below;sel=0 +//@ name=cases;type=text;label=List cases for Option 2 (comma-separated);value= + + +//Check that this macro was run from within a case +if ( typeof(macro) == 'unknown' ) { + msgbox('This macro must be run from within a case.'); + exit; +} + +//Determine available cases +cases = list_cases(); +num_cases = #cases; + +//if 'Select cases' is enabled, parse the input to get the list of cases that should be compared +if (macro.mode == '2) Compare only the cases listed below') +{ + input_cases = split(macro.cases, ','); //delimited with commas + for (i=0; i<#input_cases; i++) //check each input case + { + match = false; //a match has not yet been found + for (j=0; j 4) +{ + msgbox('This macro requires 4 or less cases.' + + ' Check your inputs and try again.'); + exit; +} + + +//outln('Cases: ' + cases); +//outln('Number of cases: ' + num_cases); +//outln(cases[3]); + +lcoe = alloc(0,num_cases); +aep = alloc(0,num_cases); +arrayRatedPower = alloc(0,num_cases); +npv = alloc(0,num_cases); +capacityFactor = alloc(0,num_cases); +capEx = alloc(0,num_cases); +opEx = alloc(0,num_cases); +irr = alloc(0,num_cases); +aep_battery = alloc(0, num_cases); +batt_charge_sys = alloc(0, num_cases); +batt_charge_grid = alloc(0, num_cases); + +for (i=0; i' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[3]+''+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[3]) +' /kWh'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[3]) +' kWh'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[3]) +'% '+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[3]) +' '+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[3]) +' '+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[3]) +' '+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
Internal Rate of Return'+ sprintf("%.1f",irr[3]) +' '+ sprintf("%.1f",irr[2]) +' '+ sprintf("%.1f",irr[1]) +' '+ sprintf("%.1f",irr[0]) +'
' + + '
' + '
' + '
' + + '' + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==3) +{ +reportCode = +'' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
Internal Rate of Return'+ sprintf("%.1f",irr[2]) +' '+ sprintf("%.1f",irr[1]) +' '+ sprintf("%.1f",irr[0]) +'
' + + '
' + '
' + '
' + + '' + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==2) +{ +//Get change in capex, opex, and aep contribution for two case comparison + + if ((batt_charge_sys[1]+batt_charge_grid[1])>(batt_charge_sys[0]+batt_charge_grid[0])) + { + baselineCase = 1; + advancedCase = 0; + } + if (lcoe[0]>=lcoe[1]) + { + baselineCase = 0; + advancedCase = 1; + } + +battChargeBaseline = batt_charge_sys[baselineCase] + batt_charge_grid[baselineCase]; +battChargeAdvanced = batt_charge_sys[advancedCase] + batt_charge_grid[advancedCase]; +battChargeSysChange = batt_charge_sys[baselineCase] - batt_charge_sys[advancedCase]; +battChargeGridChange = batt_charge_grid[baselineCase] - batt_charge_grid[advancedCase]; +//outln(lcoe[baselineCase]-lcoe[advancedCase]); +//outln(capexLcoeChange); +//outln(opexLcoeChange); +//outln(aepLcoeChange); +//outln(totalLcoeChange); +//outln('baseline case = '+baselineCase); +//outln('baseline= '+cases[baselineCase]); +//outln('advanced case='+cases[advancedCase]); +reportCode = +'' +'' + 'SAM ME Wave Energy Case Comparison Report' + '' + +'' + +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
Internal Rate of Return'+ sprintf("%.1f",irr[1]) +' '+ sprintf("%.1f",irr[0]) +'
' + + '
' + '
' + '
' + + '' + + '
' + + '' + +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; + +} + +report = tempfile('html'); //specify a temporary location to save the plot + +ok = write_text_file(report, reportCode); +if (!ok) + { + msgbox('Report rendering failed.'); + exit; + } +browse(report); + +msgbox('Please save the report opened in your browser as a PDF.'); + +//// Delete temporary chart file + +remove_file(report); + + + + + + + + From 2bafba0826bca4cff0b79dc9cd0ac4e7ba8bf330 Mon Sep 17 00:00:00 2001 From: Matt Prilliman Date: Tue, 6 Aug 2024 20:04:09 -0500 Subject: [PATCH 02/15] Add monthly energy chart to macro --- .../PV Battery/PV Battery Compare Cases.lk | 273 +++++++++++++++--- 1 file changed, 239 insertions(+), 34 deletions(-) diff --git a/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk index b9d03ba60b..561ab9ed36 100644 --- a/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk +++ b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk @@ -84,23 +84,35 @@ if (num_cases > 4) //outln('Cases: ' + cases); //outln('Number of cases: ' + num_cases); //outln(cases[3]); - +fin = alloc(0, num_cases); lcoe = alloc(0,num_cases); +lcos = alloc(0, num_cases); aep = alloc(0,num_cases); arrayRatedPower = alloc(0,num_cases); npv = alloc(0,num_cases); capacityFactor = alloc(0,num_cases); capEx = alloc(0,num_cases); opEx = alloc(0,num_cases); -irr = alloc(0,num_cases); aep_battery = alloc(0, num_cases); batt_charge_sys = alloc(0, num_cases); batt_charge_grid = alloc(0, num_cases); +dispatch_choice = alloc(0, num_cases); +monthly_energy = alloc(12, num_cases); +monthly_bill = alloc(12, num_cases); +irr_bill = alloc(0, num_cases); +irr_bill_table = alloc(0, num_cases); +batt_annual_charge_grid = []; +batt_annual_charge_sys = []; for (i=0; i 0 && fin[i-1] != fin[i]) { + msgbox('The macro can only compare cases with the same financial model.'); + exit; + } /* if (config[1] != 'LCOE Calculator') @@ -118,21 +130,51 @@ for (i=0; i' ''+ sprintf("$%.2f",lcoe[0]) +' /kWh' '' + '' + 'Levelized Cost of Storage' + ''+ sprintf("$%.2f",lcos[3]) +' /kWh' + ''+ sprintf("$%.2f",lcos[2]) +' /kWh' + ''+ sprintf("$%.2f",lcos[1]) +' /kWh' + ''+ sprintf("$%.2f",lcos[0]) +' /kWh' + '' '' 'Annual Energy Production' ''+ sprintf("%,",aep[3]) +' kWh' @@ -269,11 +311,18 @@ reportCode = ''+ sprintf("$%,",npv[0]) +' ' '' '' - 'Internal Rate of Return' - ''+ sprintf("%.1f",irr[3]) +' ' - ''+ sprintf("%.1f",irr[2]) +' ' - ''+ sprintf("%.1f",irr[1]) +' ' - ''+ sprintf("%.1f",irr[0]) +' ' + ''+sprintf(irr_bill_string)+' ' + ''+ sprintf("%.1f",irr_bill[3]) +' %' + ''+ sprintf("%.1f",irr_bill[2]) +' %' + ''+ sprintf("%.1f",irr_bill[1]) +' %' + ''+ sprintf("%.1f",irr_bill[0]) +' %' + '' + '' + 'Dispatch Option' + ''+ sprintf(dispatch_choice[3]) +' ' + ''+ sprintf(dispatch_choice[2]) +' ' + ''+ sprintf(dispatch_choice[1]) +' ' + ''+ sprintf(dispatch_choice[0]) +' ' '' '' @@ -295,7 +344,7 @@ reportCode = 'var aep2 = {' 'x: xValues,' 'y: ['+ aep_system[3] +','+ aep_system[2] +','+ aep_system[1] +','+ aep_system[0] +'],' - 'name: "OpEx",' + 'name: "System Generation",' 'type: "bar"' '};' @@ -314,6 +363,58 @@ reportCode = 'Plotly.newPlot("lcoePlot", lcoeData, layout);' '' + + '
' + '
' + '
' + + '' '
' '' @@ -374,6 +475,12 @@ reportCode = ''+ sprintf("$%.2f",lcoe[1]) +' /kWh' ''+ sprintf("$%.2f",lcoe[0]) +' /kWh' '' + '' + 'Levelized Cost of Storage' + ''+ sprintf("$%.2f",lcos[2]) +' /kWh' + ''+ sprintf("$%.2f",lcos[1]) +' /kWh' + ''+ sprintf("$%.2f",lcos[0]) +' /kWh' + '' '' 'Annual Energy Production' ''+ sprintf("%,",aep[2]) +' kWh' @@ -406,10 +513,16 @@ reportCode = ''+ sprintf("$%,",npv[0]) +' ' '' '' - 'Internal Rate of Return' - ''+ sprintf("%.1f",irr[2]) +' ' - ''+ sprintf("%.1f",irr[1]) +' ' - ''+ sprintf("%.1f",irr[0]) +' ' + ''+sprintf(irr_bill_string)+' ' + ''+ sprintf("%.1f",irr_bill[2]) +' ' + ''+ sprintf("%.1f",irr_bill[1]) +' ' + ''+ sprintf("%.1f",irr_bill[0]) +' ' + '' + '' + 'Dispatch Option' + ''+ sprintf(dispatch_choice[2]) +' ' + ''+ sprintf(dispatch_choice[1]) +' ' + ''+ sprintf(dispatch_choice[0]) +' ' '' '' @@ -431,7 +544,7 @@ reportCode = 'var aep2 = {' 'x: xValues,' 'y: ['+ aep_system[2] +','+ aep_system[1] +','+ aep_system[0] +'],' - 'name: "OpEx",' + 'name: "System Generation",' 'type: "bar"' '};' @@ -450,6 +563,51 @@ reportCode = 'Plotly.newPlot("lcoePlot", lcoeData, layout);' '' + + '
' + '
' + '
' + + '' '' '' @@ -525,7 +683,6 @@ reportCode = '' '' '' - '' '' '' '' @@ -534,6 +691,11 @@ reportCode = '' '' '' + '' + '' + '' + '' + '' '' '' '' @@ -561,9 +723,14 @@ reportCode = '' '' '' - '' - '' - '' + '' + '' + '' + '' + '' + '' + '' + '' '' '
'+cases[2]+''+cases[1]+''+cases[0]+'
'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Levelized Cost of Storage'+ sprintf("$%.2f",lcos[1]) +' /kWh'+ sprintf("$%.2f",lcos[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("$%,",npv[0]) +'
Internal Rate of Return'+ sprintf("%.1f",irr[1]) +' '+ sprintf("%.1f",irr[0]) +' '+sprintf(irr_bill_string)+' '+ irr_bill_table[1] +' '+ irr_bill_table[0] +'
Dispatch Option'+ sprintf(dispatch_choice[1]) +' '+ sprintf(dispatch_choice[0]) +'
' @@ -573,19 +740,19 @@ reportCode = '' + + '
' + '
' + '
' + + '' '
' @@ -614,7 +819,7 @@ reportCode = 'x: ["Baseline", "System Charging", "Grid Charging", "Advanced Case"],' 'textposition: "inside",' 'text: ["'+ cases[baselineCase] +'"," "," "," ","'+ cases[advancedCase] +'"],' - 'measure: ["absolute", "relative", "relative", "relative", "total"],' + 'measure: ["absolute", "relative", "relative", "total"],' 'y: ['+ battChargeBaseline +','+ -1*battChargeSysChange +','+ -1*battChargeGridChange +','+ battChargeAdvanced +'],' 'base: 0,' 'decreasing: { marker: { color: "Maroon" , line:{color : "red", width :2}}},' @@ -623,7 +828,7 @@ reportCode = '}];' 'var layout1 = {' - 'title:"Change in Battery Annual Energy Charging",' + 'title:"Change in Year 1 Battery Annual Energy Charging",' 'waterfallgap : 0.3,' 'xaxis: {tickfont: {size: 15},ticks: "outside"},' 'yaxis:{title: "Annual Energy Charged kWh"}' @@ -647,7 +852,7 @@ reportCode = ''; } - +outln(reportCode); report = tempfile('html'); //specify a temporary location to save the plot ok = write_text_file(report, reportCode); From 3ada194e5e7adb0220f364d3616c5e8e6edb483e Mon Sep 17 00:00:00 2001 From: Matt Prilliman Date: Tue, 13 Aug 2024 08:38:27 -0500 Subject: [PATCH 03/15] Cashflow graphs comparison --- .../PV Battery/PV Battery Compare Cases.lk | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk index 561ab9ed36..7e3104fc61 100644 --- a/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk +++ b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk @@ -98,11 +98,13 @@ batt_charge_sys = alloc(0, num_cases); batt_charge_grid = alloc(0, num_cases); dispatch_choice = alloc(0, num_cases); monthly_energy = alloc(12, num_cases); +annual_cashflow = alloc(40, num_cases); monthly_bill = alloc(12, num_cases); irr_bill = alloc(0, num_cases); irr_bill_table = alloc(0, num_cases); batt_annual_charge_grid = []; batt_annual_charge_sys = []; +annual_cashflow_bin = []; for (i=0; i' + + '
' + '
' + '
' + + '' + '
' From 83854baa731c2388014d65a97e574d84c02fe68c Mon Sep 17 00:00:00 2001 From: Matt Prilliman Date: Wed, 21 Aug 2024 21:18:34 -0500 Subject: [PATCH 04/15] Test PV only report --- .../Flat Plate PV/PV Battery Compare Cases.lk | 949 +++++++++++++++++ .../macros/Flat Plate PV/PV Compare Cases.lk | 951 ++++++++++++++++++ .../PV Battery/PV Battery Compare Cases.lk | 120 +++ 3 files changed, 2020 insertions(+) create mode 100644 deploy/runtime/macros/Flat Plate PV/PV Battery Compare Cases.lk create mode 100644 deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk diff --git a/deploy/runtime/macros/Flat Plate PV/PV Battery Compare Cases.lk b/deploy/runtime/macros/Flat Plate PV/PV Battery Compare Cases.lk new file mode 100644 index 0000000000..507adaac74 --- /dev/null +++ b/deploy/runtime/macros/Flat Plate PV/PV Battery Compare Cases.lk @@ -0,0 +1,949 @@ +/*@ +This macro allows you to compare multiple PV Battery cases. +This may be helpful for modeling a variety of scenarios, including: +
    +
  • Model a baseline system in contrast with an alternate system. +
  • Compare systems with different PV or battery configurations. +
  • Compare systems located at different resource locations. +
+ +Instructions: +
    +
  1. Create the cases that you wish to compare. +
  2. Define the PV module, inverter, system design, battery system, losses, system cost, and financial parameters for all the created cases. +
  3. Simulate all the cases. +
  4. Open the PV Battery Compare Cases Macro and select a simulation option from the list. +
      +
    • You may choose all of the cases in the existing project to be compared, OR +
    • You may choose which cases to compare by typing their names into the input box, separated by ONLY a comma (no space). +
    +
  5. Click 'Run macro' at the top of the screen. +
  6. When prompted, confirm the cases that will be compared. +
  7. When the macro simulation is complete, view the results in your browser. +
+ +@*/ +//Macro user interface widgets +//@ name=mode;type=combo;label=Choose an option;value=1) Compare all cases,2) Compare only the cases listed below;sel=0 +//@ name=cases;type=text;label=List cases for Option 2 (comma-separated);value= + + +//Check that this macro was run from within a case +if ( typeof(macro) == 'unknown' ) { + msgbox('This macro must be run from within a case.'); + exit; +} + +//Determine available cases +cases = list_cases(); +num_cases = #cases; + +//if 'Select cases' is enabled, parse the input to get the list of cases that should be compared +if (macro.mode == '2) Compare only the cases listed below') +{ + input_cases = split(macro.cases, ','); //delimited with commas + for (i=0; i<#input_cases; i++) //check each input case + { + match = false; //a match has not yet been found + for (j=0; j 4) +{ + msgbox('This macro requires 4 or less cases.' + + ' Check your inputs and try again.'); + exit; +} + + +//outln('Cases: ' + cases); +//outln('Number of cases: ' + num_cases); +//outln(cases[3]); +fin = alloc(0, num_cases); +lcoe = alloc(0,num_cases); +lcos = alloc(0, num_cases); +aep = alloc(0,num_cases); +arrayRatedPower = alloc(0,num_cases); +npv = alloc(0,num_cases); +capacityFactor = alloc(0,num_cases); +capEx = alloc(0,num_cases); +opEx = alloc(0,num_cases); +aep_battery = alloc(0, num_cases); +batt_charge_sys = alloc(0, num_cases); +batt_charge_grid = alloc(0, num_cases); +dispatch_choice = alloc(0, num_cases); +monthly_energy = alloc(12, num_cases); +annual_cashflow = alloc(40, num_cases); +monthly_bill = alloc(12, num_cases); +irr_bill = alloc(0, num_cases); +irr_bill_table = alloc(0, num_cases); +batt_annual_charge_grid = []; +batt_annual_charge_sys = []; +annual_cashflow_bin = []; + +for (i=0; i 0 && fin[i-1] != fin[i]) { + msgbox('The macro can only compare cases with the same financial model.'); + exit; + } + /* + if (config[1] != 'LCOE Calculator') + + { + + msgbox('The ME Wave report macro only works with the LCOE Calculator selected as the financial model.'); + + exit; + + } + */ + if (config[1] == 'LCOE Calculator') { + lcoe[i] = get('lcoe_fcr'); + } + else { + lcoe[i] = get('lcoe_nom'); + } + lcos[i] = get('lcos_nom'); + aep[i] = get('annual_energy'); + arrayRatedPower[i] = get('system_capacity'); + npv[i] = get('project_return_aftertax_npv'); + capacityFactor[i] = get('capacity_factor'); + capEx[i] = get('total_installed_cost'); + opEx[i] = get('present_value_oandm'); + monthly_energy_bin = get('monthly_energy'); + for (j = 0; j < 12; j++) { + monthly_energy[j][i] = monthly_energy_bin[j]; + } + analysis_period = get('analysis_period'); + if (config[1] == "Single Owner" || config[1] == "Merchant Plant" || config[1] == "All Equity Partnership Flip" || config[1] == "Leveraged Partnership Flip" || config[1] == "Community Solar") { + + annual_cashflow_bin = get('cf_project_return_aftertax'); + } + else if (config[1] == "Residential" || config[1] == "Commercial") { + annual_cashflow_bin = get('cf_after_tax_cash_flow'); + } + else { + annual_cashflow_bin = get('cf_tax_investor_aftertax'); + } + for (j = 0; j < analysis_period+1; j++) { + annual_cashflow[j][i] = annual_cashflow_bin[j]; + } + for (j = analysis_period + 1; j < 40; j++) { + annual_cashflow[j][i] = 0; + } + + + if (config[1] == "Commercial" || config[1] == "Residential" || config[1] == "Third Party" || config[1] == "Host Developer") { + irr_bill[i] = get('savings_year1'); + irr_bill_string = "Net savings with system"; + irr_bill_table[i] = sprintf("$%.1f",irr_bill[i]); + } + else { + irr_bill[i] = get('project_return_aftertax_irr'); + irr_bill_string = "Internal rate of return"; + irr_bill_table[i] = sprintf("%.1f%",irr_bill[i]); + } +} +outln(batt_annual_charge_grid); +outln(batt_annual_charge_sys); +outln(batt_charge_sys); +outln(batt_charge_grid); + +//outln(lcoe); +//outln(aep); +//outln(capEx); +//outln(opEx); +//outln(arrayRatedPower); +//outln(structure); +//outln(pto); +//outln(foundation); +//outln(development); +//outln(engmanag); +//outln(commissioning); +//outln(access); +//outln(otherinfras); +//outln(projectContingency); +//outln(reserveAccounts); +//outln(financial); +//outln(insurance); +//outln(operations); +//outln(maintenance); + +//get cost in dollar per kw +capexKw = alloc(0,num_cases); +opexKw = alloc(0,num_cases); + +//get cost in dollar per kw +for (i=0; i' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[3]+''+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[3]) +' /kWh'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[3]) +' kWh'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[3]) +'% '+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[3]) +' '+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[3]) +' '+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[3]) +' '+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[3]) +' %'+ sprintf("%.1f",irr_bill[2]) +' %'+ sprintf("%.1f",irr_bill[1]) +' %'+ sprintf("%.1f",irr_bill[0]) +' %
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==3) +{ +reportCode = +'' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[2]) +' '+ sprintf("%.1f",irr_bill[1]) +' '+ sprintf("%.1f",irr_bill[0]) +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==2) +{ + +//outln(lcoe[baselineCase]-lcoe[advancedCase]); +//outln(capexLcoeChange); +//outln(opexLcoeChange); +//outln(aepLcoeChange); +//outln(totalLcoeChange); +//outln('baseline case = '+baselineCase); +//outln('baseline= '+cases[baselineCase]); +//outln('advanced case='+cases[advancedCase]); +reportCode = +'' +'' + 'SAM ME Wave Energy Case Comparison Report' + '' + +'' + +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ irr_bill_table[1] +' '+ irr_bill_table[0] +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; + +} +outln(reportCode); +report = tempfile('html'); //specify a temporary location to save the plot + +ok = write_text_file(report, reportCode); +if (!ok) + { + msgbox('Report rendering failed.'); + exit; + } +browse(report); + +msgbox('Please save the report opened in your browser as a PDF.'); + +//// Delete temporary chart file + +remove_file(report); + + + + + + + + diff --git a/deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk b/deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk new file mode 100644 index 0000000000..8d22a978e7 --- /dev/null +++ b/deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk @@ -0,0 +1,951 @@ +/*@ +This macro allows you to compare multiple PV Battery cases. +This may be helpful for modeling a variety of scenarios, including: +
    +
  • Model a baseline system in contrast with an alternate system. +
  • Compare systems with different PV or battery configurations. +
  • Compare systems located at different resource locations. +
+ +Instructions: +
    +
  1. Create the cases that you wish to compare. +
  2. Define the PV module, inverter, system design, battery system, losses, system cost, and financial parameters for all the created cases. +
  3. Simulate all the cases. +
  4. Open the PV Battery Compare Cases Macro and select a simulation option from the list. +
      +
    • You may choose all of the cases in the existing project to be compared, OR +
    • You may choose which cases to compare by typing their names into the input box, separated by ONLY a comma (no space). +
    +
  5. Click 'Run macro' at the top of the screen. +
  6. When prompted, confirm the cases that will be compared. +
  7. When the macro simulation is complete, view the results in your browser. +
+ +@*/ +//Macro user interface widgets +//@ name=mode;type=combo;label=Choose an option;value=1) Compare all cases,2) Compare only the cases listed below;sel=0 +//@ name=cases;type=text;label=List cases for Option 2 (comma-separated);value= + + +//Check that this macro was run from within a case +if ( typeof(macro) == 'unknown' ) { + msgbox('This macro must be run from within a case.'); + exit; +} + +//Determine available cases +cases = list_cases(); +num_cases = #cases; + +//if 'Select cases' is enabled, parse the input to get the list of cases that should be compared +if (macro.mode == '2) Compare only the cases listed below') +{ + input_cases = split(macro.cases, ','); //delimited with commas + for (i=0; i<#input_cases; i++) //check each input case + { + match = false; //a match has not yet been found + for (j=0; j 4) +{ + msgbox('This macro requires 4 or less cases.' + + ' Check your inputs and try again.'); + exit; +} + + +//outln('Cases: ' + cases); +//outln('Number of cases: ' + num_cases); +//outln(cases[3]); +fin = alloc(0, num_cases); +lcoe = alloc(0,num_cases); +lcos = alloc(0, num_cases); +aep = alloc(0,num_cases); +arrayRatedPower = alloc(0,num_cases); +npv = alloc(0,num_cases); +capacityFactor = alloc(0,num_cases); +capEx = alloc(0,num_cases); +opEx = alloc(0,num_cases); +aep_battery = alloc(0, num_cases); +aep_system = alloc(0, num_cases); +batt_charge_sys = alloc(0, num_cases); +batt_charge_grid = alloc(0, num_cases); +dispatch_choice = alloc(0, num_cases); +monthly_energy = alloc(12, num_cases); +annual_cashflow = alloc(40, num_cases); +monthly_bill = alloc(12, num_cases); +irr_bill = alloc(0, num_cases); +irr_bill_table = alloc(0, num_cases); +batt_annual_charge_grid = []; +batt_annual_charge_sys = []; +annual_cashflow_bin = []; + +for (i=0; i 0 && fin[i-1] != fin[i]) { + msgbox('The macro can only compare cases with the same financial model.'); + exit; + } + + if (config[1] == 'LCOE Calculator' || config[1] == "None") + + { + + msgbox('The PV report macro does not work with the LCOE Calculator financial model or with No Financial model.'); + + exit; + + } + + if (config[1] == 'LCOE Calculator') { + lcoe[i] = get('lcoe_fcr'); + } + else { + lcoe[i] = get('lcoe_nom'); + } + lcos[i] = get('lcos_nom'); + aep[i] = get('annual_energy'); + aep_system[i] = aep[i]; + arrayRatedPower[i] = get('system_capacity'); + npv[i] = get('project_return_aftertax_npv'); + capacityFactor[i] = get('capacity_factor'); + capEx[i] = get('total_installed_cost'); + opEx[i] = get('present_value_oandm'); + monthly_energy_bin = get('monthly_energy'); + for (j = 0; j < 12; j++) { + monthly_energy[j][i] = monthly_energy_bin[j]; + } + analysis_period = get('analysis_period'); + if (config[1] == "Single Owner" || config[1] == "Merchant Plant" || config[1] == "All Equity Partnership Flip" || config[1] == "Leveraged Partnership Flip" || config[1] == "Community Solar") { + + annual_cashflow_bin = get('cf_project_return_aftertax'); + } + else if (config[1] == "Residential" || config[1] == "Commercial") { + annual_cashflow_bin = get('cf_after_tax_cash_flow'); + } + else { + annual_cashflow_bin = get('cf_tax_investor_aftertax'); + } + for (j = 0; j < analysis_period+1; j++) { + annual_cashflow[j][i] = annual_cashflow_bin[j]; + } + for (j = analysis_period + 1; j < 40; j++) { + annual_cashflow[j][i] = 0; + } + + + if (config[1] == "Commercial" || config[1] == "Residential" || config[1] == "Third Party" || config[1] == "Host Developer") { + irr_bill[i] = get('savings_year1'); + irr_bill_string = "Net savings with system"; + irr_bill_table[i] = sprintf("$%.1f",irr_bill[i]); + } + else { + irr_bill[i] = get('project_return_aftertax_irr'); + irr_bill_string = "Internal rate of return"; + irr_bill_table[i] = sprintf("%.1f%",irr_bill[i]); + } +} +outln(batt_annual_charge_grid); +outln(batt_annual_charge_sys); +outln(batt_charge_sys); +outln(batt_charge_grid); + +//outln(lcoe); +//outln(aep); +//outln(capEx); +//outln(opEx); +//outln(arrayRatedPower); +//outln(structure); +//outln(pto); +//outln(foundation); +//outln(development); +//outln(engmanag); +//outln(commissioning); +//outln(access); +//outln(otherinfras); +//outln(projectContingency); +//outln(reserveAccounts); +//outln(financial); +//outln(insurance); +//outln(operations); +//outln(maintenance); + +//get cost in dollar per kw +capexKw = alloc(0,num_cases); +opexKw = alloc(0,num_cases); + +//get cost in dollar per kw +for (i=0; i' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[3]+''+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[3]) +' /kWh'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[3]) +' kWh'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[3]) +'% '+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[3]) +' '+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[3]) +' '+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[3]) +' '+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[3]) +' %'+ sprintf("%.1f",irr_bill[2]) +' %'+ sprintf("%.1f",irr_bill[1]) +' %'+ sprintf("%.1f",irr_bill[0]) +' %
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==3) +{ +reportCode = +'' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[2]) +' '+ sprintf("%.1f",irr_bill[1]) +' '+ sprintf("%.1f",irr_bill[0]) +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==2) +{ + +//outln(lcoe[baselineCase]-lcoe[advancedCase]); +//outln(capexLcoeChange); +//outln(opexLcoeChange); +//outln(aepLcoeChange); +//outln(totalLcoeChange); +//outln('baseline case = '+baselineCase); +//outln('baseline= '+cases[baselineCase]); +//outln('advanced case='+cases[advancedCase]); +reportCode = +'' +'' + 'SAM ME Wave Energy Case Comparison Report' + '' + +'' + +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ irr_bill_table[1] +' '+ irr_bill_table[0] +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; + +} +outln(reportCode); +report = tempfile('html'); //specify a temporary location to save the plot + +ok = write_text_file(report, reportCode); +if (!ok) + { + msgbox('Report rendering failed.'); + exit; + } +browse(report); + +msgbox('Please save the report opened in your browser as a PDF.'); + +//// Delete temporary chart file + +remove_file(report); + + + + + + + + diff --git a/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk index 7e3104fc61..8cdfa7d508 100644 --- a/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk +++ b/deploy/runtime/macros/PV Battery/PV Battery Compare Cases.lk @@ -436,6 +436,72 @@ reportCode = 'Plotly.newPlot("monthlyPlot", monthlyData, layout);' '' + + '
' + '
' + '
' + + '' + + '
' '' @@ -629,6 +695,60 @@ reportCode = 'Plotly.newPlot("monthlyPlot", monthlyData, layout);' '' + + '
' + '
' + '
' + + '' '
' '' From ca666740e273c60f629ed7fed895a777d4a0e182 Mon Sep 17 00:00:00 2001 From: Matt Prilliman <54449384+mjprilliman@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:25:51 -0600 Subject: [PATCH 05/15] Compare cases should work for all base technologies; battery has separate script --- .../macros/Flat Plate PV/Compare Cases.lk | 966 ++++++++++++++++++ .../macros/Flat Plate PV/PV Compare Cases.lk | 27 +- .../macros/Wind Power/PV Compare Cases.lk | 947 +++++++++++++++++ 3 files changed, 1934 insertions(+), 6 deletions(-) create mode 100644 deploy/runtime/macros/Flat Plate PV/Compare Cases.lk create mode 100644 deploy/runtime/macros/Wind Power/PV Compare Cases.lk diff --git a/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk b/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk new file mode 100644 index 0000000000..fc5d88cb55 --- /dev/null +++ b/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk @@ -0,0 +1,966 @@ +/*@ +This macro allows you to compare multiple PV Battery cases. +This may be helpful for modeling a variety of scenarios, including: +
    +
  • Model a baseline system in contrast with an alternate system. +
  • Compare systems with different PV or battery configurations. +
  • Compare systems located at different resource locations. +
+ +Instructions: +
    +
  1. Create the cases that you wish to compare. +
  2. Define the PV module, inverter, system design, battery system, losses, system cost, and financial parameters for all the created cases. +
  3. Simulate all the cases. +
  4. Open the PV Battery Compare Cases Macro and select a simulation option from the list. +
      +
    • You may choose all of the cases in the existing project to be compared, OR +
    • You may choose which cases to compare by typing their names into the input box, separated by ONLY a comma (no space). +
    +
  5. Click 'Run macro' at the top of the screen. +
  6. When prompted, confirm the cases that will be compared. +
  7. When the macro simulation is complete, view the results in your browser. +
+ +@*/ +//Macro user interface widgets +//@ name=mode;type=combo;label=Choose an option;value=1) Compare all cases,2) Compare only the cases listed below;sel=0 +//@ name=cases;type=text;label=List cases for Option 2 (comma-separated);value= + + +//Check that this macro was run from within a case +if ( typeof(macro) == 'unknown' ) { + msgbox('This macro must be run from within a case.'); + exit; +} + +//Determine available cases +cases = list_cases(); +num_cases = #cases; + +//if 'Select cases' is enabled, parse the input to get the list of cases that should be compared +if (macro.mode == '2) Compare only the cases listed below') +{ + input_cases = split(macro.cases, ','); //delimited with commas + for (i=0; i<#input_cases; i++) //check each input case + { + match = false; //a match has not yet been found + for (j=0; j 4) +{ + msgbox('This macro requires 4 or less cases.' + + ' Check your inputs and try again.'); + exit; +} + + +//outln('Cases: ' + cases); +//outln('Number of cases: ' + num_cases); +//outln(cases[3]); +tech = alloc(0, num_cases); +fin = alloc(0, num_cases); +lcoe = alloc(0,num_cases); +lcos = alloc(0, num_cases); +aep = alloc(0,num_cases); +arrayRatedPower = alloc(0,num_cases); +npv = alloc(0,num_cases); +capacityFactor = alloc(0,num_cases); +capEx = alloc(0,num_cases); +opEx = alloc(0,num_cases); +aep_battery = alloc(0, num_cases); +aep_system = alloc(0, num_cases); +batt_charge_sys = alloc(0, num_cases); +batt_charge_grid = alloc(0, num_cases); +dispatch_choice = alloc(0, num_cases); +monthly_energy = alloc(12, num_cases); +annual_cashflow = alloc(40, num_cases); +monthly_bill = alloc(12, num_cases); +irr_bill = alloc(0, num_cases); +irr_bill_table = alloc(0, num_cases); +batt_annual_charge_grid = []; +batt_annual_charge_sys = []; +annual_cashflow_bin = []; + +for (i=0; i 0 && fin[i-1] != fin[i]) { + msgbox('The macro can only compare cases with the same financial model.'); + exit; + } + + if (config[1] == 'LCOE Calculator' || config[1] == "None") + + { + + msgbox('The PV report macro does not work with the LCOE Calculator financial model or with No Financial model.'); + + exit; + + } + + tech[i] = config[0]; + lcoe[i] = get('lcoe_nom'); + lcos[i] = get('lcos_nom'); + aep[i] = get('annual_energy'); + aep_system[i] = aep[i]; + arrayRatedPower[i] = get('system_capacity'); + npv[i] = get('project_return_aftertax_npv'); + capacityFactor[i] = get('capacity_factor'); + capEx[i] = get('total_installed_cost'); + opEx[i] = get('present_value_oandm'); + monthly_energy_bin = get('monthly_energy'); + for (j = 0; j < 12; j++) { + monthly_energy[j][i] = monthly_energy_bin[j]; + } + analysis_period = get('analysis_period'); + if (config[1] == "Single Owner" || config[1] == "Merchant Plant" || config[1] == "All Equity Partnership Flip" || config[1] == "Leveraged Partnership Flip" || config[1] == "Community Solar") { + + annual_cashflow_bin = get('cf_project_return_aftertax'); + } + else if (config[1] == "Residential" || config[1] == "Commercial") { + annual_cashflow_bin = get('cf_after_tax_cash_flow'); + } + else { + annual_cashflow_bin = get('cf_tax_investor_aftertax'); + } + for (j = 0; j < analysis_period+1; j++) { + annual_cashflow[j][i] = annual_cashflow_bin[j]; + } + for (j = analysis_period + 1; j < 40; j++) { + annual_cashflow[j][i] = 0; + } + + + if (config[1] == "Commercial" || config[1] == "Residential" || config[1] == "Third Party" || config[1] == "Host Developer") { + irr_bill[i] = get('savings_year1'); + irr_bill_string = "Net savings with system"; + irr_bill_table[i] = sprintf("$%.1f",irr_bill[i]); + } + else { + irr_bill[i] = get('project_return_aftertax_irr'); + irr_bill_string = "Internal rate of return"; + irr_bill_table[i] = sprintf("%.1f%",irr_bill[i]); + } +} +outln(batt_annual_charge_grid); +outln(batt_annual_charge_sys); +outln(batt_charge_sys); +outln(batt_charge_grid); + +//outln(lcoe); +//outln(aep); +//outln(capEx); +//outln(opEx); +//outln(arrayRatedPower); +//outln(structure); +//outln(pto); +//outln(foundation); +//outln(development); +//outln(engmanag); +//outln(commissioning); +//outln(access); +//outln(otherinfras); +//outln(projectContingency); +//outln(reserveAccounts); +//outln(financial); +//outln(insurance); +//outln(operations); +//outln(maintenance); + +//get cost in dollar per kw +capexKw = alloc(0,num_cases); +opexKw = alloc(0,num_cases); + +//get cost in dollar per kw +for (i=0; i' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[3]+''+cases[2]+''+cases[1]+''+cases[0]+'
Technology'+ tech[3] +''+ tech[2] +''+ tech[1] +''+ tech[0] +'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[3]) +' /kWh'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[3]) +' kWh'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[3]) +'% '+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[3]) +' '+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[3]) +' '+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[3]) +' '+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[3]) +' %'+ sprintf("%.1f",irr_bill[2]) +' %'+ sprintf("%.1f",irr_bill[1]) +' %'+ sprintf("%.1f",irr_bill[0]) +' %
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==3) +{ +reportCode = +'' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[2]+''+cases[1]+''+cases[0]+'
Technology'+ tech[2] +''+ tech[1] +''+ tech[0] +'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[2]) +' '+ sprintf("%.1f",irr_bill[1]) +' '+ sprintf("%.1f",irr_bill[0]) +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==2) +{ + +//outln(lcoe[baselineCase]-lcoe[advancedCase]); +//outln(capexLcoeChange); +//outln(opexLcoeChange); +//outln(aepLcoeChange); +//outln(totalLcoeChange); +//outln('baseline case = '+baselineCase); +//outln('baseline= '+cases[baselineCase]); +//outln('advanced case='+cases[advancedCase]); +reportCode = +'' +'' + 'SAM ME Wave Energy Case Comparison Report' + '' + +'' + +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[1]+''+cases[0]+'
Technology'+ tech[1] +''+ tech[0] +'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ irr_bill_table[1] +' '+ irr_bill_table[0] +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; + +} +outln(reportCode); +report = tempfile('html'); //specify a temporary location to save the plot + +ok = write_text_file(report, reportCode); +if (!ok) + { + msgbox('Report rendering failed.'); + exit; + } +browse(report); + +msgbox('Please save the report opened in your browser as a PDF.'); + +//// Delete temporary chart file + +remove_file(report); + + + + + + + + diff --git a/deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk b/deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk index 8d22a978e7..fc5d88cb55 100644 --- a/deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk +++ b/deploy/runtime/macros/Flat Plate PV/PV Compare Cases.lk @@ -84,6 +84,7 @@ if (num_cases > 4) //outln('Cases: ' + cases); //outln('Number of cases: ' + num_cases); //outln(cases[3]); +tech = alloc(0, num_cases); fin = alloc(0, num_cases); lcoe = alloc(0,num_cases); lcos = alloc(0, num_cases); @@ -127,12 +128,8 @@ for (i=0; i' ''+cases[0]+'' '' + '' + 'Technology' + ''+ tech[3] +'' + ''+ tech[2] +'' + ''+ tech[1] +'' + ''+ tech[0] +'' + '' '' 'Levelized Cost of Energy' ''+ sprintf("$%.2f",lcoe[3]) +' /kWh' @@ -519,6 +523,12 @@ reportCode = ''+cases[1]+'' ''+cases[0]+'' '' + '' + 'Technology' + ''+ tech[2] +'' + ''+ tech[1] +'' + ''+ tech[0] +'' + '' '' 'Levelized Cost of Energy' ''+ sprintf("$%.2f",lcoe[2]) +' /kWh' @@ -756,6 +766,11 @@ reportCode = ''+cases[1]+'' ''+cases[0]+'' '' + '' + 'Technology' + ''+ tech[1] +'' + ''+ tech[0] +'' + '' '' 'Levelized Cost of Energy' ''+ sprintf("$%.2f",lcoe[1]) +' /kWh' diff --git a/deploy/runtime/macros/Wind Power/PV Compare Cases.lk b/deploy/runtime/macros/Wind Power/PV Compare Cases.lk new file mode 100644 index 0000000000..46284733f7 --- /dev/null +++ b/deploy/runtime/macros/Wind Power/PV Compare Cases.lk @@ -0,0 +1,947 @@ +/*@ +This macro allows you to compare multiple PV Battery cases. +This may be helpful for modeling a variety of scenarios, including: +
    +
  • Model a baseline system in contrast with an alternate system. +
  • Compare systems with different PV or battery configurations. +
  • Compare systems located at different resource locations. +
+ +Instructions: +
    +
  1. Create the cases that you wish to compare. +
  2. Define the PV module, inverter, system design, battery system, losses, system cost, and financial parameters for all the created cases. +
  3. Simulate all the cases. +
  4. Open the PV Battery Compare Cases Macro and select a simulation option from the list. +
      +
    • You may choose all of the cases in the existing project to be compared, OR +
    • You may choose which cases to compare by typing their names into the input box, separated by ONLY a comma (no space). +
    +
  5. Click 'Run macro' at the top of the screen. +
  6. When prompted, confirm the cases that will be compared. +
  7. When the macro simulation is complete, view the results in your browser. +
+ +@*/ +//Macro user interface widgets +//@ name=mode;type=combo;label=Choose an option;value=1) Compare all cases,2) Compare only the cases listed below;sel=0 +//@ name=cases;type=text;label=List cases for Option 2 (comma-separated);value= + + +//Check that this macro was run from within a case +if ( typeof(macro) == 'unknown' ) { + msgbox('This macro must be run from within a case.'); + exit; +} + +//Determine available cases +cases = list_cases(); +num_cases = #cases; + +//if 'Select cases' is enabled, parse the input to get the list of cases that should be compared +if (macro.mode == '2) Compare only the cases listed below') +{ + input_cases = split(macro.cases, ','); //delimited with commas + for (i=0; i<#input_cases; i++) //check each input case + { + match = false; //a match has not yet been found + for (j=0; j 4) +{ + msgbox('This macro requires 4 or less cases.' + + ' Check your inputs and try again.'); + exit; +} + + +//outln('Cases: ' + cases); +//outln('Number of cases: ' + num_cases); +//outln(cases[3]); +fin = alloc(0, num_cases); +lcoe = alloc(0,num_cases); +lcos = alloc(0, num_cases); +aep = alloc(0,num_cases); +arrayRatedPower = alloc(0,num_cases); +npv = alloc(0,num_cases); +capacityFactor = alloc(0,num_cases); +capEx = alloc(0,num_cases); +opEx = alloc(0,num_cases); +aep_battery = alloc(0, num_cases); +aep_system = alloc(0, num_cases); +batt_charge_sys = alloc(0, num_cases); +batt_charge_grid = alloc(0, num_cases); +dispatch_choice = alloc(0, num_cases); +monthly_energy = alloc(12, num_cases); +annual_cashflow = alloc(40, num_cases); +monthly_bill = alloc(12, num_cases); +irr_bill = alloc(0, num_cases); +irr_bill_table = alloc(0, num_cases); +batt_annual_charge_grid = []; +batt_annual_charge_sys = []; +annual_cashflow_bin = []; + +for (i=0; i 0 && fin[i-1] != fin[i]) { + msgbox('The macro can only compare cases with the same financial model.'); + exit; + } + + if (config[1] == 'LCOE Calculator' || config[1] == "None") + + { + + msgbox('The PV report macro does not work with the LCOE Calculator financial model or with No Financial model.'); + + exit; + + } + + + lcoe[i] = get('lcoe_nom'); + lcos[i] = get('lcos_nom'); + aep[i] = get('annual_energy'); + aep_system[i] = aep[i]; + arrayRatedPower[i] = get('system_capacity'); + npv[i] = get('project_return_aftertax_npv'); + capacityFactor[i] = get('capacity_factor'); + capEx[i] = get('total_installed_cost'); + opEx[i] = get('present_value_oandm'); + monthly_energy_bin = get('monthly_energy'); + for (j = 0; j < 12; j++) { + monthly_energy[j][i] = monthly_energy_bin[j]; + } + analysis_period = get('analysis_period'); + if (config[1] == "Single Owner" || config[1] == "Merchant Plant" || config[1] == "All Equity Partnership Flip" || config[1] == "Leveraged Partnership Flip" || config[1] == "Community Solar") { + + annual_cashflow_bin = get('cf_project_return_aftertax'); + } + else if (config[1] == "Residential" || config[1] == "Commercial") { + annual_cashflow_bin = get('cf_after_tax_cash_flow'); + } + else { + annual_cashflow_bin = get('cf_tax_investor_aftertax'); + } + for (j = 0; j < analysis_period+1; j++) { + annual_cashflow[j][i] = annual_cashflow_bin[j]; + } + for (j = analysis_period + 1; j < 40; j++) { + annual_cashflow[j][i] = 0; + } + + + if (config[1] == "Commercial" || config[1] == "Residential" || config[1] == "Third Party" || config[1] == "Host Developer") { + irr_bill[i] = get('savings_year1'); + irr_bill_string = "Net savings with system"; + irr_bill_table[i] = sprintf("$%.1f",irr_bill[i]); + } + else { + irr_bill[i] = get('project_return_aftertax_irr'); + irr_bill_string = "Internal rate of return"; + irr_bill_table[i] = sprintf("%.1f%",irr_bill[i]); + } +} +outln(batt_annual_charge_grid); +outln(batt_annual_charge_sys); +outln(batt_charge_sys); +outln(batt_charge_grid); + +//outln(lcoe); +//outln(aep); +//outln(capEx); +//outln(opEx); +//outln(arrayRatedPower); +//outln(structure); +//outln(pto); +//outln(foundation); +//outln(development); +//outln(engmanag); +//outln(commissioning); +//outln(access); +//outln(otherinfras); +//outln(projectContingency); +//outln(reserveAccounts); +//outln(financial); +//outln(insurance); +//outln(operations); +//outln(maintenance); + +//get cost in dollar per kw +capexKw = alloc(0,num_cases); +opexKw = alloc(0,num_cases); + +//get cost in dollar per kw +for (i=0; i' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[3]+''+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[3]) +' /kWh'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[3]) +' kWh'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[3]) +'% '+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[3]) +' '+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[3]) +' '+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[3]) +' '+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[3]) +' %'+ sprintf("%.1f",irr_bill[2]) +' %'+ sprintf("%.1f",irr_bill[1]) +' %'+ sprintf("%.1f",irr_bill[0]) +' %
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==3) +{ +reportCode = +'' +'' + '' + + '' + 'SAM ME Wave Energy Case Comparison Report' +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[2]+''+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[2]) +' /kWh'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[2]) +' kWh'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[2]) +'% '+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[2]) +' '+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[2]) +' '+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[2]) +' '+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ sprintf("%.1f",irr_bill[2]) +' '+ sprintf("%.1f",irr_bill[1]) +' '+ sprintf("%.1f",irr_bill[0]) +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + +'
' +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; +} + +if (num_cases ==2) +{ + +//outln(lcoe[baselineCase]-lcoe[advancedCase]); +//outln(capexLcoeChange); +//outln(opexLcoeChange); +//outln(aepLcoeChange); +//outln(totalLcoeChange); +//outln('baseline case = '+baselineCase); +//outln('baseline= '+cases[baselineCase]); +//outln('advanced case='+cases[advancedCase]); +reportCode = +'' +'' + 'SAM ME Wave Energy Case Comparison Report' + '' + +'' + +'' + +'' + +'
' + '

Case Comparison Summary

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
'+cases[1]+''+cases[0]+'
Levelized Cost of Energy'+ sprintf("$%.2f",lcoe[1]) +' /kWh'+ sprintf("$%.2f",lcoe[0]) +' /kWh
Annual Energy Production'+ sprintf("%,",aep[1]) +' kWh'+ sprintf("%,",aep[0]) +' kWh
Capacity Factor'+ sprintf("%.1f",capacityFactor[1]) +'% '+ sprintf("%.1f",capacityFactor[0]) +'%
Total Installed Cost'+ sprintf("$%,",capEx[1]) +' '+ sprintf("$%,",capEx[0]) +'
Operational Expenditures (present value)'+ sprintf("$%,",opEx[1]) +' '+ sprintf("$%,",opEx[0]) +'
Net Present Value'+ sprintf("$%,",npv[1]) +' '+ sprintf("$%,",npv[0]) +'
'+sprintf(irr_bill_string)+' '+ irr_bill_table[1] +' '+ irr_bill_table[0] +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'' +'
' + '

This report was generated using the System Advisor Model testMacro on:

' + '

' + + '' +'
' + +''; + +} +outln(reportCode); +report = tempfile('html'); //specify a temporary location to save the plot + +ok = write_text_file(report, reportCode); +if (!ok) + { + msgbox('Report rendering failed.'); + exit; + } +browse(report); + +msgbox('Please save the report opened in your browser as a PDF.'); + +//// Delete temporary chart file + +remove_file(report); + + + + + + + + From 5359940571e8ee59a5abb8edaef7a31f6b7e7004 Mon Sep 17 00:00:00 2001 From: Matt Prilliman <54449384+mjprilliman@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:58:37 -0500 Subject: [PATCH 06/15] Label text updates --- .../runtime/macros/Flat Plate PV/Compare Cases.lk | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk b/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk index fc5d88cb55..281b8d30d9 100644 --- a/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk +++ b/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk @@ -1,18 +1,18 @@ /*@ -This macro allows you to compare multiple PV Battery cases. +This macro allows you to compare multiple renewable energy system cases. This may be helpful for modeling a variety of scenarios, including:
  • Model a baseline system in contrast with an alternate system. -
  • Compare systems with different PV or battery configurations. +
  • Compare systems with different technologies or configurations for the same financial model.
  • Compare systems located at different resource locations.
Instructions:
    -
  1. Create the cases that you wish to compare. -
  2. Define the PV module, inverter, system design, battery system, losses, system cost, and financial parameters for all the created cases. +
  3. Create the cases that you wish to compare (this macro will not evaluate battery performance). +
  4. Define the resource, system specifications, losses, system cost, and financial parameters for all the created cases.
  5. Simulate all the cases. -
  6. Open the PV Battery Compare Cases Macro and select a simulation option from the list. +
  7. Open the Compare Cases Macro and select a simulation option from the list.
    • You may choose all of the cases in the existing project to be compared, OR
    • You may choose which cases to compare by typing their names into the input box, separated by ONLY a comma (no space). @@ -172,10 +172,6 @@ for (i=0; i Date: Fri, 25 Oct 2024 09:14:42 -0500 Subject: [PATCH 07/15] Html graphing edits --- .../macros/Flat Plate PV/Compare Cases.lk | 143 +++++++-------- .../Flat Plate PV/PV Battery Compare Cases.lk | 170 ++++++++---------- 2 files changed, 151 insertions(+), 162 deletions(-) diff --git a/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk b/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk index 281b8d30d9..0f9e9b1040 100644 --- a/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk +++ b/deploy/runtime/macros/Flat Plate PV/Compare Cases.lk @@ -160,7 +160,7 @@ for (i=0; i' '' - ''+cases[3]+'' - ''+cases[2]+'' - ''+cases[1]+'' ''+cases[0]+'' + ''+cases[1]+'' + ''+cases[2]+'' + ''+cases[3]+'' '' '' 'Technology' - ''+ tech[3] +'' - ''+ tech[2] +'' - ''+ tech[1] +'' ''+ tech[0] +'' + ''+ tech[1] +'' + ''+ tech[2] +'' + ''+ tech[3] +'' '' '' 'Levelized Cost of Energy' - ''+ sprintf("$%.2f",lcoe[3]) +' /kWh' - ''+ sprintf("$%.2f",lcoe[2]) +' /kWh' - ''+ sprintf("$%.2f",lcoe[1]) +' /kWh' ''+ sprintf("$%.2f",lcoe[0]) +' /kWh' + ''+ sprintf("$%.2f",lcoe[1]) +' /kWh' + ''+ sprintf("$%.2f",lcoe[2]) +' /kWh' + ''+ sprintf("$%.2f",lcoe[3]) +' /kWh' '' '' 'Annual Energy Production' - ''+ sprintf("%,",aep[3]) +' kWh' - ''+ sprintf("%,",aep[2]) +' kWh' - ''+ sprintf("%,",aep[1]) +' kWh' ''+ sprintf("%,",aep[0]) +' kWh' + ''+ sprintf("%,",aep[1]) +' kWh' + ''+ sprintf("%,",aep[2]) +' kWh' + ''+ sprintf("%,",aep[3]) +' kWh' '' '' 'Capacity Factor' - ''+ sprintf("%.1f",capacityFactor[3]) +'% ' - ''+ sprintf("%.1f",capacityFactor[2]) +'% ' - ''+ sprintf("%.1f",capacityFactor[1]) +'% ' - ''+ sprintf("%.1f",capacityFactor[0]) +'% ' + ''+ sprintf("%.1f",capacityFactor[0]) +' % ' + ''+ sprintf("%.1f",capacityFactor[1]) +' % ' + ''+ sprintf("%.1f",capacityFactor[2]) +' % ' + ''+ sprintf("%.1f",capacityFactor[3]) +' % ' '' '' 'Total Installed Cost' - ''+ sprintf("$%,",capEx[3]) +' ' - ''+ sprintf("$%,",capEx[2]) +' ' - ''+ sprintf("$%,",capEx[1]) +' ' - ''+ sprintf("$%,",capEx[0]) +' ' + ''+ sprintf("$%.2f,",capEx[0]) +' ' + ''+ sprintf("$%.2f,",capEx[1]) +' ' + ''+ sprintf("$%.2f,",capEx[2]) +' ' + ''+ sprintf("$%.2f,",capEx[3]) +' ' '' '' 'Operational Expenditures (present value)' - ''+ sprintf("$%,",opEx[3]) +' ' - ''+ sprintf("$%,",opEx[2]) +' ' - ''+ sprintf("$%,",opEx[1]) +' ' - ''+ sprintf("$%,",opEx[0]) +' ' + ''+ sprintf("$%.2f,",opEx[0]) +' ' + ''+ sprintf("$%.2f,",opEx[1]) +' ' + ''+ sprintf("$%.2f,",opEx[2]) +' ' + ''+ sprintf("$%.2f,",opEx[3]) +' ' '' '' 'Net Present Value' - ''+ sprintf("$%,",npv[3]) +' ' - ''+ sprintf("$%,",npv[2]) +' ' - ''+ sprintf("$%,",npv[1]) +' ' - ''+ sprintf("$%,",npv[0]) +' ' + ''+ sprintf("$%.2f,",npv[0]) +' ' + ''+ sprintf("$%.2f,",npv[1]) +' ' + ''+ sprintf("$%.2f,",npv[2]) +' ' + ''+ sprintf("$%.2f,",npv[3]) +' ' '' '' - ''+sprintf(irr_bill_string)+' ' - ''+ sprintf("%.1f",irr_bill[3]) +' %' - ''+ sprintf("%.1f",irr_bill[2]) +' %' - ''+ sprintf("%.1f",irr_bill[1]) +' %' + 'Internal Rate of Return' ''+ sprintf("%.1f",irr_bill[0]) +' %' + ''+ sprintf("%.1f",irr_bill[1]) +' %' + ''+ sprintf("%.1f",irr_bill[2]) +' %' + ''+ sprintf("%.1f",irr_bill[3]) +' %' '' '' @@ -322,14 +322,17 @@ reportCode = '' - '
      ' - - '' '' '