Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Apr 16, 2024
2 parents ceeee99 + d3f22be commit dda9fd7
Show file tree
Hide file tree
Showing 78 changed files with 28,966 additions and 27,724 deletions.
235 changes: 84 additions & 151 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified Grids_and_profiles/grids/IEEE39_1W.gridcal
Binary file not shown.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ Sequence voltage, currents and powers are also available.
import os
from matplotlib import pyplot as plt
import GridCalEngine.api as gce

plt.style.use('fivethirtyeight')

folder = os.path.join('..', 'Grids_and_profiles', 'grids')
Expand Down Expand Up @@ -755,7 +756,7 @@ vc_inputs = gce.ContinuationPowerFlowInput(Sbase=base_power,
Starget=base_power * 2)

# declare the CPF driver and run
vc = gce.ContinuationPowerFlowDriver(circuit=main_circuit,
vc = gce.ContinuationPowerFlowDriver(grid=main_circuit,
options=vc_options,
inputs=vc_inputs,
pf_options=pf_options)
Expand Down
2 changes: 1 addition & 1 deletion examples/contingency_analysis_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
pf_options=PowerFlowOptions(),
)

simulation = ContingencyAnalysisTimeSeries(
simulation = ContingencyAnalysisTimeSeriesDriver(
grid=main_circuit,
options=options_,
time_indices=main_circuit.get_all_time_indices(),
Expand Down
2 changes: 1 addition & 1 deletion examples/cpf_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Vbase=power_flow.results.voltage,
Starget=base_power * 2)

vc = gce.ContinuationPowerFlowDriver(circuit=main_circuit,
vc = gce.ContinuationPowerFlowDriver(grid=main_circuit,
options=vc_options,
inputs=vc_inputs,
pf_options=pf_options)
Expand Down
8 changes: 4 additions & 4 deletions src/GridCal/Gui/CascadingSteps/cascading_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run_cascade_step(self):
options = self.gridcal_main.get_selected_power_flow_options()
options.solver_type = SolverType.LM
max_isl = self.gridcal_main.ui.cascading_islands_spinBox.value()
drv = sim.Cascading(self.gridcal_main.circuit.copy(), options, max_additional_islands=max_isl)
drv = sim.CascadingDriver(self.gridcal_main.circuit.copy(), options, max_additional_islands=max_isl)

self.gridcal_main.session.run(drv,
post_func=self.gridcal_main.post_cascade,
Expand Down Expand Up @@ -101,9 +101,9 @@ def run_cascade(self):
max_isl = self.gridcal_main.ui.cascading_islands_spinBox.value()
n_lsh_samples = self.gridcal_main.ui.max_iterations_stochastic_spinBox.value()

drv = sim.Cascading(self.gridcal_main.circuit.copy(), options,
max_additional_islands=max_isl,
n_lhs_samples_=n_lsh_samples)
drv = sim.CascadingDriver(self.gridcal_main.circuit.copy(), options,
max_additional_islands=max_isl,
n_lhs_samples_=n_lsh_samples)

self.gridcal_main.session.run(drv,
post_func=self.gridcal_main.post_cascade,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ def __init__(self,
from_port: Union[BarTerminalItem, RoundTerminalItem],
to_port: Union[BarTerminalItem, RoundTerminalItem],
editor: DiagramEditorWidget,
width=5, api_object: DcLine = None):
width=5, api_object: DcLine = None,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -247,7 +248,8 @@ def __init__(self,
to_port=to_port,
editor=editor,
width=width,
api_object=api_object)
api_object=api_object,
draw_labels=draw_labels)

def contextMenuEvent(self, event):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __init__(self,
to_port: Union[BarTerminalItem, RoundTerminalItem],
editor: DiagramEditorWidget,
width=5,
api_object: HvdcLine = None):
api_object: HvdcLine = None,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -48,7 +49,8 @@ def __init__(self,
to_port=to_port,
editor=editor,
width=width,
api_object=api_object)
api_object=api_object,
draw_labels=draw_labels)

def contextMenuEvent(self, event):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,24 @@ def __init__(self,
to_port: Union[BarTerminalItem, RoundTerminalItem, None],
editor: DiagramEditorWidget,
width=5,
api_object: Line = None):
api_object: Line = None,
draw_labels: bool = True):
"""
:param from_port:
:param to_port:
:param editor:
:param width:
:param api_object:
:param draw_labels:
"""
LineGraphicTemplateItem.__init__(self,
from_port=from_port,
to_port=to_port,
editor=editor,
width=width,
api_object=api_object)
api_object=api_object,
draw_labels=draw_labels)

