Enhance SAM with features tailored to your specific needs! We collaborate with companies, universities, and organizations to privately fund new capabilities or analyses. Your investment drives innovation while benefiting the broader energy community. Email us to learn more.

Set() is not correctly setting values in a CEC Performance Model

  • Andrew
  • Topic Author
More
02 Oct 2026 10:37 #14607 by Andrew
Hello,

I have recently been running into issues with the set(string:name, variant:value):none function. I keep the values I want to input in an array and then go through the array to set each value as shown below.

set_module = define(module)
{    
    outln(module);
    set('6par_isc',module[0]);
    set('6par_is_bifacial',module[1]);
    set('6par_bvoc_units',module[2]);
    set('6par_imp',module[3]);
    set('6par_transient_thermal_model_unit_mass',module[4]);
    set('6par_voc',module[5]);
    set('6par_aisc_display',module[6]);
    set('6par_bifaciality',module[7]);
    set('6par_aspect_ratio',module[8]);
    set('6par_aisc_units',module[9]);
    set('6par_gpmp',module[10]);
    set('6par_area',module[11]);
    set('6par_bifacial_ground_clearance_height',module[12]);
    set('6par_bifacial_transmission_factor',module[13]);
    set('6par_bvoc_display',module[14]);
    set('6par_celltech',module[15]);
    set('6par_module_name',module[16]);
    set('6par_mounting',module[17]);
    set('6par_nser',module[18]);
    set('6par_standoff',module[19]);
    set('6par_tnoct',module[20]);
    set('6par_vmp',module[21]);

    return module;
};

However, several inputs end up incorrect on the SAM UI afterwards, including but not limited to (Voc, Isc,  bvoc,). Some could look like rounding errors, but some are definitely not. Shown below is the output from my code where the array is the module array and the values inbetween the before lines are the values read using the get() function in the same order. Are there any recalculations of values when some fields are set?

[ 16.27, 1, 1, 15.23, 11.0919, 49.85, 0.046, 0.8, 2.101, 1, -0.3, 2.7012, 1.524, 0.013, -0.25, 0, Boviet, 0, 132, 6, 45, 42.71 ]
///////before////////
16.15
1
1
15.22
11.0919
49.51
0.04
0.8
2.101
1
-0.29
2.7012
1.524
0.013
-0.24
0
Boviet
0
132
6
45
42.06
///////before////////

Please Log in or Create an account to join the conversation.

  • Paul Gilman
More
02 Oct 2026 11:25 #14608 by Paul Gilman
Hi Andrew,

I assume you are asking about an LK script to use with the Detailed PV model and the "CEC Performance Model with User Entered Specifications" option on the Module page.

Here is a modified version of your script that should work:

<begin>

module = [ 16.27, 1, 1, 15.23, 11.0919, 49.85, 0.046, 0.8, 2.101, 1, -0.3, 2.7012, 1.524, 0.013, -0.25, 0, "Boviet", 0, 132, 6, 45, 42.71 ];

set_module = define(module)
{    
    outln(module);
    set('6par_isc',module[0]);
    set('6par_is_bifacial',module[1]);
    set('6par_bvoc_units',module[2]);
    set('6par_imp',module[3]);
    set('6par_transient_thermal_model_unit_mass',module[4]);
    set('6par_voc',module[5]);
    set('6par_aisc_display',module[6]);
    set('6par_bifaciality',module[7]);
    set('6par_aspect_ratio',module[8]);
    set('6par_aisc_units',module[9]);
    set('6par_gpmp',module[10]);
    set('6par_area',module[11]);
    set('6par_bifacial_ground_clearance_height',module[12]);
    set('6par_bifacial_transmission_factor',module[13]);
    set('6par_bvoc_display',module[14]);
    set('6par_celltech',module[15]);
    set('6par_module_name',module[16]);
    set('6par_mounting',module[17]);
    set('6par_nser',module[18]);
    set('6par_standoff',module[19]);
    set('6par_tnoct',module[20]);
    set('6par_vmp',module[21]);

};

set_module(module);

<end>

If you continue to have trouble, please attach a copy of both your .sam file and .lk script so I can exactly replicate the problem.

Best regards,
Paul.

Please Log in or Create an account to join the conversation.

  • Andrew
  • Topic Author
More
02 Oct 2026 14:55 #14610 by Andrew
Attached is the script I am using and the accompanying csv that provides the module properties. They need to be in the same folder. I am able to condense the script to only the relevant parts if needed, but I think all the relevant parts are in the initial post.

Please Log in or Create an account to join the conversation.

  • Paul Gilman
More
05 Oct 2026 09:59 - 06 Oct 2026 11:02 #14613 by Paul Gilman
Hi Andrew,

It's always helpful to provide minimum reproducible code rather than an entire script.

Luckily, I was able to isolate the problem in your script: The xl_get() function returns values from an Excel file as strings, so you need to convert the values to the correct type before the set() commands.

Because you are reading a CSV text file, you could use the csvread(), or open(), read_line() and close() functions to have more control over the file reading process than working with the "xl_" functions. (Note that the "xl_" functions require OLE automation that is only available on Windows.)

Attached is a script that fixes the problem.

Best regards,
Paul.
Last edit: 06 Oct 2026 11:02 by Paul Gilman.

Please Log in or Create an account to join the conversation.

  • Andrew
  • Topic Author
More
05 Oct 2026 13:57 #14614 by Andrew
Hello Paul,

Thank you for your help and clarifying the convention, will make sure provide minimum reproducible code moving forward.

Sincerely,
Andrew Low

Please Log in or Create an account to join the conversation.

Moderators: Paul Gilman
Powered by Kunena Forum