Macro "Subarray Layout Optimization" Question

2 posts / 0 new
Last post
Macro "Subarray Layout Optimization" Question


I'm simulating a system on SAM for a desired array size of 6362.35 kWdc. If I check the button "Estimate subarray 1 configuration", the resulting system (33 panels in series x 838 in parallel) has a size that I know does not fit in my area, because of the number of strings in parallel.

I found out that the macro "Subarray Layout Optimization" could optimize the layout given my area constraint. However, when I try running it the following error occurs:

Macro did not finish.
[810] referencing unassigned variable:modules_per_string_npv

I cannot seem to find a way to fix this error. Does anyone have a suggestion on how to tackle this?

Thank you,


Paul Gilman

Dear Bruno,

For now the subarray layout optimization macro only works with the Residential and Commercial financial model. It will not work without a financial model because it uses the net present value (NPV) for the optimization.

It also does not work with the PPA financial models (single owner, partnership, leaseback) because of an issue with the variable name that we will fix in the next software update.

In the meantime, if you want to use the macro with a PPA financial model, you can fix it by modifying the macro script:

  1. On the Macro page, click View code at the top right of the window.
  2. Scroll down to Line 500: npv[i][j] = get('npv');
  3. Add the line npv[i][j] = get('project_return_aftertax_npv'); after that line and use forward slashes // to comment out Line 500.
  4. Click Save, and then go back to the Macro page and try running the macro again.

This workaround allows you to change the variable name, so if you run the macro for a Residential or Commercial case, you can comment out the new Line 501 and use the variable assignment on Line 500 instead.

//npv[i][j] = get('npv'); // for Residential and Commercial
npv[i][j] = get('project_return_aftertax_npv'); // for PPA models

Best regards,

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer