Skip to content

Instantly share code, notes, and snippets.

@xaliphostes
Created March 1, 2024 10:16
Show Gist options
  • Select an option

  • Save xaliphostes/05f4dffe4bcc0783e3d039f0ee4b9480 to your computer and use it in GitHub Desktop.

Select an option

Save xaliphostes/05f4dffe4bcc0783e3d039f0ee4b9480 to your computer and use it in GitHub Desktop.

Revisions

  1. xaliphostes created this gist Mar 1, 2024.
    57 changes: 57 additions & 0 deletions fractures-cost.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    import math
    import matplotlib.pyplot as plt
    import random

    def costJoint(normal: tuple[float, float], S3: tuple[float, float]):
    return 1 - abs(normal[0]*S3[0] + normal[1]*S3[1])

    def costStylolite(normal: tuple[float, float], S3: tuple[float, float]):
    return 1 - costJoint(normal, S3)

    def deg2rad(angleInDeg: float) -> float:
    b = math.pi/180
    return angleInDeg * b

    # ------------------------------------------------------------------

    def plotRotateS3():
    x = []

    yj = []
    ys = []

    font = {'family': 'serif',
    'color': 'darkred',
    'weight': 'normal',
    'size': 16,
    }

    n = [0, 1]

    for angle in range(0, 91, 1):
    x.append(angle)
    S3 = [math.cos(deg2rad(angle)), math.sin(deg2rad(angle))]

    # Joint
    costJ = costJoint(n, S3)
    yj.append(costJ)

    # Stylolite
    costS = costStylolite(n, S3)
    ys.append(costS)

    # Code de matplotlib
    fig, ax = plt.subplots()
    ax.plot(x, yj, label='Joint')
    ax.plot(x, ys, label='Stylolite')
    ax.legend()
    ax.axvline(x=30, ymax=0.5, linewidth=1, color='black', linestyle=(0, (5, 5)))
    ax.set_xlim(0, 90)
    ax.set_ylim(0, 1)
    plt.title('Cost functions for a vertical fracture', fontdict=font)
    plt.xlabel('$\sigma_3$ orientation', fontdict=font)
    plt.ylabel('Cost', fontdict=font)
    plt.show()


    plotRotateS3()