Skip to content

Setting underlying structure to implement Facade #1169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Bachibouzouk opened this issue Feb 28, 2025 · 2 comments
Open

Setting underlying structure to implement Facade #1169

Bachibouzouk opened this issue Feb 28, 2025 · 2 comments
Assignees

Comments

@Bachibouzouk
Copy link
Contributor

Bachibouzouk commented Feb 28, 2025

Follow up from the discussion which happened at 2025-02 oemof-meeting

The goal is to dicsuss the required changes in order to be able to add Facades so that user can build complex component from "basic" oemof components and add them to the network

Option A ("AtomicNode")

Image

inputs and outputs attributes are stripped from the class Node, Node as known in v0.5 is renamed after AtomicNode and SubNetwork is added

This would require 2 (easy) releases in oemof.network and 1 in oemof.solph

Pros

Cons

  • might be confusing that what used to be Node is now AtomicNode and Node is still there but just higher in the hierarchy
  • 2 releases in oemof.network which might
  • might break older version of oemof as network version is not upperbound

Option B ("AbstractNode")

Image

Pros

  • less releases to make to perform the change

Cons

  • Using "Abstract" in the naming

I will use the naming from variante A to draft pseudo code classes below

oemof.network

class Node(Entity):
     pass

class AtomicNode(Node):
    #attributes
    self.inputs
    self.outputs


class SubNetwork(Node):

      self. node_list  #AtomicNodes list

      def add_subnode(self, node: AtomicNode):
          """add an AtomicNode into the subnetwork"""

oemof.solph

class Facade(SubNetwork):
    
    #attributes
    self.label
    self.facade_type
    def build_subnetwork(self):
         """Instanciate and add AtomicNode instance to the sub network"""


class DSO(Facade):

    def __init__(self,name, el_bus):
        super().__init__(*args,name=name)
        self.facade_type = "dso"

        self.el_bus = el_bus
    def build_subnetwork(self):
        bus_f = Bus()
        feedin = Converter(
            inputs={self.el_bus: Flow()},
            outputs={bus_f: Flow()},
        )
        sink = Sink(inputs={bus_f: Flow()})
        self.add_subnode(sink, bus_f, feedin)

        bus_c = Bus()
        consumption = Converter(
            inputs={bus_c: Flow()}, outputs={self.el_bus: Flow()}
        )
        source = Source(outputs={bus_c: Flow()})
        self.add_subnode(source, bus_c, consumption)
@p-snft
Copy link
Member

p-snft commented Mar 10, 2025

I also see "Option C", to have AbstractNode and AtomicNode with explicit name prefixes.

@Bachibouzouk
Copy link
Contributor Author

We are tending towards option B because it breaks less things from the existing structure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants