--- ray/src/gen/glaze.csh 2003/06/30 18:12:24 2.2 +++ ray/src/gen/glaze.csh 2009/11/05 19:00:50 2.8 @@ -1,33 +1,113 @@ #!/bin/csh -f -# RCSid: $Id: glaze.csh,v 2.2 2003/06/30 18:12:24 greg Exp $ +# RCSid: $Id: glaze.csh,v 2.8 2009/11/05 19:00:50 greg Exp $ # # Complex glazing model (goes with glaze1.cal and glaze2.cal) # # Oct. 2002 Greg Ward +# Aug. 2004 GW (added -f option to read glazings from file) # Funding for this development generously provided by Visarc, Inc. -# (http://www.vizarc.com) +# (http://www.visarc.com) # +# Nov. 2009 Jack de Valpine - Visarc, Inc. +# -f option now clears the internal demo database and accepts +# a clear glass definition as the first entry +# in the database file +# ################################################################# # -# Supported surface types: +# The general assumption is that one surface is uncoated, and +# reflectances and transmittances are computed from this fact. +# If the user tries to enter two coated surfaces on the same +# pane, the script complains and exits. # -set sn_arr=("clear glass" "VE1-2M low-E coating" "PVB laminated" "V-175 white frit" "V-933 warm gray frit") +# Supported surface types (clear glass prepended below): +# +set sn_arr=("VE1-2M low-E coating" "PVB laminated" "V-175 white frit" "V-933 warm gray frit") # Glass-side hemispherical reflectances for each surface type: -set rg_r_arr=(0.074 0.065 .11 0.33 0.15) -set rg_g_arr=(0.077 0.058 .11 0.33 0.15) -set rg_b_arr=(0.079 0.067 .11 0.33 0.15) +set rg_r_arr=(0.065 .11 0.33 0.15) +set rg_g_arr=(0.058 .11 0.33 0.15) +set rg_b_arr=(0.067 .11 0.33 0.15) # Coating-side hemispherical reflectance for each surface type: -set rc_r_arr=(0.074 0.042 .11 0.59 0.21) -set rc_g_arr=(0.077 0.049 .11 0.59 0.21) -set rc_b_arr=(0.079 0.043 .11 0.59 0.21) +set rc_r_arr=(0.042 .11 0.59 0.21) +set rc_g_arr=(0.049 .11 0.59 0.21) +set rc_b_arr=(0.043 .11 0.59 0.21) # Hemispherical (normal) transmittance for each surface type: -set tn_r_arr=(0.862 0.756 0.63 0.21 0.09) -set tn_g_arr=(0.890 0.808 0.63 0.21 0.09) -set tn_b_arr=(0.886 0.744 0.63 0.21 0.09) +set tn_r_arr=(0.756 0.63 0.21 0.09) +set tn_g_arr=(0.808 0.63 0.21 0.09) +set tn_b_arr=(0.744 0.63 0.21 0.09) # Boolean whether coatings can have partial coverage: -set part_arr=(0 0 0 1 1) +set part_arr=(0 0 1 1) +set gfiles=() +while ($#argv > 0) + set header="Surface Tr Tg Tb Rcr Rcg Rcb Rgr Rgg Rgb Part" + if ($#argv < 2 || "$argv[1]" != '-f') then + echo "Usage: $0 [-f glazing.dat ..]" + exit 1 + endif + shift argv + # Clear internal default database + set sn_arr=() + set rg_r_arr=() ; set rg_g_arr=() ; set rg_b_arr=() + set rc_r_arr=() ; set rc_g_arr=() ; set rc_b_arr=() + set tn_r_arr=() ; set tn_g_arr=() ; set tn_b_arr=() + set part_arr=() + set gf="$argv[1]" + shift argv + set gfiles=($gfiles:q $gf:q) + if ("`sed -n 1p $gf:q`" != "$header") then + echo "Bad header in $gf -- Expected: $header" + exit 1 + endif + echo "Adding glazing types from file $gf :" + set nl=`wc -l < $gf:q` + @ i=2 + while ($i <= $nl) + set ln=(`sed -n ${i}p $gf:q`) + if ($#ln != 11) then + echo "Expected 11 words in line: $ln" + exit 1 + endif + echo $ln[1] + set sn_arr=($sn_arr:q $ln[1]) + set tn_r_arr=($tn_r_arr $ln[2]) + set tn_g_arr=($tn_g_arr $ln[3]) + set tn_b_arr=($tn_b_arr $ln[4]) + set rc_r_arr=($rc_r_arr $ln[5]) + set rc_g_arr=($rc_g_arr $ln[6]) + set rc_b_arr=($rc_b_arr $ln[7]) + set rg_r_arr=($rg_r_arr $ln[8]) + set rg_g_arr=($rg_g_arr $ln[9]) + set rg_b_arr=($rg_b_arr $ln[10]) + set part_arr=($part_arr $ln[11]) + @ i++ + end +end +if (! $#gfiles) then + unset gfiles + echo "###" + echo "### NOTE: Using internal demo database!" + echo "###" + echo +endif +# +# Make sure we have a clear glazing definition +# +if (`rcalc -n -e 'ad(a,b)=if(a-b,a-b,b-a);$1=if('"ad($rg_r_arr[1],$rc_r_arr[1])+ad($rg_g_arr[1],$rc_g_arr[1])+ad($rg_b_arr[1],$rc_b_arr[1])-.005,1,0)"`) then + set sn_arr=("clear glass" $sn_arr:q) + set rg_r_arr=(0.074 $rg_r_arr) + set rg_g_arr=(0.077 $rg_g_arr) + set rg_b_arr=(0.079 $rg_b_arr) + set rc_r_arr=(0.074 $rc_r_arr) + set rc_g_arr=(0.077 $rc_g_arr) + set rc_b_arr=(0.079 $rc_b_arr) + set tn_r_arr=(0.862 $tn_r_arr) + set tn_g_arr=(0.890 $tn_g_arr) + set tn_b_arr=(0.886 $tn_b_arr) + set part_arr=(0 $part_arr) +endif + ################################################################# # # Get user input @@ -110,7 +190,11 @@ endif echo "" echo "############################################" echo "# Glazing produced by Radiance glaze script" -echo "# `date`" +echo '# $Revision: 2.8 $' +if ($?gfiles) then + echo "# Loaded: $gfiles:q" + echo -n "# " ; date +endif echo "# Material surface normal points to interior" echo "# Number of panes in system: $np" @@ -174,8 +258,8 @@ endif else ### Low-E glazing echo "10" -echo " sr_lowE_r sr_lowE_g sr_lowE_b" -echo " st_lowE_r st_lowE_g st_lowE_b" +echo " sr_clear_r sr_clear_g sr_clear_b" +echo " st_clear_r st_clear_g st_clear_b" echo " 0 0 0" echo " glaze1.cal" echo "0"