Skip to content

Commit

Permalink
Merge pull request e2nIEE#1358 from MMajidi137/julia_pkg
Browse files Browse the repository at this point in the history
update files from dev
  • Loading branch information
MMajidi137 authored Oct 12, 2021
2 parents 09358f1 + ae81812 commit 77c7537
Show file tree
Hide file tree
Showing 22 changed files with 461 additions and 375 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Change Log

- [FIXED] poly_cost and pwl_cost consideration in merge_nets()
- [ADDED] "results" initialization for runopp()
- [CHANGED] toolbox function nets_equal()
- [ADDED] toolbox function merge_same_bus_generation_plants()

Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for for Energy Economics
Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for Energy Economics
and Energy System Technology (IEE) Kassel and individual contributors (see AUTHORS file for details).
All rights reserved.

Expand All @@ -22,4 +22,4 @@ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ['']

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down
2 changes: 1 addition & 1 deletion doc/networks/dickert_lv_networks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For all given Dickert LV Networks (in numbers: 12) the number of delivery points
The next figure shows the topology of the paper's example with lv network with mid-range, cable type
and in good case:

.. image:: /pics/networks/example_of_dickert_lv-feeders_for_neutral-range_cable.PNG
.. image:: /pics/networks/example_of_dickert_lv-feeders_for_mid-range_cable.PNG
:height: 918.0px
:width: 1282.0px
:scale: 34%
Expand Down
2 changes: 1 addition & 1 deletion doc/powerflow/ac_3ph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ pandapower uses Sequence Frame to solve three phase power flow :

.. note::

If you are interested in the pypower casefile that pandapower is using for power flow internally, you can find it in net["_ppc0"],net["_ppc1"], net["_ppc2"].
If you are interested in the pypower casefile that pandapower is using for power flow internally, you can find it in net["_ppc0"],net["_ppc1"], net["_ppc2"].
However all necessary informations are written into the pandpower format net, so the pandapower user should not usually have to deal with pypower.

1 change: 1 addition & 0 deletions doc/shortcircuit/elements.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.. _sc_elements:

==================
Network Elements
==================
Expand Down
2 changes: 1 addition & 1 deletion doc/timeseries/timeseries_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for each time step in the corresponding row. Here is a schematic example for a g
:file: datasource_example.csv
:delim: ;

This structure is saved to a *.csv file and can be read by pandas and passed to the DataSource constructor like so:
This structure is saved to a ``*.csv`` file and can be read by pandas and passed to the DataSource constructor like so:

::

Expand Down
24 changes: 23 additions & 1 deletion doc/toolbox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ General Issues

.. autofunction:: pandapower.pp_elements

.. autofunction:: pandapower.branch_element_bus_dict

.. autofunction:: pandapower.signing_system_value

.. autofunction:: pandapower.pq_from_cosphi

.. autofunction:: pandapower.cosphi_from_pq
Expand Down Expand Up @@ -69,7 +73,7 @@ Simulation Setup and Preparation

.. autofunction:: pandapower.set_scaling_by_type

.. autofunction:: pandapower.convert_format
#.. autofunction:: pandapower.convert_format

.. autofunction:: pandapower.set_data_type_of_columns_to_default

Expand All @@ -91,12 +95,22 @@ Topology Modification

.. autofunction:: pandapower.drop_lines

.. autofunction:: pandapower.drop_measurements_at_elements

.. autofunction:: pandapower.drop_duplicated_measurements

.. autofunction:: pandapower.get_connecting_branches

.. autofunction:: pandapower.get_inner_branches

.. autofunction:: pandapower.drop_inner_branches

.. autofunction:: pandapower.set_element_status

.. autofunction:: pandapower.set_isolated_areas_out_of_service

.. autofunction:: pandapower.drop_elements_simple

.. autofunction:: pandapower.drop_out_of_service_elements

.. autofunction:: pandapower.drop_inactive_elements
Expand All @@ -105,6 +119,12 @@ Topology Modification

.. autofunction:: pandapower.merge_nets

.. autofunction:: pandapower.repl_to_line

.. autofunction:: pandapower.merge_parallel_line

.. autofunction:: pandapower.merge_same_bus_generation_plants

.. autofunction:: pandapower.create_replacement_switch_for_branch

.. autofunction:: pandapower.replace_zero_branches_with_switches
Expand All @@ -121,6 +141,8 @@ Topology Modification

.. autofunction:: pandapower.replace_sgen_by_gen

.. autofunction:: pandapower.replace_pq_elmtype

.. autofunction:: pandapower.replace_ward_by_internal_elements

