- Posts: 8
Questions about CoPylot Variable Handling and the Battery Model
- Arthur800
- Topic Author
Less
More
08 Mar 2022 22:41 #10663
by Arthur800
Questions about CoPylot Variable Handling and the Battery Model was created by Arthur800
Hello, I'm studying both SAM Li-On Battery Model and CoPylot algorithms to develop research on renewable energy plants, and I'd like to divide my questions into two parts:
1. Battery Model:
So as to get a better grasp of the manual dispatch algorithm, I've read and studied the source codes provided on Github, and I've understood the hourly iteration as such:
1. At the beginning of the time step 0, the algorithm sets the initial voltage and the initial charge for the bank.
2. for the time step 0, the maximum discharge/ charge is calculated as a function of max and min SOCs, the actual charge and the voltage of the bank.
3. The voltage at the end of the time step and the current are found by solving P = VI and the electrochemical model simultaneously. The new charge is calculated from q = q - I *deltaT.
4. the final charge and voltage values are then used as initial values for the next iteration.
I followed this reasoning and tried to make my own implementation for it on Python, without PySAM. it correctly predicted the quantities at timestep 0 for the example file here, but I noticed something odd. According to the controller equations, the maximum discharge power at timestep 1 should be P = inverter_efficiency*max_scheduled_rate*voltage(q-qmax*SOCmin*0.01):
P = 0.96*0.25*525.0.33(351847 - 3.2*149880*0.15) ~= 35270.2 kW. However, the maximum available power for discharging remains the same as for time step 0 (approx 51312 kW). What would be the mistakes I might be making in my interpretation of the code?
2. The CoPylot Code:
One of my current tasks is to apply CoPylot for this structure:
1. Generate a layout based on annual TMY2 file;
2. Iterate over a custom file with latitude, longitude and date for obtaining hourly values of heat absorbed by the thermal fluid.
At this point, I wrote the basic working example found in "Demonstrating SolarPILOT's PythonAPI Through Heliostat Optimal
Aimpoint Strategy Use Case", and began searching on Github about the variable's name strings used for the API. To begin testing the handling of these variables. I wrote the line "cp.data_get_number(r, "receiver.0.q_rec_des")" at the end of the Python Script so I could get the power transmitted to the HTF after losses (already showing in the summary, but I'd like to get the value separately), but the IDE throws an "exception: access violation reading 0x0000000000000B58" error. How could I get access to the input and variables' values through Python environment without these kinds of errors?
1. Battery Model:
So as to get a better grasp of the manual dispatch algorithm, I've read and studied the source codes provided on Github, and I've understood the hourly iteration as such:
1. At the beginning of the time step 0, the algorithm sets the initial voltage and the initial charge for the bank.
2. for the time step 0, the maximum discharge/ charge is calculated as a function of max and min SOCs, the actual charge and the voltage of the bank.
3. The voltage at the end of the time step and the current are found by solving P = VI and the electrochemical model simultaneously. The new charge is calculated from q = q - I *deltaT.
4. the final charge and voltage values are then used as initial values for the next iteration.
I followed this reasoning and tried to make my own implementation for it on Python, without PySAM. it correctly predicted the quantities at timestep 0 for the example file here, but I noticed something odd. According to the controller equations, the maximum discharge power at timestep 1 should be P = inverter_efficiency*max_scheduled_rate*voltage(q-qmax*SOCmin*0.01):
P = 0.96*0.25*525.0.33(351847 - 3.2*149880*0.15) ~= 35270.2 kW. However, the maximum available power for discharging remains the same as for time step 0 (approx 51312 kW). What would be the mistakes I might be making in my interpretation of the code?
2. The CoPylot Code:
One of my current tasks is to apply CoPylot for this structure:
1. Generate a layout based on annual TMY2 file;
2. Iterate over a custom file with latitude, longitude and date for obtaining hourly values of heat absorbed by the thermal fluid.
At this point, I wrote the basic working example found in "Demonstrating SolarPILOT's PythonAPI Through Heliostat Optimal
Aimpoint Strategy Use Case", and began searching on Github about the variable's name strings used for the API. To begin testing the handling of these variables. I wrote the line "cp.data_get_number(r, "receiver.0.q_rec_des")" at the end of the Python Script so I could get the power transmitted to the HTF after losses (already showing in the summary, but I'd like to get the value separately), but the IDE throws an "exception: access violation reading 0x0000000000000B58" error. How could I get access to the input and variables' values through Python environment without these kinds of errors?
Attachments:
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
14 Mar 2022 14:48 - 14 Mar 2022 15:40 #10677
by pgilman
Replied by pgilman on topic Questions about CoPylot Variable Handling and the Battery Model
Hi Arthur,
Here is an answer to Question 1 about the battery model.
The battery power (P) equation for manual dispatch looks like this:
P = inverter_efficiency * max_scheduled_rate * voltage * qmax
...for any time that the following is true:
max_scheduled_rate * qmax >= q - qmax * min_soc * 0.01
Where qmax is typically referred to as q_full in the C++ source code code, and is equivalent to 100% SOC (state of charge), not the maximum SOC specified on the Battery Dispatch input page.
For example, for a Lithium-ion battery with four hours of usable energy (four hours between maximum SOC and minimum SOC), the maximum discharge power based on the rate would remain the same for all four hours. Your equation, on the other hand, assumes that SAM pro-rates the power as the capacity decreases.
Some of the code that regulates this is here:
github.com/NREL/ssc/blob/ca964fc280268b4e4efe686dc66c3c01ad555430/shared/lib_battery_dispatch_manual.cpp#L233
The code that enforces the SOC limits is here:
github.com/NREL/ssc/blob/ca964fc280268b4e4efe686dc66c3c01ad555430/shared/lib_battery_dispatch.cpp#L165
Best regards,
Paul.
Here is an answer to Question 1 about the battery model.
The battery power (P) equation for manual dispatch looks like this:
P = inverter_efficiency * max_scheduled_rate * voltage * qmax
...for any time that the following is true:
max_scheduled_rate * qmax >= q - qmax * min_soc * 0.01
Where qmax is typically referred to as q_full in the C++ source code code, and is equivalent to 100% SOC (state of charge), not the maximum SOC specified on the Battery Dispatch input page.
For example, for a Lithium-ion battery with four hours of usable energy (four hours between maximum SOC and minimum SOC), the maximum discharge power based on the rate would remain the same for all four hours. Your equation, on the other hand, assumes that SAM pro-rates the power as the capacity decreases.
Some of the code that regulates this is here:
github.com/NREL/ssc/blob/ca964fc280268b4e4efe686dc66c3c01ad555430/shared/lib_battery_dispatch_manual.cpp#L233
The code that enforces the SOC limits is here:
github.com/NREL/ssc/blob/ca964fc280268b4e4efe686dc66c3c01ad555430/shared/lib_battery_dispatch.cpp#L165
Best regards,
Paul.
Last edit: 14 Mar 2022 15:40 by pgilman.
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
14 Mar 2022 14:52 #10678
by pgilman
Replied by pgilman on topic Questions about CoPylot Variable Handling and the Battery Model
And, in response to your question about CoPylot:
The access violation error is caused by attempting to access the SolarPILOT object “r” after freeing the memory associated with the object via the cp.data_free(r) command.
You should access the object for results first, and then free the memory associated with the object.
Also, you should use the Summary Results dictionary to get the outputs you need. For example:
Best regards,
Paul.
The access violation error is caused by attempting to access the SolarPILOT object “r” after freeing the memory associated with the object via the cp.data_free(r) command.
You should access the object for results first, and then free the memory associated with the object.
Also, you should use the Summary Results dictionary to get the outputs you need. For example:
Code:
res = cp.summary_results(r)
print(str(res['Power absorbed byHTF']))
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
Moderators: pgilman