From daccc0ad4310c287f0633be40c40bcc5bc2fc7f8 Mon Sep 17 00:00:00 2001 From: noracato Date: Tue, 30 Jan 2024 10:49:38 +0100 Subject: [PATCH] Use Merits CurveTools to sum Fever production curves Closes #1389 --- .../fever_facade/consumer_adapter/calculable_activity.rb | 4 +++- app/models/qernel/fever_facade/producer_adapter/inject.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/qernel/fever_facade/consumer_adapter/calculable_activity.rb b/app/models/qernel/fever_facade/consumer_adapter/calculable_activity.rb index 15ef3d0dc..f175a83d8 100644 --- a/app/models/qernel/fever_facade/consumer_adapter/calculable_activity.rb +++ b/app/models/qernel/fever_facade/consumer_adapter/calculable_activity.rb @@ -44,7 +44,9 @@ def demand_curve_from_activities def production_curve_from_activities Merit::CurveTools.add_curves( calculable_activities.filter_map do |_, activity| - activity.activities.sum(&:production_curve) unless activity.empty? + unless activity.empty? + Merit::CurveTools.add_curves(activity.activities.map(&:production_curve)) + end end ) || EMPTY_CURVE end diff --git a/app/models/qernel/fever_facade/producer_adapter/inject.rb b/app/models/qernel/fever_facade/producer_adapter/inject.rb index 5bf718810..af7eba9a9 100644 --- a/app/models/qernel/fever_facade/producer_adapter/inject.rb +++ b/app/models/qernel/fever_facade/producer_adapter/inject.rb @@ -49,6 +49,10 @@ def inject_aggregator_attributes!(production) # TODO: should be a method on collection of participants demand = participants.sum(&:demand) + # puts @node.key + # puts demand + # puts production + # debugger if @node.key == :buildings_space_heater_heatpump_air_water_network_gas edge = conv.output(:useable_heat).edges.first edge.share = demand.positive? ? production / demand : 0.0