Skip to content

Commit 7e5d55b

Browse files
committed
Merge branch 'refs/heads/devel'
# Conflicts: # .idea/workspace.xml
2 parents 2de0aea + ad1f83f commit 7e5d55b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+723
-330
lines changed
13.9 KB
Binary file not shown.
13.9 KB
Binary file not shown.

src/GridCal/Gui/Diagrams/SchematicWidget/Branches/line_editor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,10 @@ def accept_click(self) -> None:
210210
if length != 0.0:
211211

212212
if self.selected_template is not None:
213-
self.line.set_length(val=length, update_electrical_values=False)
213+
self.line.disable_auto_updates()
214+
self.line.set_length(val=length)
214215
self.line.apply_template(obj=self.selected_template, Sbase=self.Sbase)
215-
216+
self.line.enable_auto_updates()
216217
else:
217218
wf = 2 * np.pi * self.frequency
218219
self.line.fill_design_properties(

src/GridCal/Session/file_handler.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,19 @@ def run(self) -> None:
105105
previous_circuit=self._previous_circuit,
106106
options=self.options)
107107

108-
try:
108+
if self.options.crash_on_errors:
109109
self.circuit = file_handler.open(text_func=self.progress_text.emit,
110110
progress_func=self.progress_signal.emit)
111-
except ValueError as e:
112-
self.valid = False
113-
self.logger.add_error(msg=str(e))
114-
self.progress_text.emit('Error loading')
115-
self.done_signal.emit()
116-
return
111+
else:
112+
try:
113+
self.circuit = file_handler.open(text_func=self.progress_text.emit,
114+
progress_func=self.progress_signal.emit)
115+
except ValueError as e:
116+
self.valid = False
117+
self.logger.add_error(msg=str(e))
118+
self.progress_text.emit('Error loading')
119+
self.done_signal.emit()
120+
return
117121

118122
self.json_files = file_handler.json_files
119123

src/GridCal/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
_current_year_ = datetime.datetime.now().year
77

88
# do not forget to keep a three-number version!!!
9-
__GridCal_VERSION__ = "5.2.1"
9+
__GridCal_VERSION__ = "5.2.5"
1010

1111
url = 'https://github.com/SanPen/GridCal'
1212

