Skip to content

Commit 38f28db

Browse files
committed
Merge branch 'refs/heads/devel' into devel_convert_map_widget
# Conflicts: # .idea/workspace.xml
2 parents 9fc00e4 + 909aa4e commit 38f28db

37 files changed

+93
-53
lines changed

src/GridCal/Gui/Diagrams/SchematicWidget/Injections/injections_template_graphics.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,12 @@ def update_nexus(self, pos):
8787
Update the nexus line that joins the parent and this object
8888
:param pos: position of this object
8989
"""
90-
parent = self.parentItem()
91-
rect = parent.rect()
92-
term = parent.get_terminal()
90+
parent_pt = self.parentItem().get_nexus_point()
9391
self.nexus.setLine(
9492
pos.x() + self.w / 2,
9593
pos.y(),
96-
parent.x() + rect.width() / 2,
97-
parent.y() + rect.height() + term.h / 2,
94+
parent_pt.x(),
95+
parent_pt.y(),
9896
)
9997
self.setZValue(-1)
10098
self.nexus.setZValue(-1)

src/GridCal/Gui/Diagrams/SchematicWidget/Substation/bus_graphics.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import numpy as np
1919
from typing import Union, TYPE_CHECKING, List, Dict
2020
from PySide6 import QtWidgets
21-
from PySide6.QtCore import Qt, QPoint, QRectF, QRect
21+
from PySide6.QtCore import Qt, QPoint, QRectF, QRect, QPointF
2222
from PySide6.QtGui import QPen, QCursor, QIcon, QPixmap, QBrush, QColor
2323
from PySide6.QtWidgets import QMenu, QGraphicsSceneMouseEvent
2424

@@ -145,6 +145,14 @@ def __init__(self,
145145

146146
self.set_position(x, y)
147147

148+
def get_nexus_point(self) -> QPointF:
149+
"""
150+
Get the connection point for the chldren nexus line
151+
:return: QPointF
152+
"""
153+
return QPointF(self.x() + self.rect().width() / 2.0,
154+
self.y() + self.rect().height() + self._terminal.h / 2.0)
155+
148156
def recolour_mode(self) -> None:
149157
"""
150158
Change the colour according to the system theme

src/GridCal/Gui/Diagrams/SchematicWidget/Substation/busbar_graphics.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import numpy as np
1919
from typing import Union, TYPE_CHECKING, List, Dict
2020
from PySide6 import QtWidgets
21-
from PySide6.QtCore import Qt, QPoint, QRectF, QRect
21+
from PySide6.QtCore import Qt, QPoint, QRectF, QRect, QPointF
2222
from PySide6.QtGui import QPen, QCursor, QIcon, QPixmap, QBrush, QColor
2323
from PySide6.QtWidgets import QMenu, QGraphicsSceneMouseEvent
2424

@@ -133,6 +133,14 @@ def __init__(self,
133133

134134
self.set_position(x, y)
135135

136+
def get_nexus_point(self) -> QPointF:
137+
"""
138+
Get the connection point for the chldren nexus line
139+
:return: QPointF
140+
"""
141+
return QPointF(self.x() + self.rect().width() / 2.0,
142+
self.y() + self.rect().height() + self._terminal.h / 2.0)
143+
136144
def recolour_mode(self) -> None:
137145
"""
138146
Change the colour according to the system theme

src/GridCal/Gui/Diagrams/SchematicWidget/Substation/cn_graphics.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import numpy as np
1919
from typing import Union, TYPE_CHECKING, List, Dict
2020
from PySide6 import QtWidgets
21-
from PySide6.QtCore import Qt, QPoint
21+
from PySide6.QtCore import Qt, QPoint, QPointF
2222
from PySide6.QtGui import QPen, QCursor, QIcon, QPixmap
2323
from PySide6.QtWidgets import QMenu, QGraphicsSceneMouseEvent
2424

@@ -108,6 +108,7 @@ def __init__(self,
108108
self._terminal = RoundTerminalItem('s', parent=self, editor=self.editor, h=20, w=20) # , h=self.h))
109109
self._terminal.setPen(QPen(Qt.transparent, self.pen_width, self.style, Qt.RoundCap, Qt.RoundJoin))
110110
self._terminal.setPos(QPoint(15, 15))
111+
self._terminal_mid_point = QPoint(20, 20) # (15, 15) + (20, 20) / 2
111112

112113
self.setPen(QPen(Qt.transparent, self.pen_width, self.style))
113114
self.setBrush(Qt.transparent)
@@ -118,6 +119,14 @@ def __init__(self,
118119
self.set_position(x, y)
119120
self.setRect(0.0, 0.0, self.w, self.h)
120121

122+
def get_nexus_point(self) -> QPointF:
123+
"""
124+
Get the connection point for the chldren nexus line
125+
:return: QPointF
126+
"""
127+
return QPointF(self.x() + self._terminal_mid_point.x(),
128+
self.y() + self._terminal_mid_point.y())
129+
121130
def recolour_mode(self) -> None:
122131
"""
123132
Change the colour according to the system theme

src/GridCal/Gui/Main/SubClasses/Settings/configuration.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ def change_theme_mode(self) -> None:
114114
additional_qss="QToolTip {color: white; background-color: black; border: 0px; }")
115115

