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.

Import O&M costs through LK script

  • Gabriel Konzen
  • Topic Author
More
11 May 2021 12:26 #9586 by Gabriel Konzen
Import O&M costs through LK script was created by Gabriel Konzen
Hi, 

I have a "for" loop to simulate different CAPEX for a power plant. Then, i want to assign the variable 'om_fixed' as a function of CAPEX. In this case, 0.5% of CAPEX.

I realized that the variable 'om_fixed' expects an array as input. So, first of all, I'm importing a .csv file with a repetition of 0.005 for every year of the simulation.

However, when I try to run the following script, I get the error: "access violation: expected numeric, but found array".

Could you please try to help me?

active_case('example');
function array_2d_to_1d( x ) 
{
for( w=0; w<#x; w++ )
{
arr[w] = x[w][0];
}
return arr;
}
oem_csv = csvread('example.csv', {'skip' = 1, 'numeric'=true, 'table'=false});
oem_annual = array_2d_to_1d(oem_csv);
set('om_fixed', oem_annual * 2); //2, is just an example of a numeric variable.
check_oem = get('om_fixed');
outln(check_oem);


Thanks,

GK

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

  • Paul Gilman
More
12 May 2021 17:19 #9592 by Paul Gilman
Replied by Paul Gilman on topic Import O&M costs through LK script
Hi GK,

Any variable that appears in the SAM user interface with a little grey and blue "val/sched" square is an array. If the array has one value, SAM interprets it as a Year 1 value and applies inflation and escalation rates to the value in out years. So, for your example you could do something like this:

Code:
x = 500; set('om_fixed', [ x ] ); check_oem = get('om_fixed'); outln(check_oem); set('om_fixed', [ x * 2 ] ); //2, is just an example of a numeric variable. check_oem = get('om_fixed'); outln(check_oem);

Best regards,
Paul.

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

Moderators: Paul Gilman
Powered by Kunena Forum