# 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=="Length") {lgth=$2;print$0}} {if($1=="Velocity") {velo=$2;print$0}} {if($1=="Rgas") {rgas=$2;print$0}} {if($1=="kgas") {kgas=$2;print$0}} {if($1=="Cpgas") {cpgas=$2;print$0}} {if($1=="mugas") {mugas=$2;print$0}} {if($1=="Tflow") {tinlet=$2;print$0}} {if($1=="Pflow") {pinlet=$2;print$0}} {if($1=="Turb") {turb=$2;print$0}} # END { # density will be in lbm/ft^3 {gasdens=pinlet/rgas/(tinlet+459.67)} {prndlt=cpgas*mugas*3600/kgas} # (note: Length is input in inches) {renl=gasdens*velo*(lgth/12.)/mugas} {scratch1=sqrt(132500.*turb^2)-1} {scratch2=39.2*turb^2} {recrit=500000.} {if(turb>0.000) {recrit=(scratch1/scratch2)^2}} {A=.037*recrit^.8-.664*sqrt(recrit)} {havg=(.037*(renl^.8)-A)*(prndlt^.333)*kgas*12./lgth} # xcrit will be inches.... {xcrit=12.*recrit*mugas/gasdens/velo} {if(xcrit>lgth) {havg=.664*sqrt(renl)*(prndlt^.333)*kgas*12./lgth}} # h's include the leading edge effect: {scratch1=gasdens*velo/12./mugas} {lamscratch=.332*(prndlt^.333)*kgas} {turbscratch=.0296*(prndlt^.333)*kgas} {x[1]=lgth/20.;renx[1]=scratch1*x[1]} {for(jk=2;jk<=20;jk++) {x[jk]=x[jk-1]+lgth/20.;renx[jk]=scratch1*x[jk]}} # {for(jk=1;jk<=20;jk++) {hlam[jk]=lamscratch*sqrt(renx[jk])*12./x[jk]}} {for(jk=1;jk<=20;jk++) {hturb[jk]=turbscratch*(renx[jk]^.8)*12./x[jk]}} {for(jk=1;jk<=20;jk++) {h[jk]=hturb[jk]; if(renx[jk]hmax) {hmax=h[jk]}}} {for(jk=1;jk<=20;jk++) {hratio[jk]=int(20*h[jk]/hmax)}} {for(jk=1;jk<=20;jk++) {km=0;scratch=""; while(km<=hratio[jk]) {scratch=scratch "#";km=km+1}; hstars[jk]=scratch}} # {print "#----------------------Output--------------------#"} {printf("%-12s %12.3f\n","Gas Density", gasdens)} {printf("%-12s %12.3f\n","Prandlt No.",prndlt)} {printf("%-12s %12.0f\n","Reyn(L)",renl)} {printf("%-12s %12.1f\n","Re(crit)",recrit)} {printf("%-12s %12.1f\n","Xcrit(in)",xcrit)} {printf("%-12s %12.1f\n","Avg. h",havg)} # {print " "} {printf("%-8s %-10s %-8s %-8s %-8s \n","X(in)","Ren(x)","Hlam","Hturb","H(x)")} {for(jk=1;jk<=20;jk++) {printf("%-8.2f %-10.0f %-8.0f %-8.0f %-8.0f %s\n", x[jk],renx[jk],hlam[jk],hturb[jk],h[jk],hstars[jk])}} {print "#.......................End of File..............#"} }