116116
# note: The 0px border on the tooltips allow it to render properly
117-
118-
diagram = self.get_selected_diagram_widget()
119-
if diagram is not None:
117+
for diagram in self.diagram_widgets_list:
120118
if isinstance(diagram, SchematicWidget):
121119
diagram.set_dark_mode()
122120

@@ -131,9 +129,7 @@ def change_theme_mode(self) -> None:
131129
additional_qss="QToolTip {color: black; background-color: white; border: 0px;}")
132130

133131
# note: The 0px border on the tooltips allow it to render properly
134-
135-
diagram = self.get_selected_diagram_widget()
136-
if diagram is not None:
132+
for diagram in self.diagram_widgets_list:
137133
if isinstance(diagram, SchematicWidget):
138134
diagram.set_light_mode()
139135

src/GridCalEngine/DataStructures/numerical_circuit.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,8 @@ def compile_numerical_circuit_at(circuit: MultiCircuit,
19951995
opf_results: Union[OptimalPowerFlowResults, None] = None,
19961996
use_stored_guess=False,
19971997
bus_dict: Union[Dict[Bus, int], None] = None,
1998-
areas_dict: Union[Dict[Area, int], None] = None) -> NumericalCircuit:
1998+
areas_dict: Union[Dict[Area, int], None] = None,
1999+
logger=Logger()) -> NumericalCircuit:
19992000
"""
20002001
Compile a NumericalCircuit from a MultiCircuit
20012002
:param circuit: MultiCircuit instance
@@ -2006,11 +2007,10 @@ def compile_numerical_circuit_at(circuit: MultiCircuit,
20062007
:param use_stored_guess: use the storage voltage guess?
20072008
:param bus_dict (optional) Dict[Bus, int] dictionary
20082009
:param areas_dict (optional) Dict[Area, int] dictionary
2010+
:param logger: Logger instance
20092011
:return: NumericalCircuit instance
20102012
"""
20112013

2012-
logger = Logger()
2013-
20142014
if circuit.get_connectivity_nodes_number() + circuit.get_switches_number():
20152015
# process topology, this
20162016
circuit.process_topology_at(t_idx=t_idx, logger=logger)

src/GridCalEngine/Simulations/ATC/available_transfer_capacity_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def run(self):
502502
idx2b = self.options.bus_idx_to
503503

504504
# declare the numerical circuit
505-
nc = compile_numerical_circuit_at(circuit=self.grid, t_idx=None)
505+
nc = compile_numerical_circuit_at(circuit=self.grid, t_idx=None, logger=self.logger)
506506

507507
# declare the linear analysis
508508
linear = LinearAnalysis(

src/GridCalEngine/Simulations/ATC/available_transfer_capacity_ts_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def run(self) -> None:
269269
la_driver.run()
270270

271271
# get the branch indices to analyze
272-
nc = compile_numerical_circuit_at(self.grid)
272+
nc = compile_numerical_circuit_at(self.grid, logger=self.logger)
273273
br_idx = nc.branch_data.get_monitor_enabled_indices()
274274
con_br_idx = nc.branch_data.get_contingency_enabled_indices()
275275

src/GridCalEngine/Simulations/ContinuationPowerFlow/continuation_power_flow_driver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def run_at(self, t_idx: Union[int, None] = None) -> ContinuationPowerFlowResults
9191
t_idx=t_idx,
9292
apply_temperature=self.pf_options.apply_temperature_correction,
9393
branch_tolerance_mode=self.pf_options.branch_impedance_tolerance_mode,
94-
opf_results=self.opf_results)
94+
opf_results=self.opf_results,
95+
logger=self.logger)
9596

9697
islands = nc.split_into_islands(ignore_single_node_islands=self.pf_options.ignore_single_node_islands)
9798

src/GridCalEngine/Simulations/LinearFactors/linear_analysis_driver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def run(self):
101101
nc = compile_numerical_circuit_at(
102102
circuit=self.grid,
103103
t_idx=None,
104-
opf_results=self.opf_results
104+
opf_results=self.opf_results,
105+
logger=self.logger
105106
)
106107

