Convergence issues with GenericStorage (CHP/heatpump combination)

Hello everyone,
My name is Christian and I’m new to this forum (and as you will see when looking to my attached code, I’m also new in Python and energy modelling).

Since some time I’m trying to size an energy system for our multi-family house.
This energy system is planned to consist of a CHP and a heatpump.

As the heatpump and the CHP are not really modulating that well in real life, I’d need to to add a Thermal Storage and probably as well an electrical storage to make it efficient.

I’ve modeled a very basic Thermal storage and eliminated all losses to make it “attractive” (lines 255 to 275), but whenever I activate this part of the code, the model is not converging anymore.
Without storage, the model with 8760 time-steps is converging within 66 seconds running on my elderly laptop.

Does anyone have similar experience or even an idea how to solve that ?
Any advice is highly appreciated.

I’ve attached the yearly demand of the house (“test.csv”) and the python code I’ve been using.

Kind Regards,
Christian (186.6 KB)

1 Like

He @shaundasschaf, please note that adding a storage will couple different time steps. Without, each of the n time steps can be solved independently. Thus adding one increase the complexity from O(n) to O(n²) in the worst case.

Looking at your code, you are using rather complex models (i.e. GenericCHP). Often, a Transformer (with constant efficiencies) is good enough. That should save you a lot of time. If you really need the complex model, note that implementing a loss rate will also help with the convergence issue. Losses will limit the usage of a storage so that it’s no longer meaningful to store something in January to use it in December. Thus, the complexity will de-facto be decreased. To make long-term coupling disappear by force, you can time-slice your problem, e.g. solving it week by week.

At last, it’s possible to tell cbc when the results are “good enough”. In the following example, it will stop improving the answer once it’s 0.1 % close to the optimum.

    solve_kwargs={"tee": True},
    cmdline_options={'ratio': 0.001},

(With GenericCHP it still takes long on my PC. Just using the battery storage, it converges in minutes even without changes.)

1 Like

Hello @pschoen ,
thank you very much for your comprehensive answer.
I introduced the convergence criteria (‘ratio’) and switched to basic transformers with constant COPs . This has drastically decreased the computation time.

Now I’m back to the issue, that made me switch to the more complex models:
My transformers are modulating power between 0 and the nominal_value. By setting ‘min’ to something I can limit the power modulation range, but the transformer is not switching of anymore and creates a lot of excess energy.
I’d need to model a heatpump, that has a constant power output and is filling the thermal storage whenever there is excess power and then switching off when the storage is full.
Similar for the CHP, that has a certain power modulation capability but not down to zero.

Is there any solution to make a basic transformer behave like that ?

Kind Regards,

Hello @pschoen,
figured it out myself and understood, what the “status” means in combination with the NonConvex flow.

‘minimum_uptime’ setting further decreased calculation times, allowing now to calculate 1 month in something like 100 seconds with electrical and thermal storage activated.
(full 8760h still do not converge over night)

Thanks a lot for your help again.