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)
import bem2d from importlib import reload import bem2d import matplotlib.pyplot as plt bem2d = reload(bem2d) # List of elements for forward model 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)
PARAMETERS["density"]) # Shear wave speed (m/s) PARAMETERS["eta"] = PARAMETERS["mu"] / ( 2 * PARAMETERS["cs"]) # Radiation damping coefficient (kg / (m^2 * s)) PARAMETERS["d_c"] = 0.05 # state evolution length scale (m) PARAMETERS["f_0"] = 0.6 # baseline coefficient of friction PARAMETERS["block_velocity_x"] = 1e-9 PARAMETERS["block_velocity_y"] = 0 PARAMETERS["v_0"] = 1e-6 # reference velocity # Create fault elements N_ELEMENTS = 50 N_NODES = 3 * N_ELEMENTS ELEMENTS_FAULT = [] ELEMENT = {} L = 10000 x1, y1, x2, y2 = bem2d.discretized_line(-L, 0, L, 0, N_ELEMENTS) # 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())
bem2d = reload(bem2d) plt.close("all") PLOT_ELEMENTS = False # Material properties mu = 30e9 nu = 0.25 # Define elements 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)
import bem2d.newton_rate_state bem2d = reload(bem2d) plt.close("all") """ Taken from Ben's 1d example: http://tbenthompson.com/post/block_slider/ """ # TODO: Save information from rupture problem as .pkl/.npz # 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
nu = 0.25 n_pts = 102 width = 5 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() # Define elements elements_surface = [] elements_fault = [] element = {} # Traction free surface x1, y1, x2, y2 = bem2d.discretized_line(-5, 0, 5, 0, 20) 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) # Constant slip fault x1, y1, x2, y2 = bem2d.discretized_line(-1, -1, 0, 0, 1) for i in range(0, x1.size): element["x1"] = x1[i] element["y1"] = y1[i] element["x2"] = x2[i]
import bem2d import matplotlib.pyplot as plt bem2d = reload(bem2d) # Material and geometric constants plt.close("all") SLIP_TYPE = "tensile_slip" print(SLIP_TYPE) mu = 3e10 nu = 0.25 n_elements = 10 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) # Convert to dictionary of lists elements_DL = pd.DataFrame(elements).to_dict("list") # Convert back to list of dictionaries elements_LD = pd.DataFrame(elements_DL).to_dict("records") print(elements == elements_LD)