Skip to content

Commit 64e6f14

Browse files
committed
Fix heat pump efficiency with one input
1 parent 0eb1373 commit 64e6f14

2 files changed

Lines changed: 30 additions & 20 deletions

File tree

app/projects/dtos.py

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -478,26 +478,36 @@ def convert_to_dto(scenario: Scenario):
478478
efficiencies = []
479479
inflow_direction = []
480480
# TODO: make sure the length is equal to the number of timesteps
481-
for energy_vector in ["Electricity", "Heat"]:
482-
if energy_vector in input_mapping:
483-
# TODO get the case where get fails
484-
inflow_direction.append(
485-
input_connection.get(bus__type=energy_vector).bus.name
486-
)
487-
if isinstance(cop, list):
488-
efficiency = (
489-
(1 / np.array(cop)).tolist()
490-
if energy_vector == "Electricity"
491-
else (1 - 1 / np.array(cop)).tolist()
492-
)
493-
else:
494-
efficiency = (
495-
(1 / cop)
496-
if energy_vector == "Electricity"
497-
else (1 - 1 / cop)
481+
if len(input_mapping) == 1:
482+
# in MVS the coefficient are applied to the output bus and not the input bus
483+
# so for one unit electricity there should be "COP" unit of heat
484+
if isinstance(cop, list):
485+
efficiency = np.array(cop).tolist()
486+
else:
487+
efficiency = cop
488+
inflow_direction = input_mapping
489+
efficiencies.append(efficiency)
490+
else:
491+
for energy_vector in ["Electricity", "Heat"]:
492+
if energy_vector in input_mapping:
493+
# TODO get the case where get fails
494+
inflow_direction.append(
495+
input_connection.get(bus__type=energy_vector).bus.name
498496
)
499-
500-
efficiencies.append(efficiency)
497+
if isinstance(cop, list):
498+
efficiency = (
499+
(1 / np.array(cop)).tolist()
500+
if energy_vector == "Electricity"
501+
else (1 - 1 / np.array(cop)).tolist()
502+
)
503+
else:
504+
efficiency = (
505+
(1 / cop)
506+
if energy_vector == "Electricity"
507+
else (1 - 1 / cop)
508+
)
509+
510+
efficiencies.append(efficiency)
501511

502512
if len(efficiencies) == 0:
503513
print("ERROR, a heat pump should at least have one electrical input!")

app/projects/scenario_topology_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def handle_asset_form_post(request, scen_id=0, asset_type_name="", asset_uuid=No
192192

193193
# will apply for he
194194
cop_calculator_id = request.POST.get("copId", "")
195-
if asset_type_name == "heat_pump" and cop_calculator_id is not "":
195+
if asset_type_name == "heat_pump" and cop_calculator_id != "":
196196
existing_cop = get_object_or_404(COPCalculator, id=cop_calculator_id)
197197
existing_cop.asset = asset
198198
existing_cop.save()

0 commit comments

Comments
 (0)