Skip to content

Commit

Permalink
fix: ensure that storage table int columns remain int
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Feb 3, 2021
1 parent 8ab8e84 commit fd7596c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions powersimdata/input/transform_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ def _add_storage_unit(self, entry):
:param int bus_id: bus identification number.
:param dict entry: storage details, containing at least "bus_id" and "capacity".
"""
gen = {g: 0 for g in self.grid.storage["gen"].columns}
storage = self.grid.storage
gen = {g: 0 for g in storage["gen"].columns}
gen["bus_id"] = entry["bus_id"]
gen["Vg"] = 1
gen["mBase"] = 100
Expand All @@ -379,9 +380,9 @@ def _add_storage_unit(self, entry):
gen["Pmin"] = -1 * entry["capacity"]
gen["ramp_10"] = entry["capacity"]
gen["ramp_30"] = entry["capacity"]
self.grid.storage["gen"] = self.grid.storage["gen"].append(
gen, ignore_index=True, sort=False
)
storage["gen"] = storage["gen"].append(gen, ignore_index=True, sort=False)
# Maintain int columns after the append converts them to float
storage["gen"] = storage["gen"].astype({"bus_id": "int", "status": "int"})

def _add_storage_gencost(self):
"""Sets generation cost of storage unit."""
Expand All @@ -403,7 +404,8 @@ def _add_storage_data(self, storage_id, entry):
:param dict entry: storage details, containing at least:
"bus_id", "capacity".
"""
data = {g: 0 for g in self.grid.storage["StorageData"].columns}
storage = self.grid.storage
data = {g: 0 for g in storage["StorageData"].columns}

capacity = entry["capacity"]
duration = entry["duration"]
Expand All @@ -427,9 +429,11 @@ def _add_storage_data(self, storage_id, entry):
data["InEff"] = entry["InEff"]
data["LossFactor"] = entry["LossFactor"]
data["rho"] = 1
self.grid.storage["StorageData"] = self.grid.storage["StorageData"].append(
storage["StorageData"] = storage["StorageData"].append(
data, ignore_index=True, sort=False
)
# Maintain int columns after the append converts them to float
storage["StorageData"] = storage["StorageData"].astype({"UnitIdx": "int"})


def voltage_to_x_per_distance(grid):
Expand Down

0 comments on commit fd7596c

Please sign in to comment.