.. autofunction:: pandapower.replace_xward_by_internal_elements
Expand Down
6 changes: 2 additions & 4 deletions pandapower/control/controller/trafo/ContinuousTapControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ def __init__(self, net, tid, vm_set_pu, tol=1e-3, side="lv", trafotype="2W", in_
self.check_tap_bounds = check_tap_bounds
self.vm_set_pu = vm_set_pu
self.trafotype = trafotype
if trafotype == "2W":
net.trafo["tap_pos"] = net.trafo.tap_pos.astype(float)
elif trafotype == "3W":
net.trafo3w["tap_pos"] = net.trafo3w.tap_pos.astype(float)
self.tol = tol

def control_step(self, net):
Expand All @@ -78,6 +74,8 @@ def control_step(self, net):
self.tap_pos = np.clip(self.tap_pos, self.tap_min, self.tap_max)

# WRITE TO NET
if net[self.trafotable].tap_pos.dtype != "float":
net[self.trafotable].tap_pos = net[self.trafotable].tap_pos.astype(float)
net[self.trafotable].at[self.tid, "tap_pos"] = self.tap_pos

def is_converged(self, net):
Expand Down
12 changes: 5 additions & 7 deletions pandapower/opf/run_powermodels.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os

from pandapower.converter.powermodels.to_pm import convert_to_pm_structure, dump_pm_json
from pandapower.converter.powermodels.from_pm import read_pm_results_to_net

Expand All @@ -10,8 +9,8 @@

def _runpm(net, delete_buffer_file=True, pm_file_path=None, pdm_dev_mode=False):
"""
Converts the pandapower net to a pm json file, saves it to disk, runs a PowerModels.jl julia function and reads
the results back to the pandapower net
Converts the pandapower net to a pm json file, saves it to disk, runs a PandaModels.jl, and reads
the results back to the pandapower net:
INPUT
----------
**net** - pandapower net
Expand Down Expand Up @@ -47,7 +46,7 @@ def _call_pandamodels(buffer_file, julia_file, dev_mode): # pragma: no cover
from julia import Base
except ImportError:
raise ImportError(
"Please install pyjulia properlly to run pandapower with PowerModels.jl. \nMore info on https://pandapower.readthedocs.io/en/v2.6.0/opf/powermodels.html")
"Please install pyjulia properlly to run pandapower with PandaModels.jl.")

try:
julia.Julia()
Expand All @@ -56,9 +55,8 @@ def _call_pandamodels(buffer_file, julia_file, dev_mode): # pragma: no cover
"Could not connect to julia, please check that Julia is installed and pyjulia is correctly configured")

if not Base.find_package("PandaModels"):
print("PandaModels is not installed in julia. It is added now!")
print("PandaModels.jl is not installed in julia. It is added now!")
Pkg.Registry.update()
# Pkg.update()
Pkg.add("PandaModels")

if dev_mode:
Expand All @@ -79,9 +77,9 @@ def _call_pandamodels(buffer_file, julia_file, dev_mode): # pragma: no cover
except ImportError:
raise ImportError("cannot use PandaModels")


Main.buffer_file = buffer_file
result_pm = Main.eval(julia_file + "(buffer_file)")

return result_pm


33 changes: 18 additions & 15 deletions pandapower/opf/validate_opf_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,25 @@ def _check_necessary_opf_parameters(net, logger):
else:
controllables = net[element_type].index if element_type == 'gen' else []

missing_col = columns.loc[~columns.isin(net[element_type].columns)].values
na_col = [col for col in set(columns)-set(missing_col) if
net[element_type][col].isnull().any()]

# --- logging for missing data in element tables with controllables
if len(controllables) and len(missing_col):
if element_type != "ext_grid":
logger.error("These columns are missing in " + element_type + ": " +
str(missing_col))
error = True
else: # "ext_grid" -> no error due to missing columns at ext_grid
logger.debug("These missing columns in ext_grid are considered in OPF as " +
"+- 1000 TW.: " + str(missing_col))
# determine missing values
if len(na_col):
missing_val.append(element_type)
if len(controllables):

missing_col = columns.loc[~columns.isin(net[element_type].columns)].values
na_col = [col for col in set(columns)-set(missing_col) if
net[element_type][col].isnull().any()]

if len(missing_col):
if element_type != "ext_grid":
logger.error("These columns are missing in " + element_type + ": " +
str(missing_col))
error = True
else: # "ext_grid" -> no error due to missing columns at ext_grid
logger.debug("These missing columns in ext_grid are considered in OPF as " +
"+- 1000 TW.: " + str(missing_col))

# determine missing values
if len(na_col):
missing_val.append(element_type)

if missing_val:
logger.info("These elements have missing power constraint values, which are considered " +
Expand Down
8 changes: 6 additions & 2 deletions pandapower/optimal_powerflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pandapower.pypower.printpf import printpf
from pandapower.pd2ppc import _pd2ppc
from pandapower.pf.run_newton_raphson_pf import _run_newton_raphson_pf
from pandapower.results import _copy_results_ppci_to_ppc, init_results, \
from pandapower.results import _copy_results_ppci_to_ppc, init_results, verify_results, \
_extract_results


Expand All @@ -36,7 +36,11 @@ def _optimal_powerflow(net, verbose, suppress_warnings, **kwargs):
net["OPF_converged"] = False
net["converged"] = False
_add_auxiliary_elements(net)
init_results(net, "opf")

if not ac or net["_options"]["init_results"]:
verify_results(net)
else:
init_results(net, "opf")

ppc, ppci = _pd2ppc(net)

Expand Down
Loading

0 comments on commit 77c7537

Please sign in to comment.