Where to find how ssc handles bi-directional inverters in the source code

  • Casey Zak
  • Topic Author
More
04 Mar 2025 21:06 #13917 by Casey Zak
Hi there,

I've been poking around the ssc source code trying to figure out how ssc treats bi-directional inverters (or an inverter-charger) for DC-coupled PV-battery hybrid systems. I've found some github issues and forum posts with some diagrams but haven't been able to trace it in the actual code.

Specifically, I'd like to understand if the inverter is modeled as working the same (same efficiency curve, pso, clipping limit etc) whether you are converting DC to AC or AC to DC.

Thanks!

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

  • Paul Gilman
More
05 Mar 2025 16:33 #13924 by Paul Gilman
Hi Casey,

For PV+Battery systems with DC-connected batteries, SAM treats the inverter as bi-directional with the same parameters regardless of whether it is converting DC to AC, or AC to DC.

The model is defined in lib_shared_inverter.cpp:  github.com/NREL/ssc/blob/patch/shared/lib_shared_inverter.cpp

(For PV+Battery AC-connected, standalone, and generic battery configurations, the model uses the simple "battery bidirectional inverter" defined in lib_power_electronics.cpp: github.com/NREL/ssc/blob/31d4a54a01f2531fbb412aee93e5ac39a973a3ce/shared/lib_power_electronics.cpp#L38 .)

Best regards,
Paul.

Best regards,
Paul.

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

  • Casey Zak
  • Topic Author
More
06 Mar 2025 21:04 #13932 by Casey Zak
Paul,

Thanks for your response. It's great to hear that you all are thinking along the same lines I am. However, I'm still a bit unclear on how this is treated in SSC. For context, our company's software (tyba.ai) uses PySAM for solar and inverter modeling but does it's own battery modeling. We do currently model bi-directional inverters for DC-coupled hybrid systems that can grid charge, but I don't think we are doing it correctly. At a minimum, I'd like to make sure we are modeling things inline with the approach ssc takes , and of course if possible utilize functionality already built into ssc.

In our case (and I assume in the FOM Automated Dispatch PV+DC scenario in ssc), we have a Pdc time series due to battery dispatch, where some intervals are charging and some are discharging. So to get the grid effect we want Pac = f(Pdc). But if the inverter works the same both ways, sometimes Pdc is an inverter model input and sometimes it is an output. So we would need to define Pinput = f(Poutput) as well as Poutput = f(Pinput) and apply them to the appropriate intervals

And in fact in lib_shared_inverter.cpp I do see SharedInverter::calculateRequiredDCpower, which seems to define Pinput = f(Poutput) using newton's method. But, then it only seems to get used in one place in lib_battery_dispatch.cpp, and it seems to be for the purpose of calculating the DC discharge power required to meet a particular AC load requirement. So I'm still not seeing where the inverter model gets applied to battery grid charging in the PV+DC case. Could you point me to that part of the code or explain how ssc treats it?

Thank you again for your help!

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

  • Paul Gilman
More
10 Mar 2025 11:59 - 10 Mar 2025 12:15 #13940 by Paul Gilman
Hi Casey,

The code for bi-directional inverter calculations are here:

github.com/NREL/ssc/blob/31d4a54a01f2531fbb412aee93e5ac39a973a3ce/shared/lib_battery_powerflow.cpp#L654

Specifically, for battery charging:

github.com/NREL/ssc/blob/31d4a54a01f2531fbb412aee93e5ac39a973a3ce/shared/lib_battery_powerflow.cpp#L792

And, for discharging:

github.com/NREL/ssc/blob/31d4a54a01f2531fbb412aee93e5ac39a973a3ce/shared/lib_battery_powerflow.cpp#L880

We are using the same equations and parameters for forwards and backwards operation of the inverter (for DC-connected batteries with a PV array).

The functions above determine how much of the battery’s DC power draw comes from PV versus the grid. There is a bunch of code that determines what the DC value needs to be, and then runs the same p_ac = f(p_dc) equations as it does for discharging.

See the use of std::abs here:

github.com/NREL/ssc/blob/31d4a54a01f2531fbb412aee93e5ac39a973a3ce/shared/lib_shared_inverter.cpp#L271

github.com/NREL/ssc/blob/31d4a54a01f2531fbb412aee93e5ac39a973a3ce/shared/lib_shared_inverter.cpp#L289

Best regards,
Paul.
Last edit: 10 Mar 2025 12:15 by Paul Gilman.

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

  • Casey Zak
  • Topic Author
More
10 Mar 2025 17:14 #13941 by Casey Zak
Paul,

Thanks so much, this is exactly what I was looking for!

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

Moderators: Paul Gilman
Powered by Kunena Forum