Commit adf6ea1e authored by Alex Breuer's avatar Alex Breuer

Added sources for SGT test case.

parent e5d82376
# Sources
This directory contains the source input for the SGT runs.
Used commands:
```
python3 ./generate.py -t ricker -s -1 -e 1 -d 1E-4 -c 1.92 -m 1 -p ricker.pdf -o ricker.ascii
python3 ./generate.py -t gaussian -s -0.65 -e 0.65 -d 1E-4 -c 60 -m 1 -p gaussian.pdf -o gaussian.ascii
./generate_forward.sh
./generate_point_forces.sh
```
* Contact: Alex Breuer
#!/usr/bin/python3
##
# @file This file is part of EDGE.
#
# @author Alexander Breuer (anbreuer AT ucsd.edu)
#
# @section LICENSE
# Copyright (c) 2018, Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# @section DESCRIPTION
# Generates the source time histories.
##
import logging
import argparse
import math
def ricker( i_t1,
i_t2,
i_dt,
i_f=1.0,
i_M0=1.0):
"""Generates slip rate samples as given by the Ricker wavelet.
Source: Geophysical Journal International 166.2 (2006): 855-877.
An arbitrary high-order discontinuous Galerkin method for
elastic waves on unstructured meshes I. The two-dimensional isotropic case with external source terms
Eq. (64)
Moment rate time history: a*(0.5+b(t-T)^2)*exp(b*(t-T)^2) )
Arguments:
i_t1 {float} -- start time of the sampling.
i_t2 {float} -- end time of the sampling.
i_dt {float} -- time step of the sampling.
i_f {float} -- central frequency of the wavelet.
i_M0 {float} -- scaling used for the moment-rate time history.
Returns:
[array of float] -- sampled slip rates.
"""
# set parameters as used in the equation above
l_a = i_M0
l_b = -(math.pi * i_f)**2
# slip rate samples
l_sr = []
# local time
l_t = i_t1
while( l_t < i_t2 ):
l_sr.append( l_a * ( 0.5 + l_b * l_t**2 ) * math.exp( l_b * l_t**2 ) )
l_t = l_t + i_dt
return l_sr
def gaussian( i_t1,
i_t2,
i_dt,
i_a,
i_M0 ):
"""Generates slip rate samples, given by a Gaussian.
Moment rate time history: M0*exp(-a*t^2) )
Arguments:
i_t1 {float} -- start time of the sampling.
i_t2 {float} -- end time of the sampling.
i_dt {float} -- time step of the sampling.
i_a {float} -- decay.
i_M0 {float} -- scaling used for the moment-rate time history.
Returns:
[array of float] -- sampled slip rates.
"""
# slip rate samples
l_sr = []
# local time
l_t = i_t1
while( l_t < i_t2 ):
l_sr.append( i_M0 * math.exp( -i_a*l_t**2 ) )
l_t = l_t + i_dt
return l_sr
# set up logger
logging.basicConfig( level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' )
# command line arguments
l_parser = argparse.ArgumentParser( description='Generates a sampled source time function.' )
l_parser.add_argument( '-s',
dest = 't1',
required = True,
type = float,
help = 'start time' )
l_parser.add_argument( '-e',
dest = 't2',
required = True,
type = float,
help = 'end time' )
l_parser.add_argument( '-d',
dest = 'dt',
required = True,
type = float,
help = 'time step of the sampling' )
l_parser.add_argument( '-t',
dest = 'type',
type = str,
help = 'type of the source: either "ricker" or "gaussian"' )
l_parser.add_argument( '-c',
dest = 'c',
required = True,
type = float,
help = 'central frequency (ricker) or decay rate (gaussian)' )
l_parser.add_argument( '-m',
dest = 'm',
required = True,
type = float,
help = 'scaling (magnitude)' )
l_parser.add_argument( '-p',
dest = 'p',
required = False,
default = "",
type = str,
help = 'path to output file for plot (optional)' )
l_parser.add_argument( '-o',
dest = 'o',
required = True,
type = str,
help = 'path to ASCII output file' )
l_args = vars(l_parser.parse_args())
logging.info( 'generating sampled ricker wavelet' )
# derive sampling
if( l_args['type'] == 'ricker' ):
l_samples = ricker( l_args['t1'],
l_args['t2'],
l_args['dt'],
l_args['c'],
l_args['m'] )
elif( l_args['type'] == 'gaussian' ):
l_samples = gaussian( l_args['t1'],
l_args['t2'],
l_args['dt'],
l_args['c'],
l_args['m'] )
else: assert( False )
print( len(l_samples) )
if l_args['p'] != '':
logging.info( 'plotting waveform and spectrum' )
import matplotlib.pyplot
from matplotlib.backends.backend_pdf import PdfPages
import numpy
l_pdf = PdfPages( l_args['p'] )
matplotlib.pyplot.plot( numpy.linspace(l_args['t1'], l_args['t2'], num=len(l_samples)), l_samples )
l_pdf.savefig()
matplotlib.pyplot.figure()
matplotlib.pyplot.xlim( (0, 10) )
matplotlib.pyplot.magnitude_spectrum( l_samples, Fs=1/l_args['dt'] )
l_pdf.savefig()
l_pdf.close()
with open(l_args['o'], 'w') as l_file:
for l_sa in l_samples:
l_file.write("%s\n" % l_sa)
#!/bin/bash
##
# @file This file is part of EDGE.
#
# @author Alexander Breuer (anbreuer AT ucsd.edu)
#
# @section LICENSE
# Copyright (c) 2018, Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# @section DESCRIPTION
# Converts the ASCII sources to HDF5.
##
for base in ricker_forward
do
args=""
for type in points scalings time_parameters time_pointers time_series
do
args="${args} ${base}_ascii/${type}.ascii -c ${base}_ascii/${type}.dmp"
done
rm ${base}.h5 2> /dev/null
h5import ${args} -o ${base}.h5 > /dev/null
done
#!/bin/bash
##
# @file This file is part of EDGE.
#
# @author Alexander Breuer (anbreuer AT ucsd.edu)
#
# @section LICENSE
# Copyright (c) 2018, Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# @section DESCRIPTION
# Generates the HDF5 source for the point forces.
##
rm -r point_forces
mkdir point_forces
cd point_forces
while IFS=, read -r recv_name recv_x recv_y recv_z
do
for dim in x y
do
mkdir ${recv_name}_${dim}_ascii
cd ${recv_name}_${dim}_ascii
ln -s ../../gaussian_point_force_ascii/* .
# set location