ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/glaze.csh
Revision: 2.8
Committed: Thu Nov 5 19:00:50 2009 UTC (14 years, 5 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R0, rad4R2P1, rad5R3, HEAD
Changes since 2.7: +49 -16 lines
Log Message:
Altered -f option behavior to remove default database

File Contents

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