-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1459 from quintel/plexos-coupling
New must run adapter types import/export
- Loading branch information
Showing
9 changed files
with
71 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Qernel | ||
module MeritFacade | ||
# This class adapts an export consumer to act as must run. It uses the same methods for flexible edges as the export adapter. | ||
class ExportConsumerAdapter < ConsumerAdapter | ||
def inject! | ||
input_edge = target_api.node.input(@context.carrier).edges.first | ||
demand = participant.production(:mj) | ||
|
||
target_api.demand = demand | ||
|
||
if input_edge.edge_type == :inversed_flexible | ||
# We need to override the calculation of an inversed flexible edge. | ||
# and set the demand explicitly. | ||
input_edge.dataset_set(:value, demand) | ||
input_edge.dataset_set(:calculated, true) | ||
end | ||
|
||
super | ||
end | ||
|
||
def input_of_carrier | ||
source_api.full_load_hours * source_api.input_capacity * MJ_TO_MHW | ||
end | ||
end | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
app/models/qernel/merit_facade/import_always_on_adapter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Qernel | ||
module MeritFacade | ||
# This class adapts an import producer to act as must run. It uses the same methods for flexible edges as the import adapter. | ||
class ImportAlwaysOnAdapter < AlwaysOnAdapter | ||
def inject! | ||
super | ||
elec_edge = target_api.node.output(:electricity).edges.first | ||
|
||
return unless elec_edge.edge_type == :flexible | ||
|
||
# We need to override the calculation of the flexible edge and set the | ||
# demand explicitly. | ||
elec_edge.dataset_set(:value, target_api.demand) | ||
elec_edge.dataset_set(:calculated, true) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters