-
-
Save mackstann/3841417a2814ca37ece2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
class R(object): | |
outer_wall = 15 | |
inner_wall = 1.5 | |
ceiling = 50 | |
floor = 20 | |
class T(object): | |
"""Design temperatures""" | |
indoor = 72 | |
outdoor = 25 | |
class Surface(object): | |
def __init__(self, area, r): | |
self.area = area | |
self.r = r | |
@property | |
def u(self): | |
return 1.0/self.r | |
@property | |
def delta_t(self): | |
return self.indoor_temp - self.outdoor_temp | |
@property | |
def heatloss(self): | |
return self.area * self.u * self.delta_t | |
S = Surface | |
S.outer_walls = S(10*10*2, R.outer_wall) | |
S.inner_walls = S(10*10*2, R.inner_wall) | |
S.ceiling = S(10*10, R.ceiling) | |
S.floor = S(10*10, R.floor) | |
S.outer_walls.outdoor_temp = T.outdoor | |
S.ceiling.outdoor_temp = T.outdoor | |
S.floor.outdoor_temp = T.outdoor | |
S.inner_walls.outdoor_temp = T.indoor | |
air_volume = 10*10*10.0 | |
air_temp = T.indoor | |
fan_cfm = 50 | |
air_temp_over_time = [] | |
seconds = 3600 | |
for x in range(seconds): | |
cf_new_air = fan_cfm/60.0 | |
cf_old_air = air_volume - cf_new_air | |
air_temp = (cf_old_air/air_volume)*air_temp + (cf_new_air/air_volume)*T.indoor | |
S.outer_walls.indoor_temp = \ | |
S.ceiling.indoor_temp = \ | |
S.floor.indoor_temp = \ | |
S.inner_walls.indoor_temp = air_temp | |
heat_loss_to_outdoors = (S.outer_walls.heatloss + S.ceiling.heatloss + S.floor.heatloss) / 3600.0 | |
heat_loss_to_indoors = S.inner_walls.heatloss / 3600.0 | |
heat_loss = heat_loss_to_outdoors + heat_loss_to_indoors | |
heat_loss_in_cf_degrees = heat_loss/0.018 | |
heat_loss_in_degrees = heat_loss_in_cf_degrees / air_volume | |
air_temp -= heat_loss_in_degrees | |
if '--print' in sys.argv: | |
print "heat loss from outer walls:", S.outer_walls.heatloss | |
print "heat loss from floor:", S.floor.heatloss | |
print "heat loss from ceiling:", S.ceiling.heatloss | |
print "heat loss from outdoors:", heat_loss_to_outdoors | |
print "heat gain from indoors:", -heat_loss_to_indoors | |
print "room temp change:", -heat_loss_in_degrees | |
print "room temp:", air_temp | |
air_temp_over_time.append(air_temp) | |
if '--plot' in sys.argv: | |
from pylab import arange, array, plot, show | |
x = arange(0, seconds) | |
y = array(air_temp_over_time) | |
plot(x, y) | |
show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment