seisflows.examples.sfexample2d

SEISFLOWS SPECFEM2D WORKSTATION EXAMPLE 1

This example will run two iterations of an inversion to assess misfit between a homogeneous halfspace model and a slightly perturbed homogeneous halfspace model using 3 events and 1 receiver.

Note

You can change the number of events (NTASK) and iterations (NITER) by changing the constants below the import statements

Warning

Because we are using 3 events and only 1 receiver, the results of this inversion will be of questionable quality. This example is only meant to highlight how SeisFlows operates during an inversion workflow.

Note

The tasks involved include: 1. Download, configure and compile SPECFEM2D 2. Set up a SPECFEM2D working directory 3. Generate starting model from Tape2007 example 4. Generate target model w/ perturbed starting model 5. Set up a SeisFlows working directory 6. Run two iterations of an inversion workflow

$ seisflows examples run 1

Module Contents

Classes

SFExample2D

A class for running SeisFlows examples. Simplifies calls structure so that

class seisflows.examples.sfexample2d.SFExample2D(ntask=None, event_id=None, niter=None, nsta=None, nproc=None, method='run', specfem2d_repo=None, with_mpi=False, mpiexec='mpirun', **kwargs)

A class for running SeisFlows examples. Simplifies calls structure so that multiple example runs can benefit from the code written here

print_dialogue()

Print help/system dialogue message that explains the setup of th this workflow

_check_mpi_executable()

If User wants to run examples with MPI, checks that MPI executable is available and can be used to run solver. Sometimes if we don’t ‘$ module load mpi’, we will get ‘mpirun: command not found’

static define_dir_structures(cwd, specfem2d_repo, ex='Tape2007')

Define the example directory structure, which will contain abridged versions of the SPECFEM2D working directory

Parameters
  • cwd (str) – current working directory

  • specfem2d_repo (str) – location of the SPECFEM2D repository

download_specfem2d()

Download the latest version of SPECFEM2D from GitHub, devel branch. Last successfully tested 4/28/22

configure_specfem2d()

Run ./configure within the SPECFEM2D repo directory. This function assumes it is being run from inside the repo. Should guess all the configuration options. Probably the least stable part of the example

make_specfem2d_executables()

Run $ make all in SPECFEM2D to create binary executables

create_specfem2d_working_directory()

Create the working directory where we will generate our initial and final models using one of the SPECFEM2D examples

setup_specfem2d_for_model_init()

Make some adjustments to the original parameter file to. This function assumes it is running from inside the SPECFEM2D/DATA dir

setup_specfem2d_for_model_true()

Make some adjustments to the parameter file to create the final velocity model. This function assumes it is running from inside the SPECFEM2D/DATA directory

run_xspecfem2d_binaries()

Runs the xmeshfem2d and then xspecfem2d binaries using subprocess and then do some cleanup to get files in the correct locations. Runs either with ‘./’ or with mpiexec

cleanup_xspecfem2d_run(choice=None)

Do some cleanup after running the SPECFEM2D binaries to make sure files are in the correct locations, and rename the OUTPUT_FILES directory so that it does not get overwritten by subsequent runs

Parameters

choice (str) – Rename the OUTPUT_FILES directory with a suffix tag msut be ‘INIT’ or ‘TRUE’. If None, will not rename but the

setup_seisflows_working_directory()

Create and set the SeisFlows parameter file, making sure all required parameters are set correctly for this example problem

finalize_specfem2d_par_file()

Final changes to the SPECFEM2D Par_file before running SeisFlows. Par_file will be used to control all the child specfem2d directories. Need to tell them to read models from .bin files, and to use existing station files rather than create them from the Par_file

run_sf_example()

Use subprocess to run the SeisFlows example we just set up

main()

Setup the example and then optionally run the actual seisflows workflow