# awk script # # the begin command is executed BEFORE anything else is done BEGIN {FS=" "; "date" | getline date; print date } # start of file reading sequence..... {N=N+1} {if(N==1) {printf "Input file [ %12s ]\n",FILENAME ; print "#----------------------Input---------------------#"}} {if($1=="mdothot") {mdothot=$2;print$0}} {if($1=="Cphot") {Cphot=$2;print$0}} {if($1=="Thotin") {Thotin=$2;print$0}} {if($1=="Thotout") {Thotout=$2;print$0}} {if($1=="mdotcool") {mdotcool=$2;print$0}} {if($1=="Cpcool") {Cpcool=$2;print$0}} {if($1=="Tcoolin") {Tcoolin=$2;print$0}} {if($1=="Tcoolout") {Tcoolout=$2;print$0}} {if($1=="Type") {Type=$2;print$0}} # # start of calculations..... END { #Calculate Q for each fluid. #Must tweak input data until they are equal absolute magnitude #Qhot should be negative; Qcool should be positive {Qhot=mdothot*Cphot*(Thotout-Thotin)} {Qcool=mdotcool*Cpcool*(Tcoolout-Tcoolin)} # {print" "} {print"#-----------------Output--------------------#"} {print"Qhot=",Qhot,"BTU/hr"} {print"Qcool=",Qcool,"BTU/hr"} {print"Qhot+Qcool must = zero or following calcs are wrong"} {print" "} # {if(Type==1) { print"Parallel flow x-chngr, Thotout must be > Tcoolout"; delT1=Thotin-Tcoolin; delT2=Thotout-Tcoolout; LMTD=(delT1-delT2)/log(delT1/delT2); UA=Qcool/LMTD; print"Overall U is the overall heat transfer coefficient of the design (BTU/hr/sqft/F)."; print"A is the effective heat transfer area of the design (sqft)."; print"UA and Qcheck shown below is based on coolside flow."; {print" "} printf("%-24s %12.2f %10s\n","LMTD =",LMTD,"F"); printf("%-24s %12.2f %10s\n","Overall U * Area =",UA,"BTU/hr/F") printf("%-24s %12.2f %10s\n","Qcheck =",LMTD*UA,"BTU/hr") }} # {if(Type==2) { print"Counter-flow x-chngr, Thotout must be > Tcoolin"; delT1=Thotin-Tcoolout; delT2=Thotout-Tcoolin; LMTD=(delT1-delT2)/log(delT1/delT2); UA=Qcool/LMTD; print"Overall U is the overall heat transfer coefficient of the design (BTU/hr/sqft/F)."; print"A is the effective heat transfer area of the design (sqft)."; print"UA and Qcheck shown below is based on coolside flow."; {print" "} printf("%-24s %12.2f %10s\n","LMTD =",LMTD,"F"); printf("%-24s %12.2f %10s\n","Overall U * Area =",UA,"BTU/hr/F") printf("%-24s %12.2f %10s\n","Qcheck =",LMTD*UA,"BTU/hr") }} {print "#.......................End of File..............#"} }