import json, numpy as np C=json.load(open('climate.json')) T=np.arange(-10,51) # exceed index thresholds def hist(ex): # hours in bin [t,t+1) for t=-10..49, plus below -10 ex=np.array(ex,float); h=ex[:-1]-ex[1:]; below=8760-ex[0] mids=np.concatenate([[-12.0],T[:-1]+0.5]); return mids,np.concatenate([[below],h]) eta=0.5; A_dry=6.0; A_evap=4.0; f_dry=0.02; f_twr=0.01; f_pump=0.01 hfg=2430.0; coc=4.0 water_per_kwh=3600/hfg*coc/(coc-1) # L per kWh heat rejected evaporatively incl blowdown def chiller_kw(Ts,Tc): Te=Ts-2+273.15; Tk=Tc+273.15 cop=eta*Te/max(Tk-Te,3.0); return 1/cop def annual(site,Ts,evap): d=C[site]; md,hd=hist(d['dbExceed']); mw,hw=hist(d['wbExceed']) E=0.0; W=0.0; hours_mech=0 for t,h in zip(md,hd): if h==0: continue if t+A_dry<=Ts: E+=h*(f_dry+f_pump) else: if not evap: E+=h*(chiller_kw(Ts,t+8)+f_dry+f_pump); hours_mech+=h if evap: n_dry_fail=sum(h for t,h in zip(md,hd) if t+A_dry>Ts) # assign the n_dry_fail hottest hours to the wettest wet-bulb hours (assumption of co-occurrence) order=sorted(zip(mw,hw),key=lambda x:-x[0]); left=n_dry_fail for t,h in order: if left<=0: break k=min(h,left); left-=k if t+A_evap<=Ts: E+=k*(f_twr+f_pump); W+=k*water_per_kwh else: E+=k*(chiller_kw(Ts,t+6)+f_twr+f_pump); W+=k*water_per_kwh; hours_mech+=k return E/8760, W/8760, hours_mech print('water L per kWh evaporated heat',round(water_per_kwh,2)) sites=list(C) res={} for s in sites: res[s]={} for Ts in [17,27,32,40,45]: for ev in [False,True]: e,w,hm=annual(s,Ts,ev); res[s][(Ts,ev)]=(e,w,hm) # rack blend: 87% liquid at Ts, 13% air via 17 C water liq=115/132; air=17/132 print('\nsite, class: cooling kWh per IT kWh (waterless | evap), water L per IT kWh (evap), blended with 13% air at W17') out={} for s in sites: line=[] for Ts in [17,27,32,40,45]: e0=liq*res[s][(Ts,False)][0]+air*res[s][(17,False)][0] e1=liq*res[s][(Ts,True)][0]+air*res[s][(17,True)][0] w1=liq*res[s][(Ts,True)][1]+air*res[s][(17,True)][1] line.append((Ts,round(e0,3),round(e1,3),round(w1,3))) out.setdefault(s,{})[Ts]=dict(e_dry=e0,e_evap=e1,w_evap=w1,pure_dry=res[s][(Ts,False)][0],pure_evap=res[s][(Ts,True)][0],pure_w=res[s][(Ts,True)][1],hm_dry=res[s][(Ts,False)][2]) print(s.ljust(18),line) json.dump(out,open('energy.json','w'),indent=0) # headline: Dallas W45 vs W17 waterless for s in ['Dallas_TX','Phoenix_AZ','Hillsboro_OR','Ashburn_VA']: print(s,'pure liquid W45 dry',round(res[s][(45,False)][0],3),'W17 dry',round(res[s][(17,False)][0],3),'W17 evap water',round(res[s][(17,True)][1],2))