ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/glaze.csh
Revision: 2.7
Committed: Mon Feb 11 19:18:25 2008 UTC (16 years, 2 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad3R9
Changes since 2.6: +4 -4 lines
Log Message:
Changed naming of specular component

File Contents

# User Rev Content
1 greg 2.1 #!/bin/csh -f
2 greg 2.7 # RCSid: $Id: glaze.csh,v 2.6 2008/02/11 19:13:05 greg Exp $
3 greg 2.1 #
4     # Complex glazing model (goes with glaze1.cal and glaze2.cal)
5     #
6     # Oct. 2002 Greg Ward
7 greg 2.3 # Aug. 2004 GW (added -f option to read glazings from file)
8 greg 2.2 # Funding for this development generously provided by Visarc, Inc.
9 greg 2.4 # (http://www.visarc.com)
10 greg 2.1 #
11    
12     #################################################################
13     #
14 greg 2.5 # The general assumption is that one surface is uncoated, and
15     # reflectances and transmittances are computed from this fact.
16     # If the user tries to enter two coated surfaces on the same
17     # pane, the script complains and exits.
18     #
19 greg 2.1 # Supported surface types:
20     #
21     set sn_arr=("clear glass" "VE1-2M low-E coating" "PVB laminated" "V-175 white frit" "V-933 warm gray frit")
22     # Glass-side hemispherical reflectances for each surface type:
23     set rg_r_arr=(0.074 0.065 .11 0.33 0.15)
24     set rg_g_arr=(0.077 0.058 .11 0.33 0.15)
25     set rg_b_arr=(0.079 0.067 .11 0.33 0.15)
26     # Coating-side hemispherical reflectance for each surface type:
27     set rc_r_arr=(0.074 0.042 .11 0.59 0.21)
28     set rc_g_arr=(0.077 0.049 .11 0.59 0.21)
29     set rc_b_arr=(0.079 0.043 .11 0.59 0.21)
30     # Hemispherical (normal) transmittance for each surface type:
31     set tn_r_arr=(0.862 0.756 0.63 0.21 0.09)
32     set tn_g_arr=(0.890 0.808 0.63 0.21 0.09)
33     set tn_b_arr=(0.886 0.744 0.63 0.21 0.09)
34     # Boolean whether coatings can have partial coverage:
35     set part_arr=(0 0 0 1 1)
36    
37 greg 2.6 set gfiles=()
38 greg 2.3 while ($#argv > 0)
39 greg 2.4 set header="Surface Tr Tg Tb Rcr Rcg Rcb Rgr Rgg Rgb Part"
40 greg 2.3 if ($#argv < 2 || "$argv[1]" != '-f') then
41     echo "Usage: $0 [-f glazing.dat ..]"
42     exit 1
43     endif
44     shift argv
45     set gf="$argv[1]"
46     shift argv
47 greg 2.6 set gfiles=($gfiles:q $gf:q)
48 greg 2.3 if ("`sed -n 1p $gf:q`" != "$header") then
49     echo "Bad header in $gf -- Expected: $header"
50     exit 1
51     endif
52     echo "Adding glazing types from file $gf :"
53     set nl=`wc -l < $gf:q`
54     @ i=2
55     while ($i <= $nl)
56     set ln=(`sed -n ${i}p $gf:q`)
57 greg 2.4 if ($#ln != 11) then
58     echo "Expected 11 words in line: $ln"
59 greg 2.3 exit 1
60     endif
61     echo $ln[1]
62     set sn_arr=($sn_arr:q $ln[1])
63     set tn_r_arr=($tn_r_arr $ln[2])
64     set tn_g_arr=($tn_g_arr $ln[3])
65     set tn_b_arr=($tn_b_arr $ln[4])
66     set rc_r_arr=($rc_r_arr $ln[5])
67     set rc_g_arr=($rc_g_arr $ln[6])
68     set rc_b_arr=($rc_b_arr $ln[7])
69 greg 2.5 set rg_r_arr=($rg_r_arr $ln[8])
70     set rg_g_arr=($rg_g_arr $ln[9])
71     set rg_b_arr=($rg_b_arr $ln[10])
72 greg 2.4 set part_arr=($part_arr $ln[11])
73 greg 2.3 @ i++
74     end
75     end
76 greg 2.6 if (! $#gfiles) unset gfiles
77 greg 2.3
78 greg 2.1 #################################################################
79     #
80     # Get user input
81     #
82     echo -n "Enter the number of panes in the system: "
83     set np="$<"
84     if ($np != 1 && $np != 2) then
85     echo "Must be 1 or 2 pane system"
86     exit 1
87     endif
88     echo ""
89     echo "Window normal faces interior"
90     echo ""
91     if ($np == 1) then
92     echo " | |"
93     echo " | |"
94     echo " | |"
95     echo " | |-->"
96     echo " | |"
97     echo " | |"
98     echo " | |"
99     echo " s1 s2"
100     else
101     echo " | | | |"
102     echo " | | | |"
103     echo " | | | |"
104     echo " | | | |-->"
105     echo " | | | |"
106     echo " | | | |"
107     echo " | | | |"
108     echo " s1 s2 s3 s4"
109     endif
110     echo ""
111     echo "Supported surface types are:"
112     set i=1
113     while ($i <= $#sn_arr)
114     echo " " $i - $sn_arr[$i]
115     @ i++
116     end
117     echo ""
118     echo -n "What is the type of s1? "
119     set s1t="$<"
120     echo -n "What is the type of s2? "
121     set s2t="$<"
122     if ($s1t != 1 && $s2t != 1) then
123     echo "One surface of each pane must be $sn_arr[1]"
124     exit 1
125     endif
126     if ($part_arr[$s1t]) then
127     echo -n "Enter fraction coverage for s1 (0-1): "
128     set s1c="$<"
129     endif
130     if ($part_arr[$s2t]) then
131     echo -n "Enter fraction coverage for s2 (0-1): "
132     set s2c="$<"
133     endif
134     if ($np == 2) then
135     echo -n "What is the type of s3? "
136     set s3t="$<"
137     echo -n "What is the type of s4? "
138     set s4t="$<"
139     if ($s3t != 1 && $s4t != 1) then
140     echo "One surface of each pane must be $sn_arr[1]"
141     exit 1
142     endif
143     if ($part_arr[$s3t]) then
144     echo -n "Enter fraction coverage for s3 (0-1): "
145     set s3c="$<"
146     endif
147     if ($part_arr[$s4t]) then
148     echo -n "Enter fraction coverage for s4 (0-1): "
149     set s4c="$<"
150     endif
151     endif
152    
153     #################################################################
154     #
155     # Begin material comments
156     #
157     echo ""
158     echo "############################################"
159     echo "# Glazing produced by Radiance glaze script"
160 greg 2.7 echo '# $Revision: 2.6 $'
161 greg 2.6 if ($?gfiles) then
162     echo "# Loaded: $gfiles:q"
163     echo "# `date`"
164     endif
165 greg 2.1 echo "# Material surface normal points to interior"
166     echo "# Number of panes in system: $np"
167    
168     if ($np == 2) goto glaze2
169     #################################################################
170     #
171     # Compute single glazing
172     #
173     set sc=1
174     echo "# Exterior surface s1 type: $sn_arr[$s1t]"
175     if ($?s1c) then
176     echo "# s1 coating coverage: $s1c"
177     set sc=$s1c
178     endif
179     echo "# Interior surface s2 type: $sn_arr[$s2t]"
180     if ($?s2c) then
181     echo "# s2 coating coverage: $s2c"
182     set sc=$s2c
183     endif
184     if ($s1t != 1) then
185     set ct=$s1t
186     echo -n "# Exterior normal hemispherical reflectance: "
187     ev ".265*($sc*$rc_r_arr[$ct]+(1-$sc)*$rc_r_arr[1])+.670*($sc*$rc_g_arr[$ct]+(1-$sc)*$rc_g_arr[1])+.065*($sc*$rc_b_arr[$ct]+(1-$sc)*$rc_b_arr[1])"
188     echo -n "# Interior normal hemispherical reflectance: "
189     ev ".265*($sc*$rg_r_arr[$ct]+(1-$sc)*$rg_r_arr[1])+.670*($sc*$rg_g_arr[$ct]+(1-$sc)*$rg_g_arr[1])+.065*($sc*$rg_b_arr[$ct]+(1-$sc)*$rg_b_arr[1])"
190     else
191     set ct=$s2t
192     echo -n "# Exterior normal hemispherical reflectance: "
193     ev ".265*($sc*$rg_r_arr[$ct]+(1-$sc)*$rg_r_arr[1])+.670*($sc*$rg_g_arr[$ct]+(1-$sc)*$rg_g_arr[1])+.065*($sc*$rg_b_arr[$ct]+(1-$sc)*$rg_b_arr[1])"
194     echo -n "# Interior normal hemispherical reflectance: "
195     ev ".265*($sc*$rc_r_arr[$ct]+(1-$sc)*$rc_r_arr[1])+.670*($sc*$rc_g_arr[$ct]+(1-$sc)*$rc_g_arr[1])+.065*($sc*$rc_b_arr[$ct]+(1-$sc)*$rc_b_arr[1])"
196     endif
197     echo -n "# Normal hemispherical transmittance: "
198     ev ".265*($sc*$tn_r_arr[$ct]+(1-$sc)*$tn_r_arr[1])+.670*($sc*$tn_g_arr[$ct]+(1-$sc)*$tn_g_arr[1])+.065*($sc*$tn_b_arr[$ct]+(1-$sc)*$tn_b_arr[1])"
199     echo "#"
200     echo "void BRTDfunc glaze1_unnamed"
201     if ($part_arr[$s1t] || $part_arr[$s2t]) then
202     ### Frit glazing
203     echo "10"
204     echo " sr_frit_r sr_frit_g sr_frit_b"
205     echo " st_frit_r st_frit_g st_frit_b"
206     echo " 0 0 0"
207     echo " glaze1.cal"
208     echo "0"
209     echo "11"
210     if ($s2t == 1) then
211     ev "$s1c*($rg_r_arr[$s1t]-$rg_r_arr[1])" \
212     "$s1c*($rg_g_arr[$s1t]-$rg_g_arr[1])" \
213     "$s1c*($rg_b_arr[$s1t]-$rg_b_arr[1])"
214     ev "$s1c*$rc_r_arr[$s1t]" "$s1c*$rc_g_arr[$s1t]" "$s1c*$rc_b_arr[$s1t]"
215     ev "$s1c*$tn_r_arr[$s1t]" "$s1c*$tn_g_arr[$s1t]" "$s1c*$tn_b_arr[$s1t]"
216     echo " 1 $s1c"
217     else
218     ev "$s2c*$rc_r_arr[$s2t]" "$s2c*$rc_g_arr[$s2t]" "$s2c*$rc_b_arr[$s2t]"
219     ev "$s2c*($rg_r_arr[$s2t]-$rg_r_arr[1])" \
220     "$s2c*($rg_g_arr[$s2t]-$rg_g_arr[1])" \
221     "$s2c*($rg_b_arr[$s2t]-$rg_b_arr[1])"
222     ev "$s2c*$tn_r_arr[$s2t]" "$s2c*$tn_g_arr[$s2t]" "$s2c*$tn_b_arr[$s2t]"
223     echo " -1 $s2c"
224     endif
225     else
226     ### Low-E glazing
227     echo "10"
228 greg 2.7 echo " sr_clear_r sr_clear_g sr_clear_b"
229     echo " st_clear_r st_clear_g st_clear_b"
230 greg 2.1 echo " 0 0 0"
231     echo " glaze1.cal"
232     echo "0"
233     echo "19"
234     echo " 0 0 0"
235     echo " 0 0 0"
236     echo " 0 0 0"
237     if ($s2t == 1) then
238     echo " 1"
239     set st=$s1t
240     else
241     echo " -1"
242     set st=$s2t
243     endif
244     echo " $rg_r_arr[$st] $rg_g_arr[$st] $rg_b_arr[$st]"
245     echo " $rc_r_arr[$st] $rc_g_arr[$st] $rc_b_arr[$st]"
246     echo " $tn_r_arr[$st] $tn_g_arr[$st] $tn_b_arr[$st]"
247     endif
248     echo ""
249     exit 0
250    
251     glaze2:
252     #################################################################
253     #
254     # Compute double glazing
255     #
256     if ($s2t != 1) then
257     set s2r_rgb=($rc_r_arr[$s2t] $rc_g_arr[$s2t] $rc_b_arr[$s2t])
258     set s1r_rgb=($rg_r_arr[$s2t] $rg_g_arr[$s2t] $rg_b_arr[$s2t])
259     set s12t_rgb=($tn_r_arr[$s2t] $tn_g_arr[$s2t] $tn_b_arr[$s2t])
260     else
261     set s2r_rgb=($rg_r_arr[$s1t] $rg_g_arr[$s1t] $rg_b_arr[$s1t])
262     set s1r_rgb=($rc_r_arr[$s1t] $rc_g_arr[$s1t] $rc_b_arr[$s1t])
263     set s12t_rgb=($tn_r_arr[$s1t] $tn_g_arr[$s1t] $tn_b_arr[$s1t])
264     endif
265     if ($s4t != 1) then
266     set s4r_rgb=($rc_r_arr[$s4t] $rc_g_arr[$s4t] $rc_b_arr[$s4t])
267     set s3r_rgb=($rg_r_arr[$s4t] $rg_g_arr[$s4t] $rg_b_arr[$s4t])
268     set s34t_rgb=($tn_r_arr[$s4t] $tn_g_arr[$s4t] $tn_b_arr[$s4t])
269     else
270     set s4r_rgb=($rg_r_arr[$s3t] $rg_g_arr[$s3t] $rg_b_arr[$s3t])
271     set s3r_rgb=($rc_r_arr[$s3t] $rc_g_arr[$s3t] $rc_b_arr[$s3t])
272     set s34t_rgb=($tn_r_arr[$s3t] $tn_g_arr[$s3t] $tn_b_arr[$s3t])
273     endif
274     set s12c=1
275     echo "# Exterior surface s1 type: $sn_arr[$s1t]"
276     if ($?s1c) then
277     echo "# s1 coating coverage: $s1c"
278     set s12c=$s1c
279     endif
280     echo "# Inner surface s2 type: $sn_arr[$s2t]"
281     if ($?s2c) then
282     echo "# s2 coating coverage: $s2c"
283     set s12c=$s2c
284     endif
285     set s34c=1
286     echo "# Inner surface s3 type: $sn_arr[$s3t]"
287     if ($?s3c) then
288     echo "# s3 coating coverage: $s3c"
289     set s34c=$s3c
290     endif
291     echo "# Interior surface s4 type: $sn_arr[$s4t]"
292     if ($?s4c) then
293     echo "# s4 coating coverage: $s4c"
294     set s34c=$s4c
295     endif
296     # Approximate reflectance and transmittance for comment using gray values
297     set rglass=`ev ".265*$rg_r_arr[1]+.670*$rg_g_arr[1]+.065*$rg_b_arr[1]"`
298     set tglass=`ev ".265*$tn_r_arr[1]+.670*$tn_g_arr[1]+.065*$tn_b_arr[1]"`
299     set s1r_gry=`ev "$s12c*(.265*$s1r_rgb[1]+.670*$s1r_rgb[2]+.065*$s1r_rgb[3])+(1-$s12c)*$rglass"`
300     set s2r_gry=`ev "$s12c*(.265*$s2r_rgb[1]+.670*$s2r_rgb[2]+.065*$s2r_rgb[3])+(1-$s12c)*$rglass"`
301     set s12t_gry=`ev "$s12c*(.265*$s12t_rgb[1]+.670*$s12t_rgb[2]+.065*$s12t_rgb[3])+(1-$s12c)*$tglass"`
302     set s3r_gry=`ev "$s34c*(.265*$s3r_rgb[1]+.670*$s3r_rgb[2]+.065*$s3r_rgb[3])+(1-$s34c)*$rglass"`
303     set s4r_gry=`ev "$s34c*(.265*$s4r_rgb[1]+.670*$s4r_rgb[2]+.065*$s4r_rgb[3])+(1-$s34c)*$rglass"`
304     set s34t_gry=`ev "$s34c*(.265*$s34t_rgb[1]+.670*$s34t_rgb[2]+.065*$s34t_rgb[3])+(1-$s34c)*$tglass"`
305     echo -n "# Exterior normal hemispherical reflectance: "
306     ev "$s1r_gry + $s12t_gry^2*$s3r_gry"
307     echo -n "# Interior normal hemispherical reflectance: "
308     ev "$s4r_gry + $s34t_gry^2*$s2r_gry"
309     echo -n "# Normal hemispherical transmittance: "
310     ev "$s12t_gry*$s34t_gry"
311     echo "#"
312     echo "void BRTDfunc glaze2_unnamed"
313    
314     if ($part_arr[$s3t] || $part_arr[$s4t]) then
315     ### Front pane has frit
316     if ($part_arr[$s1t] || $part_arr[$s2t]) then
317     echo "Only one pane can have frit"
318     exit 1
319     endif
320     if ($?s3c) then
321     set sc=$s3c
322     set s3g=`ev "1-$s3c"`
323     else
324     set s3c=0
325     set s3g=1
326     endif
327     if ($?s4c) then
328     set sc=$s4c
329     set s4g=`ev "1-$s4c"`
330     else
331     set s4c=0
332     set s4g=1
333     endif
334     echo "10"
335     echo "if(Rdot,cr($s4g*rclr,$s3g*$s4g*tclr,fr($s2r_rgb[1])),cr(fr($s1r_rgb[1]),ft($s12t_rgb[1]),$s3g*rclr))"
336     echo "if(Rdot,cr($s4g*rclr,$s3g*$s4g*tclr,fr($s2r_rgb[2])),cr(fr($s1r_rgb[2]),ft($s12t_rgb[2]),$s3g*rclr))"
337     echo "if(Rdot,cr($s4g*rclr,$s3g*$s4g*tclr,fr($s2r_rgb[3])),cr(fr($s1r_rgb[3]),ft($s12t_rgb[3]),$s3g*rclr))"
338     echo "$s3g*$s4g*ft($s12t_rgb[1])*tclr"
339     echo "$s3g*$s4g*ft($s12t_rgb[2])*tclr"
340     echo "$s3g*$s4g*ft($s12t_rgb[3])*tclr"
341     echo " 0 0 0"
342     echo " glaze2.cal"
343     echo "0"
344     echo "9"
345     ev "$sc*$s4r_rgb[1]-$s3c*$rg_r_arr[1]" \
346     "$sc*$s4r_rgb[2]-$s3c*$rg_g_arr[1]" \
347     "$sc*$s4r_rgb[3]-$s3c*$rg_b_arr[1]"
348     ev "$s12t_rgb[1]^2*($sc*$s3r_rgb[1]-$s4c*$rg_r_arr[1])" \
349     "$s12t_rgb[2]^2*($sc*$s3r_rgb[2]-$s4c*$rg_g_arr[1])" \
350     "$s12t_rgb[3]^2*($sc*$s3r_rgb[3]-$s4c*$rg_b_arr[1])"
351     ev "$sc*$s12t_rgb[1]*$s34t_rgb[1]" \
352     "$sc*$s12t_rgb[2]*$s34t_rgb[2]" \
353     "$sc*$s12t_rgb[3]*$s34t_rgb[3]"
354     else if ($part_arr[$s1t] || $part_arr[$s2t]) then
355     ### Back pane has frit
356     if ($?s1c) then
357     set sc=$s1c
358     set s1g=`ev "1-$s1c"`
359     else
360     set s1c=0
361     set s1g=1
362     endif
363     if ($?s2c) then
364     set sc=$s2c
365     set s2g=`ev "1-$s2c"`
366     else
367     set s2c=0
368     set s2g=1
369     endif
370     echo "10"
371     echo "if(Rdot,cr(fr($s4r_rgb[1]),ft($s34t_rgb[1]),$s2g*rclr),cr($s1g*rclr,$s1g*$s2g*tclr,fr($s3r_rgb[1])))"
372     echo "if(Rdot,cr(fr($s4r_rgb[2]),ft($s34t_rgb[2]),$s2g*rclr),cr($s1g*rclr,$s1g*$s2g*tclr,fr($s3r_rgb[2])))"
373     echo "if(Rdot,cr(fr($s4r_rgb[3]),ft($s34t_rgb[3]),$s2g*rclr),cr($s1g*rclr,$s1g*$s2g*tclr,fr($s3r_rgb[3])))"
374     echo "$s1g*$s2g*ft($s34t_rgb[1])*tclr"
375     echo "$s1g*$s2g*ft($s34t_rgb[2])*tclr"
376     echo "$s1g*$s2g*ft($s34t_rgb[3])*tclr"
377     echo " 0 0 0"
378     echo " glaze2.cal"
379     echo "0"
380     echo "9"
381     ev "$s34t_rgb[1]^2*($sc*$s2r_rgb[1]-$s1c*$rg_r_arr[1])" \
382     "$s34t_rgb[2]^2*($sc*$s2r_rgb[2]-$s1c*$rg_g_arr[1])" \
383     "$s34t_rgb[3]^2*($sc*$s2r_rgb[3]-$s1c*$rg_b_arr[1])"
384     ev "$sc*$s1r_rgb[1]-$s2c*$rg_r_arr[1]" \
385     "$sc*$s1r_rgb[2]-$s2c*$rg_g_arr[1]" \
386     "$sc*$s1r_rgb[3]-$s2c*$rg_b_arr[1]"
387     ev "$sc*$s34t_rgb[1]*$s12t_rgb[1]" \
388     "$sc*$s34t_rgb[2]*$s12t_rgb[2]" \
389     "$sc*$s34t_rgb[3]*$s12t_rgb[3]"
390     else
391     ### Low-E and regular glazing only
392     echo "10"
393     echo "if(Rdot,cr(fr($s4r_rgb[1]),ft($s34t_rgb[1]),fr($s2r_rgb[1])),cr(fr($s1r_rgb[1]),ft($s12t_rgb[1]),fr($s3r_rgb[1])))"
394     echo "if(Rdot,cr(fr($s4r_rgb[2]),ft($s34t_rgb[2]),fr($s2r_rgb[2])),cr(fr($s1r_rgb[2]),ft($s12t_rgb[2]),fr($s3r_rgb[2])))"
395     echo "if(Rdot,cr(fr($s4r_rgb[3]),ft($s34t_rgb[3]),fr($s2r_rgb[3])),cr(fr($s1r_rgb[3]),ft($s12t_rgb[3]),fr($s3r_rgb[3])))"
396     echo "ft($s34t_rgb[1])*ft($s12t_rgb[1])"
397     echo "ft($s34t_rgb[2])*ft($s12t_rgb[2])"
398     echo "ft($s34t_rgb[3])*ft($s12t_rgb[3])"
399     echo " 0 0 0"
400     echo " glaze2.cal"
401     echo "0"
402     echo "9"
403     echo " 0 0 0"
404     echo " 0 0 0"
405     echo " 0 0 0"
406     endif
407     echo ""
408     exit 0