#! /bin/sh
# This input file reproduces the output in Juhlin (1995) Figure 6b.
# Note that the source in Table 1 in Juhlin (1995) is given as g(t), but should be f(t)
# be f(t), i.e. the derivative of the Gaussian (dg)
# Since the dg source waveform is defined by its avg frequency content
# favg should be set to 24.15 Hz to correpsond to alpha=10000 in
# Juhlin (1995)  

#suea2df dt=0.0005 lt=0.4 zmax=762 xmin=-00 xmax=1530 dx=6 verbose=1 \
##snfile=tmp hsz=00 vsx=200 snaptime=0.19,0.59,0.99 efile=mod \
#bc=2,1,1,0 qsw=0 asw=1 \
#xl=0 \
#0 \
# zl=150,156 \
# vpl=2898,3320 \
# vsl=1398,1398 \
# rhol=2250,2250\
# epl=0.2566,0\
# dsl=0.3796,0\
# anl=0,0\
#>out2

modelfile=model.unif            # input model file for unif2aniso
ninf=1                          # number of interfaces (surface counts)
x0=0,0,0                        # x-position(s) for  vp00,vs00,rho00, etc.
z0=0,150,156			# z-position(s) for  vp00,vs00,rho00, etc.
nz=254                          # size of z (depth) dimension  of model
nx=510                          # size of x (horizontal) dimension of model
dz=3                            # increment in z direction
dx=3                            # increment in x direction
vp00=2898,3320                  # P-wavespeed(s) at (z0,x0)
vs00=1398,1498                  # S-wavespeed(s) at (z0,x0)
rho00=2250,2250                 # density(s) at (z0,x0)
eps00=0.2566,0			# epsilons(s)
delta00=0.3796,0		# delta(s) at (z0,x0)
gamma00=0,0			 # gammas(s) at (z0,x0)
method=linear			# linear, mono, akima, spline  interpolation
				#   of boundaries in unif2aniso models

dt=0.0005                       # time sampling interval
lt=0.4	                        # latest time modeled
fx=0                            # first x value
verbose=1                       # =1 chatty, =0 silent
snfile="snaps.su"                # output file for snapshots
rhofile="rho_file"              # input file of densities, if not set rho=1000
hsz=0.0		                # z-position of horizontal line of geophones
vsx=0.0		                # x-position of vertical line of geophones
snaptime=0.02,.03,.04,0.05,.06,.07,.08,.09,.1,.11,.12,.13,.14,.15,.16,.17,.18,.19,.2,.21,.22,.23,.24,.25,.25,.26,.27,.28,.29,.3,,.35,.4	
# times of snapshots
c=2,1,1,0                      # boundary conditions
qsw=0                           # =1 put in attenuation
asw=0                           # =1 anisotropy
sx=0				# x-position of sources
sz=12				# z-position of sources
favg=24.15                      # average frequency
ts=.05                          # source duration
wtype=dg                        # waveform type


# build stiffness and density files
unif2aniso < $modelfile ninf=$ninf x0=$x0 z0=$z0 nz=$nz nx=$nx \
dx=$dx dz=$dz vp00=$vp00 vs00=$vs00 rho00=$rho00 method=$method

# the files c11_file c13_file c15_file c33_file c35_file c55_file rho_file
# are generated by unif2aniso
# transpose stiffness and density
for i in c11 c13 c15 c33 c35 c55 rho
do
        echo $xbox $ybox
        ximage <  ${i}_file n1=$nz n2=$nx perc=99 xbox=$xbox ybox=$ybox \
         wbox=$nx hbox=$nz  legend=1 title=" ${i} parameter file  " &
        sleep 2

        xbox=`expr $xbox + 110 `
        ybox=`expr $ybox + 5 `

        mv ${i}_file tmp.file
        transp n1=$nz < tmp.file > ${i}_file
done

rm tmp.file

# run suea2df
suea2df dt=$dt lt=$lt nz=$nz fx=$fx nx=$nx dx=$dx dz=$dz verbose=1 \
snfile=$snfile rhofile=$rhofile hsz=$hsz vsx=$vsx snaptime=$snaptime \
bc=$bc qsw=$qsw asw=$asw sx=$sx sz=$sz favg=$favg ts=$ts wtype=$wtype \
>out2


n2=`bc -l <<-END
      scale=1
       $nx * 2
END`

echo $n2


suxmovie < snaps.su n1=$nz n2=$n2 clip=1e-13 loop=1 title="snapshots horizontal vertical " width=$n2 height=$nz  sleep=2 &

sleep 10


# shot gathers from a horizontal line of geophones
suximage <  hs.su xbox=0 ybox=400 wbox=$nx hbox=$nz  perc=99 title="  shot gathers  vertical horizontal " &
suximage <  vsp.su xbox=400 ybox=400  wbox=$nx hbox=$nz  perc=99 title=" VSP  vertical horizontal " &
