Skip to content

Commit

Permalink
Added Comfort Model for EN Adaptive
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Mar 30, 2016
1 parent 9d7fa12 commit 231609e
Showing 1 changed file with 152 additions and 78 deletions.
230 changes: 152 additions & 78 deletions contrib/comfort_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,84 +380,128 @@ def findSaturatedVaporPressureTorr(T):
return X


def calcBalTemp(
initialGuess, windSpeed,
relHumid, metRate, cloLevel, exWork):
balTemper = initialGuess
delta = 3
while abs(delta) > 0.01:
delta, ppd, set, taAdj, coolingEffect = comfPMVElevatedAirspeed(
balTemper, balTemper, windSpeed,
relHumid, metRate, cloLevel, exWork)
balTemper = balTemper - delta
return balTemper


def calcComfRange(
initialGuessUp, initialGuessDown,
radTemp, windSpeed, relHumid,
metRate, cloLevel, exWork, eightyPercent):
upTemper = initialGuessUp
upDelta = 3
while abs(upDelta) > 0.01:
pmv, ppd, set, taAdj, coolingEffect = comfPMVElevatedAirspeed(
upTemper, radTemp, windSpeed,
relHumid, metRate, cloLevel, exWork)
if eightyPercent == True:
upDelta = 1 - pmv
upTemper = upTemper + upDelta
else:
upDelta = 0.5 - pmv
upTemper = upTemper + upDelta

if initialGuessDown == None:
downTemper = upTemper - 6
else: downTemper = initialGuessDown
downDelta = 3
while abs(downDelta) > 0.01:
pmv, ppd, set, taAdj, coolingEffect = comfPMVElevatedAirspeed(
downTemper, radTemp, windSpeed,
relHumid, metRate, cloLevel, exWork)
if eightyPercent == True:
downDelta = -1 - pmv
downTemper = downTemper + downDelta
def comfAdaptiveComfortASH55(self, ta, tr, runningMean, vel, eightyOrNinety, levelOfConditioning=0):
# Define the variables that will be used throughout the calculation.
r = []
coolingEffect = 0
if eightyOrNinety == True: offset = 3.5
else: offset = 2.5
to = (ta + tr) / 2
# See if the running mean temperature is between 10 C and 33.5 C (the range where the adaptive model is supposed to be used).
if runningMean >= 10.0 and runningMean <= 33.5:

if (vel >= 0.6 and to >= 25):
# calculate cooling effect of elevated air speed
# when top > 25 degC.
if vel < 0.9: coolingEffect = 1.2
elif vel < 1.2: coolingEffect = 1.8
elif vel >= 1.2: coolingEffect = 2.2
else: pass

# Figure out the relation between comfort and outdoor temperature depending on the level of conditioning.
if levelOfConditioning == 0: tComf = 0.31 * runningMean + 17.8
elif levelOfConditioning == 1: tComf = 0.09 * runningMean + 22.6
else: tComf = ((0.09 * levelOfConditioning) + (0.31 * (1 - levelOfConditioning))) * runningMean + ((22.6 * levelOfConditioning) + (17.8 * (1 - levelOfConditioning)))

tComfLower = tComf - offset
tComfUpper = tComf + offset + coolingEffect
r.append(tComf)
r.append(to - tComf)
r.append(tComfLower)
r.append(tComfUpper)

# See if the conditions are comfortable.
if to > tComfLower and to < tComfUpper:
# compliance
acceptability = True
else:
downDelta = -0.5 - pmv
downTemper = downTemper + downDelta
# nonCompliance
acceptability = False
r.append(acceptability)

return upTemper, downTemper
# Append a number to the result list to show whether the values are too hot, too cold, or comfortable.
if acceptability == True: r.append(0)
elif to > tComfUpper: r.append(1)
else: r.append(-1)

elif runningMean < 10.0:
# The prevailing temperature is too cold for the adaptive standard but we will use some correlations from adaptive-style surveys of conditioned buildings to give a good guess.
if levelOfConditioning == 0: tComf = 24.024 + (0.295 * (runningMean - 22.0)) * math.exp((-1) * (((runningMean - 22) / (33.941125)) * ((runningMean - 22) / (33.941125))))
else:
conditOffset = 2.6 * levelOfConditioning
tComf = conditOffset + 24.024 + (0.295 * (runningMean - 22.0)) * math.exp((-1) * (((runningMean - 22) / (33.941125)) * ((runningMean - 22) / (33.941125))))

