湿空冷耗水量计算及源代码

直接拿去用吧

function InitValues()
{
f = document.forms[‘WaterUsage’];
f.FlowIP.value = fix(1000,0);
f.FlowSI.value = fix(m3h(1000),0);
f.HotWaterIP.value = fix(95,2);
f.HotWaterSI.value = fix(Celsius(95),2);
f.ColdWaterIP.value = fix(85,2);
f.ColdWaterSI.value = fix(Celsius(85),2);
f.WetBulbIP.value = fix(78,2);
f.WetBulbSI.value = fix(Celsius(78),2);
f.DriftRate.value = “0.005”;
f.Conc.value = “3”;
InputChange(f.Conc);
}

function InputChange(txtInput)
{
var x = parseFloat(txtInput.value);
if (isNaN(x)) x=0;
var n = txtInput.name;
var f = txtInput.form;
if (txtInput == f.FlowIP || txtInput == f.FlowSI)
{
if (txtInput == f.FlowSI) x = gpm(x);
if (x < 10) x=10;
if (x > 1e6) x=1e6;
f.FlowIP.value = fix(x,0);
f.FlowSI.value = fix(m3h(x),0);
}
else if (txtInput == f.HotWaterIP || txtInput == f.HotWaterSI)
{
if (txtInput == f.HotWaterSI) x = Fahrenheit(x);
if (x < 40) x=40;
if (x > 145) x=145;
f.HotWaterIP.value = fix(x,2);
f.HotWaterSI.value = fix(Celsius(x),2);
}
else if (txtInput == f.ColdWaterIP || txtInput == f.ColdWaterSI)
{
if (txtInput == f.ColdWaterSI) x = Fahrenheit(x);
if (x < 35) x=35;
if (x > 120) x=120;
f.ColdWaterIP.value = fix(x,2);
f.ColdWaterSI.value = fix(Celsius(x),2);
}
else if (txtInput == f.WetBulbIP || txtInput == f.WetBulbSI)
{
if (txtInput == f.WetBulbSI) x = Fahrenheit(x);
if (x < 20) x=20;
if (x > 90) x=90;
f.WetBulbIP.value = fix(x,2);
f.WetBulbSI.value = fix(Celsius(x),2);
}
else if (txtInput == f.DriftRate)
{
if (x < 0.001) x = 0.001;
if (x > 0.050) x = 0.050;
f.DriftRate.value = fix(x,3);
}
else if (txtInput == f.Conc)
{
if (x < 1.5) x = 1.5;
if (x > 10) x = 10;
f.Conc.value = x;
}

f.EvapIP.value = “”;
f.EvapSI.value = “”;
f.DriftIP.value = “”;
f.DriftSI.value = “”;
f.BlowDownIP.value = “”;
f.BlowDownSI.value = “”;
f.TotalIP.value = “”;
f.TotalSI.value = “”;

var G = parseFloat(f.FlowIP.value);
var Thw = parseFloat(f.HotWaterIP.value);
var Tcw = parseFloat(f.ColdWaterIP.value);
var Twb = parseFloat(f.WetBulbIP.value);
var DR = parseFloat(f.DriftRate.value);
var C = parseFloat(f.Conc.value);
var R = Thw – Tcw;
var A = Tcw – Twb;
if (A>=3 && A<=40 && R>=5 && R<=50 && R>=A/4 && R<=A*4)
{
var E = G * Evap(Thw, Tcw, Twb);
var D = G * DR / 100;
var B = Blowdown(E, D, C);
var T = E + D + B;
f.EvapIP.value = fix(E,2);
f.EvapSI.value = fix(m3h(E),2);
f.DriftIP.value = fix(D,2);
f.DriftSI.value = fix(m3h(D),2);
f.BlowDownIP.value = fix(B,2);
f.BlowDownSI.value = fix(m3h(B),2);
f.TotalIP.value = fix(T,2);
f.TotalSI.value = fix(m3h(T),2);
}
}

function generateCurves(url, metric)
{
f = document.forms[‘WaterUsage’];
if (url && url.length > 0 && f.EvapIP.value.length > 0)
{
var G = parseFloat(f.FlowIP.value);
var Thw = parseFloat(f.HotWaterIP.value);
var Tcw = parseFloat(f.ColdWaterIP.value);
var Twb = parseFloat(f.WetBulbIP.value);
var DR = parseFloat(f.DriftRate.value);
var C = parseFloat(f.Conc.value);
var str = “”;
if (metric)
{
str = “?u=SI”;
str += “&flow=” + f.FlowSI.value;
str += “&hw=” + f.HotWaterSI.value;
str += “&cw=” + f.ColdWaterSI.value;
str += “&wb=” + f.WetBulbSI.value;
}
else
{
str = “?u=IP”;
str += “&flow=” + f.FlowIP.value;
str += “&hw=” + f.HotWaterIP.value;
str += “&cw=” + f.ColdWaterIP.value;
str += “&wb=” + f.WetBulbIP.value;
}
str += “&dr=” + f.DriftRate.value;
str += “&c=” + f.Conc.value;
window.open(url + str, “_blank”);
}
}
function Fahrenheit(t)
{
return t*1.8+32;
}

function Celsius(t)
{
return (t-32)/1.8;
}

function gpm(f)
{
return f/0.227124707;
}

