# Software

We provide two different codes for download: WPP and SW4. Both codes solve the seismic wave equations in displacement formulation using a node based finite difference approach, satisfying the principle of summation by parts. This principle guarantees energy stability of the numerical solution. Both codes use a distributed memory programming model that is implemented with the MPI library. The major difference between WPP and SW4 lies in the accuracy of the underlying numerical method. SW4 implements a fourth order accurate method in space and time [SP-12a], while WPP uses a second order accurate technique. As long as the solution is well-resolved on the computational mesh, SW4 should be significantly more efficient than WPP. This is because a coarser grid can be used to capture waves with the same frequency content. Compared to a second order accurate method, the advantages of a fourth order method are more pronounced when the solution needs to be more accurate. This is because the error diminishes at a faster rate as the grid size is reduced. A fourth order method is also more efficient when the solution needs to remain accurate for longer times, because the phase error grows at a slower rate in a higher order numerical method. Keeping the phase error small is, for example, important to accurately predict the arrival times of waves that have propagated over many wave lengths. The fourth order method is also significantly more accurate for calculating surface waves, in particular when the ratio between the compressional and shear wave speeds is large, i.e. Cp/Cs ≫ 1, see [KP-12].

## SW4

SW4 (Seismic Waves, 4th order) implements substantial capabilities for 3-D seismic modeling, with a free surface condition on the top boundary, absorbing super-grid conditions on the far-field boundaries [PS-13], and an arbitrary number of point force and/or point moment tensor source terms. Each source time function can have one of many predefined analytical time dependencies, or interpolate a user defined discrete time series. Complex rupture mechanisms can be described with the SRF file format. SW4 supports a fully 3-D heterogeneous material model that can be specified in several formats. It uses a curvilinear mesh near the free surface to honor the free surface boundary condition on a realistic topography. The curvilinear mesh is automatically generated from the description of the topography. To make SW4 more computationally efficient, the seismic wave equations are discretized on a Cartesian mesh below the curvilinear grid. The Cartesian mesh, which extends to the bottom of the computational domain, is also generated automatically.

SW4 solves the seismic wave equations in Cartesian coordinates. It is therefore appropriate for regional simulations, where the curvature of the earth can be neglected. Locations can be specified directly in Cartesian coordinates, or through geographic (latitude, longitude) coordinates. SW4 can be built to use the Proj.4 library for calculating the mapping between geographic and Cartesian coordinates, or use an approximate spheroidal mapping. SW4 can output synthetic seismograms in an ASCII text format, or in the SAC format. It can also present simulation information as GMT scripts, which can be used to create annotated maps. Furthermore, SW4 can output the solution as well as the material model along 2-D grid planes or 3-D volumes.

Visco-elastic behavior can be important when modeling the dissipative nature of realistic materials, especially for higher frequencies. SW4 uses the rheological model of standard linear solid (SLS) elements, coupled in parallel. The coefficients in each SLS are determined such that the resulting quality factors Qp and Qs, for the attenuation of P- and S-waves, become approximately constant as function of frequency. These quality factors can vary from grid point to grid point over the computational domain and are read in the same way as the elastic properties of the material model. The numerical method for solving the visco-elastic wave equation is based on the technique described in [PS-12].

SW4 implements Cartesian local mesh refinement. This feature allows the computational mesh to be made finer near the free surface, where more resolution often is needed to resolve short wave lengths in the solution, for example in sedimentary basins. The mesh refinement is performed in the vertical direction and each Cartesian grid is constructed based on user specified refinement levels. In this approach, the grid size in all three spatial directions is doubled across each mesh refinement interface, leading to substantial savings in memory and computational effort. The energy conserving mesh refinement coupling method described in [PS-10] is used to handle the hanging nodes along the refinement interface.

While most of the SW4 code is written in C++, almost all numerical computations are implemented in Fortan-77. Compatible versions of the C++ and Fortran-77 compilers as well as the MPI library must therefore be available to build the code. We have built and tested SW4 on a variety of machines, ranging from single processor laptops to large super-computers with O(10, 000) cores.

With the exception of some minor details, the syntax of the SW4 command file is the same as in WPP. Most of the input and output files also use the same formats, but we have taken the opportunity to improve the image file format. With the exception of mesh refinement, SW4 supports most of the functionality of WPP, version 2.2. Compared to version 1.0 of SW4, the main improvement in version 1.1 is the rfile command for setting up the material model. Similar to efiles, the rfile command reads the material properties from a binary file that supports a hierarchical data structure, allowing the material model to be represented at a higher resolution near the surface of the earth. Compared to efiles, the rfiles are more straight forward to generate, use linear interpolation to define the material properties between the data points, and can be read in parallel (if a parallel file system is available). We also support automatic byte-swapping to account for big/little endian byte ordering. Reading rfiles has been shown to work well on very large parallel machines (tested on up to 131,072 cores). Furthermore, SW4 provides limited support for modeling wave propagation in general anisotropic materials, described by a 21 parameter stiffness tensor.

SW4 is distributed by the Computational Infrastructure for Geodynamics (CIG): https://geodynamics.org/cig/software/

### SW4 Version 1.19 Software and Guide is now available

## WPP

WPP (Wave Propagation Program) is the predecessor of SW4. It discretizes the seismic wave equations using a second order accurate numerical method that satisfies the principle of summation by parts, [NPSK-07].