Grid Modifications¶
This module provides functions for modifying existing grids by adding components and zones.
functions are found in pyflow_acdc.Class_editor
Add Grid Components¶
Add AC Node¶
- add_AC_node(grid, kV_base, node_type='PQ', Voltage_0=1.01, theta_0=0.01, Power_Gained=0, Reactive_Gained=0, Power_load=0, Reactive_load=0, name=None, Umin=0.9, Umax=1.1, Gs=0, Bs=0, x_coord=None, y_coord=None, geometry=None)¶
Adds an AC node to the grid.
Parameter
Type
Description
Default
Units
gridGrid
Grid to modify
Required
kV_basefloat
Base voltage
Required
kV
node_typestr
Node type (‘PQ’, ‘PV’, or ‘Slack’)
‘PQ’
Voltage_0float
Initial voltage magnitude in p.u.
1.01
p.u.
theta_0float
Initial voltage angle
0.01
rad
Power_Gainedfloat
Active power generation
0
p.u.
Reactive_Gainedfloat
Reactive power generation
0
p.u.
Power_loadfloat
Active power load
0
p.u.
Reactive_loadfloat
Reactive power load
0
p.u.
namestr
Node name
None
Uminfloat
Minimum voltage magnitude
0.9
p.u.
Umaxfloat
Maximum voltage magnitude
1.1
p.u.
Gsfloat
Shunt conductance
0
p.u.
Bsfloat
Shunt susceptance
0
p.u.
x_coordfloat
X coordinate for plotting
None
y_coordfloat
Y coordinate for plotting
None
geometryGeometry
Shapely geometry object
None
Example
node = pyf.add_AC_node(grid, kV_base=400, name='bus1', node_type='PQ') #OR node1 = pyf.Node_AC('PQ', 1, 0,66, Power_Gained=0.5, name='Bus1') grid.nodes_AC.append(node1)
Add AC Line¶
- add_line_AC(grid, fromNode, toNode,MVA_rating=None, r=0, x=0, b=0, g=0,R_Ohm_km=None,L_mH_km=None, C_uF_km=0, G_uS_km=0, A_rating=None ,m=1, shift=0, name=None,tap_changer=False,Expandable=False,N_cables=1,Length_km=1,geometry=None,data_in='pu',Cable_type:str ='Custom',update_grid=True):
Adds an AC line to the grid.
Parameter
Type
Description
Default
Unit
gridGrid
Grid to modify
Required
fromNodeNode_AC
Source node
Required
toNodeNode_AC
Destination node
Required
mfloat
Transformer ratio
1
shiftfloat
Phase shift angle
0
radians
tap_changerbool
If True, creates tap changer transformer
False
Expandablebool
If True, creates expandable line
False
N_cablesint
Number of parallel cables
1
geometryGeometry
Shapely geometry object
None
data_instr
Input format (‘pu’, ‘Ohm’, ‘Real’)
‘pu’
For lines with data_in = ‘pu’:
Parameter
Type
Description
Default
Unit
r, x, b, gfloat
Line parameters in p.u.
0
p.u.
MVA_ratingfloat
Line rating in MVA
Required
MVA
For lines with data_in = ‘Ohm’:
Parameter
Type
Description
Default
Unit
r, x, b, gfloat
Line parameters in Ω
0
Ω
MVA_ratingfloat
Line rating in MVA
Required
MVA
For lines with data_in = ‘Real’:
Parameter
Type
Description
Default
Unit
R_Ohm_kmfloat
Resistance
Required
Ω/km
L_mH_kmfloat
Inductance
Required
mH/km
C_uF_kmfloat
Capacitance
0
μF/km
G_uS_kmfloat
Conductance
0
μS/km
A_ratingfloat
Current rating
Required
A
Length_kmfloat
Line length
1
km
For pre defined cable types database
Parameter
Type
Description
Default
Unit
Cable_typestr
Cable specification name
Required
Length_kmfloat
Line length
1
km
Example
import pyflow_acdc as pyf #Create nodes node1 = pyf.Node_AC('PQ', 1, 0,66, Power_Gained=0.5, name='Bus1') node2 = pyf.Node_AC('Slack', 1, 0,66,name='Bus2') #Create grid grid = pyf.Grid(100,nodes_AC=[node1,node2]) #For data_in = 'pu' line_pu = pyf.add_line_AC(grid, node1, node2, r=0.029, x=0.0032,b=0.0022, Length_km=10,MVA_rating=50) #For data_in = 'Ohm' line_ohm = pyf.add_line_AC(grid, node1, node2, r=1.2632, x=0.1393,b=0.0000505, Length_km=10,MVA_rating=50, data_in='Ohm') #For data_in = 'Real' line_real = pyf.add_line_AC(grid, node1, node2, R_Ohm_km=0.128, L_mH_km=0.443,C_uF_km=0.163, G_uS_km=0.0, Length_km=10, A_rating=445,data_in='Real') #For pre defined cable types database line_db = pyf.add_line_AC(grid, node1, node2, Cable_type='NREL_XLPE_185mm_66kV',Length_km=10)
Line sizing¶
Add Cable Options¶
- add_cable_option(grid, cable_types: list, name=None)¶
Adds a cable option to the grid. This is a list that will link different line sizing options to one singular cable type list, so that only a set maximum number of different ones are used.
Parameter
Type
Description
Default
Unit
gridGrid
Grid to modify
Required
cable_typeslist
List of cable types
Required
namestr
Name of the cable option
None
Example
cable_option = pyf.add_cable_option(grid,[ 'ABB_Cu_XLPE_95mm2_66kV', #0 'ABB_Cu_XLPE_120mm2_66kV', #1 'ABB_Cu_XLPE_150mm2_66kV', #2 'ABB_Cu_XLPE_185mm2_66kV', #3 'ABB_Cu_XLPE_240mm2_66kV', #4 'ABB_Cu_XLPE_300mm2_66kV', #5 'ABB_Cu_XLPE_400mm2_66kV', #6 'ABB_Cu_XLPE_500mm2_66kV', #7 'ABB_Cu_XLPE_630mm2_66kV', #8 'ABB_Cu_XLPE_800mm2_66kV', #9 'ABB_Cu_XLPE_1000mm2_66kV'] )#10 grid.cab_types_allowed = 3
Add Line sizing¶
- add_line_sizing(grid, fromNode, toNode, cable_types: list = [], active_config: int = 0, Length_km=1.0, S_base=100, name=None, cable_option=None, update_grid=True, geometry=None)¶
Adds a line sizing to the grid.
Parameter
Type
Description
Default
Unit
gridGrid
Grid to modify
Required
fromNodeNode_AC
Source node
Required
toNodeNode_AC
Destination node
Required
cable_typeslist
List of cable types
Required
active_configint
Active configuration
First of the list
Length_kmfloat
Line length
1
km
S_basefloat
Base power
100
MVA
namestr
Name of the line sizing
None
cable_optionstr
Cable option
update_gridbool
Update the grid
True
geometryGeometry
Shapely geometry object
None
Add DC Node¶
- add_DC_node(grid, kV_base, node_type='P', Voltage_0=1.01, Power_Gained=0, Power_load=0, name=None, Umin=0.95, Umax=1.05, x_coord=None, y_coord=None, geometry=None)¶
Adds a DC node to the grid.
Parameter
Type
Description
Default
Unit
gridGrid
Grid to modify
Required
kV_basefloat
Base voltage
Required
kV
node_typestr
Node type (‘P’, ‘Slack’, or ‘Droop’)
‘P’
Voltage_0float
Initial voltage magnitude
1.01
p.u.
Power_Gainedfloat
Power generation
0
p.u.
Power_loadfloat
Power load
0
p.u.
namestr
Node name
None
Uminfloat
Minimum voltage magnitude
0.95
p.u.
Umaxfloat
Maximum voltage magnitude
1.05
p.u.
x_coordfloat
X coordinate for plotting
None
y_coordfloat
Y coordinate for plotting
None
geometryGeometry
Shapely geometry object
None
Example
import pyflow_acdc as pyf #Create grid grid = pyf.Grid(100) #Create DC node node = pyf.add_DC_node(grid, kV_base=525, name='dc_bus1') #OR node1 = pyf.Node_DC('P', 1, 0,0,525,name='Bus1') grid.nodes_DC.append(node1)
Add DC Line¶
- add_line_DC(grid, fromNode, toNode, r=0.001, MW_rating=9999,Length_km=1,R_Ohm_km=None,A_rating=None,polarity='m', name=None,geometry=None,Cable_type:str ='Custom',data_in='pu',update_grid=True):
Adds a DC line to the grid.
Parameter
Type
Description
Default
Unit
gridGrid
Grid to modify
Required
fromNodeNode_DC
Source node
Required
toNodeNode_DC
Destination node
Required
rfloat
Line resistance
0.001
p.u.
MW_ratingfloat
Power rating
9999
MW
Length_kmfloat
Line length
1
km
R_Ohm_kmfloat
Line resistance in ohms per kilometer
None
Ω/km
A_ratingfloat
Line rating
None
A
polaritystr
‘m’ for asymmetric monopolar, ‘sm’ for symmetric monopolar, ‘b’ for bipolar
‘m’
namestr
Line name
None
geometryGeometry
Shapely geometry object
None
Cable_typestr
Cable specification name
‘Custom’
data_instr
Input data format (‘pu’ or ‘Ohm’)
‘pu’
update_gridbool
Whether to update the grid after adding the line
True
Example
import pyflow_acdc as pyf #Create grid grid = pyf.Grid(100) #Create nodes node1 = pyf.add_DC_node(grid, 525) node2 = pyf.add_DC_node(grid, 525) line = pyf.add_line_DC(grid, node1, node2, Resistance_pu=0.0000318, MW_rating=1000, polarity='b', Length_km=10) #OR node3 = pyf.add_DC_node(grid, 525) node4 = pyf.add_DC_node(grid, 525) line_db = pyf.add_line_DC(grid, node3, node4, Cable_type='NREL_HVDC_2500mm_525kV', polarity='b', Length_km=10)
Add AC/DC Converter¶
- add_ACDC_converter(grid, AC_node, DC_node, AC_type='PV', DC_type=None, P_AC_MW=0, Q_AC_MVA=0, P_DC_MW=0, Transformer_resistance=0, Transformer_reactance=0, Phase_Reactor_R=0, Phase_Reactor_X=0, Filter=0, Droop=0, kV_base=None, MVA_max=None, nConvP=1, polarity=1, lossa=1.103, lossb=0.887, losscrect=2.885, losscinv=4.371, Ucmin=0.85, Ucmax=1.2, name=None, geometry=None)¶
Adds an AC/DC converter to the grid.
Parameter
Type
Description
Default
Unit
gridGrid
Grid to modify
Required
AC_nodeNode_AC
AC side node
Required
DC_nodeNode_DC
DC side node
Required
AC_typestr
AC control type (‘PV’, ‘PQ’, ‘Slack’)
‘PV’
DC_typestr
DC control type (‘P’, ‘Slack’, ‘Droop’)
None
P_AC_MWfloat
AC active power setpoint
0
MW
Q_AC_MVAfloat
AC reactive power setpoint
0
MVAr
P_DC_MWfloat
DC power setpoint
0
MW
Transformer_resistancefloat
Transformer resistance
0
pu
Transformer_reactancefloat
Transformer reactance
0
pu
Phase_Reactor_Rfloat
Phase reactor resistance
0
pu
Phase_Reactor_Xfloat
Phase reactor reactance
0
pu
Filterfloat
Filter susceptance
0
pu
Droopfloat
Droop constant
0
pu
kV_basefloat
AC side base voltage
None
kV
MVA_maxfloat
Converter rating
None
MVA
nConvPint
Number of parallel converters
1
geometryGeometry
Shapely geometry object
None
Returns
AC_DC_converter
Created converter
For Power Flow AC side control type:
AC_typeDC_typeAdditional requiered Values
Slack
PAC
None
PQ
PAC
Q_AC_MVAPV
PAC
P_AC_MWFor Power Flow DC side control type:
DC_typeAC_typeRequiered Values
P
PQ, PV
P_DC_MWDroop
PQ, PV
P_DC_MW,Droop
Example
conv = pyf.add_ACDC_converter(grid, ac_node, dc_node, MVA_max=1000)
Add Generator¶
- add_gen(grid, node_name, gen_name=None, price_zone_link=False, lf=0, qf=0, MWmax=99999, MWmin=0, MVArmin=None, MVArmax=None, PsetMW=0, QsetMVA=0, Smax=None, fuel_type='Other', geometry=None)¶
Adds a generator to the grid.
Parameter
Type
Description
gridGrid
Grid to modify
node_namestr
Name of node to connect to
gen_namestr
Generator name
MWmaxfloat
Maximum active power
MWminfloat
Minimum active power
MVArminfloat
Minimum reactive power
MVArmaxfloat
Maximum reactive power
fuel_typestr
Generator fuel type
Returns
Gen_AC
Created generator
Example
gen = pyf.add_gen(grid, "bus1", MWmax=500, fuel_type="Natural Gas")
Add Renewable Source¶
- add_RenSource(grid, node_name, base, ren_source_name=None, available=1, zone=None, price_zone=None, Offshore=False, MTDC=None, geometry=None, ren_type='Wind')¶
Adds a renewable energy source to the grid.
Parameter
Type
Description
gridGrid
Grid to modify
node_namestr
Name of node to connect to
basefloat
Base power in MW
ren_typestr
Type (‘Wind’, ‘Solar’)
zonestr
Renewable zone name
price_zonestr
Price zone name
Returns
Ren_Source
Created renewable source
Example
source = pyf.add_RenSource(grid, "bus1", 100, ren_type="Wind")
Add Price Zone¶
- add_price_zone(grid, name, price, import_pu_L=1, export_pu_G=1, a=0, b=1, c=0, import_expand_pu=0)¶
Adds a price zone to the grid.
Parameter
Type
Description
gridGrid
Grid to modify
namestr
Zone name
pricefloat
Base price
import_pu_Lfloat
Import limit p.u.
export_pu_Gfloat
Export limit p.u.
Returns
Price_Zone
Created price zone
Example
zone = pyf.add_price_zone(grid, "Zone1", price=50)
Assign Node to Price Zone¶
- assign_nodeToPrice_Zone(grid, node_name, ACDC, new_price_zone_name)¶
Assigns a node to a price zone.
Parameter
Type
Description
gridGrid
Grid containing node
node_namestr
Name of node to assign
ACDCstr
‘AC’ or ‘DC’
new_price_zone_namestr
Name of target price zone
Example
pyf.assign_nodeToPrice_Zone(grid, "bus1", "AC", "Zone1")
Line Modifications¶
Change Line to Expandable¶
- change_line_AC_to_expandable(grid, line_name)¶
Converts an AC line to an expandable line.
Parameter
Type
Description
gridGrid
Grid containing line
line_namestr
Name of line to convert
Example
pyf.change_line_AC_to_expandable(grid, "line1")
Change Line to Reconducting¶
- change_line_AC_to_reconducting(grid, line_name, r_new, x_new, g_new, b_new, MVA_rating_new, Life_time, base_cost)¶
Converts an AC line to a reconducting line.
Parameter
Type
Description
gridGrid
Grid containing line
line_namestr
Name of line to convert
r_newfloat
Resistance of reconducting line
x_newfloat
Reactance of reconducting line
g_newfloat
Conductance of reconducting line
b_newfloat
Susceptance of reconducting line
MVA_rating_newfloat
MVA rating of reconducting line
Life_timefloat
Life time of reconducting line
base_costfloat
Base cost of reconducting line
Internally the original line is included into the reconducting line, as a base line,
line.rec_branchis set to False. When set to True, the reconducted line is active in the grid.Example
pyf.change_line_AC_to_reconducting(grid, "line1", r_new=0.1, x_new=0.2, g_new=0, b_new=0.1, MVA_rating_new=100, Life_time=20, base_cost=1000000)
Change Line to Transformer¶
- change_line_AC_to_tap_transformer(grid, line_name)¶
Converts an AC line to a tap-changing transformer.
Parameter
Type
Description
gridGrid
Grid containing line
line_namestr
Name of line to convert
Example
pyf.change_line_AC_to_tap_transformer(grid, "line1")