src/GridCalEngine/DataStructures/hvdc_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def get_power(self, Sbase: float, theta: Vec) -> Tuple[Vec, Vec, Vec, Vec, Vec,
299299
else:
300300
Losses[i] = 0
301301
Pf[i] = 0
302-
Pt[0] = 0
302+
Pt[i] = 0
303303

304304
# compute loading
305305
loading[i] = Pf[i] / (self.rate[i] + 1e-20)

src/GridCalEngine/Devices/Branches/hvdc_line.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None,
210210

211211
self.dc_link_voltage = float(dc_link_voltage)
212212

213-
# self.n_lines = int(n_lines)
214-
215213
self.angle_droop = float(angle_droop)
216214

217215
self.loss_factor = float(loss_factor)
@@ -245,11 +243,11 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None,
245243

246244
self.control_mode: HvdcControlType = control_mode
247245

248-
self._Pset_prof: Vec = Profile(default_value=Pset, data_type=float)
249-
self._active_prof: IntVec = Profile(default_value=active, data_type=bool)
250-
self._Vset_f_prof: Vec = Profile(default_value=Vset_f, data_type=float)
251-
self._Vset_t_prof: Vec = Profile(default_value=Vset_t, data_type=float)
252-
self._angle_droop_prof: Vec = Profile(default_value=angle_droop, data_type=float)
246+
self._Pset_prof: Profile = Profile(default_value=Pset, data_type=float)
247+
self._active_prof: Profile = Profile(default_value=active, data_type=bool)
248+
self._Vset_f_prof: Profile = Profile(default_value=Vset_f, data_type=float)
249+
self._Vset_t_prof: Profile = Profile(default_value=Vset_t, data_type=float)
250+
self._angle_droop_prof: Profile = Profile(default_value=angle_droop, data_type=float)
253251

254252
# Line locations
255253
self._locations: LineLocations = LineLocations()

src/GridCalEngine/Devices/Branches/line.py

Lines changed: 86 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None, cn_from: Connectivi
103103
self.fault_pos = float(fault_pos)
104104

105105
# total impedance and admittance in p.u.
106-
self.R = float(r)
107-
self.X = float(x)
108-
self.B = float(b)
106+
self._R = float(r)
107+
self._X = float(x)
108+
self._B = float(b)
109109

110-
self.R0 = float(r0)
111-
self.X0 = float(x0)
112-
self.B0 = float(b0)
110+
self._R0 = float(r0)
111+
self._X0 = float(x0)
112+
self._B0 = float(b0)
113113

114-
self.R2 = float(r2)
115-
self.X2 = float(x2)
116-
self.B2 = float(b2)
114+
self._R2 = float(r2)
115+
self._X2 = float(x2)
116+
self._B2 = float(b2)
117117

118118
# Conductor base and operating temperatures in ºC
119119
self.temp_base = float(temp_base)
@@ -146,7 +146,6 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None, cn_from: Connectivi
146146
self.register(key='tolerance', units='%', tpe=float,
147147
definition='Tolerance expected for the impedance values % is expected '
148148
'for transformers0% for lines.')
149-
150149
self.register(key='length', units='km', tpe=float, definition='Length of the line (not used for calculation)')
151150
self.register(key='temp_base', units='ºC', tpe=float, definition='Base temperature at which R was measured.')
152151
self.register(key='temp_oper', units='ºC', tpe=float, definition='Operation temperature to modify R.',
@@ -179,6 +178,78 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None, cn_from: Connectivi
179178
definition='Possible sequence line types (>1 to denote association), - to denote no association',
180179
display=False)
181180

181+
@property
182+
def R(self):
183+
return self._R
184+
185+
@R.setter
186+
def R(self, value):
187+
self._R = float(value)
188+
189+
@property
190+
def X(self):
191+
return self._X
192+
193+
@X.setter
194+
def X(self, value):
195+
self._X = float(value)
196+
197+
@property
198+
def B(self):
199+
return self._B
200+
201+
@B.setter
202+
def B(self, value):
203+
self._B = float(value)
204+
205+
@property
206+
def R0(self):
207+
return self._R0
208+
209+
@R0.setter
210+
def R0(self, value):
211+
self._R0 = float(value)
212+
213+
@property
214+
def X0(self):
215+
return self._X0
216+
217+
@X0.setter
218+
def X0(self, value):
219+
self._X0 = float(value)
220+
221+
@property
222+
def B0(self):
223+
return self._B0
224+
225+
@B0.setter
226+
def B0(self, value):
227+
self._B0 = float(value)
228+
229+
@property
230+
def R2(self):
231+
return self._R2
232+
233+
@R2.setter
234+
def R2(self, value):
235+
self._R2 = float(value)
236+
237+
@property
238+
def X2(self):
239+
return self._X2
240+
241+
@X2.setter
242+
def X2(self, value):
243+
self._X2 = float(value)
244+
245+
@property
246+
def B2(self):
247+
return self._B2
248+
249+
@B2.setter
250+
def B2(self, value):
251+
self._B2 = float(value)
252+
182253
@property
183254
def length(self) -> float:
184255
"""
@@ -194,18 +265,17 @@ def length(self, val: float):
194265
:param val:
195266
:return:
196267
"""
197-
self.set_length(val, update_electrical_values=True)
268+
self.set_length(val)
198269

199-
def set_length(self, val: float, update_electrical_values: bool = True):
270+
def set_length(self, val: float):
200271
"""
201272
202273
:param val:
203-
:param update_electrical_values:
204274
:return:
205275
"""
206276
if isinstance(val, float):
207277
if val > 0.0:
208-
if self._length != 0 and update_electrical_values:
278+
if self._length != 0 and self.auto_update_enabled:
209279
factor = np.round(val / self._length, 6) # new length / old length
210280

211281
self.R *= factor
@@ -218,6 +288,7 @@ def set_length(self, val: float, update_electrical_values: bool = True):
218288
self.X2 *= factor
219289
self.B2 *= factor
220290

291+
# set the value
221292
self._length = val
222293
else:
223294
print('The length cannot be zero, ignoring value')
@@ -408,7 +479,7 @@ def get_equivalent_transformer(self) -> Transformer2W:
408479
elm.temperature_prof = self.temp_oper_prof
409480
return elm
410481

411-
def fill_design_properties(self, r_ohm, x_ohm, c_nf, length, Imax, freq, Sbase, apply_to_profile: bool = True,):
482+
def fill_design_properties(self, r_ohm, x_ohm, c_nf, length, Imax, freq, Sbase, apply_to_profile: bool = True, ):
412483
"""
413484
Fill R, X, B from not-in-per-unit parameters
414485
:param r_ohm: Resistance per km in OHM/km

src/GridCalEngine/Devices/Branches/series_reactance.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None, cn_from: Connectivi
2020
r=1e-20, x=1e-20, rate=1.0, active=True, tolerance=0, cost=100.0,
2121
mttf=0, mttr=0, r_fault=0.0, x_fault=0.0, fault_pos=0.5,
2222
temp_base=20, temp_oper=20, alpha=0.00330,
23-
template=None, contingency_factor=1.0, protection_rating_factor: float = 1.4,
23+
contingency_factor=1.0, protection_rating_factor: float = 1.4,
2424
contingency_enabled=True, monitor_loading=True,
2525
r0=1e-20, x0=1e-20, r2=1e-20, x2=1e-20,
2626
capex=0, opex=0, build_status: BuildStatus = BuildStatus.Commissioned):
@@ -45,7 +45,6 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None, cn_from: Connectivi
4545
:param temp_base: Base temperature at which `r` is measured in °C
4646
:param temp_oper: Operating temperature in °C
4747
:param alpha: Thermal constant of the material in °C
48-
:param template: Basic branch template
4948
:param contingency_factor: Rating factor in case of contingency
5049
:param protection_rating_factor: Rating factor before the protections tripping
5150
:param contingency_enabled: enabled for contingencies (Legacy)

src/GridCalEngine/Devices/Branches/switch.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Switch(BranchParent):
1414
"""
1515
The **Switch** class represents the connections between nodes (i.e.
16-
:ref:`buses<bus>`) in **GridCal**. A Switch is an devices that cuts or allows the flow.
16+
:ref:`buses<bus>`) in **GridCal**. A Switch is a devices that cuts or allows the flow.
1717
"""
1818

1919
def __init__(self, bus_from: Bus = None, bus_to: Bus = None,
@@ -22,7 +22,6 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None,
2222
rate=1.0,
2323
active=True,
2424
contingency_factor=1.0, protection_rating_factor: float = 1.4,
25-
# is_open=False,
2625
retained=True,
2726
normal_open=False,
2827
rated_current=0.0):
@@ -81,7 +80,7 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None,
8180

8281
self.register(key='normal_open', units="", tpe=bool,
8382
definition='Normal position of the switch')
84-
self.register(key='rated_current', units="KA", tpe=float,
83+
self.register(key='rated_current', units="kA", tpe=float,
8584
definition='Rated current of the switch device.')
8685

8786
def copy(self, bus_dict=None):

0 commit comments

Comments
 (0)