This file will become your README and also the index of your documentation.
pip install cylinder
This basic model provides the core function for a step change calculation in a mixed hot water cylinder
Load some data that can be used to test the model - flow and electricity pricing
df = (pd.DataFrame(load_demand(path = Path('../data/drawprofiles'),bed=3,unit=3)))
df.columns=["flow"]
df = df.merge(load_power(path = Path('../data')), how='left', left_index=True, right_index=True)
df.head()
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
</style>
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
flow | price | price_kw | date | week | hour | day | peak | tou | cost | n_cost | sr_cost | lr_cost | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
timestamp | |||||||||||||
2020-01-01 00:00:00 | 0.0 | 7.920 | 0.007920 | 2020-01-01 | 1 | 0 | 2 | 0 | 0.02 | 0.027920 | -0.22080 | 0.162438 | 0.149272 |
2020-01-01 00:01:00 | 0.0 | 8.526 | 0.008526 | 2020-01-01 | 1 | 0 | 2 | 0 | 0.02 | 0.028526 | -0.21474 | 0.158675 | 0.145694 |
2020-01-01 00:02:00 | 0.0 | 9.132 | 0.009132 | 2020-01-01 | 1 | 0 | 2 | 0 | 0.02 | 0.029132 | -0.20868 | 0.155010 | 0.142235 |
2020-01-01 00:03:00 | 0.0 | 9.738 | 0.009738 | 2020-01-01 | 1 | 0 | 2 | 0 | 0.02 | 0.029738 | -0.20262 | 0.151437 | 0.138888 |
2020-01-01 00:04:00 | 0.0 | 10.344 | 0.010344 | 2020-01-01 | 1 | 0 | 2 | 0 | 0.02 | 0.030344 | -0.19656 | 0.147952 | 0.135645 |
Create a hot water cylinder object and initialise it with the data
hwc = HWC(T_set=68, T_deadband=2, element=3000, radius=.25, height=1)
print(f'The HWC volume is {int(hwc.Volume*1000)} liters')
The HWC volume is 196 liters
Default thermogram
plt.imshow(hwc.thermogram)
<matplotlib.image.AxesImage>
Run the model for a single day on thermostat and plot the results
results = []
for index, row in df[:24*60].iterrows():
raw_flow = row['flow']
hwc.flow = raw_flow*(hwc.T_demand-hwc.T_cold)/(hwc.T-hwc.T_cold)
hwc._thermostat()
hwc.T = hwc._update_temperatures(action=1)
results.append([index,hwc.T, hwc.thermostat, hwc.flow,row.cost])
r,c = row.day, row.hour
hwc.thermogram[r,c] = hwc.thermostat * 1 * hwc.Q /60 + hwc.thermogram[r,c]*(1- 0.1)
results = pd.DataFrame(results, columns=['time','T','thermostat','flow','cost']).set_index('time')
plt.imshow(hwc.thermogram)
<matplotlib.image.AxesImage>
fig, ax = plt.subplots(nrows=2, figsize=(12,6), sharex=True)
ax[0].plot(results['T'])
ax[0].set_ylabel('°C')
ax[0].set_title('Temperature')
ax[1].plot(results['thermostat'])
ax[1].xaxis.set_major_formatter(mdates.DateFormatter("%H:%M"))
ax[1].xaxis.set_minor_formatter(mdates.DateFormatter("%H:%M"))
hwc = HWC(T_set=68, T_deadband=2, element=3000, radius=.25, height=1)
results = []
for index, row in df[:24*60].iterrows():
raw_flow = 0
hwc.flow = raw_flow*(hwc.T_demand-hwc.T_cold)/(hwc.T-hwc.T_cold)
hwc._thermostat()
hwc.T = hwc._update_temperatures(action=0)
results.append([index,hwc.T, hwc.thermostat, hwc.flow,row.cost])
r,c = row.day, row.hour
hwc.thermogram[r,c] = hwc.thermostat * 1 * hwc.Q /60 + hwc.thermogram[r,c]*(1- 0.1)
results = pd.DataFrame(results, columns=['time','T','thermostat','flow','cost']).set_index('time')
fig, ax = plt.subplots(nrows=2, figsize=(12,6), sharex=True)
ax[0].plot(results['T'])
ax[0].set_ylabel('°C')
ax[0].set_title('Temperature')
ax[1].plot(results['thermostat'])
ax[1].xaxis.set_major_formatter(mdates.DateFormatter("%H:%M"))
ax[1].xaxis.set_minor_formatter(mdates.DateFormatter("%H:%M"))
plt.imshow(hwc.thermogram)
<matplotlib.image.AxesImage>