Skip to content

Commit

Permalink
Merge 45ce662 into 3513608
Browse files Browse the repository at this point in the history
  • Loading branch information
uvchik committed Jan 21, 2020
2 parents 3513608 + 45ce662 commit 3528b9d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
21 changes: 17 additions & 4 deletions deflex/basic_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,13 @@ def chp_table(heat_b, heat_demand, table_collection, regions=None):
)
eta_elec_chp = round(heat_b[region]["elec_chp"], 2)

# Due to the different efficiency between heat from chp-plants and
# heat from heat-plants the share of the output is different to the
# share of the input. As heat-plants will produce more heat per fuel
# factor will be greater than 1 and for chp-plants smaller than 1.
out_share_factor_chp = heat_b[region]["out_share_factor_chp"]
out_share_factor_hp = heat_b[region]["out_share_factor_hp"]

# Remove 'district heating' and 'electricity' and spread the share
# to the remaining columns.
share = pd.DataFrame(columns=heat_b[region]["fuel_share"].columns)
Expand Down Expand Up @@ -562,9 +569,13 @@ def chp_table(heat_b, heat_demand, table_collection, regions=None):

# CHP
trsf.loc["limit_heat_chp", (region, src)] = round(
sum_val * share.loc[rows[0], fuel] + 0.5
sum_val * share.loc[rows[0], fuel] * out_share_factor_chp + 0.5
)
cap_heat_chp = round(
max_val * share.loc[rows[0], fuel] * out_share_factor_chp
+ 0.005,
2,
)
cap_heat_chp = round(max_val * share.loc[rows[0], fuel] + 0.005, 2)
trsf.loc["capacity_heat_chp", (region, src)] = cap_heat_chp
cap_elec = cap_heat_chp / eta_heat_chp * eta_elec_chp
trsf.loc["capacity_elec_chp", (region, src)] = round(cap_elec, 2)
Expand All @@ -585,10 +596,12 @@ def chp_table(heat_b, heat_demand, table_collection, regions=None):

# HP
trsf.loc["limit_hp", (region, src)] = round(
sum_val * share.loc[rows[1], fuel] + 0.5
sum_val * share.loc[rows[1], fuel] * out_share_factor_hp + 0.5
)
trsf.loc["capacity_hp", (region, src)] = round(
max_val * share.loc[rows[1], fuel] + 0.005, 2
max_val * share.loc[rows[1], fuel] * out_share_factor_hp
+ 0.005,
2,
)
if trsf.loc["capacity_hp", (region, src)] > 0:
trsf.loc["efficiency_hp", (region, src)] = eta_hp
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def read(fname):
install_requires=[
"oemof >= 0.3.0",
"pandas >= 0.17.0",
"reegis >= v0.1.0",
"reegis > v0.1.1",
"demandlib",
"workalendar",
"networkx",
Expand Down
33 changes: 22 additions & 11 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import shutil
import pandas as pd
from oemof import solph
from deflex import main, config as cfg
from nose.tools import assert_raises_regexp
from deflex import main, config as cfg, scenario_tools
from nose.tools import assert_raises_regexp, eq_


class TestMain:
Expand All @@ -36,16 +36,27 @@ def test_main_secure(self):
main.main_secure(1910, "de55")

def test_main_secure_with_es(self):
main.main(2014, "de21", es=self.es)
assert os.path.isfile(
os.path.join(
self.base_path,
"deflex",
"2014",
"results_cbc",
"deflex_2014_de21.esys",
)
main.main(2014, "de21", es=self.es, extra_regions=["DE03", "DE07"])
fn = os.path.join(
self.base_path,
"deflex",
"2014",
"results_cbc",
"deflex_2014_de21.esys",
)
assert os.path.isfile(fn)
sc = scenario_tools.Scenario()
sc.restore_es(fn)
flows = [x for x in sc.es.results["main"].keys() if x[1] is not None]
commodity_regions = [
x[0].label.region
for x in flows
if x[1].label.tag == "commodity"
and x[1].label.subtag == "natural_gas"
and x[1].label.cat == "bus"
and x[0].label.cat == "source"
]
eq_(commodity_regions, ["DE", "DE03", "DE07"])

def test_main_secure_with_xls_file(self):
my_es = solph.EnergySystem(timeindex=self.date_time_index)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_scenario_powerplant_and_chp.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ def test_chp(self):
transf = basic_scenario.scenario_chp(
self.pp, self.regions, 2014, "de21"
)["transformer"]
eq_(int(transf.loc["capacity", ("DE01", "hard coal")]), 485)
eq_(int(transf.loc["capacity_elec_chp", ("DE01", "hard coal")]), 806)
eq_(int(transf.loc["capacity", ("DE01", "hard coal")]), 623)
eq_(int(transf.loc["capacity_elec_chp", ("DE01", "hard coal")]), 667)

0 comments on commit 3528b9d

Please sign in to comment.