Skip to content

Commit

Permalink
Fix line lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
henhuy committed Sep 28, 2023
1 parent 1565b7f commit 2c3f2aa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ def main():
)

data = pd.concat([data, data], ignore_index=True)
data["wind"].iloc[8760 - 24:8760] = 0
data["wind"].iloc[8760*2 - 24:8760] = 0
data["pv"].iloc[8760 - 24:8760] = 0
data["pv"].iloc[8760 * 2 - 24:8760] = 0
data["wind"].iloc[8760 - 24 : 8760] = 0
data["wind"].iloc[8760 * 2 - 24 : 8760] = 0
data["pv"].iloc[8760 - 24 : 8760] = 0
data["pv"].iloc[8760 * 2 - 24 : 8760] = 0

##########################################################################
# Initialize the energy system and read/calculate necessary parameters
Expand Down Expand Up @@ -167,14 +167,14 @@ def main():
"timesteps_per_period": aggregation1.hoursPerPeriod,
"order": aggregation1.clusterOrder,
"occurrences": aggregation1.clusterPeriodNoOccur,
"timeindex": aggregation1.timeIndex
"timeindex": aggregation1.timeIndex,
},
{
"timesteps_per_period": aggregation2.hoursPerPeriod,
"order": aggregation2.clusterOrder,
"occurrences": aggregation2.clusterPeriodNoOccur,
"timeindex": aggregation2.timeIndex
}
"timeindex": aggregation2.timeIndex,
},
],
infer_last_interval=False,
)
Expand Down Expand Up @@ -318,7 +318,9 @@ def main():

# Concatenate flows:
flows = pd.concat([flow["sequences"] for flow in results.values()], axis=1)
flows.columns = [f"{oemof_tuple[0]}-{oemof_tuple[1]}" for oemof_tuple in results.keys()]
flows.columns = [
f"{oemof_tuple[0]}-{oemof_tuple[1]}" for oemof_tuple in results.keys()
]
print(flows)

electricity_bus = solph.views.node(results, "electricity")
Expand Down
5 changes: 3 additions & 2 deletions src/oemof/solph/_energy_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ def __init__(

if tsa_parameters is not None:
msg = (
"CAUTION! You specified the 'tsa_parameters' attribute for your "
"energy system.\n This will lead to setting up energysystem with aggregated timeseries. "
"CAUTION! You specified the 'tsa_parameters' attribute for "
"your energy system.\n This will lead to setting up "
"energysystem with aggregated timeseries. "
"Storages and flows will be adapted accordingly.\n"
"Please be aware that the feature is experimental as of "
"now. If you find anything suspicious or any bugs, "
Expand Down
6 changes: 4 additions & 2 deletions src/oemof/solph/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ def _add_parent_block_sets(self):
sum(
len(self.es.tsa_parameters[p]["order"])
for p in self.PERIODS
) + 1
)
+ 1
)
)
)
Expand Down Expand Up @@ -536,7 +537,8 @@ def _add_parent_block_sets(self):
for p in self.PERIODS
)
),
# cluster periods in original timeseries (from TSAM)
# cluster periods in original timeseries
# (from TSAM)
list(
itertools.chain.from_iterable(
itertools.repeat(
Expand Down
15 changes: 8 additions & 7 deletions src/oemof/solph/components/_generic_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ def _storage_content_bound_rule(block, n, t):
# ************* Constraints ***************************

def _storage_inter_minimum_level_rule(block):
# See FINE implementation at https://github.com/FZJ-IEK3-VSA/FINE/blob/57ec32561fb95e746c505760bd0d61c97d2fd2fb/FINE/storage.py#L1329
# See FINE implementation at
# https://github.com/FZJ-IEK3-VSA/FINE/blob/
# 57ec32561fb95e746c505760bd0d61c97d2fd2fb/FINE/storage.py#L1329
for n in self.STORAGES:
for p, i, g in m.TIMEINDEX_CLUSTER:
t = get_timeindex(p, i, g)
Expand All @@ -558,8 +560,7 @@ def _storage_inter_minimum_level_rule(block):
)
rhs = (
self.storage_content_inter[n, inter_i]
* (1 - n.loss_rate[t])
** (g * m.timeincrement[tk])
* (1 - n.loss_rate[t]) ** (g * m.timeincrement[tk])
+ self.storage_content_intra[n, p, k, g]
)
self.storage_inter_minimum_level.add(
Expand All @@ -576,7 +577,6 @@ def _storage_inter_minimum_level_rule(block):
)

def _storage_inter_maximum_level_rule(block):
# See FINE implementation at https://github.com/FZJ-IEK3-VSA/FINE/blob/57ec32561fb95e746c505760bd0d61c97d2fd2fb/FINE/storage.py#L1329
for n in self.STORAGES:
for p, i, g in m.TIMEINDEX_CLUSTER:
t = get_timeindex(p, i, g)
Expand All @@ -591,8 +591,7 @@ def _storage_inter_maximum_level_rule(block):
)
lhs = (
self.storage_content_inter[n, inter_i]
* (1 - n.loss_rate[t])
** (g * m.timeincrement[tk])
* (1 - n.loss_rate[t]) ** (g * m.timeincrement[tk])
+ self.storage_content_intra[n, p, k, g]
)
rhs = n.nominal_storage_capacity * n.max_storage_level[t]
Expand Down Expand Up @@ -685,7 +684,9 @@ def _inter_storage_balance_rule(block, n, i):
break

k = m.es.tsa_parameters[p]["order"][ii]
t = get_timeindex(p, k, m.es.tsa_parameters[p]["timesteps_per_period"] - 1)
t = get_timeindex(
p, k, m.es.tsa_parameters[p]["timesteps_per_period"] - 1
)
expr = 0
expr += block.storage_content_inter[n, i + 1]
expr += -block.storage_content_inter[n, i] * (
Expand Down

0 comments on commit 2c3f2aa

Please sign in to comment.