5.11. Radiance

[Note]Note

Using Radiance in BCVTB requires Radiance simulation experience. A BCVTB user that is new to Radiance should first learn to use Radiance before attempting to use Radiance in BCVTB.

[Note]Note

The example has only been tested on Mac OS X and Linux, but not on Windows.

Radiance is a collection of command line programs that are executed in various orders to perform simulations. Radiance commands with arguments are often stored in a script file for repetitive execution. The system command actor provides a means to perform Radiance simulations by executing this script and collecting the output. The BCVTB distribution includes two BCVTB Radiance examples.

Radiance should be downloaded and installed on the computer as normal (the installation process varies based on the operating system). Do not forget to set the environment variables PATH and RAYPATH as described in the README file that is provided by the Radiance installation program. See also Section 3.3, “Setting system environment variables” for how to set environment variables for the BCVTB.

The following example uses Radiance to calculate average illuminance at a point in a model. This example generates a sky file based on weather file input, compiles an octree model and calculates illuminance at the point.

We first create a Radiance script that computes the illuminance. The script takes as input arguments the month, day, and hour, the direct normal and diffuse horizontal irradiation, as well as the latitude, longitude and meridien. The output of the csh script is the illuminance, which will be written to the console. The script is as follows:

#!/bin/csh
############################################################
# Script to run radiance.
############################################################
set month = $argv[1]
set day = $argv[2]
set hour = `ev $argv[3]-.5`
set dirnorm = $argv[4]
set difhoriz = $argv[5]
set lat = $argv[6]
set long = $argv[7]
set mer = $argv[8]

set alt = `gensky $month $day $hour -a $lat -o $long -m $mer | awk '{if(NR==3)if($6>0) print 1; else print 0}'`

if ($alt == 1) then
### Generate perez sky
gendaylit $month $day $hour -a $lat -o $long -m $mer -W $dirnorm $difhoriz -g .1 > rads/sky.rad

cat >> rads/sky.rad <<EOF

skyfunc glow skyglow
0
0
4 1 1 1 0

skyglow source sky
0
0
4 0 0 1 180

skyglow source ground
0
0
4 0 0 -1 180
       
EOF

### Compile octree model
oconv rads/sky.rad rads/approx.mat rads/room_basic.rad rads/top_panels.rad rads/desks.rad \
	rads/PC.rad rads/window_pane.rad rads/glass.rad > octs/model_sky.oct

### Create file of test points
echo 22 60 32 0 0 1 > data/test.pts

### Perform rtrace simulation
rtrace -h- -w- -n 2 -I -ab 2 -ad 2000 -as 1000 < data/test.pts octs/model_sky.oct | \
	rcalc -e '$1=179*($1*0.265+$2*0.670+$3*0.065)' 

else
	echo 0.0
endif

Next, we create a Ptolemy II model that prepares the input data for the Radiance script, parses the output of the Radiance script, and displays the illuminance in a plotter.

Figure 5.37 shows the Ptolemy II system model that performs the following five steps for each time step iteration:

  1. Read a line from the a weather data file that is in the EnergyPlus epw format.

  2. Parse the weather record for the necessary data (month, day, hour, direct normal irradiance, and diffuse horizontal irradiance).

  3. Run the Radiance script to simulate daylight using information from the weather data. This step will generate a Perez sky, compile an octree model, and simulate illuminance at a point.

  4. Convert the script output from string to double precision format.

  5. Plot illuminance vs. time.


The line reader actor reads the epw weather data file. The header (first 8 lines) is skipped by entering 8 into the numberOfLinesToSkip field as shown in Figure 5.38.


The parsing of the file is done by a composite actor. Looking inside the composite actor reveals an expression actor that splits the string at the commas into an array and five array element actors that select an element from the array as shown in Figure 5.39.


The system command actor runs a C shell script containing Radiance commands. The values read from the weather data file are passed as arguments to this C shell script as shown in Figure 5.40.


The output of the csh script that is called by the SystemCommand actor is the illuminance, but of type string and not double precision. The composite actor String2Double contains actors that convert the string to double as shown in Figure 5.41. The trim actor is required to strip the newline character from the end of the string.


The TimedPlotter actor plots the illuminance vs. time, measured in hours from the beginning of the weather data file, as shown in Figure 5.42.