Skip to content

Commit d7d66e0

Browse files
committed
Update PVsyst OND - PAN to SAM.lk
Improve error messages and descriptions for : * File names with parentheses * SAM parameters that are not provided in PAN files -- use current value on Module/Inverter page instead of setting to default value
1 parent 97f3fab commit d7d66e0

1 file changed

Lines changed: 38 additions & 19 deletions

File tree

deploy/runtime/macros/Flat Plate PV/PVsyst OND - PAN to SAM.lk

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
/*@
22

3-
<p>This macro reads data from an OND or PAN file and populates inputs on SAM's
4-
Module or Inverter input page.</p>
3+
<p>This macro reads data from a PVsyst OND or PAN file and populates inputs on SAM's
4+
Module or Inverter input page. For modules, it sets the model option at the top
5+
of the Module page to "CEC Performance Model with User Entered Sepcifications".
6+
For inveters, it sets the option at the top of the Inverter page to "Inverter
7+
Datasheet".</p>
58

69
<p>The macro was tested with OND and PAN text files from PVsyst Version 6.6 and
7-
later with SAM 2021.12.02. It will not convert binary OND or PAN files from older versions
10+
later with SAM 2025.4.16. It will not convert binary OND or PAN files from older versions
811
of PVsyst.</p>
912

10-
<p><strong>Notes:</strong></p>
13+
<p>After running the macro, check the data on the Module or Inverter page to verify the data.</p>
14+
15+
<p><strong>Notes</strong></p>
16+
<ul>
17+
<li>For inverters:
1118
<ul>
12-
<li>For inverters, the script reads the number of MPPT inputs from the OND file
19+
<li>The macro reads the number of MPPT inputs from the OND file
1320
and sets the value in SAM accordingly. For inverters with more than one MPPT input,
1421
you may need to assign a subarray to each MPPT input on the System Design page.</li>
15-
<li>For bifacial modules, the script does not read the bifaciality factor from
16-
the PAN file. You will need to set the bifacial inputs by hand on SAM's Module
17-
input page.</li>
22+
<li>The macro does not set parameters for the inverter temperature derate curves
23+
on the Inverter page.</li>
24+
</ul></li>
25+
<li>For modules:
26+
<ul>
27+
<li>For bifacial modules, the macro does not read the bifaciality factor from
28+
the PAN file. You will need to set the bifacial parameters yourself on the Module
29+
page.</li>
1830
<li>Some module types defined in PVsyst are not defined in SAM and are set to
1931
monoSi. This only affects the initial guess for the solver's iterative
2032
algorithm so will not affect simulation results. For example, the macro sets
2133
the PVsyst technol parameter "mtGaInP2GaAsGe" to monoSi in SAM.</li>
34+
<li>The macro does not set parameters for SAM's cell temperature model, so you
35+
should set NOCT, mounting configuration, and transient thermal model correction
36+
parameters yourself on the Module page as appropriate.</li>
37+
</ul></li>
2238
</ul>
2339
@*/
2440

@@ -31,6 +47,11 @@ function read_pvsyst_file ( file , T )
3147
n = 0;
3248
T{'error'} = '';
3349
fin = open( file, 'r' );
50+
if (fin == 0)
51+
{
52+
T{'error'} = 'Failed to open file\n\n' + file + '.' + '\n\nFile path must not contain parentheses.';
53+
return T;
54+
}
3455
read_line( fin, first_line );
3556
if ( strpos( lower(first_line), 'pvobject_' ) < 0 )
3657
{
@@ -68,7 +89,7 @@ function read_pvsyst_file ( file , T )
6889
}
6990
close( fin );
7091
T{'skippeddata'} = skipped_data;
71-
return( T );
92+
return T ;
7293
}
7394

7495
// opens a pan file and returns a table of pan variables and their values
@@ -93,7 +114,7 @@ function read_pan_file ( f )
93114
Tvars{'vmp'} = '';
94115
Tvars{'voc'} = '';
95116

96-
return( read_pvsyst_file( f, Tvars ) );
117+
return read_pvsyst_file( f, Tvars );
97118

98119
}
99120

@@ -114,7 +135,7 @@ function read_ond_file ( f )
114135
Tvars{'nbmppt'} = '';
115136
Tvars{'night_loss'} = '';
116137

117-
return( read_pvsyst_file( f, Tvars ) );
138+
return read_pvsyst_file( f, Tvars );
118139

119140
}
120141

@@ -132,9 +153,6 @@ function pan_to_sam_vars( T )
132153
bvocunits = 0; // V/degC in SAM
133154
area = to_real(T.width) * to_real(T.height);
134155
modulename = T.manufacturer + ' ' + T.model;
135-
mounting = 0;
136-
standoff = 6;
137-
tnoct = 46;
138156

139157
// lookup table of module types (only affects initial guess for iterative solution)
140158
// module types as provided by pvsyst team April 2022
@@ -159,6 +177,7 @@ function pan_to_sam_vars( T )
159177
cell_types = ['monoSi','multiSi','CdTe','CIS','CIGS','Amorphous'];
160178

161179
// assign SAM variable values
180+
// do not set bifacial, NOCT, standoff height, approximate installation height or transient thermal model parameters
162181
sam_var{'6par_aisc_display'} = aisc; // muisc /1000 // muisc is mA/degC
163182
sam_var{'6par_aisc_units'} = aiscunits; // not in pvsys, set to 0 for A/degC
164183
sam_var{'6par_area'} = area; // width * height, pvsyst cell area is not used
@@ -170,10 +189,7 @@ function pan_to_sam_vars( T )
170189
sam_var{'6par_imp'} = to_real(T.imp); // A
171190
sam_var{'6par_isc'} = to_real(T.isc); // A
172191
sam_var{'6par_module_name'} = modulename; // manufacturer + model (strings)
173-
sam_var{'6par_mounting'} = mounting; // use default, see field thermal loss factor inputs in pvsyst
174192
sam_var{'6par_nser'} = to_real(T.ncels);
175-
sam_var{'6par_standoff'} = standoff; // use default, see field thermal loss factor inputs in pvsyst
176-
sam_var{'6par_tnoct'} = tnoct; // not used in pvsyst, set to 46 ??
177193
sam_var{'6par_vmp'} = to_real(T.vmp); //
178194
sam_var{'6par_voc'} = to_real(T.voc); // V
179195

@@ -219,7 +235,7 @@ function set_sam_inputs( var , model )
219235
// Main
220236
////////////////////////////////////////////////////////////////////////////////
221237

222-
fname = choose_file( homedir(), 'Choose PAN or OND file', 'PVsyst files (*.ond;*.pan)|*.ond;*.pan' );
238+
fname = choose_file( '', 'Choose PAN or OND file', 'PVsyst files (*.ond;*.pan)|*.ond;*.pan' );
223239
outln( 'Converting ' + fname + '...' );
224240
if ( strpos( lower(fname), 'pan' ) > -1 )
225241
{
@@ -248,9 +264,12 @@ elseif ( strpos( lower(fname), 'ond' ) > -1 )
248264
}
249265
else
250266
{
251-
msgbox( 'Failed to convert OND file!\n' + pan_vars{'error'} + '\n\nThis macro cannot convert binary files from PVsyst versions earlier than Version 6.6.');
267+
msgbox( 'Failed to convert OND file!\n' + ond_vars{'error'} + '\n\nThis macro cannot convert binary files from PVsyst versions earlier than Version 6.6.');
252268
}
253269
}
254270
else
271+
{
255272
outln( 'File must have extension pan or ond.' );
273+
}
274+
256275
outln('Done.');

0 commit comments

Comments
 (0)