def test_wave_through_drained_linear_elastic_soil(self): """ Test dynamic calculation on a drained linear elastic soil column. a line load of -1kN is instantly placed on the soil column. The soil parameters are chosen such that after 0.002 seconds, the wave is reflected at the bottom of the geometry such that half the stress in the soil column is cancelled out. :return: """ test_name = 'test_1d_wave_prop_drained_soil.gid' file_path = test_helper.get_file_path(os.path.join('.', test_name)) simulation = test_helper.run_kratos(file_path) # get effective stress efective_stresses = test_helper.get_cauchy_stress_tensor(simulation) efective_stresses_yy = [ integration_point[1, 1] for element in efective_stresses for integration_point in element ] # get coordinates of the gauss points gauss_coordinates = test_helper.get_gauss_coordinates(simulation) gauss_coordinates_y = [ integration_point[1] for element in gauss_coordinates for integration_point in element ] # calculate the expected effective stress in the soil column expected_effective_stresses_yy = [ -1000 if gauss_coordinate_y >= -0.49 else 0 if gauss_coordinate_y <= -0.51 else -500 for gauss_coordinate_y in gauss_coordinates_y ] # calculate root mean square error square_errors = [ (efective_stress_yy - expected_effective_stresses_yy[idx])**2 for idx, efective_stress_yy in enumerate(efective_stresses_yy) ] rmse = (sum(square_errors) / len(square_errors))**0.5 # assert root mean square error, the allowable error is 10% of the applied load self.assertLess(rmse, 100)
def assert_linear_elastic_block(self, simulation, top_node_nbrs, n_dim): """ Assert results of a linear elastic block. The sides of the block can move freely in vertical direction and are fixed in horizontal direction. The bottom of the block is fixed. On top of the block, a load of 10kN/m2 is placed. Results are: total stresses, effective stresses, displacements and green langrange strains. :param simulation: Kratos simulation :param top_node_nbrs: node numbers of the nodes at the top of the geometry :param n_dim: number of dimensions :return: """ total_stresses = test_helper.get_total_stress_tensor(simulation) total_stresses_xx = [ integration_point[0, 0] for element in total_stresses for integration_point in element ] if n_dim >= 2: total_stresses_yy = [ integration_point[1, 1] for element in total_stresses for integration_point in element ] if n_dim >= 3: total_stresses_zz = [ integration_point[2, 2] for element in total_stresses for integration_point in element ] efective_stresses = test_helper.get_cauchy_stress_tensor(simulation) efective_stresses_xx = [ integration_point[0, 0] for element in efective_stresses for integration_point in element ] if n_dim >= 2: efective_stresses_yy = [ integration_point[1, 1] for element in efective_stresses for integration_point in element ] if n_dim >= 3: efective_stresses_zz = [ integration_point[2, 2] for element in efective_stresses for integration_point in element ] displacements = test_helper.get_displacement(simulation) x_displacements = [displacement[0] for displacement in displacements] if n_dim >= 2: y_displacements = [ displacement[1] for displacement in displacements ] if n_dim >= 3: z_displacements = [ displacement[2] for displacement in displacements ] green_lagrange_strains = test_helper.get_green_lagrange_strain_tensor( simulation) green_lagrange_strains_xx = [ integration_point[0, 0] for element in green_lagrange_strains for integration_point in element ] if n_dim == 2: green_lagrange_strains_yy = [ integration_point[1, 1] for element in green_lagrange_strains for integration_point in element ] elif n_dim == 3: green_lagrange_strains_yy = [ integration_point[1, 1] for element in green_lagrange_strains for integration_point in element ] green_lagrange_strains_zz = [ integration_point[2, 2] for element in green_lagrange_strains for integration_point in element ] # Assert integration point information for idx, total_stress_xx in enumerate(total_stresses_xx): self.assertAlmostEqual(0.0, total_stress_xx) self.assertAlmostEqual(-1e4, total_stresses_yy[idx]) if n_dim >= 3: self.assertAlmostEqual(0.0, total_stresses_zz[idx]) self.assertAlmostEqual(0.0, efective_stresses_xx[idx]) self.assertAlmostEqual(-1e4, efective_stresses_yy[idx]) if n_dim >= 3: self.assertAlmostEqual(0.0, efective_stresses_zz[idx]) self.assertAlmostEqual(0.0, green_lagrange_strains_xx[idx]) self.assertAlmostEqual(-0.00033333, green_lagrange_strains_yy[idx]) if n_dim >= 3: self.assertAlmostEqual(0.0, green_lagrange_strains_zz[idx]) # Assert displacements for x_displacement in x_displacements: self.assertAlmostEqual(0.0, x_displacement) for top_node_nbr in top_node_nbrs: self.assertAlmostEqual(-0.00033333, y_displacements[top_node_nbr], 6) if n_dim >= 3: for z_displacement in z_displacements: self.assertAlmostEqual(0.0, z_displacement)
def test_benchmark2_2(self): """ In this benchmark a two stage model is tested, where a simple clay dike is put on top of a sand layer. The test is calculated using gravity loading. And UMAT-Mohr-Coulomb This test compares minimum, maximum stress in the last stage. :return: """ test_name = os.path.join('Simple_Dike_Gravity_Loading', 'simple_dike_test_with_gravity_umat.gid') project_path = test_helper.get_file_path(os.path.join('.', test_name)) n_stages = 2 stages = test_helper.run_stages(project_path, n_stages) max_x_total_stress_plaxis = 0.0 min_x_total_stress_plaxis = -140430.9 max_y_total_stress_plaxis = -1377.6 min_y_total_stress_plaxis = -424253.415 cauchy_stresses_kratos = test_helper.get_cauchy_stress_tensor( stages[-1]) x_cauchy_stress_kratos = [[ gauss_point[0, 0] for gauss_point in element ] for element in cauchy_stresses_kratos] y_cauchy_stress_kratos = [[ gauss_point[1, 1] for gauss_point in element ] for element in cauchy_stresses_kratos] min_x_cauchy_stress_kratos, max_x_cauchy_stress_kratos = min( min(x_cauchy_stress_kratos)), max(max(x_cauchy_stress_kratos)) min_y_cauchy_stress_kratos, max_y_cauchy_stress_kratos = min( min(y_cauchy_stress_kratos)), max(max(y_cauchy_stress_kratos)) relative_precision_stress = 0.05 absolute_precision_stress = 1e3 self.assertAlmostEqual(max_x_total_stress_plaxis, max_x_cauchy_stress_kratos, delta=max( abs(max_x_total_stress_plaxis * relative_precision_stress), absolute_precision_stress)) self.assertAlmostEqual(min_x_total_stress_plaxis, min_x_cauchy_stress_kratos, delta=max( abs(min_x_total_stress_plaxis * relative_precision_stress), absolute_precision_stress)) self.assertAlmostEqual( max_y_total_stress_plaxis, max_y_cauchy_stress_kratos, delta=max(max_y_total_stress_plaxis * relative_precision_stress, absolute_precision_stress)) self.assertAlmostEqual(min_y_total_stress_plaxis, min_y_cauchy_stress_kratos, delta=max( abs(min_x_total_stress_plaxis * relative_precision_stress), absolute_precision_stress))
def test_benchmark1_3(self): """ smooth rigid strip footing on elastic soil :return: """ from analytical_solutions import rigid_footing import math # test_name = 'smoothrigidfootingonelasticsoil_2' file_path = test_helper.get_file_path( os.path.join('.', test_name + '.gid')) simulation = test_helper.run_kratos(file_path) cauchy_stress_tensor = test_helper.get_cauchy_stress_tensor(simulation) step_size = 0.005 B = 1 delta = 0.88 G = 500 nu = 0.333 settlement = 0.01 F = settlement * 2 * (1 + nu) * G / delta sigma_v = rigid_footing(0, B, delta, G, nu, settlement) print("sigma_v = " + str(sigma_v)) # x = [i * step_size for i in range(int(B / step_size) + 1)] xmid = [(x[i] + x[i + 1]) / 2 for i in range(len(x) - 1)] # sigma_v = [2 / math.pi * F / 2 / (B * math.sqrt(1 - (xi / B) ** 2)) for xi in xmid] model_part = simulation._list_of_output_processes[0].model_part elements = model_part.Elements distances = [] min_distance_elements = [] min_distance_idxs = [] for xi in xmid: min_distance = 10**10 min_distance_element = None for element_idx, element in enumerate(elements): nodes = element.GetNodes() #integration_points = element.GetIntegrationPoints() centroid = [0, 0, 0] centre_x = sum([node.X0 for node in nodes]) / len(nodes) centre_y = sum([node.X0 for node in nodes]) / len(nodes) centre_z = sum([node.X0 for node in nodes]) / len(nodes) centroid = [[centre_x[i], centre_y[i], centre_z[i]] for i in range(len(centre_x))] for node in nodes: centroid[0] = centroid[0] + node.X0 centroid[1] = centroid[1] + node.Y0 centroid[2] = centroid[2] + node.Z0 centroid = [x / len(nodes) for x in centroid] # for integration_point in integration_points: # distance = compute_distance(integration_point,[xi,0.0,0.0]) distance = test_helper.compute_distance( centroid, [xi, 0.0, 0.0]) if distance < min_distance: min_distance = distance min_distance_element = element min_distance_idx = element_idx min_distance_elements.append(min_distance_element) min_distance_idxs.append(min_distance_idx) distances.append(min_distance) cauchy_stresses_at_load = [ cauchy_stress_tensor[min_distance_idx] for min_distance_idx in min_distance_idxs ] reaction_force = [ (cauchy_stress_at_load[0][3] + cauchy_stress_at_load[1][3] + cauchy_stress_at_load[2][3]) / 3 * step_size for cauchy_stress_at_load in cauchy_stresses_at_load ] cauchy_stress_tensor[min_distance_idxs]
def assert_linear_elastic_saturated_block(self, simulation, n_dim): """ Assert results of a linear elastic fully saturated block. The sides of the block can move freely in vertical direction and are fixed in horizontal direction. The bottom of the block is fixed. On top of the block, a hydrostatic water load is applied with a hydraulic head 1 meter above the top of the soil placed. Results are: total stresses, effective stresses, displacements, green langrange strains and water pressure. :param simulation: Kratos simulation :param top_node_nbrs: node numbers of the nodes at the top of the geometry :param n_dim: number of dimensions :return: """ # get total stresses total_stresses = test_helper.get_total_stress_tensor(simulation) total_stresses_xx = [ integration_point[0, 0] for element in total_stresses for integration_point in element ] if n_dim >= 2: total_stresses_yy = [ integration_point[1, 1] for element in total_stresses for integration_point in element ] if n_dim >= 3: total_stresses_zz = [ integration_point[2, 2] for element in total_stresses for integration_point in element ] # get effective stresses efective_stresses = test_helper.get_cauchy_stress_tensor(simulation) efective_stresses_xx = [ integration_point[0, 0] for element in efective_stresses for integration_point in element ] if n_dim >= 2: efective_stresses_yy = [ integration_point[1, 1] for element in efective_stresses for integration_point in element ] if n_dim >= 3: efective_stresses_zz = [ integration_point[2, 2] for element in efective_stresses for integration_point in element ] # get strains green_lagrange_strains = test_helper.get_green_lagrange_strain_tensor( simulation) green_lagrange_strains_xx = [ integration_point[0, 0] for element in green_lagrange_strains for integration_point in element ] if n_dim >= 2: green_lagrange_strains_yy = [ integration_point[1, 1] for element in green_lagrange_strains for integration_point in element ] if n_dim >= 3: green_lagrange_strains_zz = [ integration_point[2, 2] for element in green_lagrange_strains for integration_point in element ] # get displacements displacements = test_helper.get_displacement(simulation) x_displacements = [displacement[0] for displacement in displacements] if n_dim >= 2: y_displacements = [ displacement[1] for displacement in displacements ] if n_dim >= 3: z_displacements = [ displacement[2] for displacement in displacements ] # get water pressures water_pressures = test_helper.get_water_pressure(simulation) # get coordinates nodal_coordinates = test_helper.get_nodal_coordinates(simulation) gauss_coordinates = test_helper.get_gauss_coordinates(simulation) # get the coordinates of all gauss points in a list gauss_coordinates_x = [ integration_point[0] for element in gauss_coordinates for integration_point in element ] if n_dim >= 2: gauss_coordinates_y = [ integration_point[1] for element in gauss_coordinates for integration_point in element ] if n_dim >= 3: gauss_coordinates_z = [ integration_point[2] for element in gauss_coordinates for integration_point in element ] # Calculate expected values expected_water_pressure = [ coord[1] * 1e4 - 2e4 for coord in nodal_coordinates ] #todo correct this expected_displacements_y = [ coord[1] * 0.0001667 for coord in nodal_coordinates ] expected_total_stress_xx = [ gauss_coordinate_y * 1e4 - 2e4 for gauss_coordinate_y in gauss_coordinates_y ] if n_dim >= 2: expected_eff_stress_yy = [ (1 - gauss_coordinate_y) * 1e4 for gauss_coordinate_y in gauss_coordinates_y ] expected_strain_yy = [(1 - gauss_coordinate_y) * 0.00033333 for gauss_coordinate_y in gauss_coordinates_y ] if n_dim >= 3: expected_total_stress_zz = expected_total_stress_xx # Assert integration point information for idx, total_stress_xx in enumerate(total_stresses_xx): self.assertAlmostEqual(expected_total_stress_xx[idx], total_stress_xx, 4) if n_dim >= 2: self.assertAlmostEqual(-1e4, total_stresses_yy[idx], 1) if n_dim >= 3: self.assertAlmostEqual(expected_total_stress_zz[idx], total_stresses_zz[idx], 4) self.assertAlmostEqual(0.0, efective_stresses_xx[idx], 4) if n_dim >= 2: self.assertAlmostEqual(expected_eff_stress_yy[idx], efective_stresses_yy[idx], 4) if n_dim >= 3: self.assertAlmostEqual(0.0, efective_stresses_zz[idx], 4) self.assertAlmostEqual(0.0, green_lagrange_strains_xx[idx]) if n_dim >= 2: self.assertAlmostEqual(expected_strain_yy[idx], green_lagrange_strains_yy[idx]) if n_dim >= 3: self.assertAlmostEqual(0.0, green_lagrange_strains_zz[idx]) # Assert displacements for x_displacement in x_displacements: self.assertAlmostEqual(0.0, x_displacement) for node_idx in range(len(nodal_coordinates)): #todo correct expected displacement # if n_dim >= 2: # self.assertAlmostEqual(expected_displacements_y[node_idx], y_displacements[node_idx], 6) self.assertAlmostEqual(expected_water_pressure[node_idx], water_pressures[node_idx], 6) if n_dim >= 3: for z_displacement in z_displacements: self.assertAlmostEqual(0.0, z_displacement)