forked from e2nIEE/pandapower
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request e2nIEE#1356 from MMajidi137/julia_pkg
add test file
- Loading branch information
Showing
4 changed files
with
167 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
.. _sc_elements: | ||
================== | ||
Network Elements | ||
================== | ||
|
||
Correction factors for generator and branch elements are implemented as defined in the IEC 60909 standard. The results for all elements are tested against commercial software to ensure that correction factors are correctly applied. | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
voltage_source | ||
current_source | ||
branch_elements | ||
.. _sc_elements: | ||
================== | ||
Network Elements | ||
================== | ||
|
||
Correction factors for generator and branch elements are implemented as defined in the IEC 60909 standard. The results for all elements are tested against commercial software to ensure that correction factors are correctly applied. | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
voltage_source | ||
current_source | ||
branch_elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
==================================== | ||
Running a Short-Circuit Calculation | ||
==================================== | ||
|
||
The short circuit calculation is carried out with the calc_sc function: | ||
|
||
.. autofunction:: pandapower.shortcircuit.calc_sc | ||
|
||
|
||
.. code:: python | ||
import pandapower.shortcircuit as sc | ||
import pandapower.networks as nw | ||
net = nw.mv_oberrhein() | ||
net.ext_grid["s_sc_min_mva"] = 100 | ||
net.ext_grid["rx_min"] = 0.1 | ||
net.line["endtemp_degree"] = 20 | ||
sc.calc_sc(net, case="min") | ||
print(net.res_bus_sc) | ||
==================================== | ||
Running a Short-Circuit Calculation | ||
==================================== | ||
|
||
The short circuit calculation is carried out with the calc_sc function: | ||
|
||
.. autofunction:: pandapower.shortcircuit.calc_sc | ||
|
||
|
||
.. code:: python | ||
import pandapower.shortcircuit as sc | ||
import pandapower.networks as nw | ||
net = nw.mv_oberrhein() | ||
net.ext_grid["s_sc_min_mva"] = 100 | ||
net.ext_grid["rx_min"] = 0.1 | ||
net.line["endtemp_degree"] = 20 | ||
sc.calc_sc(net, case="min") | ||
print(net.res_bus_sc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for Energy Economics | ||
# and Energy System Technology (IEE), Kassel. All rights reserved. | ||
|
||
|
||
import pytest | ||
|
||
julia_installed = [] | ||
|
||
@pytest.mark.slow | ||
@pytest.mark.skipif(julia_installed == False, reason="requires julia installation") | ||
def test_julia_installation(): | ||
|
||
try: | ||
from julia.core import UnsupportedPythonError | ||
except AssertionError: | ||
UnsupportedPythonError = Exception | ||
|
||
try: | ||
from julia import Main | ||
status = True | ||
|
||
except (AssertionError, RuntimeError, UnsupportedPythonError) as e: | ||
status = False | ||
print(e) | ||
|
||
|
||
julia_installed.append(status) | ||
|
||
|
||
@pytest.mark.slow | ||
@pytest.mark.skipif(julia_installed == False, reason="requires julia installation") | ||
@pytest.mark.dependency(depends=['test_julia_installation']) | ||
def test_julia_connection(): | ||
|
||
try: | ||
import julia | ||
except: | ||
raise AssertionError( | ||
"install pyjulia properlly to run PandaModels.jl") | ||
|
||
try: | ||
julia.Julia() | ||
except: | ||
raise AssertionError( | ||
"cannot connect to julia, check pyjulia configuration") | ||
|
||
|
||
@pytest.mark.slow | ||
@pytest.mark.skipif(julia_installed == False, reason="requires julia installation") | ||
@pytest.mark.dependency(depends=['test_julia_connection']) | ||
def test_pandamodels_installation(): | ||
|
||
from julia import Main | ||
from julia import Pkg | ||
from julia import Base | ||
|
||
if Base.find_package("PandaModels"): | ||
# remove PandaModels to reinstall it | ||
Pkg.rm("PandaModels") | ||
Pkg.resolve() | ||
|
||
else: | ||
print("PandaModels is not installed yet!") | ||
|
||
Pkg.Registry.update() | ||
Pkg.add("PandaModels") | ||
Pkg.build() | ||
Pkg.resolve() | ||
print("PandaModels is added to julia packages") | ||
|
||
try: | ||
Main.using("PandaModels") | ||
print("using PandaModels in its base mode!") | ||
except: | ||
raise AssertionError("cannot use PandaModels in its base mode") | ||
|
||
|
||
@pytest.mark.slow | ||
@pytest.mark.skipif(julia_installed == False, reason="requires julia installation") | ||
@pytest.mark.dependency(depends=['test_pandamodels_installation']) | ||
def test_pandamodels_dev_mode(): | ||
|
||
from julia import Main | ||
from julia import Pkg | ||
from julia import Base | ||
|
||
if Base.find_package("PandaModels"): | ||
# remove PandaModels to reinstall it | ||
Pkg.rm("PandaModels") | ||
Pkg.resolve() | ||
|
||
|
||
Pkg.Registry.update() | ||
Pkg.add("PandaModels") | ||
print("installing dev mode is a slow process!") | ||
Pkg.resolve() | ||
Pkg.develop("PandaModels") | ||
# add pandamodels dependencies: slow process | ||
Pkg.instantiate() | ||
Pkg.build() | ||
Pkg.resolve() | ||
print("dev mode of PandaModels is added to julia packages") | ||
|
||
try: | ||
Pkg.activate("PandaModels") | ||
Main.using("PandaModels") | ||
print("using PandaModels in its dev mode!") | ||
except: | ||
raise AssertionError("cannot use PandaModels in its base mode") | ||
|
||
# activate julia base mode | ||
Pkg.activate() | ||
# remove dev mod | ||
Pkg.rm("PandaModels") | ||
Pkg.resolve() | ||
# reinstall base mode | ||
Pkg.Registry.update() | ||
Pkg.add("PandaModels") | ||
Pkg.build() | ||
Pkg.resolve() | ||
print("PandaModels is added to julia packages") | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# test_julia_installation() | ||
# test_julia_connection() | ||
# test_pandamodels_installation() | ||
# test_pandamodels_dev_mode() | ||
|
||
pytest.main([__file__]) |