pyhydronic 2.0.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hydronic/__init__.py +46 -0
- hydronic/comfort.py +820 -0
- hydronic/heat.py +383 -0
- hydronic/misc.py +44 -0
- hydronic/version.py +2 -0
- pyhydronic-2.0.0.dist-info/METADATA +124 -0
- pyhydronic-2.0.0.dist-info/RECORD +11 -0
- pyhydronic-2.0.0.dist-info/WHEEL +6 -0
- pyhydronic-2.0.0.dist-info/licenses/COPYING +674 -0
- pyhydronic-2.0.0.dist-info/licenses/LICENSE +22 -0
- pyhydronic-2.0.0.dist-info/top_level.txt +1 -0
hydronic/heat.py
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Hydronic -- calculations for modeling heated structures
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2026, Perry Kundert
|
|
5
|
+
#
|
|
6
|
+
# Hydronic is free software: you can redistribute it and/or modify it under the
|
|
7
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
8
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
9
|
+
# version. See the LICENSE file at the top of the source tree.
|
|
10
|
+
#
|
|
11
|
+
# Hydronic is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
12
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
"""Rudimentary heat flow between interconnected spaces.
|
|
17
|
+
|
|
18
|
+
A structure is a tree of 'space's (each with an 'environment' of some substance at some
|
|
19
|
+
temperature), connected by 'portal's (walls, windows, floors, ...) with an area and R value. Each
|
|
20
|
+
time step, 'compute' the BTUs flowing through every portal, then 'absorb' them to update each
|
|
21
|
+
space's temperature.
|
|
22
|
+
|
|
23
|
+
All units are US/Imperial, as used in the R values of North American building materials:
|
|
24
|
+
temperatures in degrees F, dimensions in ft, heat in BTU, R in F.ft^2.h/BTU.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import absolute_import, division, print_function
|
|
29
|
+
|
|
30
|
+
import copy
|
|
31
|
+
import time
|
|
32
|
+
|
|
33
|
+
from .misc import Error, near, scale
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Conversion constants
|
|
37
|
+
ft_per_m = 3.2808399
|
|
38
|
+
F_per_C = ( 212. - 32. ) / 100.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def C_to_F( C ):
|
|
42
|
+
return scale( C, ( 0., 100. ), ( 32., 212. ))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def F_to_C( F ):
|
|
46
|
+
return scale( F, ( 32., 212. ), ( 0., 100. ))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def ft( f=0, i=0 ):
|
|
50
|
+
"""Convert feet and inches to fractional feet"""
|
|
51
|
+
return f + i / 12.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def daytime( t ):
|
|
55
|
+
"""Convert a time span in seconds, into: ##d hh:mm:ss"""
|
|
56
|
+
t = int( t )
|
|
57
|
+
return "%02dd %02d:%02d:%02d" % (
|
|
58
|
+
t // 3600 // 24,
|
|
59
|
+
( t // 3600 ) % 24,
|
|
60
|
+
( t % 3600 ) // 60,
|
|
61
|
+
t % 60 )
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def dimension( s ):
|
|
65
|
+
"""Convert a (x,y) or (x,y,z) dimension into ft'in"x..."""
|
|
66
|
+
return 'x'.join( "%2d'%2d\"" % ( i // 12, i % 12 )
|
|
67
|
+
for i in ( int( round( f * 12 + .0001 )) for f in s ))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# Spatial dimension indices
|
|
71
|
+
WI = 0
|
|
72
|
+
LN = 1
|
|
73
|
+
HI = 2
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def resize( size, w=None, l=None, h=None ):
|
|
77
|
+
"""Return a copy of (w,l,h) 'size', with any of w, l or h replaced"""
|
|
78
|
+
return ( size[WI] if w is None else w,
|
|
79
|
+
size[LN] if l is None else l,
|
|
80
|
+
size[HI] if h is None else h )
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def area( s ):
|
|
84
|
+
return s[WI] * s[LN]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def volume( s ):
|
|
88
|
+
return s[WI] * s[LN] * s[HI]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def merge( a, b, how=None ):
|
|
92
|
+
"""Merges two spaces in the 'how' dimension. At least 1 of the other 2 must be identical. If not
|
|
93
|
+
specified, chooses the first non-equal dimension to merge. If either is None, the other is
|
|
94
|
+
returned. The remaining dimension is averaged, weighted to conserve total area and volume.
|
|
95
|
+
|
|
96
|
+
"""
|
|
97
|
+
if a is None or b is None:
|
|
98
|
+
return b if a is None else a
|
|
99
|
+
|
|
100
|
+
if how is None:
|
|
101
|
+
for how in ( WI, LN, HI ):
|
|
102
|
+
if not near( a[how], b[how] ):
|
|
103
|
+
break
|
|
104
|
+
|
|
105
|
+
ok = False
|
|
106
|
+
r = list( a )
|
|
107
|
+
r[how] = a[how] + b[how]
|
|
108
|
+
for dim in ( ( how + 1 ) % 3, ( how + 2 ) % 3 ):
|
|
109
|
+
if near( a[dim], b[dim] ):
|
|
110
|
+
ok = True
|
|
111
|
+
else:
|
|
112
|
+
r[dim] = ( a[dim] * a[how] + b[dim] * b[how] ) / ( a[how] + b[how] )
|
|
113
|
+
if not ok:
|
|
114
|
+
raise Error( "No common dimension found merging %r and %r" % ( a, b ))
|
|
115
|
+
return tuple( r )
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# BTU required to raise 1 ft^3 of different compounds by 1 degree F
|
|
119
|
+
# Estimates are from Siegenthaler, Modern Hydronic Heating ..., pg 255.
|
|
120
|
+
BTU_ft3_F = {}
|
|
121
|
+
BTU_ft3_F['air'] = 290. / ( 2000 * 8 )
|
|
122
|
+
BTU_ft3_F['concrete'] = 20000. / ( 2000 * 4 / 12. )
|
|
123
|
+
|
|
124
|
+
# Wild guess
|
|
125
|
+
BTU_ft3_F['tile'] = 15000. / ( 2000 * 4 / 12. ) # ?
|
|
126
|
+
BTU_ft3_F['soil'] = 10000. / ( 2000 * 4 / 12. ) # ?
|
|
127
|
+
BTU_ft3_F['wood'] = 5000. / ( 2000 * 4 / 12. ) # ?
|
|
128
|
+
|
|
129
|
+
# 1 BTU raises 1 pound of water by 1F degree.
|
|
130
|
+
# 1 ft^3 is 7.4805 US gallons, and 1 US gallon is 8.3403 pounds
|
|
131
|
+
#BTU_ft3_F['water'] = 1. * 7.4805 * 8.3403
|
|
132
|
+
# 1 ft^3 is 6.2288 Imp. gallons, which is 10 pounds (by definition)
|
|
133
|
+
BTU_ft3_F['water'] = 1. * 6.2288 * 10.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _temperature( e ):
|
|
137
|
+
"""The temperature of an environment, or of a raw number"""
|
|
138
|
+
return e.temperature if isinstance( e, environment ) else float( e )
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class environment( object ):
|
|
142
|
+
"""A description of an environment, composed of some substance with a certain thermal inertia.
|
|
143
|
+
Has a temperature and a composition of substance '.what', and hence a thermal inertia, but no
|
|
144
|
+
inherent volume. An optional 'sensor' may be attached by the application (eg. to replace the
|
|
145
|
+
modeled temperature with a measured one); it is not used here.
|
|
146
|
+
|
|
147
|
+
"""
|
|
148
|
+
def __init__( self, temp=C_to_F( 0. ), what="air", sensor=None ):
|
|
149
|
+
self.temperature = temp # degrees F
|
|
150
|
+
self.what = what
|
|
151
|
+
self.inertia = BTU_ft3_F[what] # Thermal inertia per ft^3
|
|
152
|
+
self.sensor = sensor
|
|
153
|
+
|
|
154
|
+
def __str__( self ):
|
|
155
|
+
return "%-10.10s %6.2fC" % ( self.what, F_to_C( self.temperature ))
|
|
156
|
+
|
|
157
|
+
def absorb( self, BTU, volume ):
|
|
158
|
+
"""Compute temperature change. The total BTU's absorbed, spread over the volume's thermal
|
|
159
|
+
mass."""
|
|
160
|
+
self.temperature += BTU / ( self.inertia * volume )
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class portal( object ):
|
|
164
|
+
"""Defines a connection between spaces, with an area and R value; assumes that the "inside" has
|
|
165
|
+
a stationary air film of (default) R0.68. Computes heat transfer to the adjoining space. Also
|
|
166
|
+
estimates surface temperature.
|
|
167
|
+
|
|
168
|
+
EXAMPLES
|
|
169
|
+
# A 3'x5' R3 window
|
|
170
|
+
portal( "Window 1 W", "world", ( 3., 5. ), 3. )
|
|
171
|
+
|
|
172
|
+
Assumes an air film of R.68 (default) on the inside, for purposes of estimating the surface
|
|
173
|
+
temperature. For a purely radiant surface (where inside radiant temperature equals outside
|
|
174
|
+
temperature), use an R value of 0.0, and supply only a non-zero value for film.
|
|
175
|
+
|
|
176
|
+
"""
|
|
177
|
+
def __init__( self, name, onto, size, R, film=0.68 ):
|
|
178
|
+
self.name = name
|
|
179
|
+
self.onto = onto # The name of the space connected to
|
|
180
|
+
self.size = size # (x,y[,z]) in ft (optional z ignored)
|
|
181
|
+
self.R_film = film
|
|
182
|
+
self.R_core = R
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def R( self ):
|
|
186
|
+
return self.R_core + self.R_film
|
|
187
|
+
|
|
188
|
+
def __str__( self ):
|
|
189
|
+
return "%12.12s (%7.2fft^2) R%3d %s" % (
|
|
190
|
+
dimension( self.size ), self.area(), self.R, self.name )
|
|
191
|
+
|
|
192
|
+
def area( self ):
|
|
193
|
+
return self.size[0] * self.size[1]
|
|
194
|
+
|
|
195
|
+
def transfer( self, inside, outside, dt ):
|
|
196
|
+
"""Computes the BTU heat transfer from environment 'inside' to 'outside' for period 'dt'
|
|
197
|
+
seconds. Each may be an environment, or a raw temperature (F). Heat lost from inside is -'ve.
|
|
198
|
+
|
|
199
|
+
A
|
|
200
|
+
Q = --- x (delta-T)
|
|
201
|
+
R
|
|
202
|
+
|
|
203
|
+
Q = BTU/h rate of heat transfer
|
|
204
|
+
A = area (ft^2)
|
|
205
|
+
R = R value (degrees-F x ft^2 * hr./BTU)
|
|
206
|
+
delta-T = temperature surface differential
|
|
207
|
+
"""
|
|
208
|
+
BTUh = ( _temperature( outside ) - _temperature( inside )) * self.area() / self.R
|
|
209
|
+
return BTUh * dt / 60 / 60 # BTUh is in hours
|
|
210
|
+
|
|
211
|
+
INSIDE_SURFACE = 1
|
|
212
|
+
INSIDE_AIR = 2
|
|
213
|
+
|
|
214
|
+
def temperature( self, inside, outside, what=INSIDE_SURFACE ):
|
|
215
|
+
"""Compute approximate interior surface temperature, given the total R value of the portal, and
|
|
216
|
+
the R value of the inside surface air film(s), and the inside and outside air temperatures.
|
|
217
|
+
|
|
218
|
+
The temperature drop across the wall section is proportional to the R value of each section.
|
|
219
|
+
Therefore, if the total R value (including interior air film) is (say) R6.8, then an air
|
|
220
|
+
film of R.68 would represent 10% of the temperature drop. If the interior air temperature
|
|
221
|
+
is 70F and exterior is -30F, then the wall will be 10F cooler than the interior temperature.
|
|
222
|
+
|
|
223
|
+
See www.irtalk.com/forums/storage/9/2105/Effective%20R-value%201.pdf
|
|
224
|
+
|
|
225
|
+
It is invalid to define a portal with a total R value equal to zero, but we'll default to
|
|
226
|
+
the outside temperature if so.
|
|
227
|
+
|
|
228
|
+
"""
|
|
229
|
+
ti = _temperature( inside )
|
|
230
|
+
to = _temperature( outside )
|
|
231
|
+
if self.R > 0:
|
|
232
|
+
if what == self.INSIDE_SURFACE:
|
|
233
|
+
# Computing the inside surface temperature, given the inside and outside air (and
|
|
234
|
+
# surface) temperatures; remove the fraction of the temperature gradient through the
|
|
235
|
+
# insulation that is the result of the air film.
|
|
236
|
+
return ti - ( ti - to ) * self.R_film / ( self.R_core + self.R_film )
|
|
237
|
+
elif what == self.INSIDE_AIR:
|
|
238
|
+
# Computing the inside air temperature, given the inside surface temperature and
|
|
239
|
+
# outside air (and surface) temperatures.
|
|
240
|
+
return ti + ( ti - to ) / self.R_core * self.R_film
|
|
241
|
+
return to
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class space( object ):
|
|
245
|
+
"""Implements an environmental space with an inside and an outside. Computes energy flow between
|
|
246
|
+
the space and whatever portal(s) to other spaces are provided.
|
|
247
|
+
|
|
248
|
+
In general the space will be connected to the "outside" of one or more other spaces. For
|
|
249
|
+
example, the root 'space' might typically represent the outside walls of a structure. Its
|
|
250
|
+
'loop' method would be passed the outside temperature, and would compute the gains/losses to
|
|
251
|
+
the walls and roof of the house.
|
|
252
|
+
|
|
253
|
+
A house would be composed of 1 or more rooms, which would typically be interconnected with
|
|
254
|
+
each-other (sharing walls, doors, etc.).
|
|
255
|
+
|
|
256
|
+
Each computation of heat flow to/from the space and its sub-spaces specifies a time base 'now'
|
|
257
|
+
and period 'dt' for the computation, and passes a description of the weather 'outside' during
|
|
258
|
+
that period.
|
|
259
|
+
|
|
260
|
+
The sub-space then computes its own gains/losses to/from its sub-spaces for the time period
|
|
261
|
+
(using its current initial conditions), and then computes its own gains/losses during the
|
|
262
|
+
period to the (provided) 'outside'. It calculates its (net) ending condition (for use in the
|
|
263
|
+
next loop as the next initial condition), and returns the gains/losses to the caller.
|
|
264
|
+
|
|
265
|
+
"""
|
|
266
|
+
def __init__( self, name, size, initial=None, now=None ):
|
|
267
|
+
self.name = name # Unique amongst spaces!
|
|
268
|
+
self.size = size # (x,y,z) in ft
|
|
269
|
+
self.conditions = environment() if initial is None else copy.copy( initial )
|
|
270
|
+
self.now = time.time() if now is None else now
|
|
271
|
+
self.start = self.now
|
|
272
|
+
self.subspaces = []
|
|
273
|
+
self.portals = []
|
|
274
|
+
|
|
275
|
+
def __str__( self ):
|
|
276
|
+
return "%-16.16s (%7.2fft^2) %20.20s %s" % (
|
|
277
|
+
self.name, self.area(), dimension( self.size ), str( self.conditions ))
|
|
278
|
+
|
|
279
|
+
def contains( self, something ):
|
|
280
|
+
self.subspaces.append( something )
|
|
281
|
+
|
|
282
|
+
def connects( self, onto ):
|
|
283
|
+
self.portals.append( onto )
|
|
284
|
+
|
|
285
|
+
def walk( self, depth=0 ):
|
|
286
|
+
"""A recursive generator that yields (space,depth) for the space and all subspaces in order"""
|
|
287
|
+
yield self, depth
|
|
288
|
+
for subs in self.subspaces:
|
|
289
|
+
for s, d in subs.walk( depth=depth + 1 ):
|
|
290
|
+
yield s, d
|
|
291
|
+
|
|
292
|
+
def area( self ):
|
|
293
|
+
return area( self.size )
|
|
294
|
+
|
|
295
|
+
def volume( self ):
|
|
296
|
+
return volume( self.size )
|
|
297
|
+
|
|
298
|
+
def current( self, cond=None ):
|
|
299
|
+
"""Copy current conditions of this space (and all subspaces) into the supplied dictionary"""
|
|
300
|
+
if cond is None:
|
|
301
|
+
cond = {}
|
|
302
|
+
for subs in self.subspaces:
|
|
303
|
+
subs.current( cond )
|
|
304
|
+
cond[self.name] = copy.copy( self.conditions )
|
|
305
|
+
return cond
|
|
306
|
+
|
|
307
|
+
def compute( self, initial=None, results=None, now=None ):
|
|
308
|
+
"""Takes a map of 1 or more current environment conditions, and computes a map of BTU gain/loss
|
|
309
|
+
deltas from/onto each of the spaces, via each port, since our last 'now'. The 'results' in
|
|
310
|
+
+/- BTUs are keyed (space,other,portal).
|
|
311
|
+
|
|
312
|
+
A gain/loss computed from one space onto another is also included as an inverse loss/gain
|
|
313
|
+
from the other space onto the corresponding space.
|
|
314
|
+
|
|
315
|
+
After 'compute' is finished, the 'absorb' method should be invoked with the 'results'
|
|
316
|
+
dictionary.
|
|
317
|
+
|
|
318
|
+
"""
|
|
319
|
+
if initial is None:
|
|
320
|
+
initial = self.current()
|
|
321
|
+
if results is None:
|
|
322
|
+
results = {}
|
|
323
|
+
if now is None:
|
|
324
|
+
now = time.time()
|
|
325
|
+
dt = now - self.now
|
|
326
|
+
|
|
327
|
+
# Compute all subspaces, too, using same timestamp, and collect their results
|
|
328
|
+
for sub in self.subspaces:
|
|
329
|
+
sub.compute( initial, results, now )
|
|
330
|
+
|
|
331
|
+
# Compute our net BTU gain/loss for period 'dt', adding the gain/loss to our results, and
|
|
332
|
+
# adding the inverse to the other space's results.
|
|
333
|
+
for port in self.portals:
|
|
334
|
+
if port.onto not in initial:
|
|
335
|
+
raise Error( "%s: Couldn't find conditions for %s, via %s" % (
|
|
336
|
+
self.name, port.onto, port.name ))
|
|
337
|
+
BTU = port.transfer( self.conditions, initial[port.onto], dt )
|
|
338
|
+
here = ( self.name, port.onto, port.name )
|
|
339
|
+
there = ( port.onto, self.name, port.name )
|
|
340
|
+
results[here] = results.get( here, 0. ) + BTU
|
|
341
|
+
results[there] = results.get( there, 0. ) - BTU
|
|
342
|
+
|
|
343
|
+
self.now = now
|
|
344
|
+
return results
|
|
345
|
+
|
|
346
|
+
def absorb( self, results ):
|
|
347
|
+
"""Calculate the change in temperature due to the given deltas, and let all subspaces do the
|
|
348
|
+
same. Since the results is keyed by a tuple of names: (space,other,portal), we must traverse
|
|
349
|
+
and pick out all that apply to this space.
|
|
350
|
+
|
|
351
|
+
"""
|
|
352
|
+
for ( s, o, p ), btu in results.items():
|
|
353
|
+
if s == self.name:
|
|
354
|
+
self.conditions.absorb( btu, self.volume() )
|
|
355
|
+
for subs in self.subspaces:
|
|
356
|
+
subs.absorb( results )
|
|
357
|
+
|
|
358
|
+
def surfaces( self, root ):
|
|
359
|
+
"""Yields (portal, temperature) for every surface bounding this space: its own portals, and any
|
|
360
|
+
other space's portals onto it (found by walking 'root', eg. the 'world'). The temperature
|
|
361
|
+
(F) is that of the surface, as seen from inside this space.
|
|
362
|
+
|
|
363
|
+
"""
|
|
364
|
+
spaces = dict( ( s.name, s ) for s, _ in root.walk() )
|
|
365
|
+
for p in self.portals:
|
|
366
|
+
yield p, p.temperature( self.conditions, spaces[p.onto].conditions )
|
|
367
|
+
for s in spaces.values():
|
|
368
|
+
if s is not self:
|
|
369
|
+
for p in s.portals:
|
|
370
|
+
if p.onto == self.name:
|
|
371
|
+
yield p, p.temperature( self.conditions, s.conditions )
|
|
372
|
+
|
|
373
|
+
def radiant( self, root ):
|
|
374
|
+
"""Mean radiant temperature (F) of this space: the area-weighted mean temperature of all its
|
|
375
|
+
surfaces. This is the usual approximation to the view-factor weighted mean seen by an
|
|
376
|
+
occupant, and is Fanger's t_r (once converted to C). Defaults to the air temperature.
|
|
377
|
+
|
|
378
|
+
"""
|
|
379
|
+
total = weighted = 0.
|
|
380
|
+
for p, t in self.surfaces( root ):
|
|
381
|
+
total += p.area()
|
|
382
|
+
weighted += p.area() * t
|
|
383
|
+
return weighted / total if total else self.conditions.temperature
|
hydronic/misc.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Hydronic -- calculations for modeling heated structures
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2026, Perry Kundert
|
|
5
|
+
#
|
|
6
|
+
# Hydronic is free software: you can redistribute it and/or modify it under the
|
|
7
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
8
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
9
|
+
# version. See the LICENSE file at the top of the source tree.
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
"""Small numeric helpers; formerly imported from ownercredit.misc, now dependency-free."""
|
|
13
|
+
|
|
14
|
+
from __future__ import absolute_import, division, print_function
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Error( ValueError ):
|
|
18
|
+
"""Invalid input, or a computation that failed to converge."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def near( a, b, significance=1.0e-4 ):
|
|
22
|
+
"""True iff a and b differ by no more than the factor 'significance' of the larger magnitude.
|
|
23
|
+
Default is to within 4 decimal places."""
|
|
24
|
+
return abs( a - b ) <= significance * max( abs( a ), abs( b ))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def clamp( val, lim ):
|
|
28
|
+
"""Limit val to the (min, max) 'lim'. A NaN limit is ignored, since no value is < or > NaN."""
|
|
29
|
+
if val < lim[0]:
|
|
30
|
+
return lim[0]
|
|
31
|
+
if val > lim[1]:
|
|
32
|
+
return lim[1]
|
|
33
|
+
return val
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def scale( val, dom, rng, clamped=False ):
|
|
37
|
+
"""Map 'val' linearly from domain 'dom' to range 'rng', optionally clamped to 'rng'. Either may be
|
|
38
|
+
in increasing or decreasing order, but neither may be zero-sized."""
|
|
39
|
+
if dom[1] == dom[0]:
|
|
40
|
+
raise Error( "Scaling %r requires a non-zero domain: %r" % ( val, dom ))
|
|
41
|
+
result = rng[0] + ( val - dom[0] ) * ( rng[1] - rng[0] ) / ( dom[1] - dom[0] )
|
|
42
|
+
if clamped:
|
|
43
|
+
result = clamp( result, ( min( rng ), max( rng )))
|
|
44
|
+
return result
|
hydronic/version.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyhydronic
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Heat flow through structures, and Fanger's thermal comfort (PMV/PPD) equation
|
|
5
|
+
Author-email: Perry Kundert <perry@dominionrnd.com>
|
|
6
|
+
License-Expression: GPL-3.0-or-later OR LicenseRef-Proprietary
|
|
7
|
+
Project-URL: Homepage, https://github.com/pjkundert/pyhydronic
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/pjkundert/pyhydronic/issues
|
|
9
|
+
Project-URL: Commercial Support, https://dominionrnd.com/products/hydronic-comfort
|
|
10
|
+
Keywords: hydronic,radiant,heating,thermostat,comfort,Fanger,PMV,PPD,ISO 7730,heat flow,mean radiant temperature
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Manufacturing
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 2
|
|
17
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Home Automation
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=2.7
|
|
23
|
+
Description-Content-Type: text/plain
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
License-File: COPYING
|
|
26
|
+
Provides-Extra: tests
|
|
27
|
+
Requires-Dist: pytest>=4.6; extra == "tests"
|
|
28
|
+
Requires-Dist: flake8; extra == "tests"
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: build; extra == "dev"
|
|
31
|
+
Requires-Dist: setuptools>=77; extra == "dev"
|
|
32
|
+
Requires-Dist: wheel; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
#+title: Pyhydronic: Heat Flow and Thermal Comfort
|
|
36
|
+
#+author: Perry Kundert
|
|
37
|
+
#+email: perry@dominionrnd.com
|
|
38
|
+
#+OPTIONS: ^:nil toc:nil
|
|
39
|
+
|
|
40
|
+
* Pyhydronic
|
|
41
|
+
|
|
42
|
+
Thermostats measure the wrong thing. People don't feel the air temperature; they feel the heat
|
|
43
|
+
they lose -- by convection to the air, and by radiation to every surface around them. A room at
|
|
44
|
+
21C with a wall of cold windows feels cool; the same room over a warm radiant floor feels warm.
|
|
45
|
+
|
|
46
|
+
Pyhydronic (=import hydronic=) computes both halves of that:
|
|
47
|
+
|
|
48
|
+
- =hydronic.heat= :: Heat flow between interconnected /spaces/ (rooms, slabs, hydronic zones, the
|
|
49
|
+
ground, the outdoors) through /portals/ (walls, windows, floors) of some area and R value. This
|
|
50
|
+
estimates every surface's temperature, and hence each room's mean radiant temperature.
|
|
51
|
+
- =hydronic.comfort= :: Fanger's comfort equation (ISO 7730): the Predicted Mean Vote (PMV) and
|
|
52
|
+
Predicted Percentage Dissatisfied (PPD) for any air and radiant temperature, humidity, air
|
|
53
|
+
speed, clothing and activity -- and the air temperature =setpoint= yielding neutral comfort.
|
|
54
|
+
|
|
55
|
+
Pure Python with no dependencies, for Python 2.7 and 3. It has controlled a multi-zone hydronic
|
|
56
|
+
radiant slab home for over a decade.
|
|
57
|
+
|
|
58
|
+
* Install
|
|
59
|
+
|
|
60
|
+
#+BEGIN_EXAMPLE
|
|
61
|
+
python3 -m pip install pyhydronic # or: python2 -m pip install pyhydronic
|
|
62
|
+
#+END_EXAMPLE
|
|
63
|
+
|
|
64
|
+
For Python 2 systems without access to PyPI, use the source; eg. as a git submodule:
|
|
65
|
+
|
|
66
|
+
#+BEGIN_EXAMPLE
|
|
67
|
+
git submodule add https://github.com/pjkundert/pyhydronic.git pyhydronic
|
|
68
|
+
ln -s pyhydronic/hydronic hydronic # or add pyhydronic/ to PYTHONPATH
|
|
69
|
+
#+END_EXAMPLE
|
|
70
|
+
|
|
71
|
+
* Use
|
|
72
|
+
|
|
73
|
+
How comfortable is a room with 21C air, if cold windows drag its mean radiant temperature (t_r)
|
|
74
|
+
down to 17C? What air temperature would make it comfortable?
|
|
75
|
+
|
|
76
|
+
#+BEGIN_SRC python
|
|
77
|
+
from hydronic import fanger
|
|
78
|
+
|
|
79
|
+
f = fanger( clo=1.0, met=1.2, hum=0.4 ) # winter clothes, sitting/standing, 40% RH
|
|
80
|
+
f.PMV( t_a=21, t_r=21 ) # -0.24: neutral
|
|
81
|
+
f.PMV( t_a=21, t_r=17 ) # -0.64: slightly cool
|
|
82
|
+
f.PPD( t_a=21, t_r=17 ) # 13.6% dissatisfied
|
|
83
|
+
f.setpoint( t_r=17 ) # 26.9C air restores neutral comfort
|
|
84
|
+
f.setpoint( t_r=25 ) # 19.8C suffices over a warm radiant floor
|
|
85
|
+
#+END_SRC
|
|
86
|
+
|
|
87
|
+
Where does t_r come from? Model the room (US units: F, ft, R values), and ask:
|
|
88
|
+
|
|
89
|
+
#+BEGIN_SRC python
|
|
90
|
+
from hydronic import space, portal, environment, C_to_F, F_to_C, ft
|
|
91
|
+
|
|
92
|
+
world = space( 'world', ( 1e4, 1e4, 1e4 ), environment( C_to_F( -20 )), now=0 )
|
|
93
|
+
room = space( 'room', ( ft(12), ft(14), ft(9) ), environment( C_to_F( 21 )), now=0 )
|
|
94
|
+
world.contains( room )
|
|
95
|
+
room.connects( portal( 'walls', 'world', ( ft(26), ft(9) ), R=20 ))
|
|
96
|
+
room.connects( portal( 'window', 'world', ( ft(8), ft(5) ), R=2 ))
|
|
97
|
+
room.connects( portal( 'ceiling', 'world', room.size, R=50 ))
|
|
98
|
+
|
|
99
|
+
F_to_C( room.radiant( world )) # 19.1C: walls 19.7C, ceiling 20.4C, window 10.6C
|
|
100
|
+
world.absorb( world.compute( now=60 )) # advance 1 minute; room loses ~36 BTU
|
|
101
|
+
#+END_SRC
|
|
102
|
+
|
|
103
|
+
The [[file:examples/][examples]] build a two room house on a radiant slab, and compare an air-temperature thermostat
|
|
104
|
+
against a comfort (PMV) thermostat; and reproduce the classic "comfort lines" of neutral air vs.
|
|
105
|
+
radiant temperature:
|
|
106
|
+
|
|
107
|
+
#+BEGIN_EXAMPLE
|
|
108
|
+
python examples/radiant_room.py --mode air # sunroom air held at 21C, but PMV -0.3
|
|
109
|
+
python examples/radiant_room.py --mode comfort # sunroom held at PMV ~0
|
|
110
|
+
python examples/comfort_lines.py
|
|
111
|
+
#+END_EXAMPLE
|
|
112
|
+
|
|
113
|
+
* More
|
|
114
|
+
|
|
115
|
+
| [[file:README-model.org][README-model.org]] | The heat flow model: spaces, portals, radiant floors, time steps |
|
|
116
|
+
| [[file:README-comfort.org][README-comfort.org]] | Fanger's PMV / PPD: inputs, validation, caveats |
|
|
117
|
+
| [[file:README-development.org][README-development.org]] | Nix, make, testing under Python 2.7 and 3, releasing |
|
|
118
|
+
| [[file:docs/README.org][docs/]] | Reference papers |
|
|
119
|
+
|
|
120
|
+
* License and Commercial Support
|
|
121
|
+
|
|
122
|
+
Dual licensed: GPLv3 (or later), or a commercial license from Dominion Research & Development
|
|
123
|
+
Corp.; see [[file:LICENSE][LICENSE]]. We help thermostat, controller and building automation vendors put comfort
|
|
124
|
+
-- not just air temperature -- at the center of their products: [[https://dominionrnd.com/products/hydronic-comfort][dominionrnd.com]].
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
hydronic/__init__.py,sha256=6ckp8j59wdkhPNm2JqovwegZ2kCc8Zi5PBQg-SOxgYU,2247
|
|
2
|
+
hydronic/comfort.py,sha256=WAAfM2cD3D5BGIo1sILH7C2IfnAN4AjE-tDqOaczwpI,38925
|
|
3
|
+
hydronic/heat.py,sha256=0_TMS9Z_CIQbUWWr-O5n0g5NrIxyAkgAbMc5G68ruMQ,15921
|
|
4
|
+
hydronic/misc.py,sha256=unZj7OhG3UuPwtmYVQM0wbCJIEvma7i87S9H9rIshTQ,1678
|
|
5
|
+
hydronic/version.py,sha256=fcHjNgZ_b1QSu88O94LeDahd5dK6RF6sjiGqZl_6wa8,120
|
|
6
|
+
pyhydronic-2.0.0.dist-info/licenses/COPYING,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
7
|
+
pyhydronic-2.0.0.dist-info/licenses/LICENSE,sha256=JIE1SsG7H_e2p8PaGbDfqUDUQB2WCY6ydWyQvy0AmzQ,1206
|
|
8
|
+
pyhydronic-2.0.0.dist-info/METADATA,sha256=CzB-ztYCFF4XjCrFRnOom-fyfzHX1varwjZcEHYlQOc,5970
|
|
9
|
+
pyhydronic-2.0.0.dist-info/WHEEL,sha256=Uvlg2aNlEKdilsyFSJt1QX5me0eEbCjQzR3nZeFkvy4,109
|
|
10
|
+
pyhydronic-2.0.0.dist-info/top_level.txt,sha256=rjUhrDKEfgTw6TsZrmBwSqRWgm9g1G6CRCpRVN86w1Y,9
|
|
11
|
+
pyhydronic-2.0.0.dist-info/RECORD,,
|