ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/glaze.csh
Revision: 2.4
Committed: Wed Aug 25 01:40:12 2004 UTC (19 years, 8 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 2.3: +6 -5 lines
Log Message:
Added missing partial boolean (Jack fixed this)

File Contents

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