Saturday, December 29, 2012

Intuitive Sort Order for Alphanumeric Strings

I have developed some code to sort arrays of strings which contain a mixture of letters and numbers.  A common problem in string sorts is that the natural alphabetical order is not the same as the order of digits, since we consider consecutive digits in the aggregate but consecutive letters individually.  Hence, in alphabetical order "str10" precedes "str2", because 1 is before 2 alphabetically.  What we normally want to do is to compare 10 with 2, which would cause us to say "str2" precedes "str10".

To accomplish this I first create linked lists of alphameric and numeric strings (one linked list for each string).  I then compare the corresponding nodes of the two lists.  Permission is granted to use and adapt this code on an "as is" basis with no warranty of any kind.

Friday, December 28, 2012

Convective Heat Transfer on a Building Envelope (Wind Chill?)

I'd like to make a brief mathematical investigation into the concept of a wind chill factor and how one particular scheme common in popular culture (and even affecting some in industry) does not relate well to modelling of a building envelope.  Wind chill is the temperature which a human being perceives accounting for the effects of wind and temperature together.  The preceding sentence is awkward because it is trying to say too much at once, so let me try again:

A wind chill index (expressed in units equivalent(ish) to temperature measurements) is answering a question:  What temperature TWC (with wind speed = 0) will be perceived by a human being as equivalent to temperature Tactual (with wind speed = Vactual)?  (We are talking here more particularly about the exposed skin of a human being.  Also, it isn't purely a matter of perception.)

Human beings, not buildings.  Consider the following differences:
  • buildings (in cold climates) have a much lower surface temperature than humans
  • the amount (and temperature) of moisture on their surfaces is generally different and has a different internal transport mechanism (brick has basically no moisture and that moisture is already cold, human skin normally has moisture—perspiration—which evaporates more rapidly in windy conditions than calm conditions causing heat loss, because evaporation requires energy)
  • unlike human beings, buildings do not have psychological comfort issues affecting their perception of temperature (and, admittedly, cannot reasonably be considered to perceive anything)
The equation used today for wind chill index has some theoretical basis but in the end is empirically derived.  That means they did experiments and found something that "works".  It is a very pragmatic way to deal with complex issues, especially ones that include psychological/cognitive components.  (I'm not "disrespecting" empirical equations, they're useful.)

So, where do I start?  I would hard pressed with my current knowledge/understanding to deal with the evaporative cooling effects on human skin as compared with buildings, though such investigation might be meritorious.  I will not attempt to compare the psychology of buildings with that of humans—I hope you understand.  I will however seek to show how the concept of an "equivalent temperature in the absence of wind" yields different results depending on the surface temperature of the material in question.  As such, although we will not compare human skin with face brick, we will compare warm Surface X with cool Surface X.

Convective Heat Transfer

The convective heat transfer equation is simple enough:

                q = hc AS (TS – Tair)

where q is the heat energy (per unit time), hc is the heat transfer coefficient, AS is the surface area, TS is the temperature of the surface and Tair is the ambient air temperature.
The heat transfer coefficient varies with wind speed.  Suppose we want to find an air temperature TWC (no wind, hNW) which causes the same rate of heat loss as Tactual (wind speed = Wactual, hactual).  In that case, we need to relate:

                hNW AS (TS – TWC) = q = hactual AS (TS – Tactual),

which simplifies to

               TWC = TS – (hactual / hNW)(TS – Tactual).

A Little Problem

This leaves me with a problem.  I want to have some type of reasonable value for the convective heat transfer coefficient ratio (hactual / hNW).  How do I get that?  I will engage in a little pragmatism and pretend that the wind chill equation will still give me a way to get an (hactual / hNW) ratio.  It probably gets me something close to reality, but the main point will stand regardless of the realism of this ratio.  From the wind chill equation we get a 15 mph wind at -31°F being equivalent to no wind at -59°F.  Here's what we get for the ratio for human skin (which I have to use since that's what the wind chill equation is based on):

            (hactual / hNW) =  (TS – TWC) / (TS – Tactual)
                                   =  (88 – (-59)) / (88 – (-31))
                                   = 1.235

