Skip to content

Commit eddfb85

Browse files
committed
5.5.15
1 parent 94352d3 commit eddfb85

13 files changed

Lines changed: 133 additions & 39 deletions

File tree

.idea/workspace.xml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/index.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ insights, or a student diving into practical algorithms, VeraGrid’s got
2626
your back. It’s a high quality product made for all of us now and for
2727
the future generations.
2828

29-
🎥 `Watch the introduction video on YouTube <https://www.youtube.com/watch?v=4ZDyWIX8_VE>`_
29+
🎥 Watch the spotlight series videos:
30+
31+
- `1 - introduction <https://www.youtube.com/watch?v=4ZDyWIX8_VE>`_
32+
33+
- `2 - Power flow <https://www.youtube.com/watch?v=d9dTyO4wels>`_
34+
35+
- `3 - Optimal power flow <https://www.youtube.com/watch?v=o6oXBJ1Efqc>`_
36+
3037

3138

3239

doc/md_source/optimal_power_flow.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Show the real associated values
2323
Control batteries
2424
Control the batteries state of charge when running the optimization in time series.
2525

26+
🎥 [Watch the OPF video on YouTube](https://www.youtube.com/watch?v=o6oXBJ1Efqc)
2627

2728
## API
2829

src/VeraGrid/__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
# remember to keep a three-number version!!!
9-
__VeraGrid_VERSION__ = "5.5.14"
9+
__VeraGrid_VERSION__ = "5.5.15"
1010

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

src/VeraGridEngine/Devices/Branches/underground_line_type.py

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,35 @@ class UndergroundLineType(EditableDevice):
1111
__slots__ = (
1212
'Imax',
1313
'Vnom',
14+
'_freq',
1415
'R',
1516
'X',
1617
'B',
18+
'_C',
1719
'R0',
1820
'X0',
1921
'B0',
22+
'_C0',
2023
'n_circuits'
2124
)
2225

2326
def __init__(self, name: str = 'UndergroundLine', idtag: None | str = None, Imax: float = 1.0,
24-
Vnom: float = 1.0, R: float = 0.0, X: float = 0.0, B: float = 0.0,
25-
R0: float = 0.0, X0: float = 0.0, B0: float = 0.0) -> None:
27+
Vnom: float = 1.0, R: float = 0.0, X: float = 0.0, B: float = 0.0, C: float = 0.0,
28+
R0: float = 0.0, X0: float = 0.0, B0: float = 0.0, C0: float = 0.0,
29+
freq: float = 50.0) -> None:
2630
"""
2731
Constructor
2832
:param name: name of the device
2933
:param Imax: rating in kA
3034
:param R: Resistance of positive sequence in Ohm/km
3135
:param X: Reactance of positive sequence in Ohm/km
3236
:param B: Susceptance of positive sequence in uS/km
37+
:param C: Capacitance of positive sequence in uF/km (alternative to B)
3338
:param R0: Resistance of zero sequence in Ohm/km
3439
:param X0: Reactance of zero sequence in Ohm/km
3540
:param B0: Susceptance of zero sequence in uS/km
41+
:param C0: Capacitance of zero sequence in uF/km (alternative to B0)
42+
:param freq: Frequency of underground line (Hz)
3643
"""
3744
EditableDevice.__init__(self,
3845
name=name,
@@ -42,26 +49,34 @@ def __init__(self, name: str = 'UndergroundLine', idtag: None | str = None, Imax
4249

4350
self.Imax = float(Imax)
4451
self.Vnom = float(Vnom)
52+
self._freq = float(freq)
4553

4654
# impudence and admittance per unit of length
4755
self.R = float(R)
4856
self.X = float(X)
4957
self.B = float(B)
58+
self._C = float(C)
5059

5160
self.R0 = float(R0)
5261
self.X0 = float(X0)
5362
self.B0 = float(B0)
63+
self._C0 = float(C0)
5464

5565
self.n_circuits = 1
5666

5767
self.register(key='Imax', units='kA', tpe=float, definition='Current rating of the line', old_names=['rating'])
5868
self.register(key='Vnom', units='kV', tpe=float, definition='Voltage rating of the line')
69+
self.register(key='freq', units='Hz', tpe=float, definition='Cable frequency')
5970
self.register(key='R', units='Ohm/km', tpe=float, definition='Positive-sequence resistance per km')
6071
self.register(key='X', units='Ohm/km', tpe=float, definition='Positive-sequence reactance per km')
6172
self.register(key='B', units='uS/km', tpe=float, definition='Positive-sequence shunt susceptance per km')
73+
self.register(key='C', units='uF/km', tpe=float,
74+
definition='Positive-sequence shunt capacitance per km (alternative to B')
6275
self.register(key='R0', units='Ohm/km', tpe=float, definition='Zero-sequence resistance per km')
6376
self.register(key='X0', units='Ohm/km', tpe=float, definition='Zero-sequence reactance per km')
6477
self.register(key='B0', units='uS/km', tpe=float, definition='Zero-sequence shunt susceptance per km')
78+
self.register(key='C0', units='uF/km', tpe=float,
79+
definition='Zero-sequence shunt capacitance per km (alternative to B0')
6580
self.register(key='n_circuits', units='', tpe=int, definition='number of circuits')
6681

6782
def get_values(self, Sbase: float, length: float):
@@ -100,19 +115,36 @@ def y_shunt(self):
100115
"""
101116
return 1j * self.B
102117

103-
def change_base(self, Sbase_old, Sbase_new):
104-
"""
105-
change the per unit base
106-
:param Sbase_old: old base in MVA
107-
:param Sbase_new: new base in MVA
108-
"""
109-
b = Sbase_new / Sbase_old
118+
@property
119+
def C(self) -> float:
120+
return self._C
121+
122+
@C.setter
123+
def C(self, C: float):
124+
self._C = float(C)
125+
126+
if self.auto_update_enabled:
127+
self.B = 2 * np.pi * self._freq * self._C
128+
129+
@property
130+
def C0(self) -> float:
131+
return self._C0
132+
133+
@C0.setter
134+
def C0(self, C0: float):
135+
self._C0 = float(C0)
136+
137+
if self.auto_update_enabled:
138+
self.B0 = 2 * np.pi * self._freq * self._C0
110139

111-
self.R *= b
112-
self.X *= b
113-
self.B *= b
140+
@property
141+
def freq(self) -> float:
142+
return self._freq
114143

115-
self.R0 *= b
116-
self.X0 *= b
117-
self.B0 *= b
144+
@freq.setter
145+
def freq(self, freq: float):
146+
self._freq = float(freq)
118147

148+
if self.auto_update_enabled:
149+
self.B = 2 * np.pi * self._freq * self._C
150+
self.B0 = 2 * np.pi * self._freq * self._C0

src/VeraGridEngine/Devices/Injections/load.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
# SPDX-License-Identifier: MPL-2.0
55
from __future__ import annotations
66

7-
import pdb
87
from typing import Union, List
98
import numpy as np
109
import pandas as pd
1110
from matplotlib import pyplot as plt
1211
from VeraGridEngine.enumerations import DeviceType, BuildStatus
1312
from VeraGridEngine.Devices.Parents.load_parent import LoadParent
1413
from VeraGridEngine.Devices.profile import Profile
15-
from VeraGridEngine.Utils.Symbolic.block import Block, Var, Const, DynamicVarType
14+
from VeraGridEngine.Utils.Symbolic.block import Block, Var, DynamicVarType
1615
from VeraGridEngine.Utils.Symbolic.symbolic import piecewise
1716
from VeraGridEngine.Devices.Parents.editable_device import get_at
1817

@@ -58,6 +57,7 @@ class Load(LoadParent):
5857
'_Ir3_prof',
5958
'_Ii3_prof',
6059

60+
'_contract_power',
6161
'_n_customers',
6262
'_n_customers_prof',
6363

@@ -72,7 +72,9 @@ def __init__(self, name='Load', idtag=None, code='',
7272
G1=0.0, G2=0.0, G3=0.0, B1=0.0, B2=0.0, B3=0.0,
7373
Ir1=0.0, Ir2=0.0, Ir3=0.0, Ii1=0.0, Ii2=0.0, Ii3=0.0, Pl0=1.0, Ql0=1.0,
7474
active=True, mttf=0.0, mttr=0.0, capex=0, opex=0,
75-
init_params: dict[str, float] = {},
75+
n_customers: int = 0,
76+
contracted_power: float = 0.0,
77+
init_params: dict[str, float] | None = None,
7678
build_status: BuildStatus = BuildStatus.Commissioned):
7779
"""
7880
The load object implements the so-called ZIP model, in which the load can be
@@ -166,13 +168,15 @@ def __init__(self, name='Load', idtag=None, code='',
166168
self._Ii2_prof = Profile(default_value=self.Ii2, data_type=float)
167169
self._Ii3_prof = Profile(default_value=self.Ii3, data_type=float)
168170

169-
self._n_customers: int = 1
171+
self._n_customers: int = n_customers
170172
self._n_customers_prof = Profile(default_value=self._n_customers, data_type=int)
171173

174+
self._contract_power: float = contracted_power
175+
172176
self.Pl0 = Pl0
173177
self.Ql0 = Ql0
174178

175-
self.init_params = init_params
179+
self.init_params = init_params if init_params is not None else dict()
176180

177181
self.register(key='Ir', units='MW', tpe=float,
178182
definition='Active power of the current component at V=1.0 p.u.', profile_name='Ir_prof')
@@ -217,6 +221,7 @@ def __init__(self, name='Load', idtag=None, code='',
217221
profile_name='B3_prof')
218222
self.register(key='n_customers', units='unit', tpe=int,
219223
definition='Number of customers represented by this load', profile_name='n_customers_prof')
224+
self.register(key='contract_power', units='MW', tpe=float, definition='Nominal contracted power', )
220225

221226
@property
222227
def Ir_prof(self) -> Profile:
@@ -701,6 +706,28 @@ def n_customers(self, val: int):
701706
except ValueError as e:
702707
print(e)
703708

709+
@property
710+
def contract_power(self) -> float:
711+
"""
712+
Return the contracted power
713+
"""
714+
return self._contract_power
715+
716+
@contract_power.setter
717+
def contract_power(self, val: float):
718+
"""
719+
Set the contracted power
720+
:param val: value greater than 0
721+
"""
722+
try:
723+
val2 = float(val)
724+
if val2 > 0:
725+
self._contract_power = val2
726+
else:
727+
print("Do they contract negative power?")
728+
except ValueError as e:
729+
print(e)
730+
704731
@property
705732
def n_customers_prof(self) -> Profile:
706733
"""

src/VeraGridEngine/Topology/GridReduction/ptdf_grid_reduction.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ def ptdf_reduction_projected(grid: MultiCircuit,
342342
Flow0_gen = lin.get_flows(Pgen)
343343
Flow0_gen_srap = lin.get_flows(Pgen_srap)
344344

345+
# Flows0 = lin.PTDF @ Pbus0
346+
# Flows0_check = Flow0_load + Flow0_gen + Flow0_gen_srap
347+
345348
if grid.has_time_series:
346349
Pload_ts = get_Pload_ts(grid)
347350
Pgen_ts, Pgen_srap_ts = get_Pgen_ts(grid)
@@ -373,9 +376,9 @@ def ptdf_reduction_projected(grid: MultiCircuit,
373376
X, _, _, _ = np.linalg.lstsq(lin2.PTDF, b)
374377
Pbus3_load, Pbus3_gen, Pbus3_gen_srap = X[:, 0], X[:, 1], X[:, 2]
375378

376-
dPload = Pbus_load2 - Pbus3_load
377-
dPgen = Pbus_gen2 - Pbus3_gen
378-
dPgen_srap = Pbus_gen_srap2 - Pbus3_gen_srap
379+
dPload = Pbus3_load - Pbus_load2
380+
dPgen = Pbus3_gen - Pbus_gen2
381+
dPgen_srap = Pbus3_gen_srap - Pbus_gen_srap2
379382

380383
if grid.has_time_series:
381384

@@ -409,17 +412,15 @@ def ptdf_reduction_projected(grid: MultiCircuit,
409412
grid.add_load(bus=bus, api_obj=elm)
410413

411414
if abs(dPgen[i]) > tol:
412-
elm = Generator(name=f"compensated gen {i}", P=dPgen[i], srap_enabled=False,
413-
is_controlled=False, power_factor=0.999)
415+
elm = Generator(name=f"compensated gen {i}", P=dPgen[i], srap_enabled=False)
414416

415417
if dPbus_gen_ts is not None:
416418
elm.P_prof = -dPbus_gen_ts[:, i]
417419

418420
grid.add_generator(bus=bus, api_obj=elm)
419421

420422
if abs(dPgen_srap[i]) > tol:
421-
elm = Generator(name=f"compensated gen {i}", P=dPgen_srap[i], srap_enabled=True,
422-
is_controlled=False, power_factor=0.999)
423+
elm = Generator(name=f"compensated gen {i}", P=dPgen_srap[i], srap_enabled=True)
423424

424425
if dPbus_gen_srap_ts is not None:
425426
elm.P_prof = -dPbus_gen_srap_ts[:, i]
@@ -431,8 +432,6 @@ def ptdf_reduction_projected(grid: MultiCircuit,
431432
# Flows0 = lin.PTDF @ Pbus0
432433
# Flows4 = lin2.PTDF @ Pbus4
433434
# diff = Flows0[i_branches] - Flows4
434-
435-
436435

437436
return grid, logger
438437

src/VeraGridEngine/__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
# remember to keep a three-number version!!!
9-
__VeraGridEngine_VERSION__ = "5.5.14"
9+
__VeraGridEngine_VERSION__ = "5.5.15"
1010

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

src/VeraGridServer/__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
# remember to keep a three-number version!!!
9-
__VeraGridServer_VERSION__ = "5.5.14"
9+
__VeraGridServer_VERSION__ = "5.5.15"
1010

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

14.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)