def remove_symbol(self) -> None:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ def __init__(self,
editor: DiagramEditorWidget,
width=5,
api_object: Union[Line, Transformer2W, VSC, UPFC, HvdcLine, DcLine, FluidPath, None] = None,
arrow_size=10):
arrow_size=10,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -433,8 +434,9 @@ def __init__(self,
:param width:
:param api_object:
:param arrow_size:
:param draw_labels:
"""
GenericDBWidget.__init__(self, parent=None, api_object=api_object, editor=editor, draw_labels=True)
GenericDBWidget.__init__(self, parent=None, api_object=api_object, editor=editor, draw_labels=draw_labels)
QGraphicsLineItem.__init__(self)

if isinstance(api_object, Transformer2W):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def __init__(self,
from_port: Union[BarTerminalItem, RoundTerminalItem],
to_port: Union[BarTerminalItem, RoundTerminalItem],
editor: DiagramEditorWidget, width=5,
api_object: SeriesReactance = None):
api_object: SeriesReactance = None,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -46,7 +47,8 @@ def __init__(self,
to_port=to_port,
editor=editor,
width=width,
api_object=api_object)
api_object=api_object,
draw_labels=draw_labels)

def contextMenuEvent(self, event):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class TransformerGraphicItem(LineGraphicTemplateItem):
def __init__(self,
from_port: Union[BarTerminalItem, RoundTerminalItem],
to_port: Union[BarTerminalItem, RoundTerminalItem],
editor: DiagramEditorWidget, width=5,
api_object: Transformer2W = None):
editor: DiagramEditorWidget,
width=5,
api_object: Transformer2W = None,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -54,7 +56,8 @@ def __init__(self,
to_port=to_port,
editor=editor,
width=width,
api_object=api_object)
api_object=api_object,
draw_labels=draw_labels)

def contextMenuEvent(self, event):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class UpfcGraphicItem(LineGraphicTemplateItem):

def __init__(self, from_port: BarTerminalItem, to_port: BarTerminalItem,
editor: DiagramEditorWidget, width=5,
api_object: UPFC = None):
api_object: UPFC = None,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -45,7 +46,8 @@ def __init__(self, from_port: BarTerminalItem, to_port: BarTerminalItem,
to_port=to_port,
editor=editor,
width=width,
api_object=api_object)
api_object=api_object,
draw_labels=draw_labels)

def contextMenuEvent(self, event):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def __init__(self,
from_port: Union[BarTerminalItem, RoundTerminalItem],
to_port: Union[BarTerminalItem, RoundTerminalItem],
editor: DiagramEditorWidget, width=5,
api_object: VSC = None):
api_object: VSC = None,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -50,7 +51,8 @@ def __init__(self,
to_port=to_port,
editor=editor,
width=width,
api_object=api_object)
api_object=api_object,
draw_labels=draw_labels)

def contextMenuEvent(self, event):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ class FluidNodeGraphicItem(GenericDBWidget, QtWidgets.QGraphicsRectItem):
"""

def __init__(self, editor: DiagramEditorWidget, fluid_node: FluidNode,
parent=None, index=0, h: int = 20, w: int = 80, x: int = 0, y: int = 0):
parent=None, index=0, h: int = 20, w: int = 80, x: int = 0, y: int = 0,
draw_labels: bool = True):

GenericDBWidget.__init__(self, parent=parent, api_object=fluid_node, editor=editor, draw_labels=True)
GenericDBWidget.__init__(self, parent=parent, api_object=fluid_node, editor=editor, draw_labels=draw_labels)
QtWidgets.QGraphicsRectItem.__init__(self, parent)

self.min_w = 180.0
Expand Down Expand Up @@ -181,6 +182,7 @@ def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
w=self.w,
h=self.h,
r=self.rotation(),
draw_labels=self.draw_labels,
graphic_object=self)

def set_position(self, x, y):
Expand Down Expand Up @@ -262,6 +264,7 @@ def change_size(self, w: int, h: Union[None, int] = None):
w=self.w,
h=int(self.min_h),
r=self.rotation(),
draw_labels=self.draw_labels,
graphic_object=self)

