-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
53 lines (42 loc) · 1.62 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
"""
import os
from pathlib import Path
from oemof.solph import EnergySystem, Model, processing
# DONT REMOVE THIS LINE!
from oemof.tabular import datapackage # noqa
from oemof.tabular.constraint_facades import CONSTRAINT_TYPE_MAP
from oemof.tabular.facades import TYPEMAP
from oemof.tabular.postprocessing import calculations, core
# scenario definition
SCENARIO = "eprom_bhkw_winter"
DATAPACKAGES_PATH = Path(__file__).parent
SCENARIO_DATAPACKAGE = DATAPACKAGES_PATH / SCENARIO / "datapackage.json"
RESULTS_PATH = Path(__file__).parent / "oemof-results"
# create energy system object
es = EnergySystem.from_datapackage(
str(SCENARIO_DATAPACKAGE),
attributemap={},
typemap=TYPEMAP,
)
# create model from energy system (this is just oemof.solph)
m = Model(es)
# add constraints from datapackage to the model
m.add_constraints_from_datapackage(
str(SCENARIO_DATAPACKAGE),
constraint_type_map=CONSTRAINT_TYPE_MAP,
)
# if you want dual variables / shadow prices uncomment line below
# m.receive_duals()
# select solver 'gurobi', 'cplex', 'glpk' etc
m.solve("cbc")
es.params = processing.parameter_as_dict(es)
es.results = m.results()
# now we use the write results method to write the results in oemof-tabular
# format
postprocessed_results = calculations.run_postprocessing(es)
postprocessed_results.to_csv(str(RESULTS_PATH / "results.csv"))
#calculator = core.Calculator(es.params, es.results)
#aggregated_flows = calculations.AggregatedFlows(calculator, from_nodes=["storage_heat", "conversion_heatpump_air"], resample_mode="1min").result
#aggregated_flows.to_csv(str(RESULTS_PATH / 'flows.csv'))
#print(aggregated_flows)