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: + + +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. + +
  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] +'
' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + '
' + '
' + '
' + + '' + + + +'' +'' + +''; + +} +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); + + + + + + + +