- Posts: 9
Learning resources
- winksaville
- Topic Author
Less
More
03 Jun 2019 13:16 #7432
by winksaville
Learning resources was created by winksaville
I was trying to learn LK and on SAM YouTube
channel
and at found
this tutorial
and
at 1:00
there is a link,
sam.nrel.gov/content/resources-learning-sam
, but that results in a 404. is that information available somewhere on the new website?
Also, other LK tutorial links would be appreciated especially for the latest version that my go over any new features.
Thanks
Wink
Also, other LK tutorial links would be appreciated especially for the latest version that my go over any new features.
Thanks
Wink
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
03 Jun 2019 15:32 #7433
by pgilman
Replied by pgilman on topic Learning resources
HI Wink,
We're still in the process of cleaning up after moving the SAM website to a new platform. Sorry about all of the broken links. I'll work on the LK materials next. In the meantime, here's a link to a collection of sample LK scripts that might be helpful:
github.com/NREL/SAM/tree/develop/samples/LK%20Scripts%20for%20SAM
Best regards,
Paul.
We're still in the process of cleaning up after moving the SAM website to a new platform. Sorry about all of the broken links. I'll work on the LK materials next. In the meantime, here's a link to a collection of sample LK scripts that might be helpful:
github.com/NREL/SAM/tree/develop/samples/LK%20Scripts%20for%20SAM
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- winksaville
- Topic Author
Less
More
- Posts: 9
03 Jun 2019 15:49 #7434
by winksaville
Replied by winksaville on topic Learning resources
Txs.
Please Log in or Create an account to join the conversation.
- winksaville
- Topic Author
Less
More
- Posts: 9
04 Jun 2019 00:12 #7435
by winksaville
Replied by winksaville on topic Learning resources
I went through the
tutorial
and created the code and everthing worked except
the plotout command:
Everything worked except the the contents of ploutout(file_name) was a 20x20 image. I looked at the
sources in the SAM/samples and found 'LK Scripts for SAM/plot_samples.lk' and uncommented the
test of plotout and it worked. There are obviously differerences but thought the biggest difference was
the test was using choose_dir:
So I changed line 20 to:
And now plot_samples.lk failed the same way, only a small image was created.
I then changed line 28 of DC-AC-ratios.lk to:
And now I see the full image, so it looks like there is a bug and some side effect
of choose_dir allows plotout to work correctly.
Should I create an issue at github.com/NREL/SAM/issues ?
the plotout command:
Code:
$ cat -n DC-AC-ratios.lk
1 ratios = csvread('/home/wink/prgs/solar/data/DC-AC-ratios.csv',
2 {'skip'=1, 'numeric'=true});
3 active_case('DC-AC-ratios');
4
5 for( i=0; i < #ratios; i++ ) {
6 r = ratios[i][0];
7 set('dc_ac_ratio', r);
8 simulate();
9
10 cf=get('capacity_factor');
11 outln('ratio[' + i + ']:' + r + '=' + cf);
12
13 x.DCACRatio[i] = r;
14 x.CapacityFactor[i] = cf;
15 x.Energy[i] = get('annual_energy');
16 x.LCOE[i] = get('lcoe_nom');
17 }
18
19 csvwrite('/home/wink/prgs/solar/data/DC-AC-ratios-results.csv', x);
20
21 newplot(true);
22 plot(x.DCACRatio, x.LCOE, { 'type'='line', 'color'='red', 'thick'='2' });
23
24 plotopt({'title'='Impact of DC/AC Ratio in Captiola', 'legend'=false});
25 axis('x1', {'label'='DC/AC ratio'});
26 axis('y1', {'label'='LCOE (cents/kwh)'});
27
28 file_name = '/home/wink/prgs/solar/data/DC-AC-ratios-results.png';
29 outln('file_name=' + file_name);
30
31 plotout(file_name);
sources in the SAM/samples and found 'LK Scripts for SAM/plot_samples.lk' and uncommented the
test of plotout and it worked. There are obviously differerences but thought the biggest difference was
the test was using choose_dir:
Code:
19 // save plot as image file
20 f_path=choose_dir(homedir(),'Save Plot');
21 f_name = f_path + '/plot.pdf';
22 outln(f_name);
23 ok = plotout( f_name , 'pdf'); // png, pdf, bmp, or jpg. Defaults to png if file type not given.
Code:
20 f_path='/home/wink/prgs/solar/data'; //choose_dir(homedir(),'Save Plot');
And now plot_samples.lk failed the same way, only a small image was created.
I then changed line 28 of DC-AC-ratios.lk to:
Code:
28 file_name = choose_dir('/home/wink/prgs/solar/data', 'Save Plot') + '/DC-AC-ratios-results.png';
And now I see the full image, so it looks like there is a bug and some side effect
of choose_dir allows plotout to work correctly.
Should I create an issue at github.com/NREL/SAM/issues ?
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
04 Jun 2019 10:51 - 04 Jun 2019 10:54 #7436
by pgilman
Replied by pgilman on topic Learning resources
Hi Wink,
The file path as you originally specified it should work:
Calling the choose_dir() function opens a Choose Folder dialog and sets the value of the path in file_name
to the folder you choose. That method also works, but might be cumbersome if you don't want to have to choose a folder every time you run the script.
I'm not sure why using choose_dir() to set the value of file_name instead of setting it explicitly causes the png to be rendered incorrectly. I was able to replicate your results in Ubuntu 16.04 LTS, but not in Windows, where the png was rendered in full size . Please do create an issue on GitHub if you don't mind, and include a link to this discussion so we can reference it for troubleshooting.
The video you watched is based on SAM 2015.1.30, and we've made several changes that make that example no longer work. Here are the changes you should to make to your script to ensure it works in SAM 2018.11.11:
Line 7: Set the value of desired_dcac_ratio instead of dc_ac_ratio and check the Estimate Subarray 1 configuration check box on the System Design page. You can do that in the script using:
Line 5: The For loop should count the number of rows in the 2-dimensional array returned by the csvread()
function:
Line 6: Set r = ratios[0] instead of the other way around.
If you are modeling small systems on the order of a few kW, you may want to check the value of calculated_dcac_ratio to make sure that the DC/AC ratio SAM was able to achieve is close enough to the desired value to meet your requirements.
Best regards,
Paul.
The file path as you originally specified it should work:
Code:
file_name = '/home/wink/prgs/solar/data/DC-AC-ratios-results.png';
Calling the choose_dir() function opens a Choose Folder dialog and sets the value of the path in file_name
to the folder you choose. That method also works, but might be cumbersome if you don't want to have to choose a folder every time you run the script.
I'm not sure why using choose_dir() to set the value of file_name instead of setting it explicitly causes the png to be rendered incorrectly. I was able to replicate your results in Ubuntu 16.04 LTS, but not in Windows, where the png was rendered in full size . Please do create an issue on GitHub if you don't mind, and include a link to this discussion so we can reference it for troubleshooting.
The video you watched is based on SAM 2015.1.30, and we've made several changes that make that example no longer work. Here are the changes you should to make to your script to ensure it works in SAM 2018.11.11:
Line 7: Set the value of desired_dcac_ratio instead of dc_ac_ratio and check the Estimate Subarray 1 configuration check box on the System Design page. You can do that in the script using:
Code:
set('enable_auto_size', 1);
Line 5: The For loop should count the number of rows in the 2-dimensional array returned by the csvread()
function:
Code:
for( i=0; i<#ratios[0]; i++);
Line 6: Set r = ratios[0] instead of the other way around.
If you are modeling small systems on the order of a few kW, you may want to check the value of calculated_dcac_ratio to make sure that the DC/AC ratio SAM was able to achieve is close enough to the desired value to meet your requirements.
Best regards,
Paul.
Last edit: 04 Jun 2019 10:54 by pgilman.
Please Log in or Create an account to join the conversation.
- winksaville
- Topic Author
Less
More
- Posts: 9
04 Jun 2019 13:43 #7437
by winksaville
Replied by winksaville on topic Learning resources
I created
issue 200
.
Please Log in or Create an account to join the conversation.
Moderators: pgilman