ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/glaze.csh
Revision: 2.3
Committed: Sat Aug 14 19:36:38 2004 UTC (19 years, 7 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 2.2: +39 -1 lines
Log Message:
Added -f option to read glazing types from file

File Contents

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