def comfAdaptiveComfortASH55(ta, tr, runningMean, vel, eightyOrNinety):
r = []
# See if the running mean temperature is between 10 C and 33.5 C and
# if not, label the data as too extreme for the adaptive method.
tempDiff = to - tComf
tComfLower = tComf - offset
tComfUpper = tComf + offset
if to > tComfLower and to < tComfUpper: acceptability = True
else: acceptability = False
if acceptability == True: condit = 0
elif to > tComfUpper: condit = 1
else: condit = -1
outputs = [tComf, tempDiff, tComfLower, tComfUpper, acceptability, condit]
r.extend(outputs)
else:
# The prevailing temperature is too hot for the adaptive method. This should usually not happen for climates on today's earth but it might be possible in the future with global warming. For this case, we will just use the adaptive model at its hottest limit.
if (vel >= 0.6 and to >= 25):
if vel < 0.9: coolingEffect = 1.2
elif vel < 1.2: coolingEffect = 1.8
elif vel >= 1.2: coolingEffect = 2.2
else: pass
if levelOfConditioning == 0: tComf = 0.31 * 33.5 + 17.8
else: tComf = ((0.09 * levelOfConditioning) + (0.31 * (1 - levelOfConditioning))) * 33.5 + ((22.6 * levelOfConditioning) + (17.8 * (1 - levelOfConditioning)))
tempDiff = to - tComf
tComfLower = tComf - offset
tComfUpper = tComf + offset + coolingEffect
if to > tComfLower and to < tComfUpper: acceptability = True
else: acceptability = False
if acceptability == True: condit = 0
elif to > tComfUpper: condit = 1
else: condit = -1
outputs = [tComf, tempDiff, tComfLower, tComfUpper, acceptability, condit]
r.extend(outputs)

if runningMean > 10.0 and runningMean < 33.5:
# Define the variables that will be used throughout the calculation.
to = (ta + tr) / 2
coolingEffect = 0
if eightyOrNinety == True: offset = 3.5
else: offset = 2.5
return r

# Define a function to tell if values are in the comfort range.
def comfBetween (x, l, r):
return (x > l and x < r)

if (vel > 0.45 and to >= 25):
def comfAdaptiveComfortEN15251(self, ta, tr, runningMean, vel, comfortClass, levelOfConditioning=0):
# Define the variables that will be used throughout the calculation.
r = []
coolingEffect = 0
if comfortClass == 1: offset = 2
elif comfortClass == 2: offset = 3
else: offset = 4
to = (ta + tr) / 2

# See if the running mean temperature is between 10 C and 30.0 C (the range where the adaptive model is supposed to be used).
if runningMean >= 10.0 and runningMean <= 30.0:
if (vel >= 0.2 and to >= 25):
# calculate cooling effect of elevated air speed
# when top > 25 degC.
if vel > 0.45 and vel < 0.75:
coolingEffect = 1.2
elif vel > 0.75 and vel < 1.05:
coolingEffect = 1.8
elif vel > 1.05:
coolingEffect = 2.2
else: pass
coolingEffect = 1.7856 * math.log(vel) + 2.9835

if levelOfConditioning == 0: tComf = 0.33 * runningMean + 18.8
elif levelOfConditioning == 1: tComf = 0.09 * runningMean + 22.6
else: tComf = ((0.09 * levelOfConditioning) + (0.33 * (1 - levelOfConditioning))) * runningMean + ((22.6 * levelOfConditioning) + (18.8 * (1 - levelOfConditioning)))

if runningMean > 15:
tComfLower = tComf - offset
tComfUpper = tComf + offset + coolingEffect
elif runningMean > 12.73 and runningMean < 15 and levelOfConditioning == 0:
tComfLow = 23.75
tComfLower = tComfLow - offset
tComfUpper = tComf + offset + coolingEffect
elif levelOfConditioning != 0:
tComfLower = tComf - offset
tComfUpper = tComf + offset + coolingEffect
else:
tComfLow = 23.75
tComfLower = tComfLow - offset
if comfortClass == 1: tComfUpper = tComf + offset
else: tComfUpper = tComf + offset + coolingEffect

