# Step 5: Static Coseismic Slip
This example involves a static simulation that solves for the deformation from prescribed coseismic slip on the main fault.
We specify 2 meters of reverse slip.
{numref}`fig:example:reverse:2d:step05:diagram` shows the boundary conditions on the domain.
:::{figure-md} fig:example:reverse:2d:step05:diagram
Boundary conditions for static coseismic slip on the main fault.
We prescribe 2 meters of reverse slip with roller boundary conditions on the lateral sides and bottom of the domain.
:::
:::{important}
In 2D simulations slip is specified in terms of opening and left-lateral components.
This provides a consistent, unique sense of slip that is independent of the fault orientation.
For our geometry in this example, right lateral slip corresponds to reverse slip on the dipping fault.
:::
:::{important}
The main fault contains one end that is buried within the domain.
When PyLith inserts cohesive cells into a mesh with buried edges (in this case a point), we must identify these buried edges so that PyLith properly adjusts the topology along these edges.
:::
% Metadata extracted from parameter files.
```{include} step05a_onefault-synopsis.md
```
## Step 5a: Coarse Mesh
:::{note}
*New in v4.1.0.*
We start with a coarse resolution mesh that captures the geometry and increase the resolution of the simulation by using uniform refinement or increasing the basis order of the solution fields.
We also introduce different origin times for the coseismic slip on the two faults.
:::
### Simulation parameters
The parameters specific to this example are in `step05a_onefault.cfg`.
We adjust the solution field to include both displacement and the Lagrange multiplier associated with the fault.
For uniform prescribed slip we use a `UniformDB`.
```{code-block} cfg
---
caption: Parameters for earthquake rupture on the main reverse fault in Step 5a.
---
[pylithapp.problem]
solution = pylith.problems.SolnDispLagrange
[pylithapp.problem.interfaces.fault]
label = fault
label_value = 20
edge = fault_end
edge_value = 21
observers.observer.data_fields = [slip, traction_change]
[pylithapp.problem.interfaces.fault.eq_ruptures.rupture]
db_auxiliary_field = spatialdata.spatialdb.UniformDB
db_auxiliary_field.description = Fault rupture auxiliary field spatial database
db_auxiliary_field.values = [initiation_time, final_slip_left_lateral, final_slip_opening]
db_auxiliary_field.data = [0.0*s, -2.0*m, 0.0*m]
```
### Running the simulation
```{code-block} console
---
caption: Run Step 5a simulation
---
$ pylith step05a_onefault.cfg
# The output should look something like the following.
>> software/pylith-debug/lib/python3.12/site-packages/pylith/apps/PyLithApp.py:79:main
-- info (application-flow)
-- Running on 1 process(es).
# -- many lines omitted --
>> src/cig/pylith/libsrc/pylith/problems/TimeDependent.cc:473:void pylith::problems::TimeDependent::solve()
-- info (application-flow)
-- Component 'timedependent.problem': Solving equations.
0 TS dt 0.001 time 0.
0 SNES Function norm 6.455846400259e+00
Linear solve converged due to CONVERGED_ATOL iterations 10
1 SNES Function norm 3.254498049626e-08
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
1 TS dt 0.001 time 0.001
>> software/pylith-debug/lib/python3.12/site-packages/pylith/problems/Problem.py:222:finalize
-- info (application-flow)
-- Finalizing problem.
```
From the end of the output written to the terminal window, we see that the linear solver converged in 10 iterations and met the absolute convergence tolerance (`ksp_atol`).
As we expect for this linear problem, the nonlinear solver converged in 1 iteration.
### Visualizing the results
In {numref}`fig:example:reverse:2d:step05a:solution` and {numref}`fig:example:reverse:2d:step05a:stress` we use the `pylith_viz` utility to visualize the simulation results.
```{code-block} console
---
caption: Visualize PyLith output using `pylith_viz`.
---
pylith_viz --filename=output/step05a_onefault-domain.h5 warp_grid --component=x --exaggeration=3000
pylith_viz --filenames=output/step05a_onefault-crust.h5,output/step05a_onefault-wedge.h5,output/step05a_onefault-slab.h5 warp_grid --field=cauchy_stress --component=xy --exaggeration=3000
```
:::{figure-md} fig:example:reverse:2d:step05a:solution
Solution for Step 5a.
The colors of the shaded surface indicate the x displacement, and the deformation is exaggerated by a factor of 3000.
The undeformed configuration is shown by the gray wireframe.
:::
:::{figure-md} fig:example:reverse:2d:step05a:stress
Cauchy stress tensor component xy for Step 5a.
The colors of the shaded surface indicate the xy component of the Cauchy stress tensor, and the deformation is exaggerated by a factor of 3000.
The undeformed configuration is shown by the gray wireframe.
With uniform slip on the fault, we generate a stress concentration at the buried end of the fault that is confined to just one or two cells.
Thus, the stress concentration is not well resolved.
:::
## Step 5b: Coarse Mesh
As in some of the previous steps in this example, we refine the mesh to improve the accuracy of the results.
The parameters specific to this example are in `step05b_onefault.cfg`.
### Simulation parameters
We adjust the solution field to include both displacement and the Lagrange multiplier associated with the fault.
For uniform prescribed slip we use a `UniformDB`.
```{code-block} cfg
---
caption: Mesh refinement parameters for Step 5b.
---
[pylithapp.problem.mesh_initializer.phases.refine_mesh]
refiner = pylith.topology.RefineUniform
```
### Running the simulation
```{code-block} console
---
caption: Run Step 5b simulation
---
$ pylith step05b_onefault.cfg
# The output should look very similar to Step 5a.
```
### Visualizing the results
In {numref}`fig:example:reverse:2d:step05b:solution` and {numref}`fig:example:reverse:2d:step05b:stress` we use the `pylith_viz` utility to visualize the simulation results.
```{code-block} console
---
caption: Visualize PyLith output using `pylith_viz`.
---
pylith_viz --filename=output/step05b_onefault-domain.h5 warp_grid --component=x --exaggeration=3000
pylith_viz --filenames=output/step05b_onefault-crust.h5,output/step05b_onefault-wedge.h5,output/step05b_onefault-slab.h5 warp_grid --field=cauchy_stress --component=xy --exaggeration=3000
```
:::{figure-md} fig:example:reverse:2d:step05b:solution
Solution for Step 5b.
The colors of the shaded surface indicate the x displacement, and the deformation is exaggerated by a factor of 3000.
The undeformed configuration is shown by the gray wireframe.
:::
:::{figure-md} fig:example:reverse:2d:step05b:stress
Cauchy stress tensor component xy for Step 5b.
The colors of the shaded surface indicate the xy component of the Cauchy stress tensor, and the deformation is exaggerated by a factor of 3000.
The undeformed configuration is shown by the gray wireframe.
Refining the mesh shows the stress concentration at the buried end of the fault is smaller in spatial extent than we observed in Step 5a.
We need a higher resolution mesh to resolve the stress concentration.
:::
## Step 5c: Coarse Mesh
We now use higher order discretization to try to better resolve the stress concentration.
The parameters specific to this example are in `step05c_onefault.cfg`.
### Simulation parameters
We adjust the solution field to include both displacement and the Lagrange multiplier associated with the fault.
For uniform prescribed slip we use a `UniformDB`.
```{code-block} cfg
---
caption: Parameters for using higher order discretization in Step 5c.
---
[pylithapp.problem]
defaults.quadrature_order = 2
[pylithapp.problem.solution.subfields]
displacement.basis_order = 2
lagrange_multiplier_fault.basis_order = 2
[pylithapp.problem.materials.slab]
derived_subfields.cauchy_strain.basis_order = 1
derived_subfields.cauchy_stress.basis_order = 1
[pylithapp.problem.materials.crust]
derived_subfields.cauchy_strain.basis_order = 1
derived_subfields.cauchy_stress.basis_order = 1
[pylithapp.problem.materials.wedge]
derived_subfields.cauchy_strain.basis_order = 1
derived_subfields.cauchy_stress.basis_order = 1
```
### Running the simulation
```{code-block} console
---
caption: Run Step 5c simulation
---
$ pylith step05c_onefault.cfg
# The output should look very similar to Steps 5a and 5b.
```
### Visualizing the results
In {numref}`fig:example:reverse:2d:step05c:solution` and {numref}`fig:example:reverse:2d:step05c:stress` we use the `pylith_viz` utility to visualize the simulation results.
```{code-block} console
---
caption: Visualize PyLith output using `pylith_viz`.
---
pylith_viz --filename=output/step05c_onefault-domain.h5 warp_grid --component=x --exaggeration=3000
pylith_viz --filenames=output/step05c_onefault-crust.h5,output/step05c_onefault-wedge.h5,output/step05c_onefault-slab.h5 warp_grid --field=cauchy_stress --component=xy --exaggeration=3000
```
:::{figure-md} fig:example:reverse:2d:step05c:solution
Solution for Step 5c.
The colors of the shaded surface indicate the x displacement, and the deformation is exaggerated by a factor of 3000.
The undeformed configuration is shown by the gray wireframe.
:::
:::{figure-md} fig:example:reverse:2d:step05c:stress
Cauchy stress tensor component xy for Step 5c.
The colors of the shaded surface indicate the xy component of the Cauchy stress tensor, and the deformation is exaggerated by a factor of 3000.
The undeformed configuration is shown by the gray wireframe.
With the higher order discretization of the solution subfields, we find better resolution of the stress concentration, which is now spread across a few cells.
:::
## Key Points
1. The displacement field is very similar for the three different discretizations.
2. Uniform slip generates a stress concentration at the buried end of the fault.
3. This stress concentration is difficult to resolve with a basis order of 1 for the solution subfields, even if we refine the mesh.
4. Using a basis order of 2 provides better resolution of the stress concentration, but it is poorly resolved without also refining the mesh.
5. Adaptive mesh refinement (not yet available in PyLith) that refines the region just around the stress concentration would help resolve the stress concentration without substantially increasing the problem size.