Energy self-sufficient system

Is it possible to set a boundary condition so that a self-sufficient energy system is created? This means that production and consumption are equal in balance.

Best regards

Actually, you have to provide any extra boundary condition. Once you assign the demand and any generation unit to the same bus, the generation unit is subjected to serve this demand entirely. You might want to use the investment mode in order to find the cost-optimal size of this generation unit to be capable of serve the given demand.

Thanks for your answer!
“you have to provide any extra boundary condition” means it is possible?
How can such a boundary condition be set? At which place in the program? In the solver itself? Like: “The annual sum of PV production must be equal to the demand”.
(Example: The demand must be covered by PV in the balance sheet, but the electricity can come from the grid temporarily if an equally high PV surplus is produced at another time.)

My sentence was missing a don’t. Actually, I wanted to say “Actually, you don’t have to provide any extra boundary condition.”

Assuming you want to model the example system you described as a start

I’d suggest to take a look at the oemof-examples repository, in particular at the simple dispatch example. This example, uses more components then you’re looking for, but nevertheless, it gives an orientation.

In order to achieve

The demand must be covered by PV in the balance sheet, but the electricity can come from the grid temporarily if an equally high PV surplus is produced at another time.

you can parametrize the Source component (respectively its flow) with

  • a normalized time series to actual_value
  • fixed=True
  • the total energy produced by the PV plant with summed_max
  • I guess a nominal_value (capacity fo the PV plant) is still required

We have several power buses. On these different buses, energy can be imported or exported via Transformer (modelling of the electricity network, the natural gas network, etc.) Different renewable energies are connected as sources on the buses. Furthermore, different loads are defined as sinks. Is it possible to summarize the generation by renewable energies (sum_RE) (on all buses) and compare it with the sum of the consumptions (sum_Load)?

sum_RE = sum(E_PV) + sum(E_Wind)+ sum(E_solarthermal) + …
sum_Load = sum(E_electricity) + sum(E_thermal) + …
sum_RE >= sum_Load

This is the definition of a self-sufficient system as we have to integrate it. Is it possible to give the solver the inequality constraint described above (sum_RE >= sum_Load)?

Thank you very much for your support.

Kind regards from Nordhausen,

Christoph Schmidt

If your problem is linear, then yes. Fourer et al (2003:139) provide a similar example, expressed using the AMPL language. I don’t use Pyomo so I don’t know if the interface accepts that kind of high‑level representation. If not, you’ll have to revert to a more canonical form with the right‑hand‑side constraints set to nonnegative constants and introduce artificial variables to achieve an equivalent system. Happy hacking, R.


Fourer, Robert, David M Gay, and Brian W Kernighan (2003). AMPL: a modeling language for mathematical programming. USA: Duxbury Press/Brooks/Cole Publishing Company. ISBN 978-0-534-38809-6. Chapter PDFs available from the web. Chapter 11 on linear programs.

Thanks a lot for the quick answer.

We have now found another way to include the condition. We have now defined the sources (PV; wind, etc.) as transformers and the sinks as well. These are now coupled with a balancing bus to which a balanced storage is also connected. This should balance the production and consumption at the end of a period.
Now we have a new problem. Assuming that our storage is set to balanced=False, we assume that the same results as in the previous simulation (without transformers, with sources and sinks) would have to occur.
Unfortunately we have deviations in the results, which are not significant. Is it possible that the deviation of the results depends on the accuracy of the solver? Hence the following questions:
Is it possible to specify the accuracy of the solver in oemof?
What is the abort criterion of the solver?
Can these values be read out from the simulation results?

Kind regards from Nordhausen

oemof interfaces to Pyomo which interfaces to whichever solver you have elected to link to at runtime. So you’ll need to state which solver library that is. Also helpful to know a bit more about your problem: linear or something else. Generally you can tune solvers and some are smarter than others. And there will be precision issues with floating point arithmetic and also problem stability for badly conditioned problems. You can also run arbitrary precision arithmetic but you won’t want to. You should be able to get some information on how well conditioned your problem is from the solver. Solvers pre‑scale too so you should have that switched on, hence confirm that. Solvers normally have several abort criteria, for instance, CPU time. Mixed integer problems normally run to some predefined tolerance relative to the linear relaxation of the same problem. All this is configurable.

Another thing to consider are closing storage inventories. If these don’t somehow match between scenarios, then your comparisons will drift accordingly. HTH, R.

First of all it is possible to add extra constraints to oemof but I do not understand the idea of the constraint sum_RE >= sum_Load.

  1. Do you equal electricity and thermal energy? This sounds strange to me. I think it should be rather sum_RE_elec >= sum_Load_elec and sum_RE_therm >= sum_Load_therm.

  2. Is it a dispatch or investment model?

  3. I do not understand why you model a PV system as a Transformer object. What is the input, a sun energy bus?

It is unlikely for LP (or do you have MILP). Try to build the energy balance for both cases. If you do not find the problem reduce the number of components and the number of time steps this makes everything easier.

The solver is cbc.

In the future, the model should also include the start-up times of the power plants, but currently the problem is linear.

We use the investment model.

We do not want to separate electrical and thermal loads and sources, but rather couple them. Because with Power to heat, electricity can be converted into heat and we use that. As in the following picture:

The goal is to be renewable in terms of the balance sheet, i.e. that the sum of renewable energies over the year is equal to the load. By defining PV and wind and the load as transformers, we were able to run all 3 on an external bus, on which an (infinite) storage is attached, which was balanced. So the condition was met. If it is possible to insert the balancing equation differently, we would like to know how. So the input for the PV transformer is the external bus. The output from the PV transformer to the electric bus is a load curve with maximum power limitation, so that the power is expanded in a cost-optimized way.

Above is an illustration of the model. It is broken down to the essential, heat is not yet included. Actually only the inside counts: The external bus is for balancing, because we do not know yet how to insert the condition as an equation. With the help of the external storage we can therefore equate renewable production and consumption over the period under consideration. With the condition balanced=True/False we can switch this condition on and off.

For this extended model (external storage: balanced=False) we assumed that the result is the same as the model without external bus (as shown in the figure below), if the transformers are defined as source/ sink.


We hope our problem becomes more understandable.

Greetings from Nordhausen

With regard to the external bus B_ex. Sometimes you have to hack a model to get something done. But generally speaking, the closer your model accords with reality, the less effort required to explain your non‑intuitive hack and why it was necessary. By the way, your great diagrams help in this regard.

If you do not have anything else than renewable sources (no fossil transformer) and a fixed demand you do not need an additional constraint. All the energy will be produced by the renewable sources. If you want to calculate the grid compensation you can just add an unlimited storage. Because from the perspective of a region the grid is nothing else than an unlimited storage. You may consider costs for this “unlimited” storage but this is another topic.