Skip to main content
Geosciences LibreTexts

2.4: Erosion Profile Jupyter Notebook

  • Page ID
    11353
  • Instructions

    • To use this page, read the text between each of the python code windows, then press RUN to execute the code in the box.
    • It is necessary to run each of the boxes in order.
    • Don't click restart in the cells unless you come back to the top of the page and start over.
    • If you modify the code, this modification will not remain after you leave or refresh this page.
    • You must run simulations/cells that require user input to completion. Make sure you see the Message informing you a cell is complete before continuing to the next cell. Here's why you must do this:
      • These cells may not be re-run until the simulation is completed, otherwise no output will be generated.
      • All following cells will not run until the user input cell is completed.
    • For Dropdown Menus: You do not need to rerun the cells with the menu to change your selection. However, you must rerun all of the following cells to implement the change.

    Be patient, some times it can take 1-2 minutes for the juypter kernel to start.

    An interactive example of how to calculate and plot the fault scarp erosion application of diffusion. A fault scarp is an offset in topography created when there is near vertical relative motion on a fault at the surface. Land on one side of the fault ends up higher in elevation, and the other side is lower, creating a step-like appearance. The change in height of the scarp due to erosion over time can be approximated with a diffusion profile, as demonstrated in 2.2: Geological Applications of the Diffusion Equation.

    Key Questions: Consider these as you work your way through this page.

    • How does the geomorphology (shape) of the fault scarp change over time?
    • Why is the fault scarp changing in this way? Be able to explain how this process works.
    • What role does the diffusion coefficient play in this process?

    First, we import the necessary packages:

    import matplotlib.pyplot as plt
    import numpy as np
    from scipy.special import erf
    
    print('Packages are imported, move on to the next cell.')

    Next lets set our parameters, and define a function to calculate the diffusion equation. a is 1/2 of the scarp height at time = 0. b is the overall background slope. x is the horizontal distance from the fault that will be considered. kappa is the diffusion coefficient, and t is a range of times that we will consider. t0 is the initial time. The next few lines define a function that will calculate the height of the scarp given a, b, kappa, x, and t using the equation derived in 2.2: Geological Applications of the Diffusion Equation. H is the height of the scarp at time = t.

    a = 0.25 # m
    b = 1/1000 # m / km
    x = np.arange(-50,51,.5) # m
    t = np.logspace(-1,3.5,7) # kyr
    kappa = 0.5 # m^2 / kyr
    t0 = 0.0001 # kyr, this cannot be 0 because then we would get a 0 in the denominator of the diffusion equation below
    
    def erosion(a,b,kappa,x,t):
        H = ((a*(erf(x/(2*np.sqrt(kappa * t))))) + (b*x)) # m
        return H
    
    print('The parameters and function are defined, move on to the next cell.')

    The first thing this cell does is call the above function to determine the initial height of the scarp at the initial time, this is assigned to the variable H0. The rest of this cell sets up a graph to show how the height of the scarp changes over time. H0 is plotted each time as a dashed line for reference. H_current is the height of the scarp at time t_current, using the function above. This line is updated each time through the for loop to create the simulation. Once you run the cell, press enter or return to move through the simulation.

    H0 = erosion(a,b,kappa,x,t0) #m
    # Create a named display
    handle = display(None, display_id=True)
    
    y= np.zeros(len(x)) 
    
    bbox = dict(boxstyle ="round", fc = '1') 
    fig, ax = plt.subplots(figsize = (7,5))
    line, = ax.plot(x,y,color='blue',label = 'Current')
    ax.set_ylim(-.4,.4)
    ax.plot(x,H0,color = 'black',linestyle = 'dashed',label = 'Original')
    ax.set_xlabel('Distance from Fault (m)') 
    ax.set_ylabel('Height (m)') 
    ax.grid('True') 
    
    ax.set_title('Fault Scarp Erosion - Time Variation')
    ax.legend()
    for t_current in t:
        print('Now Plotting:', round(t_current,1), 'kyr')
        H_current = erosion(a,b,kappa,x,t_current) #m
        line.set_ydata(H_current) 
        annotation = ax.annotate('Time = ' + str(round(t_current,1)) + ' kyr',(-40,0.13),bbox=bbox,color = 'blue',fontsize = 12)
        handle.update(fig)
        if t_current == t[0]:
          print('Click enter or return to continue: ')
        wait = input()
        annotation.remove()
    plt.close()
    
    print('The simulation is complete.')

    The next cell defines new parameters in order to consider the role of the diffusion coefficient in this process. Instead of initial time, we need an initial diffusion coefficient, kappa_0. t1 is the single instance in time that we will be considering for this simulation. The initial height, H0 must be recalculated using kappa_0 and t1. The rest of the code sets up the graph and runs the simulation. Enter typical diffusion coefficient values between: \(0.5-1.0 \frac{m^2}{kyr}\).

    kappa_0 = 0.5 # m^2 / kyr
    t1 = 251 #kyr
    H0 = erosion(a,b,kappa_0,x,t1) # m
    # Create a named display
    handle = display(None, display_id=True)
    
    y = np.zeros(len(x))
    
    bbox = dict(boxstyle ="round", fc = '1') 
    fig, ax = plt.subplots(figsize = (7,5))
    line, = ax.plot(x,y,color='blue',label = 'Current')
    ax.set_ylim(-.4,.4)
    ax.plot(x,H0,color = 'black',linestyle = 'dashed',label = 'Reference: $ \kappa $ = 0.5 $ m^2/kyr $')
    ax.set_xlabel('Distance from Fault (m)') 
    ax.set_ylabel('Height (m)') 
    ax.grid('True') 
    
    ax.set_title('Fault Scarp Erosion - Diffusion Coefficient Variation')
    ax.legend()
    print('Enter a Diffusion Coefficient between 0.5 and 1 (m^2/kyr)')
    kappa_current = float(input())
    while kappa_current >= 0.5 and kappa_current <= 1.0:
        print('Now Plotting:', kappa_current, 'm^2/kyr')
        H_current = erosion(a,b,kappa_current,x,t1) #m
        line.set_ydata(H_current)
        annotation = ax.annotate('Diffusion Coefficient = ' + str(round(kappa_current,1)) + ' $ m^2/kyr $',(-10,-0.21),bbox=bbox,color = 'blue',fontsize = 12)
        handle.update(fig)
        annotation.remove()
        print('You can end the simulation when you\'re ready by entering a NUMBER outside the range in the box')
        print('Enter a Diffusion Coefficient between 0.5 and 1 (m^2/kyr)')
        kappa_current = float(input())
    plt.close()
    
    print('The simulation is complete.')

    Using the figures above, how would you answer the key questions:

    • How does the geomorphology (shape) of the fault scarp change over time?
    • Why is the fault scarp changing in this way? Be able to explain how this process works.
    • What role does the diffusion coefficient play in this process?