# 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=="Xarea") {xarea=$2;print$0}} {if($1=="MomIn") {momin=$2;print$0}} {if($1=="ElastMod") {emod=$2;print$0}} {if($1=="Dens") {density=$2;print$0}} {if($1=="c") {c=$2;print$0}} {if($1=="Wadded") {wadded=$2;print$0}} {if($1=="Gload") {gload=$2;print$0}} # END { {beamweight=density*lgth*xarea} {totalweight=beamweight+wadded} {cantdef=gload*totalweight*lgth*lgth*lgth/8./emod/momin} {pindef=gload*totalweight*lgth*lgth*lgth/76.8/emod/momin} {fixdef=gload*totalweight*lgth*lgth*lgth/384./emod/momin} {fpdef=gload*totalweight*lgth*lgth*lgth/185.19/emod/momin} # {cantstress=(gload*totalweight*lgth/2.)*c/momin} {pinstress=(gload*totalweight*lgth/8.)*c/momin} {fixstress=(gload*totalweight*lgth/12.)*c/momin} {fpstress=(gload*totalweight*lgth/8.)*c/momin} # {effdens=totalweight/xarea/lgth} {freq=sqrt(emod*386.04/effdens)*sqrt(momin/xarea)/lgth/lgth/6.2832} # {cant1=3.52*freq} {cant2=22.*freq} {cant3=61.7*freq} {cant4=121.*freq} {cant5=200.*freq} # {pin1=9.87*freq} {pin2=39.5*freq} {pin3=88.8*freq} {pin4=158.*freq} {pin5=247.*freq} # {free1=22.*freq} {free2=61.7*freq} {free3=121.*freq} {free4=200.*freq} {free5=298.2*freq} # {fix1=22.*freq} {fix2=61.7*freq} {fix3=121.*freq} {fix4=200.*freq} {fix5=298.2*freq} # {fp1=15.4*freq} {fp2=50.*freq} {fp3=104.*freq} {fp4=178.*freq} {fp5=272.*freq} # {pf1=0.*freq} {pf2=15.4*freq} {pf3=50.*freq} {pf4=104.*freq} {pf5=178.*freq} # {print" "} {print "#---------------------------------Output--------------------------------------#"} {print" "} {printf ("%-20s %-8.0f %-20s %-8.0f\n","Beam weight =",beamweight,"Total weight =",totalweight)} {print" "} {print "BC's Static Shock Natural Freq (cps)"} {print " Deflc Stress Mode1 Mode2 Mode3 Mode4 Mode5"} {print " "} {printf ("%-12s %8.4f %10.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n","Cantilever", cantdef,cantstress,cant1,cant2,cant3,cant4,cant5)} {printf ("%-12s %8.4f %10.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n","Pinned", pindef,pinstress,pin1,pin2,pin3,pin4,pin5)} {printf ("%-12s %8.4f %10.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n","Free-Free", freedef,freestress,free1,free2,free3,free4,free5)} {printf ("%-12s %8.4f %10.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n","Fix-Fix", fixdef,fixstress,fix1,fix2,fix3,fix4,fix5)} {printf ("%-12s %8.4f %10.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n","Fix-Pin", fpdef,fpstress,fp1,fp2,fp3,fp4,fp5)} {printf ("%-12s %8.4f %10.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n","Pin-Free", pfdef,pfstress,pf1,pf2,pf3,pf4,pf5)} # {print "#-----------------------------End of File---------------------------------------#"} }