107108
analysis = LinearAnalysis(

src/GridCalEngine/Simulations/LinearFactors/linear_analysis_ts_driver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def run(self):
9292

9393
nc = compile_numerical_circuit_at(circuit=self.grid,
9494
t_idx=t,
95-
opf_results=self.opf_time_series_results)
95+
opf_results=self.opf_time_series_results,
96+
logger=self.logger)
9697

9798
driver_ = LinearAnalysis(
9899
numerical_circuit=nc,

src/GridCalEngine/Simulations/NTC/ntc_opf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,8 @@ def run_linear_ntc_opf_ts(grid: MultiCircuit,
10681068
nc: NumericalCircuit = compile_numerical_circuit_at(circuit=grid,
10691069
t_idx=t, # yes, this is not a bug
10701070
bus_dict=bus_dict,
1071-
areas_dict=areas_dict)
1071+
areas_dict=areas_dict,
1072+
logger=logger)
10721073

10731074
# formulate the bus angles ---------------------------------------------------------------------------------
10741075
for k in range(nc.bus_data.nbus):

src/GridCalEngine/Simulations/NTC/ntc_ts_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def opf(self):
7575
print('Compiling cicuit...')
7676

7777
tm0 = time.time()
78-
nc = compile_numerical_circuit_at(self.grid, t_idx=None)
78+
nc = compile_numerical_circuit_at(self.grid, t_idx=None, logger=self.logger)
7979
self.logger.add_info(f'Time circuit compiled in {time.time() - tm0:.2f} scs')
8080
print(f'Time circuit compiled in {time.time() - tm0:.2f} scs')
8181

src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ def run_nonlinear_opf(grid: MultiCircuit,
10061006
"""
10071007

10081008
# compile the system
1009-
nc = compile_numerical_circuit_at(circuit=grid, t_idx=t_idx)
1009+
nc = compile_numerical_circuit_at(circuit=grid, t_idx=t_idx, logger=logger)
10101010

10111011
if pf_init:
10121012
if Sbus_pf0 is None:

src/GridCalEngine/Simulations/OPF/linear_opf_ts.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,8 @@ def run_linear_opf_ts(grid: MultiCircuit,
16481648
nc: NumericalCircuit = compile_numerical_circuit_at(circuit=grid,
16491649
t_idx=global_t_idx, # yes, this is not a bug
16501650
bus_dict=bus_dict,
1651-
areas_dict=areas_dict)
1651+
areas_dict=areas_dict,
1652+
logger=logger)
16521653

16531654
# formulate the bus angles ---------------------------------------------------------------------------------
16541655
for k in range(nc.bus_data.nbus):

src/GridCalEngine/Simulations/PowerFlow/NumericalMethods/generalised_power_flow.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -856,13 +856,12 @@ def run_nonlinear_opf(grid: MultiCircuit,
856856
:param Sbus_pf0: Sbus initial solution
857857
:param voltage_pf0: Voltage initial solution
858858
:param plot_error: Plot the error evolution
859-
:param use_bound_slacks: add voltage module and branch loading slack variables? (default true)
860859
:param logger: Logger object
861860
:return: NonlinearOPFResults
862861
"""
863862

864863
# compile the system
865-
nc = compile_numerical_circuit_at(circuit=grid, t_idx=t_idx)
864+
nc = compile_numerical_circuit_at(circuit=grid, t_idx=t_idx, logger=logger)
866865

867866
if pf_init:
868867
if Sbus_pf0 is None:

src/GridCalEngine/Simulations/PowerFlow/power_flow_worker.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ def multi_island_pf(multi_circuit: MultiCircuit,
783783
opf_results=opf_results,
784784
use_stored_guess=options.use_stored_guess,
785785
bus_dict=bus_dict,
786-
areas_dict=areas_dict
786+
areas_dict=areas_dict,
787+
logger=logger,
787788
)
788789
# print("Normal PowerFlow")
789790

src/GridCalEngine/Simulations/ShortCircuitStudies/short_circuit_driver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def run(self):
237237
t_idx=None,
238238
apply_temperature=self.pf_options.apply_temperature_correction,
239239
branch_tolerance_mode=self.pf_options.branch_impedance_tolerance_mode,
240-
opf_results=self.opf_results)
240+
opf_results=self.opf_results,
241+
logger=self.logger)
241242

242243
calculation_inputs = numerical_circuit.split_into_islands(
243244
ignore_single_node_islands=self.pf_options.ignore_single_node_islands)

