CURENT / andes

Python toolbox / library for power system transient dynamics simulation with symbolic modeling and numerical analysis 🔥
https://ltb.curent.org
Other
224 stars 111 forks source link

Add pandapower interface #287

Closed jinningwang closed 2 years ago

jinningwang commented 2 years ago

The power flow validation of the conversion is included in the to_pandapower.

codecov[bot] commented 2 years ago

Codecov Report

Merging #287 (dfd9aca) into develop (9736af7) will decrease coverage by 0.97%. The diff coverage is 18.86%.

:exclamation: Current head dfd9aca differs from pull request most recent head c28adc6. Consider uploading reports for the commit c28adc6 to get more accurate results

@@             Coverage Diff             @@
##           develop     #287      +/-   ##
===========================================
- Coverage    78.81%   77.83%   -0.98%     
===========================================
  Files          153      157       +4     
  Lines        13011    13241     +230     
===========================================
+ Hits         10254    10306      +52     
- Misses        2757     2935     +178     
Impacted Files Coverage Δ
andes/interop/pandapower.py 8.98% <8.98%> (ø)
tests/test_pandapower.py 43.75% <43.75%> (ø)
andes/interop/pypowsybl.py 80.00% <80.00%> (ø)
andes/interop/__init__.py 100.00% <100.00%> (ø)
andes/shared.py 78.57% <100.00%> (+0.38%) :arrow_up:
andes/core/documenter.py 84.84% <0.00%> (-1.64%) :arrow_down:
andes/system.py 76.16% <0.00%> (-0.01%) :arrow_down:
andes/models/pss/ieeest.py 100.00% <0.00%> (ø)
andes/routines/__init__.py 100.00% <0.00%> (ø)
andes/models/exciter/ac8b.py 100.00% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9736af7...c28adc6. Read the comment docs.

jinningwang commented 2 years ago

Hantao,

Let us keep it here. I'll work on it after I finalize the issues we discussed today, expecting by the end of this week.

Regards, Jinning

jinningwang commented 2 years ago

Hantao,

I have finalized most of the pandapower interface functions, where the remaining features (enhance the conversion by file I/O, add support of piece-wise cost functions) can be done in the future.

The example I write in ex11 can be used to build the self-test as a baseline.

Regards, Jinning

jinningwang commented 2 years ago

The checks failed but I have no idea how to solve them. It seems that the default environment does not include pandapower.

cuihantao commented 2 years ago

I will work on it next week by adding "optional" packages for ANDES. It will allow installing interop (short for interoperability) packages with pip install andes[interop] or pip install -e .[interop]. pandapower will be the first optional package in the interop group.

cuihantao commented 2 years ago

Copied the pandapower interface description to below. We might need to add a bit to it and move it to "Getting Started" - "Interoperability" (a new section.

pandapower interface
--------------------

The interface is developed for pandapower 2.7.0, which is not pre-installed in the andes environment.

to_pandapower
.............
This function is used to convert ADNES system (ssa) to pandapower network (ssp). The power flow results
are consistent.

Note:
Line limts are set as 99999.0 in `ssp`.
`SynGen` equipped with `TurbineGov` in `ssa` is set as `controllable=True` in `ssp.gen`.
cuihantao commented 2 years ago

I would like to rename some functions in the pandapower interface. It's difficult to guess what opp_res would mean.

cuihantao commented 2 years ago

I moved pandapower from andes.io to andes.interop. Changed it in the notebook as well. You might need to update your other notebooks @jinningwang

jinningwang commented 2 years ago

case300.m issue

Hantao,

Regarding case300, the conclusions are: 1) ANDES and the interface work well, 2) the differences of PF between ANDES and pandapower are acceptable.

The detailed info is listed below: Case name:

PF results comparison:

Although the PF results are inconsistent, the max gap of voltage amplitude between ssa and ssp is less than 1e-4.

cuihantao commented 2 years ago

Hi @jinningwang , is there further changes to this PR?

cuihantao commented 2 years ago

case300.m issue

Hantao,

Regarding case300, the conclusions are: 1) ANDES and the interface work well, 2) the differences of PF between ANDES and pandapower are acceptable.

The detailed info is listed below: Case name:

  • Matpower: case300.m
  • ANDES: ssa, converted from case300.m
  • PP: ssp, converted from ssa
  • PP built-in: ssp2, retrieved from pandapower built-in case

PF results comparison:

  • case300.m vs. ssa, consistent
  • ssp vs. ssp2, consistent
  • ssa vs. ssp or ssp2, inconsistent
  • case300.m vs. ssp or ssp2, inconsistent

Although the PF results are inconsistent, the max gap of voltage amplitude between ssa and ssp is less than 1e-4.

Got it. Thanks!

jinningwang commented 2 years ago

Hi @jinningwang , is there further changes to this PR?

All my thoughts have been covered.

cuihantao commented 2 years ago

Great. We will need a test for the pandapower interface. I might let you do it this time.

You will find tests/test_pandapower.py a barebone. To start, you can move the code from the jupyter notebook to the test script. At the end, you will use

import numpy as np

...

to_pandapower(..., verify=False)

# manually extract the voltage and voltage angle vectors, and do 

np.testing.assert_almost_equal(v_andes, v_pd) 
np.testing.assert_almost_equal(a_andes, v_pd) 

to compare the power flow results from ANDES and pandapower.

One test can be written for make_link_table. You can look at the known results for a particular generator and compare the strings.

jinningwang commented 2 years ago

Great. We will need a test for the pandapower interface. I might let you do it this time.

You will find tests/test_pandapower.py a barebone. To start, you can move the code from the jupyter notebook to the test script. At the end, you will use

import numpy as np

...

to_pandapower(..., verify=False)

# manually extract the voltage and voltage angle vectors, and do 

np.testing.assert_almost_equal(v_andes, v_pd) 
np.testing.assert_almost_equal(a_andes, v_pd) 

to compare the power flow results from ANDES and pandapower.

One test can be written for make_link_table. You can look at the known results for a particular generator and compare the strings.

I would love to do it, a great chance to learn how to write a test.

jinningwang commented 2 years ago

Hantao,

I added two tests for pandapower interface. The power flow test cannot pass under default settings. Then I decreased the decimal of np.testing.assert_almost_equal to 6. Is this acceptable?

Regards, Jinning

cuihantao commented 2 years ago

Yes, six decimal digits should be okay.

From: Jinning Wang @.> Sent: Friday, March 25, 2022 12:09 PM To: cuihantao/andes @.> Cc: Hantao Cui @.>; Comment @.> Subject: Re: [cuihantao/andes] Add pandapower interface (PR #287)

Hantao,

I added two tests for pandapower interface. The power flow test cannot pass under default settings. Then I decreased the decimal of np.testing.assert_almost_equal to 6. Is this acceptable?

Regards, Jinning

— Reply to this email directly, view it on GitHub https://github.com/cuihantao/andes/pull/287#issuecomment-1079228819 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSNZA4DNJUGLJ4GVKUFJK3VBXXJXANCNFSM5QGY3X7A . You are receiving this because you commented. https://github.com/notifications/beacon/ABSNZA4ZQ5E3CSQUT3CIV7LVBXXJXA5CNFSM5QGY3X7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIBJ3TEY.gif Message ID: @. @.> >

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

cuihantao commented 2 years ago

@jinningwang Jinning, I found a better place for the notebook for pandapower interface. In my latest develop branch, I moved it to docs/examples/pandapower.ipynb.

In the "Examples" tab, I added a new section for "Interoperability" in the sidebar. It should make navigation more easily. Let me know if you have any thoughts.