# awk script # # the begin command is executed BEFORE anything else is done BEGIN {FS=" "; "date" | getline date; print date } # {N=N+1} {if(N==1) {printf "Input file [ %12s ]\n",FILENAME ; print "#----------------------Input---------------------#"}} {if($1=="Hotside") {Thot=$2;Hhot=$3;print$0}} {if($1=="Layer1") {thick1=$2;kond1=$3;print$0}} {if($1=="Layer2") {thick2=$2;kond2=$3;print$0}} {if($1=="Layer3") {thick3=$2;kond3=$3;print$0}} {if($1=="Layer4") {thick4=$2;kond4=$3;print$0}} {if($1=="Coolside") {Tcool=$2;Hcool=$3;print$0}} {if($1=="Area") {area=$2;print$0}} {if($1=="Flow") {flow=$2;print$0}} {if($1=="Cp") {cp=$2;print$0}} # END { {term1=1/Hhot} {term2=thick1/1000/kond1} {term3=thick2/1000/kond2} {term4=thick3/1000/kond3} {term5=thick4/1000/kond4} {term6=1/Hcool} # {U=1/(term1+term2+term3+term4+term5+term6)} # {QoverA=U*(Thot-Tcool)} # next assumes the flowing fluid is the *coolant* {Texit=Thot-(Thot-Tcool)*(2.71828^(-U*area/flow/cp/1000))} # next are the layer temperatures, starting on hot side # assumes thicnesses are in mm's {T1=Thot-QoverA/Hhot} {T2=T1-QoverA*thick1/1000./kond1} {T3=T2-QoverA*thick2/1000./kond2} {T4=T3-QoverA*thick3/1000./kond3} {T5=T4-QoverA*thick4/1000./kond4} {T5check=Tcool+QoverA/Hcool} # #{print Thot,Tcool} {print "#----------------------Output--------------------#"} {printf("%-12s %12.1f\n","Overall HTC", U)} {printf("%-12s %12.1f\n","Q/A",QoverA)} {printf("%-12s %12.1f\n","T(cool exit)",Texit)} {printf("%-12s %12.1f\n","T1",T1)} {printf("%-12s %12.1f\n","T2",T2)} {printf("%-12s %12.1f\n","T3",T3)} {printf("%-12s %12.1f\n","T4",T4)} {printf("%-12s %12.1f\n","T5",T5)} {printf("%-12s %12.1f\n","T5check",T5check)} # {print "#.......................End of File..............#"} }