(I've used 88°F for human skin, but that temperature will be different depending on the ambient temperature.  Oh, well.  If our ratio is 1.1 or 4.7, the math is the same—just different numbers for the end result.  The results will still show a difference from the "wind chill index" commonly talked about.)

Theoretically, the convective heat transfer coefficient is largely independent of temperature and area, but it will change based on the interaction of the fluid and the surface which will include things like geometry, orientation, surface roughness, moisture, etc.  Unfortunately, temperature differences may affect the actual coefficient.  They will affect the result if you consider radiation losses as well, since radiation transport is proportional to absolute temperature to the fourth power.

Wind Chill Effect on Surfaces at Different Temperatures Than Human Skin?

So, let's consider a surface which is maintained at a temperature of 10°F and is surrounded by an ambient temperature of -31°F and the wind speed is 15 mph.  (This is not the temperature in the boundary layer.  The point of the convective heat transfer equation is to deal with this phenomenon in a simplified way—essentially to circumvent it.)  So, what's my "equivalent temperature in the absence of wind"?

               TWC = TS – (hactual / hNW)(TS – Tactual)
                       = 10 – 1.235 (10 – (-31))
                       = -40.6 °F

So, the rate of heat loss from Surface X under the actual conditions is the same as the rate of heat loss for Surface X with no wind and a temperature of -40.6°F.

We obtained a different value than we did for the wind chill index applicable to human skin.  The reason is straightforward:  the rate of heat loss is proportional to the difference between the ambient air temperature and the surface temperature.  Now, if it is -31°F outside, what temperature is the outside surface of a building?  Perhaps -21°F?  This makes quite a difference:

               TWC = TS – (hactual / hNW)(TS – Tactual)
                       = -21 – 1.235 (-21 – (-31))
                       = -33.4 °F

So the effect is not zero, but it isn't much to talk about.  If my h ratio is actually much higher, we will get a greater difference.

Considerations on Building Outside Surface Temperatures

The thickness and properties of the building envelope materials may change the relationship between ambient air temperature and surface temperature.  Such changes will change the rate of heat loss in proportion to the temperature difference.  Is there a higher difference at glazing surfaces than concrete surfaces?

There's also a sticky point regarding solar heat gains.  Such gains on the surface will increase the rate of heat loss at the surface.  But watch out!  This is mainly behaviour occurring at the surface.  We're dealing with a cold climate situation.  Radiant heat from the sun heats up the surface only to be removed by increased rates of convection and radiation loss.  This does not help us analyse the heat losses from the interior of the building!  My plain horse sense tells me that adding thermal energy to the exterior does not cause a net increase to the rate of heat loss from the building interior.  At worst, the increased rate of convective (and radiation) loss will remove all of the radiant energy added.  To deal thoroughly with this issue, we would either need to model both in parallel (allowing them to interact numerically with each other—for transient analysis) or use a "net direct solar gain" approach that deals with the interaction of convection and radiation (gains and losses) at the surface in an integrated way.

Note that in warm climate conditions (cooling conditions), heat on the outside surface migrates toward the interior and we must therefore consider it.  It is no longer starting to go in only to double-back (as it were), but actually conducting through the envelope and so directly affecting interior conditions.

CAUTION: This is NOT a Final Answer

In closing, this article is not trying to present the final answer to this problem.  Rather I am attempting to expose the fallacy that the wind chill index (and corresponding formula) can be naively applied to energy modelling problems in building science.  Furthermore, my criticism is not directed against nor does it address considerations of the effects of wind on air leakage analysis.

Note that ASHRAE Fundamentals chapter 26 (2009) gives effective R-values which can be used.  The point of these values is to bypass all of the stuff I'm writing about in this article and account for convection and radiation losses at the surface under a 15 mph wind design condition.  You don't actually need all that wind chill stuff—chapter 26 R-values already give a reasonable estimate of the wind effects, i.e., R-0.17 at 15 mph on the exterior instead of R-0.68 on the interior for still air at a wall.

Wednesday, December 26, 2012

Degree of Saturation versus Relative Humidity

These two quantities are similar and as I worked through ASHRAE Handbook Fundamentals (2009) IP, chapter 1, I was initially baffled as to what the difference was.  First, the definitions based on ASHRAE Fundamentals:

Relative humidity:  The mole fraction of water vapour in a sample divided by the mole fraction of water vapour in saturated air at the same temperature and pressure.
Degree of saturation:  The humidity ratio of water vapour in a sample divided by the humidity ratio of water vapour in saturated air at the same temperature and pressure.
Humidity ratio:  The humidity ratio is the mass of water vapour divided by the mass of dry air in a sample. This value can also be expressed in terms of molar fractions.

Discussion of Differences

In relative humidity, imagine taking two samples, one of the air which you want to know the relative humidity of and one of saturated air at the same temperature and pressure. For example, we might take samples of 1 mole each. In the non-saturated air, we will have less water vapour than in the saturated air. On the other hand, we will have more dry air in the non-saturated sample than in the saturated sample. The same general relationship will be true of mass, but the masses and the mole fractions will relate differently due to differing molecular masses. Here's the bottom line: we compare the samples based on moles (which amounts to the number of molecules) not on a given mass or volume. When you're dealing with gases, moles is the way to go.  In other words, our non-saturated and saturated samples relate by the equation:
where the items on the left hand side are the mole fractions of water vapour and dry air in the non-saturated sample and the items on the right hand side are for saturated air.

Understanding that we need to compare these quantities with a fixed number of total moles as in the previous equation is what makes ASHRAE's equation (14) work out.  From the last given equation we have
which verifies equation (14) as given in ASHRAE Fundamentals (2009).

It is worth noting that we only had to worry about this molar equality in developing this equation. When it comes to computing the degree of saturation from the relative humidity and vice versa, we don't have to think about that. The formula will do that for us. Also, we can still compute the degree of saturation directly from values off of a psychrometric chart (for example) by reading across to the right to get \(W\)and finding \(W_S\) by finding where the dry bulb temperature intersects the saturation curve and reading across to the right.  The definition of degree of saturation doesn't require us to account for the number of moles, only the relative humidity (and yes, if you're using charts you can read it off there as well).  If you are familiar with reading psychrometric charts, you will know that reading W values is generally much easier than reading RH values.

So if you're getting different values for these quantities in your work, it's not (necessarily) a mistake or a misreading of the chart—they really are different.