- Posts: 7
Input load data in LK script
- gabrielkonzen
- Topic Author
Less
More
17 Jun 2020 07:19 #8312
by gabrielkonzen
Input load data in LK script was created by gabrielkonzen
Hi, I'm a beginner user of LK script and I'm having some difficulties to input a .csv load file with hourly data (8760) and run a simulation.
As a first exercise, I'd like to change manually the .csv file for different consumers, and then return the net present value of the simulation. I'm using the following code.
load = csvread('X:/Data/Customer1.csv', {'skip'=1, 'numeric'=true});
active_case('untitled');
set('load_user_data',load);
simulate();
result = get('npv');
outln(result);
However, the result is always the same. Even when I change the load data (Customer2.csv, for instance), the result is always the npv from the original active case.
I tried both variables "load" and "load_user_data" and none worked.
Do you know what I am doing wrong?
Thanks,
GK
As a first exercise, I'd like to change manually the .csv file for different consumers, and then return the net present value of the simulation. I'm using the following code.
load = csvread('X:/Data/Customer1.csv', {'skip'=1, 'numeric'=true});
active_case('untitled');
set('load_user_data',load);
simulate();
result = get('npv');
outln(result);
However, the result is always the same. Even when I change the load data (Customer2.csv, for instance), the result is always the npv from the original active case.
I tried both variables "load" and "load_user_data" and none worked.
Do you know what I am doing wrong?
Thanks,
GK
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
17 Jun 2020 09:43 #8313
by pgilman
Replied by pgilman on topic Input load data in LK script
Hi Gabriel,
That script should do what you expect.
The NPV may not change with the load in all cases, depending on the other assumptions in your analysis.
You might try using the elec_cost_with_system and elec_cost_without_system output variables to verify that the load data is being imported. You can also look at the annual_electric_load variable, which is the sum of the hourly (or subhourly) load values.
I would be happy to investigate if you don't mind attaching your .sam file and a couple of examples of the load data you are importing.
Best regards,
Paul.
That script should do what you expect.
The NPV may not change with the load in all cases, depending on the other assumptions in your analysis.
You might try using the elec_cost_with_system and elec_cost_without_system output variables to verify that the load data is being imported. You can also look at the annual_electric_load variable, which is the sum of the hourly (or subhourly) load values.
I would be happy to investigate if you don't mind attaching your .sam file and a couple of examples of the load data you are importing.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- gabrielkonzen
- Topic Author
Less
More
- Posts: 7
17 Jun 2020 11:44 #8316
by gabrielkonzen
Replied by gabrielkonzen on topic Input load data in LK script
Hi, Paul. Thank you for your quick answer.
I've tried using different variables and the problem persists.
When I run the simulation through the software interface, I get different results for each customer, but when I try to run through the LK script, I get always the same result from the current customer loaded in the software.
I'm sending you the files.
Thanks,
GK
I've tried using different variables and the problem persists.
When I run the simulation through the software interface, I get different results for each customer, but when I try to run through the LK script, I get always the same result from the current customer loaded in the software.
I'm sending you the files.
Thanks,
GK
Attachments:
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
17 Jun 2020 13:46 #8319
by pgilman
Replied by pgilman on topic Input load data in LK script
Hi Gabriel,
Thank you for sending the files.
The csvread() function reads data from a file into an array of form [ [x1], [x2], ... [xn] ], but the load_user_data variable expects an array of the form [x1,x2,...,xn].
The attached script shows two ways to correctly read the data from the file:
1. Read the data as a table instead of array by setting the csvread() parameter table = true.
2. Use a For loop to convert the array into the correct form.
Best regards,
Paul
Thank you for sending the files.
The csvread() function reads data from a file into an array of form [ [x1], [x2], ... [xn] ], but the load_user_data variable expects an array of the form [x1,x2,...,xn].
The attached script shows two ways to correctly read the data from the file:
1. Read the data as a table instead of array by setting the csvread() parameter table = true.
2. Use a For loop to convert the array into the correct form.
Best regards,
Paul
Attachments:
Please Log in or Create an account to join the conversation.
- gabrielkonzen
- Topic Author
Less
More
- Posts: 7
18 Jun 2020 10:04 #8326
by gabrielkonzen
Replied by gabrielkonzen on topic Input load data in LK script
Thank you, Paul. It's working.
GK
GK
Please Log in or Create an account to join the conversation.
Moderators: pgilman