13.02.2013 Views

Advanced Building Simulation

Advanced Building Simulation

Advanced Building Simulation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Dry-bulb temperature (°F)<br />

60<br />

50<br />

40<br />

30<br />

20<br />

10<br />

0<br />

+<br />

+<br />

+ +<br />

+<br />

<strong>Simulation</strong> and uncertainty: weather predictions 69<br />

+ + + + +<br />

Figure 3.4 shows a sequence of days from an actual set of recorded month of daily<br />

temperature data.<br />

In thermal energy simulations for building applications, we do not necessarily need<br />

to replicate this exact sequence; however, we need to replicate the same mean values,<br />

the same spread from minimum to maximum, and approximately the same number<br />

of “day types” in between the minimum and maximum. Following the CDF in a<br />

somewhat random fashion will enable us to meet this objective. So, how do we select<br />

the random pattern? It’s simpler than it might first appear. In effect, all we have to do<br />

is scramble 31 numbers and let each number represent a “day type” on the CDF<br />

graph, and thereby derive 31 different temperatures. To randomly order the day<br />

types, we use a computerized random number generator. Most computers have inherent<br />

random number generators, but there may be reasons why you might want to<br />

write your own. The sequence below shows a Fortran code for a random number generator<br />

that generates a flat distribution of numbers between 0 and 1, repeating itself<br />

only after around 100,000,000 selections. The values derived within the code must<br />

have eight significant figures, so double precision variables must be used. Also, an<br />

initial value, called “the seed”, must be entered to start the sequence. Though we only<br />

want 31 numbers, we need to keep internal precision to eight figures, so the sequences<br />

won’t repeat themselves very often—a lot like the weather. This code can be converted<br />

to BASIC with very few modifications.<br />

+<br />

+<br />

+ + +<br />

Ave. max. = 36.0°F<br />

Monthly ave. = 27.8°F<br />

+<br />

+ +<br />

+ +<br />

2 4 6 8 10 12 14 16 18 20<br />

Day of the month (January)<br />

Figure 3.4 Actual record of daily maximum and average temperatures for 20 consecutive days in January.<br />

Fortan code for a random number generator<br />

*** RANDOM NUMBER GENERATOR ********************************<br />

Function RANDOM (B)<br />

Double Precision B, XL, XK, XNEW<br />

XL�B * 1E7<br />

XK�23.*XL<br />

XNEW�INT (XK / 1E8)<br />

B�XK�XNEW*100000001.<br />

B�B/1E8<br />

*** Check to be sure B is not outside the range .00001 to 1.<br />

IF (B.LT.1E-5)B �ABS (B*1000.)<br />

IF (B.GE.1) B�B/10.<br />

RANDOM�B<br />

RETURN<br />

END

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!