This directory contains two examples that demonstrate computing static
Green's functions via PyLith and using them in a simple inversion for
fault slip. The directory strikeslip contains a 2-D strike-slip fault
example and the directory reverse contains a 2-D reverse fault
example. The two examples are run using exactly the same commands.

The main features of these examples are:

  * Generating a finite-element mesh using CUBIT
    + Variable mesh resolution
  * Spatially variable slip
  * Computing Green's functions using PyLith

Each example consists of two simulations. In the first simulation we
compute the displacements due to a variable slip on the fault fault
(idealized in a 2-D model with plane-strain); this serves as the
"observed" displacements. In the second simulation we compute Green's
functions for the fault. We use these Green's functions in the second
simulation and the observed displacements from the first simulation to
invert for the slip (in the first simulation).

The imposed slip in the first simulation includes a region of uniform
slip with a linear taper at each end. We use uniform linear elastic
properties with a plane-strain formulation.

The parameters for the bulk constitutive models are defined in
  mat_elastic.spatialdb

The simulation will output the displacements on the ground surface as
well as a selection of points (defined in output_points.txt).

For each of the simulations, we recommend examining the displacements,
stress field, and fault slip.


Mesh generation (optional)

  NOTE: The result of this step will overwrite the included file
        tri3_mesh.exo. You may want to copy/rename this file so that
        you have a backup copy in case you have difficulty running
        CUBIT.

  Start CUBIT and play the journal file "mesh_tri3.jou". We highly
  recommend that you study the contents of the journal files to
  understand the mesh generation process.

  NOTE: We use IDless journal files to maximize the compatibility
  of the journal files with various versions of CUBIT and Trelis.


Step 1. Forward simulation

  This simulation mimics an earthquake generating an observed
  displacement field.

  The parameters for the earthquake slip are defined in
    eqslip.spatialdb

  Run the simulation via the following command:
    pylith eqsim.cfg


Step 2. Generate Green's functions

  This simulation generates Green's functions for a subset of the fault.

  The parameters for the amplitude (and sign) of the slip impulses are
  defined in
    impulse_amplitude.spatialdb

  Run the simulation via the following command:
    pylith --problem=pylith.problems.GreensFns


Step 3. Invert for coseismic slip

  Now that we have the forward simulation (data) and Green's functions, we
  can perform an inversion for the fault slip. We have written a very
  simple Python script that performs a miminim moment solution using a
  range of penalty parameters (contained in penalty_params.txt). The inversion
  code is in invert_slip.py.  You can run the inversion by typing:

    ../invert_slip.py --impulses=output/greensfns-fault.h5 --responses=output/greensfns-points.h5 --data=output/eqsim-points.h5 --penalty=penalty_params.txt --output=output/slip_inverted.txt

  This will generate a set of predicted slip values, contained in
  output/slip_inverted.txt.


Step 4.  Plot the true and predicted slip values (**requires matplotlib**).

  The python script, plot_invresults.py, compares the inversion with the
  forward simulation.  If you have matplotlib installed, you can run
  this script by typing:

    ./plot_invresults.py --solution=output/eqsim-fault.h5 --predicted=output/slip_inverted.txt

  This will display a matplotlib window with the true solution in
  black and the predicted solution corresponding to different values
  of the penalty parameter.


Suggestions variations

  The list below includes some suggested modifications to the problem
  that will allow you to become more familiar with PyLith while
  examining some interesting physics.

  * Create a spatial variation in material properties. For example you
    might create a velocity contrast across the fault.

  * Adjust the slip distribution.

  * Adjust the location and number of the observation points.

  * Increase/decrease the resolution of the mesh.

  * Try a different penalty function for the inversion. One simple option
     would be a 1D Laplacian approximation (sets of values of [1, -2, 1])
     centered along the diagonal.

