Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/examples/wall.ipynb
Views: 531
Thermal behavior of a wall
Modeling and Simulation in Python
Copyright 2021 Allen Downey
License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
This case study is based on Gori, Marincioni, Biddulph, Elwell, "Inferring the thermal resistance and effective thermal mass distribution of a wall from in situ measurements to characterise heat transfer at both the interior and exterior surfaces", Energy and Buildings, Volume 135, 15 January 2017, Pages 398-409, which I downloaded here.
The authors put their paper under a Creative Commons license, and make their data available here. I thank them for their commitment to open, reproducible science, which made this case study possible.
The goal of their paper is to model the thermal behavior of a wall as a step toward understanding the "performance gap between the expected energy use of buildings and their measured energy use". The wall they study is identified as the exterior wall of an office building in central London, not unlike this one.
The following figure shows the scenario and their model:
On the interior and exterior surfaces of the wall, they measure temperature and heat flux over a period of three days. They model the wall using two thermal masses connected to the surfaces, and to each other, by thermal resistors.
The primary methodology of the paper is a Bayesian method for inferring the parameters of the system (two thermal masses and three thermal resistances).
The primary result is a comparison of two models: the one shown here with two thermal masses, and a simpler model with only one thermal mass. They find that the two-mass model is able to reproduce the measured fluxes substantially better.
Tempting as it is, I will not replicate their method for estimating the parameters. Rather, I will implement their model and run it with their estimated parameters.
The following cells download and read the data.
The index contains Pandas Timestamp
objects, which is good for dealing with real-world dates and times, but not as good for running the simulations, so I'm going to convert to seconds.
Subtracting the first Timestamp
yields Timedelta
objects:
Then we can convert to seconds and replace the index.
The timesteps are all 5 minutes:
Plot the measured fluxes.
Plot the measured temperatures.
Making the System object
params
is a sequence with the estimated parameters from the paper.
We'll pass params
to make_system
, which computes init
, packs the parameters into Series
objects, and computes the interpolation functions.
Make a System
object
Test the interpolation function:
Implementing the model
Next we need a slope function that takes instantaneous values of the two internal temperatures and computes their time rates of change.
The slope function gets called two ways.
When we call it directly,
state
is aState
object and the values it contains have units.When
run_solve_ivp
calls it,state
is an array and the values it contains don't have units.
In the second case, we have to apply the units before attempting the computation. require_units
applies units if necessary:
The following function computes the fluxes between the four zones.
We can test it like this.
Here's a slope function that computes derivatives of T_C1
and T_C2
Test the slope function with the initial conditions.
Now let's run the simulation, generating estimates for the time steps in the data.
Here's what the results look like.
These results are similar to what's in the paper:
.
To get the estimated fluxes, we have to go through the results and basically do the flux calculation again.
Let's see how the estimates compare to the data.
These results are also similar to what's in the paper (the bottom row):