adjtomo / seisflows

An automated workflow tool for full waveform inversion and adjoint tomography
http://seisflows.readthedocs.org
BSD 2-Clause "Simplified" License
183 stars 124 forks source link

Implement solver support for SPECFEM++ #217

Open bch0w opened 5 months ago

bch0w commented 5 months ago

SPECFEM++ developer @Rohit-Kakodkar and I agreed it would be great for the community to build in SeisFlows support for SPECFEM++, to handle workflow management for forward and adjoint simulations (and eventually inversions!).

SPECFEM++ works slightly differently than the Fortran version of the code (e.g., YAML parameter file, different source setups) and will likely need an entirely new Solver base class. Likely some minor reworking of the SeisFlows archicture will be needed as well to accommodate these changes. This will be a great first step into incorporating other numerical solvers into the SeisFlows codebase, which until now has only worked with different flavors of Fortran-based SPECFEM.

Putting this issue here as a tracker for progress on this front.

bch0w commented 3 weeks ago

Hi @Rohit-Kakodkarm here is a broad-strokes outline of what I think needs to be done to implement SPECFEM++ in SeisFlows. I'll use the terms 'specfemft' to refer to the Fortran version, and 'specfempp' to refer to SPECFEM++.

Our first goal should be to run a forward simulation (https://github.com/adjtomo/seisflows/blob/devel/seisflows/workflow/forward.py) with SeisFlows controlling SPECFEM++ under the hood. From there we can build to adjoint simulations, etc.

In the main workflow classes of SeisFlows, specfemft (2d, 3d and 3d_globe) is generalized as solver so we will need to make sure that a newly written specfempp solver class contains all the same generic functions that are expected of the solver class.

  1. Solver class: We'll need to follow some of the structure laid out in the current specfemft version (https://github.com/adjtomo/seisflows/blob/devel/seisflows/solver/specfem.py)
  1. Tool module: specfemft has a number of helper functions for e.g., navigating a specfemft working directory, getting/setting parameter file parameters (https://github.com/adjtomo/seisflows/blob/devel/seisflows/tools/specfem.py).
  1. Model class: SeisFlows currently works with specfemft Fortran binary models by interacting with them through the Model class, which stores an internal NumPy representation of a distributed model.
  1. Examples: Once we get the core functionality working, we can think about setting up an example following something like: https://github.com/adjtomo/seisflows/blob/feature-specfempp/seisflows/examples/sfexample2d.py