We will be performing a major infrastructure and web site ugprades on Friday, September 27th 8:00 am - 5:00 pm MST (UTC -7).

The website will be down during that time.

Import O&M costs through LK script

  • gabrielkonzen
  • Topic Author
More
11 May 2021 18:26 #9586 by gabrielkonzen
Import O&M costs through LK script was created by gabrielkonzen
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.

  • pgilman
More
12 May 2021 23:19 #9592 by pgilman
Replied by pgilman 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:

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: pgilman
Powered by Kunena Forum