Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert PyPSA Network object to Grid object and profiles #652

Merged
merged 19 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bcf3bed
feat: make FromPyPSA object a Grid object
rouille Sep 2, 2022
9ff3873
fix: enable roundtrip conversion (#678 and #685)
rouille Sep 2, 2022
e99c87c
feat: convert pypsa Network object to Grid object and profiles
rouille Jun 4, 2022
835e48e
test: add test for storage
rouille Sep 11, 2022
f7d3899
feat: convert PyPSA storage_units/stores to Grid storage_data (#657)
chrstphtrs Jun 30, 2022
7b2de36
feat: extract profiles from pypsa network
rouille Sep 16, 2022
c134725
docs: format docstring and remove note
rouille Sep 26, 2022
308d946
ci: update gitignore
chrstphtrs Jul 29, 2022
9c7f629
test: write tests for profile extraction
rouille Sep 16, 2022
9707a82
fix: enable grid equality for back converted pypsa networks (#689)
rouille Sep 26, 2022
3e103fc
refactor: create library of constants for grid object, casemat file a…
rouille Aug 12, 2022
9a4d290
feat: normalize inflow profiles by max
rouille Sep 16, 2022
16b190d
Merge pull request #675 from Breakthrough-Energy/ben/grideq
rouille Oct 5, 2022
0444b31
refactor: simplify logic
rouille Sep 27, 2022
b805325
feat: extract substation from arbitrary pypsa networks (#674)
FabianHofmann Oct 25, 2022
adf9309
refactor: add inflow to column name of carriers with inflow profiles
rouille Oct 28, 2022
04f2d4d
feat: support hydro inflow functionality (#691)
FabianHofmann Nov 4, 2022
0c7d0d5
Merge pull request #682 from Breakthrough-Energy/ben/profile
rouille Nov 4, 2022
3d17f0f
fix: add geographical coordinates to branch and plant data frames and…
FabianHofmann Nov 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,8 @@ dmypy.json

# Windows
Thumbs.db

# Misc
environment.yaml
.syncignore-receive*
.syncignore-send*
41 changes: 30 additions & 11 deletions powersimdata/input/abstract_grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas as pd

from powersimdata.input import const
from powersimdata.input.const import grid_const


class AbstractGrid:
Expand All @@ -12,13 +12,32 @@ def __init__(self):
self.interconnect = None
self.zone2id = {}
self.id2zone = {}
self.sub = pd.DataFrame()
self.plant = pd.DataFrame()
self.gencost = {"before": pd.DataFrame(), "after": pd.DataFrame()}
self.dcline = pd.DataFrame()
self.bus2sub = pd.DataFrame()
self.bus = pd.DataFrame()
self.branch = pd.DataFrame()
self.sub = pd.DataFrame(columns=grid_const.col_name_sub).rename_axis(
grid_const.indices["sub"]
)
self.plant = pd.DataFrame(columns=grid_const.col_name_plant).rename_axis(
grid_const.indices["plant"]
)
self.gencost = {
"before": pd.DataFrame(columns=grid_const.col_name_gencost).rename_axis(
grid_const.indices["plant"]
),
"after": pd.DataFrame(columns=grid_const.col_name_gencost).rename_axis(
grid_const.indices["plant"]
),
}
self.dcline = pd.DataFrame(columns=grid_const.col_name_dcline).rename_axis(
grid_const.indices["dcline"]
)
self.bus2sub = pd.DataFrame(columns=grid_const.col_name_bus2sub).rename_axis(
grid_const.indices["bus2sub"]
)
self.bus = pd.DataFrame(columns=grid_const.col_name_bus).rename_axis(
grid_const.indices["bus"]
)
self.branch = pd.DataFrame(columns=grid_const.col_name_branch).rename_axis(
grid_const.indices["branch"]
)
self.storage = storage_template()
self.grid_model = ""
self.model_immutables = None
Expand All @@ -30,9 +49,9 @@ def storage_template():
:return: (*dict*) -- storage structure for MATPOWER/MOST
"""
storage = {
"gen": pd.DataFrame(columns=const.col_name_plant),
"gencost": pd.DataFrame(columns=const.col_name_gencost),
"StorageData": pd.DataFrame(columns=const.col_name_storage_storagedata),
"gen": pd.DataFrame(columns=grid_const.col_name_plant),
"gencost": pd.DataFrame(columns=grid_const.col_name_gencost),
"StorageData": pd.DataFrame(columns=grid_const.col_name_storage_storagedata),
"genfuel": [],
"duration": None, # hours
"min_stor": None, # ratio
Expand Down
Empty file.
File renamed without changes.
316 changes: 316 additions & 0 deletions powersimdata/input/const/grid_const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
# The index name of each data frame
indices = {
"sub": "sub_id",
"bus2sub": "bus_id",
"branch": "branch_id",
"bus": "bus_id",
"dcline": "dcline_id",
"plant": "plant_id",
}

# AC lines
col_name_branch = [
"from_bus_id",
"to_bus_id",
"r",
"x",
"b",
"rateA",
"rateB",
"rateC",
"ratio",
"angle",
"status",
"angmin",
"angmax",
"Pf",
"Qf",
"Pt",
"Qt",
"mu_Sf",
"mu_St",
"mu_angmin",
"mu_angmax",
"branch_device_type",
"interconnect",
"from_zone_id",
"to_zone_id",
"from_zone_name",
"to_zone_name",
"from_lat",
"from_lon",
"to_lat",
"to_lon",
]
col_type_branch = [
"int",
"int",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"int",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"str",
"str",
"int",
"int",
"str",
"str",
"float",
"float",
"float",
"float",
]


# bus
col_name_bus = [
"type",
"Pd",
"Qd",
"Gs",
"Bs",
"zone_id",
"Vm",
"Va",
"baseKV",
"loss_zone",
"Vmax",
"Vmin",
"lam_P",
"lam_Q",
"mu_Vmax",
"mu_Vmin",
"interconnect",
"lat",
"lon",
]
col_type_bus = [
"int",
"float",
"float",
"float",
"float",
"int",
"float",
"float",
"float",
"int",
"float",
"float",
"float",
"float",
"float",
"float",
"str",
"float",
"float",
]


# bus to substations
col_name_bus2sub = ["sub_id", "interconnect"]
col_type_bus2sub = ["int", "str"]


# DC lines
col_name_dcline = [
"from_bus_id",
"to_bus_id",
"status",
"Pf",
"Pt",
"Qf",
"Qt",
"Vf",
"Vt",
"Pmin",
"Pmax",
"QminF",
"QmaxF",
"QminT",
"QmaxT",
"loss0",
"loss1",
"muPmin",
"muPmax",
"muQminF",
"muQmaxF",
"muQminT",
"muQmaxT",
"from_interconnect",
"to_interconnect",
]
col_type_dcline = [
"int",
"int",
"int",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"str",
"str",
]


# Generation Cost
col_name_gencost = [
"type",
"startup",
"shutdown",
"n",
"c2",
"c1",
"c0",
"interconnect",
]
col_type_gencost = ["int", "float", "float", "int", "float", "float", "float", "str"]


# Generator
col_name_plant = [
"bus_id",
"Pg",
"Qg",
"Qmax",
"Qmin",
"Vg",
"mBase",
"status",
"Pmax",
"Pmin",
"Pc1",
"Pc2",
"Qc1min",
"Qc1max",
"Qc2min",
"Qc2max",
"ramp_agc",
"ramp_10",
"ramp_30",
"ramp_q",
"apf",
"mu_Pmax",
"mu_Pmin",
"mu_Qmax",
"mu_Qmin",
"type",
"interconnect",
"GenFuelCost",
"GenIOB",
"GenIOC",
"GenIOD",
"zone_id",
"zone_name",
"lat",
"lon",
]
col_type_plant = [
"int",
"float",
"float",
"float",
"float",
"float",
"float",
"int",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"str",
"str",
"float",
"float",
"float",
"int",
"int",
"str",
"float",
"float",
]


# substations
col_name_sub = ["name", "interconnect_sub_id", "lat", "lon", "interconnect"]
col_type_sub = ["str", "int", "float", "float", "str"]


# storage
col_name_storage_storagedata = [
"UnitIdx",
"InitialStorage",
"InitialStorageLowerBound",
"InitialStorageUpperBound",
"InitialStorageCost",
"TerminalStoragePrice",
"MinStorageLevel",
"MaxStorageLevel",
"OutEff",
"InEff",
"LossFactor",
"rho",
"ExpectedTerminalStorageMax",
"ExpectedTerminalStorageMin",
"duration",
]
col_type_storage_storagedata = [
"int",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
]
Loading