Beispiel #1
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])
Beispiel #2
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])
Beispiel #3
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])
Beispiel #4
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])
Beispiel #5
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))
    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])
Beispiel #7
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])
Beispiel #9
0
    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)
Beispiel #10
0
    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)