Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pandapower interface #287

Merged
merged 36 commits into from
Mar 25, 2022
Merged

Add pandapower interface #287

merged 36 commits into from
Mar 25, 2022

Conversation

jinningwang
Copy link
Member

@jinningwang jinningwang commented Mar 8, 2022

  • Add pandapower interface functions: to_pandapower, ssa_link, opp_res, ssp_cost.
  • Add example of the interface: ex11.ipynb.

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

@codecov
Copy link

codecov bot commented Mar 8, 2022

Codecov Report

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

❗ 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%) ⬆️
andes/core/documenter.py 84.84% <0.00%> (-1.64%) ⬇️
andes/system.py 76.16% <0.00%> (-0.01%) ⬇️
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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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

@cuihantao
Copy link
Collaborator

cuihantao commented Mar 21, 2022

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
Copy link
Collaborator

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
Copy link
Collaborator

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

@cuihantao
Copy link
Collaborator

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
Copy link
Member Author

jinningwang commented Mar 23, 2022

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.

@cuihantao
Copy link
Collaborator

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

@cuihantao
Copy link
Collaborator

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
Copy link
Member Author

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

All my thoughts have been covered.

@cuihantao
Copy link
Collaborator

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Collaborator

cuihantao commented Mar 25, 2022 via email

@cuihantao cuihantao merged commit 3653454 into CURENT:develop Mar 25, 2022
@sonarcloud
Copy link

sonarcloud bot commented Mar 25, 2022

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

@jinningwang jinningwang deleted the ppintf branch March 26, 2022 18:55
@cuihantao
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants