n_elements = 2
mu = np.array([3e10])
nu = np.array([0.25])
elements = []
element = {}
L = 10000
# x1, y1, x2, y2 = bem2d.discretized_line(-L, 0, L, 0, n_elements)
x1, y1, x2, y2 = bem2d.discretized_line(-L, -L, L, L, n_elements)

for i in range(0, x1.size):
    element["x1"] = x1[i]
    element["y1"] = y1[i]
    element["x2"] = x2[i]
    element["y2"] = y2[i]
    elements.append(element.copy())
elements = bem2d.standardize_elements(elements)

# Observation coordinates for far-field calculation
n_pts = 100
width = 20000
x = np.linspace(-width, width, n_pts)
y = np.linspace(-width, width, n_pts)
x, y = np.meshgrid(x, y)
x = x.flatten()
y = y.flatten()

# Just a simple forward model for the volume
displacement_constant_slip = np.zeros((2, x.size))
stress_constant_slip = np.zeros((3, x.size))
displacement_quadratic = np.zeros((2, x.size))
stress_quadratic = np.zeros((3, x.size))
Beispiel #2
0
def test_constant_vs_quadratic_tensile_slip():
    """ Compare constant and quadratic slip elements"""
    n_elements = 1
    mu = np.array([3e10])
    nu = np.array([0.25])
    elements = []
    element = {}
    L = 10000
    x1, y1, x2, y2 = bem2d.discretized_line(-L, 0, L, 0, n_elements)

    for i in range(0, x1.size):
        element["x1"] = x1[i]
        element["y1"] = y1[i]
        element["x2"] = x2[i]
        element["y2"] = y2[i]
        elements.append(element.copy())
    elements = bem2d.standardize_elements(elements)

    # Observation coordinates for far-field calculation
    n_pts = 100
    width = 20000
    x = np.linspace(-width, width, n_pts)
    y = np.linspace(-width, width, n_pts)
    x, y = np.meshgrid(x, y)
    x = x.flatten()
    y = y.flatten()

    # Just a simple forward model for the volume
    displacement_constant_slip = np.zeros((2, x.size))
    stress_constant_slip = np.zeros((3, x.size))
    displacement_quadratic_slip = np.zeros((2, x.size))
    stress_quadratic_slip = np.zeros((3, x.size))

    for i, element in enumerate(elements):
        displacement, stress = bem2d.displacements_stresses_constant_linear(
            x,
            y,
            element["half_length"],
            mu,
            nu,
            "constant",
            "slip",
            0,
            1,
            element["x_center"],
            element["y_center"],
            element["rotation_matrix"],
            element["inverse_rotation_matrix"],
        )
        displacement_constant_slip += displacement
        stress_constant_slip += stress

    for element in elements:
        quadratic_coefficients = np.array(
            [1, 1, 1])  # constant slip quadratic element
        displacement, stress = bem2d.displacements_stresses_quadratic_farfield_coefficients(
            quadratic_coefficients,
            x,
            y,
            element["half_length"],
            mu,
            nu,
            "slip",
            0,
            1,
            element["x_center"],
            element["y_center"],
            element["rotation_matrix"],
            element["inverse_rotation_matrix"],
        )
        displacement_quadratic_slip += displacement
        stress_quadratic_slip += stress

    np.testing.assert_almost_equal(displacement_constant_slip,
                                   displacement_quadratic_slip)
    np.testing.assert_almost_equal(stress_constant_slip,
                                   stress_quadratic_slip,
                                   decimal=1)
elements_surface = []
elements_fault = []
element = {}

# Create topographic free surface elements
x1, y1, x2, y2 = bem2d.discretized_line(-10e3, 0, 10e3, 0, 60)
y1 = -1e3 * np.arctan(x1 / 1e3)
y2 = -1e3 * np.arctan(x2 / 1e3)
for i in range(0, x1.size):
    element["x1"] = x1[i]
    element["y1"] = y1[i]
    element["x2"] = x2[i]
    element["y2"] = y2[i]
    element["name"] = "surface"
    elements_surface.append(element.copy())
elements_surface = bem2d.standardize_elements(elements_surface)

# Create constant slip curved fault
x1, y1, x2, y2 = bem2d.discretized_line(-7e3, 0e3, 0, 0, 30)
y1 = 3e3 * np.arctan(x1 / 1e3)
y2 = 3e3 * np.arctan(x2 / 1e3)
for i in range(0, x1.size):
    element["x1"] = x1[i]
    element["y1"] = y1[i]
    element["x2"] = x2[i]
    element["y2"] = y2[i]
    element["name"] = "fault"
    # element["ux_local"] = 1  # strike-slip forcing
    # element["uy_local"] = 0  # tensile-forcing
    element["ux_global_quadratic"] = np.array([1, 1, 1])  # strike-slip forcing
    element["uy_global_quadratic"] = np.array([0, 0, 0])  # tensile-forcing
# Modify y1, and y2 for a sinusoidal fault
amplitude = 0.0
y1 = amplitude * np.sin(2 * np.pi * x1 / L)
y2 = amplitude * np.sin(2 * np.pi * x2 / L)

for i in range(0, x1.size):
    ELEMENT["x1"] = x1[i]
    ELEMENT["y1"] = y1[i]
    ELEMENT["x2"] = x2[i]
    ELEMENT["y2"] = y2[i]
    ELEMENT["a"] = 0.015  # frictional a parameter ()
    ELEMENT["b"] = 0.020  # frictional b parameter ()
    ELEMENT["sigma_n"] = 50e6  # normal stress (Pa)
    ELEMENTS_FAULT.append(ELEMENT.copy())
ELEMENTS_FAULT = bem2d.standardize_elements(ELEMENTS_FAULT)

# Extract parameters for later use as arrays
ELEMENTS_FAULT_ARRAYS = {}
ELEMENTS_FAULT_ARRAYS["a"] = np.array(
    [np.tile(_["a"], 3) for _ in ELEMENTS_FAULT]).flatten()
ELEMENTS_FAULT_ARRAYS["b"] = np.array(
    [np.tile(_["b"], 3) for _ in ELEMENTS_FAULT]).flatten()
ELEMENTS_FAULT_ARRAYS["additional_normal_stress"] = np.array(
    [np.tile(_["sigma_n"], 3) for _ in ELEMENTS_FAULT]).flatten()
ELEMENTS_FAULT_ARRAYS["element_normals"] = np.empty((N_ELEMENTS, 2))
ELEMENTS_FAULT_ARRAYS["element_normals"][:, 0] = np.array(
    [_["x_normal"] for _ in ELEMENTS_FAULT]).flatten()
ELEMENTS_FAULT_ARRAYS["element_normals"][:, 1] = np.array(
    [_["y_normal"] for _ in ELEMENTS_FAULT]).flatten()
# TODO: Try rupture problem with variations in a-b.  Do I have to pass elements_* dict to do this?

elements_fault = []
element = {}
L = 10000
mu = 3e10
nu = 0.25
x1, y1, x2, y2 = bem2d.discretized_line(-L, 0, L, 0, 50)

for i in range(0, x1.size):
    element["x1"] = x1[i]
    element["y1"] = y1[i]
    element["x2"] = x2[i]
    element["y2"] = y2[i]
    elements_fault.append(element.copy())
elements_fault = bem2d.standardize_elements(elements_fault)
n_elements = len(elements_fault)

# Constant slip partial derivatives
slip_to_displacement, slip_to_traction = bem2d.constant_linear_partials(
    elements_fault, elements_fault, "slip", mu, nu)

# Quadratic slip partial derivative
slip_to_displacement_quadratic, slip_to_stress_quadratic, slip_to_traction_quadratic = bem2d.quadratic_partials_all(
    elements_fault, elements_fault, mu, nu)

sm = 3e10  # Shear modulus (Pa)
density = 2700  # rock density (kg/m^3)
cs = np.sqrt(sm / density)  # Shear wave speed (m/s)
eta = sm / (2 * cs)  # The radiation damping coefficient (kg / (m^2 * s))
Vp = 1e-9  # Rate of plate motion