- Posts: 2
System power generated in Matlab from ssccall
- Lima
- Topic Author
Less
More
01 Oct 2020 13:01 #8803
by Lima
System power generated in Matlab from ssccall was created by Lima
Greetings all,
I am trying to use a generated code from SAM in Matlab.
I am using the module pvwattsv7 to do some pv analysis.
The system power generated in MatLab does not match the values in SAM.
The problem seems to be due to the timings in the weather file (NSRDB).
In the weather file the time step is one hour, but every h:30, see example:
Using the MatLab code generated by SAM and the input file above, we have for the DNI:
>> dni = ssccall('data_get_array', data, 'dn');>> dni(1:48)ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 507.0000 0.0000 794.0000 0.0000 908.0000 0.0000 962.0000 0.0000 974.0000 0.0000 976.0000 0.0000 954.0000 0.0000 900.0000 0.0000 789.0000 0.0000 512.0000 0.0000
Something is strange. Because the size of dni in MatLab is 8760 and it seems it is filled in with zeros for the hour.
Basically ssccall/pvwattsv7 only uses half of the original data and the system power generated variable is not correct.
How, can I correct this?
What am I doing wrong?Thank you.
Best,
Ricardo
SAM Version 2020.2.29, 64 bit, updated to revision 3SSC Version 242: OS X 64 bit GNU/C++ Jul 31 2020 02:59:37wxWidgets 3.1.1 on macOS High Sierra Version 10.13.6 (Build 17G5019)
I am trying to use a generated code from SAM in Matlab.
I am using the module pvwattsv7 to do some pv analysis.
The system power generated in MatLab does not match the values in SAM.
The problem seems to be due to the timings in the weather file (NSRDB).
In the weather file the time step is one hour, but every h:30, see example:
Using the MatLab code generated by SAM and the input file above, we have for the DNI:
>> dni = ssccall('data_get_array', data, 'dn');>> dni(1:48)ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 507.0000 0.0000 794.0000 0.0000 908.0000 0.0000 962.0000 0.0000 974.0000 0.0000 976.0000 0.0000 954.0000 0.0000 900.0000 0.0000 789.0000 0.0000 512.0000 0.0000
Something is strange. Because the size of dni in MatLab is 8760 and it seems it is filled in with zeros for the hour.
Basically ssccall/pvwattsv7 only uses half of the original data and the system power generated variable is not correct.
How, can I correct this?
What am I doing wrong?Thank you.
Best,
Ricardo
SAM Version 2020.2.29, 64 bit, updated to revision 3SSC Version 242: OS X 64 bit GNU/C++ Jul 31 2020 02:59:37wxWidgets 3.1.1 on macOS High Sierra Version 10.13.6 (Build 17G5019)
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
05 Oct 2020 10:29 #8810
by pgilman
Replied by pgilman on topic System power generated in Matlab from ssccall
Hi Ricardo,
If you run the MATLAB code generated by SAM without modifying the code, you should get the same or very similar results between MATLAB and SAM.
The pvwattsv7 compute module should detect the simulation time step from the length of the weather file. If the weather file 8760 data records, then it will run an hourly simulation.
For hourly weather files from the NREL National Solar Radiation Database (NSRDB), the Minute time stamp for each hour is 30, indicating that the solar irradiance was measured at the half hour. For example, for Hour 11, the irradiance was measured at 11:30.
Best regards,
Paul.
If you run the MATLAB code generated by SAM without modifying the code, you should get the same or very similar results between MATLAB and SAM.
The pvwattsv7 compute module should detect the simulation time step from the length of the weather file. If the weather file 8760 data records, then it will run an hourly simulation.
For hourly weather files from the NREL National Solar Radiation Database (NSRDB), the Minute time stamp for each hour is 30, indicating that the solar irradiance was measured at the half hour. For example, for Hour 11, the irradiance was measured at 11:30.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- Lima
- Topic Author
Less
More
- Posts: 2
05 Oct 2020 13:30 #8812
by Lima
Replied by Lima on topic System power generated in Matlab from ssccall
Hi Paul,
Thank you for your reply.
Before the message gets too long, I am quite enthusiastic about SAM.
The capabilities are great. Excellent tool.
There seems to be a problem with SAM-2020-02-29 and the MatLab Generation code libraries and MatLab.
The dni is not being read/handled correctly and therefore the system power generation is not correct.
I trace this to the time step handling.
I downloaded SAM-2018-11-11 and everything woks fine. The results from MatLab match SAM-2018-11-11.
However, with SAM-2020-02-29 the results are not correct.
I attach the weather file for your reference that I used with default values in both SAM versions .
Example with SAM-2018-11-11
>> [gen, dni] = untitled;SSC Version = 209SSC Build Information = OS X 64 bit GNU/C++ May 21 2019 01:44:30Annual energy (year 1) = 5682.09Capacity factor (year 1) = 16.216Energy yield (year 1) = 1420.52>> gen(1:24,1)ans = 0 0 0 0 0 0 0 0.0678 0.4064 0.5211 0.9283 1.1098 1.8921 2.4527 0.9268 0.6263 0.6940 0 0 0 0 0 0 0>> dni(1:24,1)ans = 0 0 0 0 0 0 0 104 79 21 70 81 371 839 95 81 456 0 0 0 0 0 0 0
Example with SAM-2020-02-29
>> [gen, dni] = untitled;SSC Version = 242SSC Build Information = OS X 64 bit GNU/C++ Jul 31 2020 02:59:37Annual energy (year 1) = 5708.28Capacity factor (year 1) = 16.2907Energy yield (year 1) = 1427.07>> gen(1:24,1)ans = 1.0e+145 * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.0000 0.0000 1.6770 0.0000 -0.0000 0.0000 0.0000 0.0000 0.0000>> dni(1:24,1)ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 104.0000 0.0000 79.0000 0.0000 21.0000 0.0000 70.0000 0.0000 81.0000 0.0000
Thank you for your reply.
Before the message gets too long, I am quite enthusiastic about SAM.
The capabilities are great. Excellent tool.
There seems to be a problem with SAM-2020-02-29 and the MatLab Generation code libraries and MatLab.
The dni is not being read/handled correctly and therefore the system power generation is not correct.
I trace this to the time step handling.
I downloaded SAM-2018-11-11 and everything woks fine. The results from MatLab match SAM-2018-11-11.
However, with SAM-2020-02-29 the results are not correct.
I attach the weather file for your reference that I used with default values in both SAM versions .
Example with SAM-2018-11-11
>> [gen, dni] = untitled;SSC Version = 209SSC Build Information = OS X 64 bit GNU/C++ May 21 2019 01:44:30Annual energy (year 1) = 5682.09Capacity factor (year 1) = 16.216Energy yield (year 1) = 1420.52>> gen(1:24,1)ans = 0 0 0 0 0 0 0 0.0678 0.4064 0.5211 0.9283 1.1098 1.8921 2.4527 0.9268 0.6263 0.6940 0 0 0 0 0 0 0>> dni(1:24,1)ans = 0 0 0 0 0 0 0 104 79 21 70 81 371 839 95 81 456 0 0 0 0 0 0 0
Example with SAM-2020-02-29
>> [gen, dni] = untitled;SSC Version = 242SSC Build Information = OS X 64 bit GNU/C++ Jul 31 2020 02:59:37Annual energy (year 1) = 5708.28Capacity factor (year 1) = 16.2907Energy yield (year 1) = 1427.07>> gen(1:24,1)ans = 1.0e+145 * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.0000 0.0000 1.6770 0.0000 -0.0000 0.0000 0.0000 0.0000 0.0000>> dni(1:24,1)ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 104.0000 0.0000 79.0000 0.0000 21.0000 0.0000 70.0000 0.0000 81.0000 0.0000
Attachments:
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
05 Oct 2020 15:15 #8813
by pgilman
Replied by pgilman on topic System power generated in Matlab from ssccall
HI Ricardo,
Thank you for sending the weather file. Would you mind also sending the .sam file you used to generate the MATLAB code?
Best regards,
Paul.
Thank you for sending the weather file. Would you mind also sending the .sam file you used to generate the MATLAB code?
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- sjanzou
Less
More
- Posts: 22
20 Oct 2020 06:09 - 21 Oct 2020 16:23 #8897
by sjanzou
Replied by sjanzou on topic System power generated in Matlab from ssccall
Ricardo,
Thanks for sending your files.
We were able to verify the issue you are reporting and is a result of the data type change in ssc from float to double between the 2018.11.11 and the 2020.2.29 release.
The error is in the return values in the data_get_array and the data_get_matrix Matlab wrapper code generated by SAM.
I am attaching an updated untitled_fixed.m Matlab script with the fixes.
There are two changes: (int32Ptr replaced with int64Ptr):
Please update your script and any Matlab scripts generated from SAM_2020.2.29 accordingly.
The new release of SAM will have this fix in the Matlab code generation.
Let us know if you have any questions,
Steve
Thanks for sending your files.
We were able to verify the issue you are reporting and is a result of the data type change in ssc from float to double between the 2018.11.11 and the 2020.2.29 release.
The error is in the return values in the data_get_array and the data_get_matrix Matlab wrapper code generated by SAM.
I am attaching an updated untitled_fixed.m Matlab script with the fixes.
There are two changes: (int32Ptr replaced with int64Ptr):
Code:
Line 71 (data_get_array): setdatatype(xobj,'int64Ptr',p_count.Value,1);
Line 83 (data_get_matrix): setdatatype(xobj,'int64Ptr',p_rows.Value*p_cols.Value,1);
Please update your script and any Matlab scripts generated from SAM_2020.2.29 accordingly.
The new release of SAM will have this fix in the Matlab code generation.
Let us know if you have any questions,
Steve
Last edit: 21 Oct 2020 16:23 by pgilman.
Please Log in or Create an account to join the conversation.
Moderators: pgilman