Skip to content

Commit

Permalink
Merge pull request #690 from openego/features/#684-clarify-disaggrega…
Browse files Browse the repository at this point in the history
…tion-names

Features/#684 clarify disaggregation names
  • Loading branch information
ClaraBuettner authored Nov 15, 2023
2 parents a98017f + eeecd5d commit f8d1972
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
6 changes: 3 additions & 3 deletions etrago/appl.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
},
},
},
"disaggregation": None, # None or 'uniform'
"spatial_disaggregation": None, # None or 'uniform'
# Temporal Complexity:
"snapshot_clustering": {
"active": False, # choose if clustering is activated
Expand Down Expand Up @@ -691,14 +691,14 @@ def run_etrago(args, json_path):
etrago.lopf()

# conduct lopf with full complex timeseries for dispatch disaggregation
etrago.dispatch_disaggregation()
etrago.temporal_disaggregation()

# start power flow based on lopf results
etrago.pf_post_lopf()

# spatial disaggregation
# needs to be adjusted for new sectors
etrago.disaggregation()
etrago.spatial_disaggregation()

# calculate central etrago results
etrago.calc_results()
Expand Down
2 changes: 1 addition & 1 deletion etrago/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"strategy": "simultaneous"
},
},
"disaggregation": null,
"spatial_disaggregation": null,
"snapshot_clustering": {
"active": false,
"method": "segmentation",
Expand Down
2 changes: 1 addition & 1 deletion etrago/cluster/disaggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def update_constraints(network, externals):
def run_disaggregation(self):
log.debug("Running disaggregation.")
if self.args["network_clustering"]["active"]:
disagg = self.args.get("disaggregation")
disagg = self.args.get("spatial_disaggregation")
skip = () if self.args["pf_post_lopf"]["active"] else ("q",)
t = time.time()
if disagg:
Expand Down
2 changes: 1 addition & 1 deletion etrago/cluster/electrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ def run_spatial_clustering(self):
None
"""
if self.args["network_clustering"]["active"]:
if self.args["disaggregation"] is not None:
if self.args["spatial_disaggregation"] is not None:
self.disaggregated_network = self.network.copy()
else:
self.disaggregated_network = self.network.copy(with_time=False)
Expand Down
28 changes: 16 additions & 12 deletions etrago/tools/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,21 @@ def dispatch_disaggregation(self):
logger.info("Time for LOPF [min]: {}".format(round(z, 2)))


def import_gen_from_links(network):
def import_gen_from_links(network, drop_small_capacities=True):
"""
create gas generators from links in order to not lose them when
dropping non-electric carriers
"""
# Discard all generators < 1kW
discard_gen = network.links[network.links["p_nom"] <= 0.001].index
network.links.drop(discard_gen, inplace=True)
for df in network.links_t:
if not network.links_t[df].empty:
network.links_t[df].drop(
columns=discard_gen.values, inplace=True, errors="ignore"
)

if drop_small_capacities:
# Discard all generators < 1kW
discard_gen = network.links[network.links["p_nom"] <= 0.001].index
network.links.drop(discard_gen, inplace=True)
for df in network.links_t:
if not network.links_t[df].empty:
network.links_t[df].drop(
columns=discard_gen.values, inplace=True, errors="ignore"
)

gas_to_add = network.links[
network.links.carrier.isin(
Expand Down Expand Up @@ -769,8 +771,10 @@ def drop_foreign_components(network):
# generators modeled as links are imported to the generators table
import_gen_from_links(network)

if args["disaggregation"]:
import_gen_from_links(etrago.disaggregated_network)
if args["spatial_disaggregation"]:
import_gen_from_links(
etrago.disaggregated_network, drop_small_capacities=False
)

# For the PF, set the P to be the optimised P
network.generators_t.p_set = network.generators_t.p_set.reindex(
Expand Down Expand Up @@ -873,7 +877,7 @@ def drop_foreign_components(network):
etrago.export_to_csv(path)
pf_solve.to_csv(os.path.join(path, "pf_solution.csv"), index=True)

if args["disaggregation"]:
if args["spatial_disaggregation"]:
etrago.disaggregated_network.export_to_csv_folder(
path + "/disaggregated_network"
)
Expand Down
4 changes: 2 additions & 2 deletions etrago/tools/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ def __init__(

lopf = lopf

dispatch_disaggregation = dispatch_disaggregation
temporal_disaggregation = dispatch_disaggregation

pf_post_lopf = run_pf_post_lopf

disaggregation = run_disaggregation
spatial_disaggregation = run_disaggregation

calc_results = calc_etrago_results

Expand Down

0 comments on commit f8d1972

Please sign in to comment.