tComf = 0.31 * runningMean + 17.8
tComfLower = tComf - offset
tComfUpper = tComf + offset + coolingEffect
r.append(tComf)
r.append(to - tComf)
r.append(tComfLower)
r.append(tComfUpper)

Expand All @@ -470,15 +514,45 @@ def comfBetween (x, l, r):
acceptability = False
r.append(acceptability)

# Append a number to the result list to show whether the values
# are too hot, too cold, or comfortable.
if acceptability == True: r.append(1)
elif to > tComfUpper: r.append(2)
else: r.append(0)
# Append a number to the result list to show whether the values are too hot, too cold, or comfortable.
if acceptability == True: r.append(0)
elif to > tComfUpper: r.append(1)
else: r.append(-1)

elif runningMean < 10.0:
# The prevailing temperature is too cold for the adaptive standard but we will use some correlations from adaptive-style surveys of conditioned buildings to give a good guess.
if levelOfConditioning == 0: tComf = 25.224 + (0.295 * (runningMean - 22.0)) * math.exp((-1) * (((runningMean - 22) / (33.941125)) * ((runningMean - 22) / (33.941125))))
else:
conditOffset = 1.4 * levelOfConditioning
tComf = conditOffset + 25.224 + (0.295 * (runningMean - 22.0)) * math.exp((-1) * (((runningMean - 22) / (33.941125)) * ((runningMean - 22) / (33.941125))))

tempDiff = to - tComf
tComfLower = tComf - offset
tComfUpper = tComf + offset
if to > tComfLower and to < tComfUpper: acceptability = True
else: acceptability = False
if acceptability == True: condit = 0
elif to > tComfUpper: condit = 1
else: condit = -1
outputs = [tComf, tempDiff, tComfLower, tComfUpper, acceptability, condit]
r.extend(outputs)
else:
# The prevailing temperature is too extreme for the adaptive method.
outputs = [None, None, False, -1]
# The prevailing temperature is too hot for the adaptive method. This should usually not happen for climates on today's earth but it might be possible in the future with global warming. For this case, we will just use the adaptive model at its hottest limit.
if (vel >= 0.2 and to >= 25):
# calculate cooling effect of elevated air speed
# when top > 25 degC.
coolingEffect = 1.7856 * math.log(vel) + 2.9835
if levelOfConditioning == 0: tComf = 0.33 * 30.0 + 18.8
else: tComf = ((0.09 * levelOfConditioning) + (0.33 * (1 - levelOfConditioning))) * 30.0 + ((22.6 * levelOfConditioning) + (18.8 * (1 - levelOfConditioning)))
tempDiff = to - tComf
tComfLower = tComf - offset
tComfUpper = tComf + offset + coolingEffect
if to > tComfLower and to < tComfUpper: acceptability = True
else: acceptability = False
if acceptability == True: condit = 0
elif to > tComfUpper: condit = 1
else: condit = -1
outputs = [tComf, tempDiff, tComfLower, tComfUpper, acceptability, condit]
r.extend(outputs)

return r
Expand All @@ -491,7 +565,7 @@ def es(ta):
g = [
-2836.5744, -6028.076559, 19.54263612,
-0.02737830188, 0.000016261698,
(7.0229056 * (10**(-10))), (-1.8680009*(10**(-13)))]
(7.0229056 * (10**(-10))), (-1.8680009 * (10**(-13)))]
tk = ta + 273.15 # air temp in K
es = 2.7150305 * math.log1p(tk)
for count, i in enumerate(g):
Expand All @@ -502,7 +576,7 @@ def es(ta):
# Do a series of checks to be sure that the input values are within
# the bounds accepted by the model.
check = (Ta < -50.0 or Ta > 50.0 or
Tmrt-Ta < -30.0 or Tmrt-Ta > 70.0)
Tmrt - Ta < -30.0 or Tmrt - Ta > 70.0)
if va < 0.5:
va = 0.5
elif va > 17:
Expand All @@ -518,7 +592,7 @@ def es(ta):
# va10m: wind speed 10m above ground level in m/s

if check == True:
ehPa = es(Ta) * (RH/ 100.0)
ehPa = es(Ta) * (RH / 100.0)
D_Tmrt = Tmrt - Ta
Pa = ehPa / 10.0 # convert vapour pressure to kPa

Expand Down

0 comments on commit 231609e

Please sign in to comment.