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

pf2pp: Added option to use a specifc variant and scenario of PowerFactory for conversion #2353

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Change Log

[upcoming release] - 2024-..-..
-------------------------------
- [ADDED] pf2pp: possibility to convert a specific varaint and scenario
- [ADDED] low voltage grid Schutterwald
- [FIXED] trafo3w with tap changer at star point corrected
- [FIXED] namespace changes from numpy 2.0 release
Expand Down
32 changes: 29 additions & 3 deletions pandapower/converter/powerfactory/export_pfd_to_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
logger = logging.getLogger(__name__)


def from_pfd(app, prj_name: str, path_dst=None, pv_as_slack=False, pf_variable_p_loads='plini',
def from_pfd(app, prj_name: str, variant_name=None, scenario_name=None, include_hidden_bus=True, path_dst=None,
pv_as_slack=False, pf_variable_p_loads='plini',
pf_variable_p_gen='pgini', flag_graphics='GPS', tap_opt='nntap',
export_controller=True, handle_us="Deactivate", is_unbalanced=False, create_sections=True):
"""
Expand Down Expand Up @@ -44,9 +45,34 @@ def from_pfd(app, prj_name: str, path_dst=None, pv_as_slack=False, pf_variable_p
raise RuntimeError('Project %s could not be found or activated' % prj_name)

prj = app.GetActiveProject()


if (variant_name is not None) and (scenario_name is not None):
variants_folder = app.GetProjectFolder('scheme')
variants = variants_folder.GetContents()
for variant in variants:
if variant.loc_name == variant_name:
break
else:
raise UserWarning(f"{variant_name} does not exist in PowerFactory.")
# found variant and activate it
variant.Activate()

scenarios = variant.GetContents()
for scenario in scenarios:
if scenario.loc_name == scenario_name:
break
else:
raise UserWarning(f"{scenario_name} does not exist in PowerFactory.")
# found scenario and activate it
scenario.Activate()
elif (variant_name is None) and (scenario_name is not None):
raise UserWarning(f"scenario_name {scenario_name} is chosen but no variant_name.")
elif (variant_name is not None) and (scenario_name is None):
raise UserWarning(f"variant_name {variant_name} is chosen but no scenario_name.")


logger.info('gathering network elements')
dict_net = create_network_dict(app, flag_graphics)
dict_net = create_network_dict(app, include_hidden_bus, flag_graphics)
pf_load_flow_failed = run_load_flow(app)
logger.info('exporting network to pandapower')
app.SetAttributeModeInternal(1)
Expand Down
6 changes: 4 additions & 2 deletions pandapower/converter/powerfactory/pf_export_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

logger = logging.getLogger(__name__)

def create_network_dict(app, flag_graphics='GPS'):
def create_network_dict(app, include_hidden_bus, flag_graphics='GPS'):
# elements to be exported from PowerFactory
set_object_extentions = {
# node elements:
Expand Down Expand Up @@ -76,8 +76,10 @@ def create_network_dict(app, flag_graphics='GPS'):

logger.info('collecting network elements')
for obj in set_object_extentions:
if obj == 'ElmTerm':
if (obj == 'ElmTerm') and (include_hidden_bus==True):
dict_net[obj] = app.GetCalcRelevantObjects(obj, 1, 0, 1)
elif (obj == 'ElmTerm') and (include_hidden_bus==False):
dict_net[obj] = app.GetCalcRelevantObjects(obj) # default: 1,0,0
else:
dict_net[obj] = app.GetCalcRelevantObjects(obj)

Expand Down