Skip to content

Commit

Permalink
Fixed saving and import display of nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Jan 5, 2017
1 parent fc21b4e commit 5c4dcb9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ def get_save_data(self):
Return the data that matches the edit_headers
:return:
"""
self.retrieve_graphic_position()
return [self.name, self.is_enabled, self.is_slack, self.Vnom, self.Vmin, self.Vmax, self.x, self.y]

def set_state(self, t):
Expand Down Expand Up @@ -766,6 +767,14 @@ def set_state(self, t):
for elm in self.shunts:
elm.Y = elm.Yprof.values[t, 0]

def retrieve_graphic_position(self):
"""
Get the position set by the graphic object
:return:
"""
if self.graphic_obj is not None:
self.x = self.graphic_obj.pos().x()
self.y = self.graphic_obj.pos().y()


class TransformerType:
Expand Down Expand Up @@ -4623,7 +4632,7 @@ def run(self):
Vavg = Vsum / iter
Vvariance = abs((power(mc_results.V_points - Vavg, 2.0) / (iter - 1)).min())

##### progress ######
# progress
variance_sum += Vvariance
err = variance_sum / iter
if err == 0:
Expand All @@ -4641,6 +4650,9 @@ def run(self):
print('Vstd:', Vvariance, ' -> ', std_dev_progress, ' %')

mc_results.compile()
# compute the averaged branch magnitudes
mc_results.sbranch, Ibranch, loading, mc_results.losses = powerflow.compute_branch_results(self.grid, mc_results.voltage)

self.results = mc_results

# send the finnish signal
Expand Down Expand Up @@ -4675,6 +4687,8 @@ def __init__(self, n, m, p=0):
self.voltage = None
self.current = None
self.loading = None
self.sbranch = None
self.losses = None

self.v_convergence = None
self.c_convergence = None
Expand Down
2 changes: 1 addition & 1 deletion UnderDevelopment/GridCal/gui/GridEditor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from GridCal.grid.CircuitOO import *
from GridCal.grid.CalculationEngine import *
from GridCal.gui.GuiFunctions import *
import sys

Expand Down
19 changes: 12 additions & 7 deletions UnderDevelopment/GridCal/gui/main/GridCalMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def open_file(self):
print(filename)
self.circuit = MultiCircuit()
self.circuit.load_file(filename=filename)
self.create_schematic_from_api(explode_factor=500)
self.create_schematic_from_api(explode_factor=1)
self.compile()

if self.circuit.time_profile is not None:
Expand Down Expand Up @@ -610,6 +610,8 @@ def create_schematic_from_api(self, explode_factor=1):
connection.redraw()
branch.graphic_obj = connection

self.grid_editor.center_nodes()

def view_objects_data(self):
"""
Expand Down Expand Up @@ -753,8 +755,10 @@ def run_power_flow(self):
self.LOCK()
self.compile()

# get the power flow options from the GUI
options = self.get_selected_power_flow_options()

# compute the automatic precision
if self.ui.auto_precision_checkBox.isChecked():
lg = np.log10(abs(self.circuit.power_flow_input.Sbus.real))
lg[lg == -np.inf] = 0
Expand All @@ -763,23 +767,23 @@ def run_power_flow(self):
options.tolerance = tolerance
self.ui.tolerance_spinBox.setValue(tol_idx)

# set power flow object instance
self.power_flow = PowerFlow(self.circuit, options)

# self.power_flow.progress_signal.connect(self.ui.progressBar.setValue)
# self.power_flow.done_signal.connect(self.UNLOCK)
# self.power_flow.done_signal.connect(self.post_power_flow)
#

# self.power_flow.start()
self.threadpool.start(self.power_flow)

self.threadpool.waitForDone()
self.post_power_flow()
else:
pass

def post_power_flow(self):
"""
Run a power flow simulation in a separated thread from the gui
Action performed after the power flow.
Returns:
"""
Expand Down Expand Up @@ -817,7 +821,7 @@ def get_selected_voltage_stability(self):

def run_voltage_stability(self):
"""
Run voltage stability (voltage collapse) in a separated thread
:return:
"""
print('run_voltage_stability')
Expand Down Expand Up @@ -897,7 +901,7 @@ def run_voltage_stability(self):

def post_voltage_stability(self):
"""
Actions performed after the voltage stability. Launched by the thread after its execution
:return:
"""
if self.voltage_stability.results is not None:
Expand Down Expand Up @@ -1005,9 +1009,10 @@ def post_stochastic(self):
print('Vbus:\n', abs(self.monte_carlo.results.voltage))
print('Ibr:\n', abs(self.monte_carlo.results.current))
print('ld:\n', abs(self.monte_carlo.results.loading))

self.color_based_of_pf(Vbus=self.monte_carlo.results.voltage,
LoadBranch=self.monte_carlo.results.loading,
Sbranch=None,
Sbranch=self.monte_carlo.results.sbranch,
Sbus=None)
self.update_available_results()

Expand Down
2 changes: 1 addition & 1 deletion UnderDevelopment/GridCal/tests/API_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with GridCal. If not, see <http://www.gnu.org/licenses/>.

from GridCal.grid.CircuitOO import *
from GridCal.grid.CalculationEngine import *
from matplotlib import pyplot as plt

grid = MultiCircuit()
Expand Down
3 changes: 1 addition & 2 deletions UnderDevelopment/GridCal/tests/DEMO_5_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import numpy as np

from GridCal.grid.CircuitOO import *
from GridCal.grid.CalculationEngine import *

np.set_printoptions(precision=4)
grid = MultiCircuit()
Expand All @@ -35,7 +35,6 @@
bus3.loads.append(Load('load 3', power=complex(25, 15)))
grid.add_bus(bus3)


bus4 = Bus('Bus 4', vnom=20)
bus4.loads.append(Load('load 4', power=complex(40, 20)))
grid.add_bus(bus4)
Expand Down

0 comments on commit 5c4dcb9

Please sign in to comment.