return self.w, self.min_h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def __init__(self,
editor: DiagramEditorWidget,
width=10,
api_object: FluidPath = None,
arrow_size=15):
arrow_size=15,
draw_labels: bool = True):
"""
:param from_port:
Expand All @@ -51,7 +52,7 @@ def __init__(self,
:param api_object:
:param arrow_size:
"""
GenericDBWidget.__init__(self, parent=None, api_object=api_object, editor=editor, draw_labels=True)
GenericDBWidget.__init__(self, parent=None, api_object=api_object, editor=editor, draw_labels=draw_labels)
LineGraphicTemplateItem.__init__(self,
from_port=from_port,
to_port=to_port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def __init__(self,
h: int = 40,
w: int = 80,
x: int = 0,
y: int = 0):
y: int = 0,
draw_labels: bool = True):
"""
:param parent:
Expand All @@ -82,7 +83,7 @@ def __init__(self,
:param x:
:param y:
"""
GenericDBWidget.__init__(self, parent=parent, api_object=bus, editor=editor, draw_labels=True)
GenericDBWidget.__init__(self, parent=parent, api_object=bus, editor=editor, draw_labels=draw_labels)
QtWidgets.QGraphicsRectItem.__init__(self, parent)

self.min_w = 180.0
Expand Down Expand Up @@ -160,6 +161,7 @@ def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
w=self.w,
h=self.h,
r=self.rotation(),
draw_labels=self.draw_labels,
graphic_object=self)

def add_big_marker(self, color: Union[None, QColor] = Qt.red, tool_tip_text: str = ""):
Expand Down Expand Up @@ -258,6 +260,7 @@ def change_size(self, w: int, dummy: float = 0.0):
w=self.w,
h=int(self.min_h),
r=self.rotation(),
draw_labels=self.draw_labels,
graphic_object=self)

return self.w, self.min_h
Expand Down Expand Up @@ -431,11 +434,11 @@ def contextMenuEvent(self, event: QtWidgets.QGraphicsSceneContextMenuEvent):
da.setIcon(del_icon)
da.triggered.connect(self.remove)

re = menu.addAction('Reduce')
re = menu.addAction('Expand schematic')
re_icon = QIcon()
re_icon.addPixmap(QPixmap(":/Icons/icons/grid_reduction.svg"))
re_icon.addPixmap(QPixmap(":/Icons/icons/grid_icon.svg"))
re.setIcon(re_icon)
re.triggered.connect(self.reduce)
re.triggered.connect(self.expand_diagram_from_bus)

menu.addSection("Add")

Expand Down Expand Up @@ -501,16 +504,6 @@ def delete_all_connections(self) -> None:
"""
self._terminal.remove_all_connections()

def reduce(self):
"""
Reduce this bus
:return:
"""
ok = yes_no_question('Are you sure that you want to reduce this bus', 'Reduce bus')
if ok:
reduce_buses(self.editor.circuit, [self.api_object])
self.remove()

def remove(self, ask: bool = True) -> None:
"""
Remove this element
Expand Down Expand Up @@ -538,6 +531,12 @@ def update_color(self):
else:
self.set_tile_color(QBrush(DEACTIVATED['color']))

def expand_diagram_from_bus(self) -> None:
"""
Expands the diagram from this bus
"""
self.editor.expand_diagram_from_bus(root_bus=self.api_object)

def enable_disable_toggle(self):
"""
Toggle bus element state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
w=self.w,
h=self.h,
r=self.rotation(),
draw_labels=self.draw_labels,
graphic_object=self)

def add_big_marker(self, color: Union[None, QColor] = Qt.red, tool_tip_text: str = ""):
Expand Down Expand Up @@ -257,6 +258,7 @@ def change_size(self, w: int, dummy: float = 0.0):
w=w,
h=int(self.min_h),
r=self.rotation(),
draw_labels=self.draw_labels,
graphic_object=self)

return w, self.min_h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

from GridCalEngine.enumerations import DeviceType, FaultType
from GridCalEngine.Devices.types import INJECTION_DEVICE_TYPES
from GridCalEngine.Simulations.Topology.topology_reduction_driver import reduce_buses
from GridCalEngine.Devices.Substation.connectivity_node import ConnectivityNode

if TYPE_CHECKING: # Only imports the below statements during type checking
Expand Down Expand Up @@ -146,6 +145,7 @@ def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
w=self.w,
h=self.h,
r=self.rotation(),
draw_labels=self.draw_labels,
graphic_object=self)

def set_position(self, x: int, y: int) -> None:
Expand Down
Loading

0 comments on commit dda9fd7

Please sign in to comment.