示例#1
0
    def test_interface_fixed_line_soil(self):
        """
        Tests an interface between a fixed line-element with and a non-fixed surface.

        The surface has a prescribed vertical displacement of -0.1 m and a horizontal line load of -1 kN
        The interface has a cohesion of 10 kN.
        Expected shear stress in the interface is 10 kN

        :return:
        """
        test_name = 'test_interface_side_cohesive'
        file_path = test_helper.get_file_path(os.path.join('.','test_interfaces', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)
        local_stress_vector = test_helper.get_local_stress_vector(simulation)
        local_stress_vector_interface = [element for element in local_stress_vector if len(element) == 4]

        x_stress = 10000
        precision = 0.01 * x_stress  # 1% precision

        for local_stress_quad in local_stress_vector_interface:
            error_gauss_1 = abs(x_stress - local_stress_quad[0][0])
            error_gauss_2 = abs(x_stress - local_stress_quad[1][0])

            self.assertLess(error_gauss_1, precision)
            self.assertLess(error_gauss_2, precision)
示例#2
0
    def test_inclined_phreatic_line(self):
        """
        test hydrostatic water pressure under an inclided phreatic line ranging over the width of the geometry

        :return:
        """
        test_name = 'test_inclinded_phreatic_line'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        water_pressure = test_helper.get_water_pressure(simulation)

        p_bot_left = water_pressure[0]
        p_bot_middle = water_pressure[47]
        p_bot_right = water_pressure[185]

        p_top_left = water_pressure[186]
        p_top_middle = water_pressure[222]
        p_top_right = water_pressure[250]

        self.assertAlmostEqual(-10000, p_bot_left)
        self.assertAlmostEqual(-7500, p_bot_middle)
        self.assertAlmostEqual(-5000, p_bot_right)

        self.assertAlmostEqual(0, p_top_left)
        self.assertAlmostEqual(0, p_top_middle)
        self.assertAlmostEqual(0, p_top_right)
示例#3
0
    def test_van_genuchten_above_phreatic_quad_4n(self):
        test_name = 'test_soil_weight_van_genuchten_above_phreatic_quad_4n'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        self.assert_total_stress(simulation, -35.21658185153758)
示例#4
0
    def test_weak_interface_on_beam(self):
        """
        Tests an interface on a beam. In this test a calculation is done with a very weak interface.
        Displacement in the beam element should be much greater than the displacement in the soil.

        :return:
        """

        # calculate case with strong interface
        test_name = 'test_weak_interface_on_beam'
        file_path = test_helper.get_file_path(
            os.path.join('.', 'test_interfaces', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)
        model_part = simulation._list_of_output_processes[0].model_part

        # Get beam and soil elements
        beam_elements = [element for element in model_part.Elements if element.GetGeometry().PointsNumber() == 2]
        soil_elements = [element for element in model_part.Elements if element.GetGeometry().PointsNumber() == 3]

        # Get average x-displacement beam- and soil- elements
        x_displacement_beam_elements = [test_helper.compute_mean_list([node.GetSolutionStepValue(Kratos.DISPLACEMENT)[0]
                                         for node in beam_element.GetNodes()]) for beam_element in beam_elements]
        x_displacement_soil_elements = [test_helper.compute_mean_list([node.GetSolutionStepValue(Kratos.DISPLACEMENT)[0]
                                         for node in soil_element.GetNodes()]) for soil_element in soil_elements]

        # Get max x-displacement beam- and soil- elements
        max_x_disp_beam = max(x_displacement_beam_elements)
        max_x_disp_soil = max(x_displacement_soil_elements)

        # Assert if beam displacement is >> than soil displacement
        self.assertGreater(max_x_disp_beam, 1e8 * max_x_disp_soil)
示例#5
0
    def test_saturated_below_phreatic_quad_8n(self):
        test_name = 'test_soil_weight_saturated_below_phreatic_quad_8n'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        self.assert_total_stress(simulation, -32.886751345948134)
示例#6
0
    def test_saturated_below_and_above_phreatic_quad_4n(self):
        test_name = 'test_soil_weight_saturated_below_and_above_phreatic_quad_4n'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        self.assert_total_stress(simulation, -36.44337567297406)
    def test_SteadyState_DamConfinedFlow_2D3N(self):
        test_name = 'test_SteadyState_DamConfinedFlow_2D3N'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        self.assert_outflow_discharge(simulation, 1.11309991)
    def test_SteadyState_DamConfinedFlowWithSheetPile_2D6N(self):
        test_name = 'test_SteadyState_DamConfinedFlowWithSheetPile_2D6N'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        self.assert_outflow_discharge(simulation, 0.827800245)
示例#9
0
    def test_excavation2(self):
        """
        Test of a two surface geometry where 1 surface is deactivated, on the boundary between the 2 surfaces,
        a no deformation condition is applied. Values are not checked on analytical value, but on the fact that at the
        boundary, no deformations should occur, opposite of the boundary deformations should occur.
        :return:
        """
        test_name = 'excavation_test2'
        file_path = test_helper.get_file_path(
            os.path.join('.', 'excavation_tests', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)

        displacements = test_helper.get_displacement(simulation)
        coordinates = test_helper.get_nodal_coordinates(simulation)

        bottom_nodes = [5, 7, 9, 12]
        # check if bottom nodes are not moving
        for bottom_node in bottom_nodes:
            self.assertEqual(0, displacements[bottom_node - 1][0])
            self.assertEqual(0, displacements[bottom_node - 1][1])
            self.assertEqual(0, displacements[bottom_node - 1][2])

        top_nodes = [1, 2, 6, 10, 13]
        top_y_displacement = [
            0, 0, 0, 2.8486711671144066e-07, 3.3932412582166974e-07
        ]
        for i in range(len(top_nodes)):
            self.assertAlmostEqual(top_y_displacement[i],
                                   displacements[top_nodes[i] - 1][1])
示例#10
0
    def test_excavation(self):
        """
        Test of a two surface geometry where 1 surface is deactivated. Values are not checked on analytical value,
        but on the fact that equal displacements should occur at both sides of the geometry.
        :return:
        """
        test_name = 'excavation_test'
        file_path = test_helper.get_file_path(
            os.path.join('.', 'excavation_tests', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)

        displacements = test_helper.get_displacement(simulation)

        bottom_nodes = [5, 7, 9, 12]
        # check if bottom nodes are not moving
        for bottom_node in bottom_nodes:
            self.assertEqual(0, displacements[bottom_node - 1][0])
            self.assertEqual(0, displacements[bottom_node - 1][1])
            self.assertEqual(0, displacements[bottom_node - 1][2])

        top_nodes = [1, 2, 6, 10, 13]
        top_y_displacement = [0, 0, 3.16312e-07, 3.14736e-07, 3.16312e-07]
        for i in range(len(top_nodes)):
            self.assertAlmostEqual(top_y_displacement[i],
                                   displacements[top_nodes[i] - 1][1])
示例#11
0
    def test_base(self):

        test_name = 'base_test'
        file_path = test_helper.get_file_path(
            os.path.join('.', 'excavation_tests', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)

        displacements = test_helper.get_displacement(simulation)

        bottom_nodes = [5, 7, 9, 12]

        # check if bottom nodes are not moving
        for bottom_node in bottom_nodes:
            self.assertEqual(0, displacements[bottom_node - 1][0])
            self.assertEqual(0, displacements[bottom_node - 1][1])
            self.assertEqual(0, displacements[bottom_node - 1][2])

        top_nodes = [1, 2, 6, 10, 13]
        top_y_displacement = [
            3.31258e-07, 3.10315e-07, 3.01343e-07, 3.10315e-07, 3.31258e-07
        ]
        for i in range(len(top_nodes)):
            self.assertAlmostEqual(top_y_displacement[i],
                                   displacements[top_nodes[i] - 1][1])
示例#12
0
    def test_excavation3(self):
        """
        Test of a two surface geometry where an excavation is applied to 1 surface, but the excavation is deactivated.
        Values are not checked on analytical value, but on the fact that all nodes should have a value equal to the base test.
        :return:
        """
        test_name = 'excavation_test3'
        file_path = test_helper.get_file_path(
            os.path.join('.', 'excavation_tests', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        displacements = test_helper.get_displacement(simulation)

        bottom_nodes = [5, 7, 9, 12]
        # check if bottom nodes are not moving
        for bottom_node in bottom_nodes:
            self.assertEqual(0, displacements[bottom_node - 1][0])
            self.assertEqual(0, displacements[bottom_node - 1][1])
            self.assertEqual(0, displacements[bottom_node - 1][2])

        top_nodes = [1, 2, 6, 10, 13]
        top_y_displacement = [
            3.31258e-07, 3.10315e-07, 3.01343e-07, 3.10315e-07, 3.31258e-07
        ]
        for i in range(len(top_nodes)):
            self.assertAlmostEqual(top_y_displacement[i],
                                   displacements[top_nodes[i] - 1][1])
示例#13
0
    def test_normal_load_tetra_10n(self):
        test_name = 'test_normal_load_tetra_10n'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        n_dim = 3
        self.assert_linear_elastic_saturated_block(simulation, n_dim)
示例#14
0
    def test_quad_8n(self):
        test_name = 'test_quad_8n'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        top_node_nbrs = [0, 2, 4, 8, 12]
        n_dim = 2
        self.assert_linear_elastic_block(simulation, top_node_nbrs, n_dim)
示例#15
0
    def test_tetra_4n(self):
        test_name = 'test_tetra_4n'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        top_node_nbrs = [0, 2, 9, 3, 6, 13, 8, 14, 20]
        n_dim = 3
        self.assert_linear_elastic_block(simulation, top_node_nbrs, n_dim)
示例#16
0
    def test_benchmark1_5(self):
        """
        test point load on circular tunnel with beam elements
        :return:
        """
        import math
        from analytical_solutions import calculate_max_deflections_ring, calculate_bending_moments_ring

        # Calculate
        test_name = 'test_tunnel'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        # get results
        moments = test_helper.get_moment(simulation)
        displacements = test_helper.get_displacement(simulation)

        max_x_disp = max(
            [abs(displacement[0]) for displacement in displacements])
        max_y_disp = max(
            [abs(displacement[1]) for displacement in displacements])
        z_moments = [moment[2] for moment in moments]
        max_moment, min_moment = max(z_moments), min(z_moments)

        # calculate analytical solution
        point_load = -100
        radius = 0.5
        youngs_modulus = 1e6
        m_inertia = 8.333e-8

        eps_h, eps_v = calculate_max_deflections_ring(point_load, radius,
                                                      youngs_modulus,
                                                      m_inertia)

        hor_deform_analytic = abs(eps_h * radius)
        vert_deform_analytic = abs(eps_v * radius * 2)

        max_moment_analytic = calculate_bending_moments_ring(
            point_load, radius, 0)
        min_moment_analytic = calculate_bending_moments_ring(
            point_load, radius, math.pi / 2)

        # calculate error between analytical solution and numerical solution
        error_max_moment = abs(max_moment_analytic - max_moment)
        error_min_moment = abs(min_moment_analytic - min_moment)

        error_max_x_disp = abs(hor_deform_analytic - max_x_disp)
        error_max_y_disp = abs(vert_deform_analytic - max_y_disp)

        # assert if error is smaller than the precision
        precision = 0.001
        self.assertLess(error_max_moment, abs(max_moment * precision))
        self.assertLess(error_min_moment, abs(min_moment * precision))

        self.assertLess(error_max_x_disp, abs(max_x_disp * precision))
        self.assertLess(error_max_y_disp, abs(max_y_disp * precision))
示例#17
0
    def test_triangle_3n_fic(self):
        test_name = 'test_triangle_3n_fic'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        top_node_nbrs = [0, 1, 5]
        n_dim = 2
        self.assert_linear_elastic_block(simulation, top_node_nbrs, n_dim)
示例#18
0
    def test_interpolate_water_pressure_inclined(self):
        """
        Test interpolate water pressure with an inclined phreatic line.
        The geometry consists out of 3 blocks. On the top block, an inclined phreatic line is defined. On the bottom
        block, 100 pressure is defined. The water pressure in the middle block is interpolated between the water pressure
        in the top and bottom block
        :return:
        """

        test_name = 'interpolate_line_2'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        water_pressure = test_helper.get_water_pressure(simulation)

        # Node numbers of the left and right boundary of the middle block
        middle_left_n_nbrs = [181, 155, 134, 110, 92, 75, 59, 45]
        middle_right_n_nbrs = [301, 287, 274, 260, 249, 235, 227, 217]

        # Pore pressures at the corners of the middle block
        p_top_middle_left = -10000
        p_bot_middle_left = -100

        p_top_middle_right = -5000
        p_bot_middle_tight = -100

        # Vertical coordinates of the left and right boundary nodes of the middle block
        vert_coord_bound_mid = [-i / 7 * 0.5 + 1.0 for i in range(8)]

        # Analytically calculate pore pressure along left and right boundary of the middle block
        dpdy_left = (p_top_middle_left - p_bot_middle_left) / (
            vert_coord_bound_mid[0] - vert_coord_bound_mid[-1])
        dpdy_right = (p_top_middle_right - p_bot_middle_tight) / (
            vert_coord_bound_mid[0] - vert_coord_bound_mid[-1])

        p_middle_left_analytic = [
            (dpdy_left * (y - vert_coord_bound_mid[0]) + p_top_middle_left)
            for y in vert_coord_bound_mid
        ]

        p_middle_right_analytic = [
            (dpdy_right * (y - vert_coord_bound_mid[0]) + p_top_middle_right)
            for y in vert_coord_bound_mid
        ]

        # Assert
        for idx, node_nr in enumerate(middle_left_n_nbrs):
            self.assertAlmostEqual(p_middle_left_analytic[idx],
                                   water_pressure[node_nr],
                                   delta=1e-6)

        for idx, node_nr in enumerate(middle_right_n_nbrs):
            self.assertAlmostEqual(p_middle_right_analytic[idx],
                                   water_pressure[node_nr],
                                   delta=1e-6)
示例#19
0
    def test_reset_displacement_truss(self):
        """
        Tests reset displacement in a truss in 4 stages
        stage 1: load is applied / reset displacement is false
        stage 2: load is applied / reset displacement is true
        stage 3: load is applied / reset displacement is false
        stage 4: load is removed / reset displacement is false

        :return:
        """

        # calculate strain
        F = -1e10  # [N]
        E = 2069e8  # [N/m2]
        A = 1  # [m2]

        eps = F / (E * A)

        # get stages
        test_name = 'geo_truss_with_reset_displacemnet'
        project_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        n_stages = 4

        stages = test_helper.get_stages(project_path, n_stages)

        displacement_stages = [None] * n_stages
        nodal_coordinates_stages = [None] * n_stages

        # run stages and get results
        for idx, stage in enumerate(stages):
            stage.Run()
            displacement_stages[idx] = test_helper.get_displacement(stage)
            nodal_coordinates_stages[idx] = test_helper.get_nodal_coordinates(
                stage)

        # Assert
        stage_nr = 0
        for idx, node in enumerate(nodal_coordinates_stages[stage_nr]):
            self.assertAlmostEqual(displacement_stages[stage_nr][idx][0],
                                   eps * node[0])

        stage_nr = 1
        for idx, node in enumerate(nodal_coordinates_stages[stage_nr]):
            self.assertAlmostEqual(displacement_stages[stage_nr][idx][0], 0)

        stage_nr = 2
        for idx, node in enumerate(nodal_coordinates_stages[stage_nr]):
            self.assertAlmostEqual(displacement_stages[stage_nr][idx][0], 0)

        stage_nr = 3
        for idx, node in enumerate(nodal_coordinates_stages[stage_nr]):
            self.assertAlmostEqual(displacement_stages[stage_nr][idx][0],
                                   -eps * node[0])
示例#20
0
    def test_tetra_10n(self):
        test_name = 'test_tetra_10n'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        top_node_nbrs = [
            0, 3, 9, 28, 53, 1, 6, 13, 32, 10, 15, 21, 44, 76, 27, 34, 41, 64,
            94, 51, 56, 74, 95, 110
        ]
        n_dim = 3
        self.assert_linear_elastic_block(simulation, top_node_nbrs, n_dim)
示例#21
0
    def test_interface_on_beam(self):
        """
        Tests an interface on a beam. In this test a calculation is done with and without interface,
        where the interface has a cohesion of 1000 kN and a stiffness of 1e12 Pa. Results should be approximately equal

        :return:
        """

        # calculate reference case without interface
        test_name = 'test_beam'
        file_path = test_helper.get_file_path(os.path.join('.','test_interfaces', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)
        base_displacement = test_helper.get_displacement(simulation)

        base_x_displacement = [displacement[0] for displacement in base_displacement]
        base_y_displacement = [displacement[1] for displacement in base_displacement]

        max_base_x_displacement = max(base_x_displacement)
        max_base_y_displacement, min_base_y_displacement = max(base_y_displacement), min(base_y_displacement)

        # calculate case with strong interface
        test_name = 'test_interface_on_beam'
        file_path = test_helper.get_file_path(
            os.path.join('.', 'test_interfaces', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)
        interface_displacement = test_helper.get_displacement(simulation)

        interface_x_displacement = [displacement[0] for displacement in interface_displacement]
        interface_y_displacement = [displacement[1] for displacement in interface_displacement]

        max_interface_x_displacement = max(interface_x_displacement)
        max_interface_y_displacement, min_interface_y_displacement = max(interface_y_displacement), min(interface_y_displacement)

        # assert base displacement is approximately equal to displacement with interface
        precision = 0.01
        self.assertLess(abs(max_interface_x_displacement - max_base_x_displacement), precision*max_base_x_displacement)
        self.assertLess(abs(max_interface_y_displacement - max_base_y_displacement), precision*max_base_y_displacement)
        self.assertLess(abs(min_interface_y_displacement - min_base_y_displacement), precision*max_base_y_displacement)
    def test_truss_between_soil(self):
        """
        Two blocks of soil are attached with very stiff truss. A point load is applied to 1 soil block.
        Check if displacements at both sides of the truss are equal.

        :return:
        """
        test_name = 'test_truss_between_soils'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        displacements = test_helper.get_displacement(simulation)

        # check if displacement in soil at both sides of truss is equal
        self.assertAlmostEqual(displacements[6][0], displacements[8][0])
示例#23
0
    def test_benchmark2_3(self):
        """
        In this benchmark a four stage model is tested.
        Stage 1: initialisation sand layer
        Stage 2: addition of sheetpile
        Stage 3: addition of dike
        Stage 4: addition of water

        The test is calculated using gravity loading.

        This test compares minimum, maximum stress and displacement in the third and fourth stage.

        :return:
        """

        test_name = r'dike_with_sheetpile_all_stage'
        project_path = test_helper.get_file_path(os.path.join('.', test_name))
        n_stages = 3
        stages = test_helper.run_stages(project_path, n_stages)
示例#24
0
    def test_benchmark1_1(self):
        """
        In this benchmark Bia-axial shearing test conditions are tested in the Kratos-Geomechanics application.
        In that way, this example can be used to verify elastic deformation with a linear elastic model.
        :return:
        """
        test_name = 'Biaxialshearstresswithlinearelasticmodel'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))

        simulation = test_helper.run_kratos(file_path)

        strain_tensor = test_helper.get_green_lagrange_strain_tensor(
            simulation)

        # check strain_tensor on all gauss points
        for i in range(len(strain_tensor)):
            for j in range(len(strain_tensor[i])):
                self.assertAlmostEqual(-0.00125, strain_tensor[i][j][0, 1])
示例#25
0
    def test_inclinded_phreatic_line_smaller_line(self):
        """
        test hydrostatic water pressure under an inclided phreatic line ranging over a part of the geometry

        :return:
        """
        test_name = 'test_inclinded_phreatic_line_smaller_line'
        file_path = test_helper.get_file_path(
            os.path.join('.', test_name + '.gid'))
        simulation = test_helper.run_kratos(file_path)

        # Get water pressure in all the nodes
        water_pressure = test_helper.get_water_pressure(simulation)

        # get node information of the bottom nodes in the geometry
        bottom_n_nbrs = [
            0, 2, 4, 9, 16, 24, 34, 47, 61, 78, 96, 115, 136, 162, 185
        ]
        x_coords_boundary_nodes = [i / 14 for i in range(15)]

        # Set turning points of the phreatic line
        head_values = [1, 1, 0.5, 0.5]
        head_x_coords = [0, 0.3, 0.7, 1]

        # Analytically calculate water pressure at the bottom of the geometry
        dhdx = (head_values[2] - head_values[1]) / (head_x_coords[2] -
                                                    head_x_coords[1])
        gamma_w = 10000

        p_bottom_analytic = [
            -head_values[1] *
            gamma_w if x <= head_x_coords[1] else -head_values[2] *
            gamma_w if x >= head_x_coords[2] else
            -(dhdx * (x - head_x_coords[1]) + head_values[1]) * gamma_w
            for x in x_coords_boundary_nodes
        ]

        # assert
        for idx, node_nr in enumerate(bottom_n_nbrs):
            self.assertAlmostEqual(p_bottom_analytic[idx],
                                   water_pressure[node_nr],
                                   delta=1e-6)
示例#26
0
    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)
示例#27
0
    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))
示例#28
0
    def test_benchmark1_4(self):
        """
        test 1D consolidation on elastic soil.

        :return:
        """
        from analytical_solutions import calculate_1D_consolidation

        # define number of stages
        n_stages = 11

        # get the parameter file names for all stages
        test_name = '1D-Consolidation_all_stages'
        file_path = test_helper.get_file_path(os.path.join('.', test_name))
        parameter_file_names = [
            os.path.join(file_path,
                         'ProjectParameters_stage' + str(i + 1) + '.json')
            for i in range(n_stages)
        ]

        # set stage parameters
        parameters_stages = [None] * n_stages
        os.chdir(file_path)
        for idx, parameter_file_name in enumerate(parameter_file_names):
            with open(parameter_file_name, 'r') as parameter_file:
                parameters_stages[idx] = Kratos.Parameters(
                    parameter_file.read())

        model = Kratos.Model()
        stages = [
            analysis.GeoMechanicsAnalysis(model, stage_parameters)
            for stage_parameters in parameters_stages
        ]

        # run stages and get water pressure results per stage
        stage_water_pressure = [None] * n_stages
        for idx, stage in enumerate(stages):
            stage.Run()
            stage_water_pressure[idx] = test_helper.get_water_pressure(stage)

        # get y coords of all the nodes
        coords = test_helper.get_nodal_coordinates(stages[0])
        y_coords = [coord[1] + 1 for coord in coords]

        # calculate analytical solution for all stages and calculate the error
        sample_height = 1
        t_vs = [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0]
        rmse_stages = [None] * (n_stages - 1)
        for idx, t_v in enumerate(t_vs):
            rel_p_stages = [
                calculate_1D_consolidation(y_coord, sample_height, t_v) * -1
                for y_coord in y_coords
            ]
            errors_stage = [
                stage_water_pressure[idx + 1][node_idx] - rel_p
                for node_idx, rel_p in enumerate(rel_p_stages)
            ]
            rmse_stages[idx] = (sum([error**2 for error in errors_stage]) /
                                len(errors_stage))**0.5

        # assert if average error in all stages is below 1 percent
        accuracy = 0.01
        for rmse_stage in rmse_stages:
            self.assertLess(rmse_stage, accuracy)
示例#29
0
 def test_wave_through_undrained_linear_elastic_soil(self):
     test_name = 'test_1d_confined_undrained_wave.gid'
     file_path = test_helper.get_file_path(os.path.join('.', test_name))
     simulation = test_helper.run_kratos(file_path)
     pass
示例#30
0
    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]