MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / solveForWetBulb

Function solveForWetBulb

src/utilities/filetypes/EpwFile.cpp:105–146  ·  view source on GitHub ↗

Using equation 35/37 in ASHRAE Fundamentals 2009 Ch. 1: W = (A W*_s - B)/C where A, B, C, and W*_s are all function of wet bulb t Solve for the root of f = W C - A W*_s + B To make things even more opaque, lets use A = a0 + a1 t B = b (t - t*) C = c0 + c1 t + c2 t

Source from the content-addressed store, hash-verified

103// C = c0 + c1 t + c2 t*
104//
105static boost::optional<double> solveForWetBulb(double drybulb, double p, double W, double deltaLimit, int itermax) {
106 const double Bp = -1.006;
107 const double b = 1.006;
108 const double c1t = 1.86 * drybulb;
109 double a0 = 2501;
110 double a1 = -2.326;
111 double c0 = 2501;
112 double c2 = -4.186;
113 double Ap = -2.326;
114 double Cp = -4.186;
115 if (drybulb < 0) {
116 a0 = 2830;
117 a1 = -0.24;
118 c0 = 2830;
119 c2 = -2.1;
120 Ap = -0.24;
121 Cp = -2.1;
122 }
123
124 int i = 0;
125 double tstar = drybulb;
126 while (i < itermax) {
127 i++;
128 const double A = a0 + a1 * tstar;
129 const double B = b * (drybulb - tstar);
130 const double C = c0 + c1t + c2 * tstar;
131 const double pwsstar = psat(tstar);
132 const double pwsstarp = psatp(tstar, pwsstar);
133 const double deltap = p - pwsstar;
134 const double Wsstar = 0.621945 * pwsstar / deltap;
135 const double Wsstarp = (0.621945 * pwsstarp * deltap + 0.621945 * pwsstar * pwsstarp) / (deltap * deltap);
136 const double f = W * C - A * Wsstar + B;
137 const double fp = W * Cp - A * Wsstarp - Ap * Wsstar + Bp;
138 const double delta = -f / fp;
139 tstar += delta;
140 // std::cout << i << " " << tstar << " " << delta / (273.15 + tstar) << '\n';
141 if (std::fabs(delta / (273.15 + tstar)) <= deltaLimit) {
142 return {tstar};
143 }
144 }
145 return boost::none;
146}
147
148// Using equation 38 in ASHRAE Fundamentals 2009 Ch. 1:
149//

Callers 3

AirStateMethod · 0.85

Calls 2

psatFunction · 0.85
psatpFunction · 0.85

Tested by

no test coverage detected