src/GridCalEngine/Simulations/SigmaAnalysis/sigma_analysis_driver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ def multi_island_sigma(multi_circuit: MultiCircuit,
251251
nc = compile_numerical_circuit_at(circuit=multi_circuit,
252252
apply_temperature=options.apply_temperature_correction,
253253
branch_tolerance_mode=options.branch_impedance_tolerance_mode,
254-
opf_results=None)
254+
opf_results=None,
255+
logger=logger)
255256
results.bus_names = nc.bus_data.names
256257

257258
calculation_inputs = nc.split_into_islands(ignore_single_node_islands=options.ignore_single_node_islands)

src/GridCalEngine/Simulations/StateEstimation/state_stimation_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def run(self):
181181
n = len(self.grid.buses)
182182
m = self.grid.get_branch_number()
183183

184-
numerical_circuit = compile_numerical_circuit_at(self.grid)
184+
numerical_circuit = compile_numerical_circuit_at(self.grid, logger=self.logger)
185185
self.results = StateEstimationResults(n=n,
186186
m=m,
187187
bus_names=numerical_circuit.bus_names,

src/GridCalEngine/Simulations/Stochastic/blackout_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def run(self):
260260

261261
# compile
262262
# print('Compiling...', end='')
263-
nc = compile_numerical_circuit_at(self.grid, t_idx=None)
263+
nc = compile_numerical_circuit_at(self.grid, t_idx=None, logger=self.logger)
264264
calculation_inputs = nc.split_into_islands(ignore_single_node_islands=self.options.ignore_single_node_islands)
265265

266266
self.results = CascadingResults(self.cascade_type)

src/GridCalEngine/Simulations/Stochastic/reliability_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def run(self):
200200
self.tic()
201201

202202
# compile the numerical circuit
203-
numerical_circuit = compile_numerical_circuit_at(self.grid, t_idx=None)
203+
numerical_circuit = compile_numerical_circuit_at(self.grid, t_idx=None, logger=self.logger)
204204

205205
evt = get_reliability_scenario(numerical_circuit,
206206
horizon=1)

src/GridCalEngine/Simulations/Stochastic/reliability_iterable.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from GridCalEngine.Simulations.PowerFlow.power_flow_worker import PowerFlowOptions, multi_island_pf_nc, PowerFlowResults
2121
from GridCalEngine.Devices.multi_circuit import MultiCircuit
2222
from GridCalEngine.DataStructures.numerical_circuit import compile_numerical_circuit_at
23-
from GridCalEngine.basic_structures import Vec, IntVec
23+
from GridCalEngine.basic_structures import Vec, IntVec,Logger
2424

2525

2626
def get_transition_probabilities(lbda: Vec, mu: Vec) -> Tuple[Vec, Vec]:
@@ -46,7 +46,8 @@ class ReliabilityIterable:
4646

4747
def __init__(self, grid: MultiCircuit,
4848
forced_mttf: Union[None, float] = None,
49-
forced_mttr: Union[None, float] = None):
49+
forced_mttr: Union[None, float] = None,
50+
logger: Logger = Logger()):
5051
"""
5152
5253
:param grid: MultiCircuit
@@ -61,11 +62,13 @@ def __init__(self, grid: MultiCircuit,
6162
# time index
6263
self.t_idx = 0
6364

65+
self.logger = logger
66+
6467
# declare the power flow options
6568
self.pf_options = PowerFlowOptions()
6669

6770
# compile the time step
68-
nc = compile_numerical_circuit_at(self.grid, t_idx=None)
71+
nc = compile_numerical_circuit_at(self.grid, t_idx=None, logger=logger)
6972

7073
# compute the transition probabilities
7174
if forced_mttf is None:
@@ -90,7 +93,7 @@ def __next__(self) -> Tuple[IntVec, PowerFlowResults]:
9093
raise StopIteration
9194

9295
# compile the time step
93-
nc = compile_numerical_circuit_at(self.grid, t_idx=self.t_idx)
96+
nc = compile_numerical_circuit_at(self.grid, t_idx=self.t_idx, logger=self.logger)
9497

9598
# determine the Markov states
9699
p = np.random.random(nc.nbr)

src/GridCalEngine/Simulations/Stochastic/stochastic_power_flow_driver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def run_single_thread_mc(self, use_lhs=False):
119119
t_idx=None,
120120
apply_temperature=False,
121121
branch_tolerance_mode=BranchImpedanceMode.Specified,
122-
opf_results=self.opf_time_series_results)
122+
opf_results=self.opf_time_series_results,
123+
logger=self.logger)
123124

124125
mc_results = StochasticPowerFlowResults(n=numerical_circuit.nbus,
125126
m=numerical_circuit.nbr,

0 commit comments

Comments
 (0)