# Temperature in Open energy modelling

Hello, this is going in a similar direction as the heat-pump COP discussion.

While testing oemof and looking into pypsa I was wondering, if there is a possibility in existing open energy models to include the temperature (and maybe pressure, but that’s not that necessary) as variable. For example: loading a heat storage does only work if the temperature of the source is higher than that of the storage.
I did not find any possibility to keep track of the temperature in oemof or pypsa, but maybe I just missed it? Or are there any workarounds / apps /… for it?
I also did not find any ressources in python for thermodynamics, except for thermopy.

What are your experiences in the field of modelling heat infrastructure (storage, networks, etc.) and coupling it with other energy carrier grids?

I’ve not yet found an open model that optimises a heat network satisfactorily. I’m working on Calliope, which doesn’t do temperature tracking (yet…). Both Oemof and PyPSA are also linear optimisers, which just doesn’t lend itself to temperature tracking, as it’s usually a nonlinear problem. One use of temperature tracking in MILP that I’ve seen before is in this study by Faille, Mondon and Al-Nasrawi. Haven’t tested the method myself, but could be worth looking into further.

For storage, the usual approach in models is to assume some sort of ideal stratification: a hot side and a cold side with no heat transfer across the boundary between the two. Then a standard hourly heat loss rate is used (~0.2%/hr). See this paper used to explain the storage model in the DER-CAM model for a good example of current-ish practice. Obviously it’s not realistic, you’d be best splitting the tank into n distinct layers, solving the heat and mass transfer equations across the boundaries at each time step. That’s what programs like TRNSYS will do when simulating heat systems.

For piping thermal energy, MILP models seem to use a per-distance loss rate, based on an assumed constant temperature & temperature difference between ground and pipe. I’ve not come across many non-linear district optimisation models, so not seen anything temperature tracking related on that front.

Sorry not to have a more constructive reply, hopefully someone else will be able to help us both on this matter!

Regarding PyPSA, it’s only doing linear optimisation at the moment, and as Bryn says, this is not generally suited to tracking the state of internal temperatures. It can only take account of the effect of temperature on the input data (i.e. exogenously), e.g. the effect of outside temperature on heat demand, heat pump efficiency, linearised heat losses in pipes and standing losses to thermal storage.

deeco can track temperature.

I’m also very keen to learn acceptable compromises to avoid non-linearity!

The task of representing thermal systems in generic energy models is not straightforward.

There is a considerable literature on the modeling and optimization of thermal systems themselves — what we might refer to as subsystems. For instance, the optimization of heat-exchanger networks (HEN) is a longstanding research topic. Then there is more applied work, for instance, the modeling and optimization of district heating networks and CHP plant. These models tend to be handcrafted in GAMS and don’t sit well with the design of a generic modeling framework, implemented in an object-oriented language like C++ or python. One thermal model I am a somewhat familiar with is a GAMS program written by Andreas Christidis to optimize the operation of CHP plant with heat accumulators (thermal storage) while selling into a volatile electricity market.

I must refer again to a (now abandoned) modeling framework called deeco, which I maintained for several years. Some of the questions posed in this forum were satisfactorily addressed by deeco, in terms of both overarching design and the implementation of specific technologies. Plant modules (concrete classes) covered a range of thermal processes including heat pumps, seasonal storage, and concentrating solar power (CSP). The CSP module relied on dimensional analysis and Nusselt, Prandtl, and Reynolds numbers to characterize the underlying fluid dynamics. Much of this is work is now archived on GitHub for reference (as Tom noted). Not all of the background thesis work is present but I can probably get hold of missing reports on request.

The key theoretical point is that the intensive and extensive states of the system are orthogonal and that the intensive state (including temperatures) can be set before the extensive state (including plant duties) is determined.

Clearly deeco is not the only or even the best solution on offer, but it does represent a significant attempt at dealing with this design issue. Moreover the model is well documented and mostly well coded. In many respects, the use of storage, be it thermal, hydro, or otherwise, is more challenging, conceptually and numerically, than the representation of thermal subsystems.