Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Library Fall 2024 #1913

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37,600 changes: 20,743 additions & 16,857 deletions deploy/libraries/CEC Modules.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Revised 2/23/22

function set_inverter_params()
{

//set('vdcmax_inverter',1500);
//set('inv_ds_mppt_hi',1500);
//set('inv_ds_vdcmax',1500);

pmp = get( 'cec_p_mp_ref' );
voc = get('cec_v_oc_ref');

Expand All @@ -25,12 +30,17 @@ function set_inverter_params()
vmppt_min = floor(voc *0.25);
vdco = round(( vmppt_max + vmppt_min ) / 2);


set('inv_ds_paco',paco);
set('inv_ds_mppt_hi',vmppt_max);
set('inv_ds_mppt_low',vmppt_min);
set('inv_ds_vdcmax',vmppt_max);
set('inv_ds_vdco',vdco);
set('inv_ds_idcmax',ceil(pmp/vmppt_max));
set('inv_ds_mppt_hi',vmppt_max);
set('inv_ds_mppt_low',vmppt_min);

set('vdcmax_inverter',vmppt_max);
set('mppt_hi_inverter', vmppt_max);
set('mppt_low_inverter', vmppt_min);
}

function run()
Expand Down Expand Up @@ -81,4 +91,4 @@ for ( i=1; i<#modules; i++ )

outln('Done.');
csvwrite( f_name(), results );
browse(f_name());
browse(f_name());
Binary file not shown.
24 changes: 16 additions & 8 deletions samples/CEC Module and Inverter Libraries/CEC Modules/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This document explains how to build the SAM CEC module library file from the CEC

2. Go to https://solarequipment.energy.ca.gov/Home/PVModuleList and click the **Download Excel file** link to the working folder.

3. Change the Excel file name with the last CEC update date in the file name `PV_Module_List_Full_Data_ADA-yyyy-m-d.xlsx`.
3. Change the Excel file name with the last CEC update date (from Row 2 in the workbook) in the file name `PV_Module_List_Full_Data_ADA-yyyy-m-d.xlsx`.

### Step 2: Manually process CEC xlsx file

Expand All @@ -30,29 +30,37 @@ This step could be automated in Excel, but this process is a good excuse to do a

5. Delete soft line breaks LF `\n` in header rows so that there is one header row that begins with "Manufacturer" and ends with "Last Update." Show hidden characters in text editor to find single LF in first row. (Note remaining lines use CRLF.) (This step is new after CEC added in-cell linebreaks to some header cells after 3/1/2019.)

5. Search and replace LF followed by comma `\n,` with nothing to remove soft line breaks from columns (assumes Windows CRLF line endings).
5. Search and replace LF followed by comma `\n,` with nothing to remove soft line breaks from columns (assumes Windows CRLF line endings). Repeat until all instances are found.

6. Search and replace comma followed by LF `,\n` with nothing to remove soft line breaks from columns (assumes Windows CRLF line endings). Repeat until all instances are found.

6. Search and replace space followed by LF ` \n` with comma `,` to fix some Excel cells with empty line in cell (see Trina modules).

6. Search and replace space followed by comma space ` ,` with comma `,`.

6. Search and replace comma followed by space `, ` with comma `,`.

5. Search and replace Greek characters in column headings row: alpha, beta, gamma. For example, replace βVoc with betaVoc. Should be one instance of gamma, and two instances each of alpha and beta.

5. Use regular expression option to replace `[^\x00-\x7F]+` with empty string. This removes non-ASCII characters that cause problems in SAM UI (and may cause problems with LK reading data from file).
5. Use regular expression search option to replace `[^\x00-\x7F]+` with empty string. This removes non-ASCII characters that cause problems in SAM UI (and may cause problems with LK reading data from file).

6. Save file and close text editor.
6. Save CSV file and close text editor.

7. Open file in Excel.
7. Open CSV file in Excel.

8. Search and replace all commas `,` with nothing. (Can't do this in text editor because don't want to change column delimiters, only commas in some text fields.)

9. Delete units row, Row 2.

10. Save and close the file.
10. Save and close CSV file.

11. Open CSV file in text editor remove double quotes `"` by replacing them with nothing. (If the file is tab-delimited, replace tabs `\t` with commas `,`.)

12. Save file and close editor.
12. Save CSV file and close editor.

### Step 3: Run LK script to convert worksheet data into SAM library file

1. Start SAM and open the latest version of the Update CEC Modules script (`update_cec_modules_2020.lk` as of this writing).
1. Start SAM and open the latest version of the Update CEC Modules script (`update_cec_modules_2023.lk` as of this writing).

2. Set `version` to the SAM version you are using to run the script.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

*/

version = '2023.10.31';
date = '11/16/2022';
version = '2023.12.17';
date = '11/14/2024';

function run_6par_gen( T )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
/*
Converts CEC module data from spreadsheet to SAM CEC Modules library CSV file:

1. Read data from CEC file.

2. Run 6-parameter coefficient calculator to calculate CEC module model parameters

3. Generate list of modules that calculator failed to generate results

4. Generate CEC Modules.csv file

Change value of version, date before running script.

*/

version = '2023.12.17';
date = '11/14/2024';

function run_6par_gen( T )
{
R = {};

ssc = ssc_create();

ssc_var( ssc, 'celltype', T.celltype );
ssc_var( ssc, 'Vmp', T.vmp );
ssc_var( ssc, 'Imp', T.imp );
ssc_var( ssc, 'Voc', T.voc );
ssc_var( ssc, 'Isc', T.isc );
ssc_var( ssc, 'alpha_isc', T.alpha_isc );
ssc_var( ssc, 'beta_voc', T.beta_voc );
ssc_var( ssc, 'gamma_pmp', T.gamma_pmp );
ssc_var( ssc, 'Nser', T.n_ser );
ssc_var( ssc, 'Tref', T.t_ref ); // optional, default value is 25

result = ssc_exec( ssc, '6parsolve' );

if ( 0 == result )
{
R.a = ssc_var( ssc, 'a' );
R.Il = ssc_var( ssc, 'Il' );
R.Io = ssc_var( ssc, 'Io' );
R.Rs = ssc_var( ssc, 'Rs' );
R.Rsh = ssc_var( ssc, 'Rsh' );
R.Adj = ssc_var( ssc, 'Adj' );
R.msg = 'ok';
}
else
{
R.msg = '\"' + result + '\"'; // enclose in quotes for Excel
}

ssc_free( ssc );

return R;
}

// read CSV file prepared from CEC Excel file and return table of SAM library items
function read_cec_csv ( fin )
{

T_cec = csvread( fin , { 'table' = true } );

for ( i=0; i<#T_cec{'Manufacturer'}; i++ )
{
T_sam{'Manufacturer'}[i] = T_cec{'Manufacturer'}[i];
T_sam{'Model'}[i] = T_cec{'Model Number'}[i];
T_sam{'BIPV'}[i] = T_cec{'BIPV'}[i];
T_sam{'Description'}[i] = T_cec{'Description'}[i];
T_sam{'T_NOCT'}[i] = to_real( T_cec{'Average NOCT'}[i] ); // C
T_sam{'A_c'}[i] = to_real( T_cec{'A_c'}[i] ); // m2
T_sam{'N_s'}[i] = to_int( T_cec{'N_s'}[i] ); // integer
T_sam{'I_sc_ref'}[i] = to_real( T_cec{'Nameplate Isc'}[i] ); // A
T_sam{'V_oc_ref'}[i] = to_real( T_cec{'Nameplate Voc'}[i] ); // V
T_sam{'I_mp_ref'}[i] = to_real( T_cec{'Nameplate Ipmax'}[i] ); // A
T_sam{'V_mp_ref'}[i] = to_real( T_cec{'Nameplate Vpmax'}[i] ); // V
T_sam{'PTC'}[i] = to_real( T_cec{'PTC'}[i] ); // W
T_sam{'Technology'}[i] = T_cec{'Technology'}[i]; // string
T_sam{'Length'}[i] = T_cec{'Long Side'}[i]; // m
T_sam{'Width'}[i] = T_cec{'Short Side'}[i]; // m

// Temperature coefficient headings converted from Greek characters to these names
T_sam{'alpha_sc'}[i] = to_real( T_cec{'alphaIsc'}[i] ) * to_real( T_cec{'Nameplate Isc'}[i] ) / 100; // convert %/C to A/C
T_sam{'beta_oc'}[i] = to_real( T_cec{'betaVoc'}[i] ) * to_real( T_cec{'Nameplate Voc'}[i] ) / 100; // convert %/C to V/C
T_sam{'gamma_pmp'}[i] = to_real( T_cec{'gammaPmax'}[i] ); // %/C
}

return T_sam;

}

// read a table of sam library items and write complete SAM library file
function sam_table_to_library( T, path, version, date )
{

// date_str is appended to library file name
dt = split( date_time(), ' ' );
t = split( dt[3], ':' );
date_str = dt[4] + '-' + dt[1] + '-' + dt[2] + '_' + t[0] + '-' + t[1];

sam_library_file = path + '/CEC Modules ' + date_str + '.csv';
bad_modules_file = path + '/Bad Modules ' + date_str + '.csv';

// Convert CEC technology names to SAM names. Coefficient generator uses
// Technology to choose initial guess conditions, so it is not critical to
// have a correct value
//cec names (note blanks): 'CIGS','Mono-c-Si','Multi-c-Si','Thin Film',''
//sam names must contain: 'mono','multi','cis','cigs','cdte','amor'
Tech{'CIGS'} = 'cigs';
Tech{'Mono-c-Si'} = 'mono';
Tech{'Multi-c-Si'} = 'multi';
Tech{'Thin Film'} = 'cdte';
Tech{'CdTe'} = 'cdte';
Tech{''} = 'multi';

outln('Opening and writing header data to library and bad modules files.');
fbad = open( bad_modules_file, 'w');
write_line( fbad, 'Manufacturer,Model,Technology,Message,celltype,vmp,imp,voc,isc,alpha_isc,beta_voc,gamma_pmp,n_ser,t_ref');
close(fbad);
flib = open( sam_library_file, 'w');
write_line( flib, 'Name,Manufacturer,Technology,Bifacial,STC,PTC,A_c,Length,Width,N_s,I_sc_ref,V_oc_ref,I_mp_ref,V_mp_ref,alpha_sc,beta_oc,T_NOCT,a_ref,I_L_ref,I_o_ref,R_s,R_sh_ref,Adjust,gamma_pmp,BIPV,Version,Date');
write_line( flib, 'Units,,,,,,m2,m,m,,A,V,A,V,A/K,V/K,C,V,A,A,Ohm,Ohm,%,%/K,,,');
write_line( flib, '[0],lib_manufacturer,cec_material,lib_is_bifacial,,,cec_area,lib_length,lib_width,cec_n_s,cec_i_sc_ref,cec_v_oc_ref,cec_i_mp_ref,cec_v_mp_ref,cec_alpha_sc,cec_beta_oc,cec_t_noct,cec_a_ref,cec_i_l_ref,cec_i_o_ref,cec_r_s,cec_r_sh_ref,cec_adjust,cec_gamma_pmp,,,');
close(flib);

outln('Writing module data to files.');
flib = open( sam_library_file, 'a');
fbad = open( bad_modules_file, 'a');
outln('Processing data for ' + #T.Manufacturer + ' modules.');
outln('First module is ' + T.Manufacturer[0] + ' ' + T.Model[0]);
//n_bad = 0; // index for list of bad modules
//n_good = 0; // index for good modules

// for each module in table
p = 0;
for ( i=0; i<#T.Manufacturer; i++ )
{
outln(T.Manufacturer[i] + ' ' + T.Model[i]);
/*
if ( p == 100)
{
out('Processing ' + i + ' of ' + #T.Manufacturer + ': ' );
outln(T.Manufacturer[i] + ' ' + T.Model[i]);
p = 0;
}
*/
celltype = Tech{T.Technology[i]};

if ( strpos( lower(T.Description[i]) , 'bifacial' ) > -1 ) { bifacial = true; }
else { bifacial = false; }

inputs_6par = { 'celltype' = celltype,
'vmp' = to_real( T.V_mp_ref[i] ),
'imp' = to_real( T.I_mp_ref[i] ),
'voc' = to_real( T.V_oc_ref[i] ),
'isc' = to_real( T.I_sc_ref[i] ),
'alpha_isc' = to_real( T.alpha_sc[i] ),
'beta_voc' = to_real(T.beta_oc[i] ),
'gamma_pmp' = to_real( T.gamma_pmp[i] ),
'n_ser' = to_int (T.N_s[i] ),
't_ref' = to_real( 25 ) };

outputs_6par = run_6par_gen( inputs_6par );

if ( outputs_6par.msg != 'ok' )
{
replace( outputs_6par.msg, ',', '-' );
replace( outputs_6par.msg, '\n', ' -- ' );
bad_data = T.Manufacturer[i] + ',' +
T.Model[i] + ',' +
T.Technology[i] + ',' +
outputs_6par.msg + ',' +
celltype + ',' +
T.V_mp_ref[i] + ',' +
T.I_mp_ref[i] + ',' +
T.V_oc_ref[i] + ',' +
T.I_sc_ref[i] + ',' +
T.alpha_sc[i] + ',' +
T.beta_oc[i] + ',' +
T.gamma_pmp[i] + ',' +
T.N_s[i] + ',' +
25;
write_line(fbad, bad_data);
//n_bad++;
}
else
{
data = T.Manufacturer[i] + ' ' + T.Model[i] + ',' + // name
T.Manufacturer[i] + ',' +
T.Technology[i] + ',' +
to_string(bifacial) + ',' +
to_string(T.I_mp_ref[i] * T.V_mp_ref[i]) + ',' + //STC
to_string(T.PTC[i]) + ',' +
to_string(T.A_c[i]) + ',' +
to_string(T.Length[i]) + ',' +
to_string(T.Width[i]) + ',' +
to_string(T.N_s[i]) + ',' +
to_string(T.I_sc_ref[i]) + ',' +
to_string(T.V_oc_ref[i]) + ',' +
to_string(T.I_mp_ref[i]) + ',' +
to_string(T.V_mp_ref[i]) + ',' +
to_string(T.alpha_sc[i]) + ',' +
to_string(T.beta_oc[i]) + ',' +
to_string(T.T_NOCT[i]) + ',' +
to_string(outputs_6par.a) + ',' + //a_ref
to_string(outputs_6par.Il) + ',' + //I_L_ref
to_string(outputs_6par.Io) + ',' + //I_o_ref
to_string(outputs_6par.Rs) + ',' + //R_s
to_string(outputs_6par.Rsh) + ',' + //R_sh_ref
to_string(outputs_6par.Adj) + ',' + //Adjust
to_string(T.gamma_pmp[i]) + ',' +
to_string(T.BIPV[i]) + ',' +
to_string(version) + ',' +
to_string(date);
write_line(flib, data);
}
p++;
}
close(flib);
close(fbad);
}

// Main ////////////////////////////////////////////////////////////////////////

cec_csv_file = choose_file( cwd() , 'Choose processed CSV file of CEC module data', 'CSV Files (*.csv)|*.csv' );
outln('Reading data from prepared CSV file.');
T = read_cec_csv( cec_csv_file );
outln('Converting data to SAM library file');
sam_table_to_library( T , path_only( cec_csv_file ), version, date );


Loading