# Modelling a switch between buses in oemof.solph

Hi everyone,

I am trying to model a group of 4 buildings with their own electricity production units (for example PV or any transformer which produces electricity). Now the task is to connect the electricity buses of these four buildings (elBus_1, elBus_2, elBus_3, elBus_4) so that they can share the electricity production. I am looking for a way to model a switch between multiple buses in oemof.solph.

The first approach I tried was to use several Transformer objects with one input, one output and a conversion factor of 1, for every combination of these electricity buses. But now we want to add investment object so that the optimizer can choose whether or not the electrical connection between buildings should be made, and also increase the number of buildings to 50. So the point-to-point connections with a Transformer would not work anymore.

Is there another way to implement this?

Hope I could explain the problem well. Looking forward to some advice.

Thanks, Neha

Hi @ndimri! Wouldn’t it be an option have one “energy community” bus where all the buildings can connect to?

Hi @pschoen, thanks for your reply. That’s what we chose to do as well but the idea was also that we want the optimizer to select whether allowing buildings to connect electrically would be more economical (and if not then in which conditions does it start to become economical). If we model this electricity connection between buildings as a bus, then this decision could not be made in the optimization itself.

I tried to define a new class like Transformer with a new constraint (sum of all input flows equals sum of all output flows), but with this approach the optimization takes very long to converge.

The node implementing sum of all input flows equals sum of all output flows is actually the Bus. You could stick to this star architecture and have a decision which buildings connect to the bus. This would make four binary variables.

If you want to have direct connections, then having 4 buildings would mean 24 possible connections. (and binary variables). This optimisation will take time. Alternatively, you could implement continuous invest to a transhipment capacity which should be a lot faster. (There is an experimental “Link” component for that, but I cannot tell if it works at the moment.)