function m3h(f)
{
return f*0.227124707;
}

function fix(x, n)
{
return (new Number(x)).toFixed(n);
}

function Evap(Thw, Tcw, Twb)
{
var R = Thw – Tcw;
var LG1 = LG(Thw, Tcw, Twb);
var Tdb = DryBulb(Twb, 0.5); //assume 50% relative humidity
var hIn = Enthalpy(Twb, Tdb);
var Win = HumidityRatio(Twb, Tdb);
var Wout = Win + 0.0008 * R * LG1;
var Wprev, hOut, TwbOut;
for (var i=0; i<5; i++)
{
Wprev = Wout;
hOut = hIn + R * LG1 + (Wout – Win) * (Tcw – 32);
TwbOut = WetBulb(hOut);
Wout = HumidityRatio(TwbOut, TwbOut);
if (Math.abs(Wout-Wprev) <= 0.00001) break;
}
return (Wout – Win) / LG1;
}

function Blowdown(Evap, Drift, Conc)
{
return (Evap – Drift * (Conc-1)) / (Conc-1);
}

function LG(Thw, Tcw, Twb)
{
var F = Fr(Thw, Tcw, Twb);
var LG = 1.3 / Math.pow(F, 1.15);
return LG;
}

function Fr(Thw, Tcw, Twb)
{
var R = Thw – Tcw;
var A = Tcw – Twb;
var Fr = 0.60589436;
Fr += -0.00562416 * Twb;
Fr += -0.00002268 * Twb * Twb;
Fr += 0.04609405 * R;
Fr += -0.00010031 * Twb * R;
Fr += -0.00074946 * R * R;
Fr += -0.06167657 * A;
Fr += 0.00008363 * Twb * A;
Fr += 0.0010762 * A * A;
Fr = Math.pow(10, Fr);
return Fr;
}

//Psychrometrics
//Reference: 2005 ASHRAE Handbook – Fundamentals

function Enthalpy(Twb, Tdb)
{
var W = HumidityRatio(Twb, Tdb);
var h = 0.24 * Tdb + W * (1061 + 0.444*Tdb);
return h;
}

function HumidityRatio(Twb, Tdb)
{
var T = Twb + 459.67;
var pws, Ws, W;
if (Twb >= 32)
{
pws = -1.0440397e4 / T;
pws += -1.129465e1;
pws += -2.7022355e-2 * T;
pws += 1.289036e-5 * T * T;
pws += -2.4780681e-9 * T * T * T;
pws += 6.5459673 * Math.log(T);
pws = Math.exp(pws);
Ws = 0.62198 * pws / (14.7 – pws);
W = ((1093-0.556*Twb)*Ws – 0.24*(Tdb-Twb)) / (1093+0.444*Tdb-Twb);
}
else
{
pws = -1.0214165e4 / T;
pws += -4.8932428;
pws += -5.3765794e-3 * T;
pws += 1.9202377e-7 * T * T;
pws += 3.5575832e-10 * T * T * T;
pws += -9.0344688e-14 * T * T * T * T;
pws += 4.1635019 * Math.log(T);
pws = Math.exp(pws);
Ws = 0.62198 * pws / (14.7 – pws);
W = ((1220-0.036*Twb)*Ws – 0.24*(Tdb-Twb)) / (1220+0.444*Tdb-0.48*Twb);
}
return W;
}

function RelativeHumidity(Twb, Tdb)
{
var W = HumidityRatio(Twb, Tdb);
var pw = 14.7 * W / (0.62198 + W);
var Ws = HumidityRatio(Tdb, Tdb);
var pws = 14.7 * Ws / (0.62198 + Ws);
return pw / pws;
}

function WetBulb(h)
{
var Twb = 32;
var hTest = Enthalpy(Twb, Twb);
var TwbPrev = Twb
var hPrev = hTest;

if (h > 12)
Twb = 38 * Math.log(h) – 63.5;
else
Twb = 2.8 * h – 0.8;

var n = 0;
var dhdT, dT;
for (var i=0; i<10; i++)
{
hTest = Enthalpy(Twb, Twb);
dhdT = (hTest – hPrev) / (Twb – TwbPrev);
dT = (hTest – h) / dhdT;
if ((Twb<=32 && Twb-dT>=32) || (Twb>=32 && Twb-dT<=32))
if (++n > 2) return 32;
TwbPrev = Twb;
hPrev = hTest;
Twb = Twb – dT;
if (Math.abs(dT) < 0.0005) break;
}
return Twb;
}

function DryBulb(Twb, RH)
{
var Tdb = Twb;
var RHtest = 1;
var TdbPrev = Tdb;
var RHprev = RHtest;

Tdb = Twb + 0.12*Math.pow(Twb,1.5)*Math.pow(1-RH,2.5);
var dRHdT, dT;
for (var i=0; i<10; i++)
{
RHtest = RelativeHumidity(Twb, Tdb);
dRHdT = (RHtest – RHprev) / (Tdb – TdbPrev);
dT = (RHtest – RH) / dRHdT;
TdbPrev = Tdb;
RHprev = RHtest;
Tdb = Tdb – dT;
if (Math.abs(dT) < 0.0005) break;
}
return Tdb;
}

Author: admin on 2016年4月15日
Category: 计算软件