def execute_test_eigen_with_constraints(self, use_block_builder):
        analysis_parameters = KratosMultiphysics.Parameters("""{
            "problem_data"    : {
                "parallel_type" : "OpenMP",
                "echo_level"    : 1,
                "start_time"    : 0.0,
                "end_time"      : 1.0
            },
            "solver_settings" : {
                "solver_type"              : "eigen_value",
                "model_part_name"          : "Structure",
                "domain_size"              : 3,
                "model_import_settings"    : {
                    "input_type"     : "use_input_model_part"
                },
                "time_stepping"            : {
                    "time_step" : 1.1
                },
                "rotation_dofs"            : true,
                "block_builder"            : true
            }
        }""")

        analysis_parameters["solver_settings"]["block_builder"].SetBool(
            use_block_builder)
        analysis_parameters_with_constraints = analysis_parameters.Clone()
        analysis_parameters_with_constraints["solver_settings"][
            "block_builder"].SetBool(
                True
            )  # Currently the EliminationB&S does not reliably work with constraints

        model = KratosMultiphysics.Model()
        analysis = StructuralMechanicsAnalysis(model,
                                               analysis_parameters.Clone())
        model_part = model["Structure"]
        SetupSystem(model_part, use_constraints=False)
        analysis.Run()

        model_with_constraints = KratosMultiphysics.Model()
        analysis_with_constraints = StructuralMechanicsAnalysisWithConstraints(
            model_with_constraints, analysis_parameters_with_constraints)
        model_part_with_constraints = model_with_constraints["Structure"]
        SetupSystem(model_part_with_constraints, use_constraints=True)
        analysis_with_constraints.Run()

        self.__CompareEigenSolution(model_part, model_part_with_constraints)

        self.__CompareEigenSolutionMasterSlave(model_part_with_constraints)
Esempio n. 2
0
    def test_cook_membrane_2d(self):
        results_filename = "cook_membrane_test/cook_membrane_results.json"
        parameters_filename = "cook_membrane_test/cook_membrane_parameters.json"
        with open(parameters_filename,'r') as parameter_file:
            parameters = KratosMultiphysics.Parameters(parameter_file.read())

        model = KratosMultiphysics.Model()
        simulation = StructuralMechanicsAnalysis(model, parameters)
        simulation.Run()

        # self._check_results(model_part, A, b)
        if self.print_results:
            self.__print_results(model, results_filename)
        if self.print_output:
            self.__post_process(model.GetModelPart(parameters["solver_settings"]["model_part_name"].GetString()))
        self.__check_results(model, results_filename)
    def test_eigen_with_constraints(self):
        analysis_parameters = KratosMultiphysics.Parameters("""{
            "problem_data"    : {
                "parallel_type" : "OpenMP",
                "echo_level"    : 1,
                "start_time"    : 0.0,
                "end_time"      : 1.0
            },
            "solver_settings" : {
                "solver_type"              : "eigen_value",
                "model_part_name"          : "Structure",
                "domain_size"              : 3,
                "model_import_settings"    : {
                    "input_type"     : "use_input_model_part"
                },
                "time_stepping"            : {
                    "time_step" : 1.1
                },
                "use_computing_model_part" : false,
                "rotation_dofs"            : true
            }
        }""")

        model = KratosMultiphysics.Model()
        analysis = StructuralMechanicsAnalysis(model,
                                               analysis_parameters.Clone())
        model_part = model["Structure"]
        SetupSystem(model_part, use_constraints=False)
        analysis.Run()

        model_with_constraints = KratosMultiphysics.Model()
        analysis_with_constraints = StructuralMechanicsAnalysisWithConstraints(
            model_with_constraints, analysis_parameters.Clone())
        model_part_with_constraints = model_with_constraints["Structure"]
        SetupSystem(model_part_with_constraints, use_constraints=True)
        analysis_with_constraints.Run()

        self.__CompareEigenSolution(model_part, model_part_with_constraints)
Esempio n. 4
0
    def test_cook_membrane_incompressible_2d(self):
        with KratosUnittest.WorkFolderScope(".", __file__):
            results_filename = "cook_membrane_test/cook_membrane_incompressible_results.json"
            parameters_filename = "cook_membrane_test/cook_membrane_parameters.json"
            with open(parameters_filename, 'r') as parameter_file:
                parameters = KratosMultiphysics.Parameters(
                    parameter_file.read())
            parameters["solver_settings"]["material_import_settings"][
                "materials_filename"].SetString(
                    "cook_membrane_test/cook_membrane_incompressible_materials.json"
                )

            model = KratosMultiphysics.Model()
            simulation = StructuralMechanicsAnalysis(model, parameters)
            simulation.Run()

            # self._check_results(model_part, A, b)
            if self.print_results:
                self.__print_results(model, results_filename)
            if self.print_output:
                self.__post_process(
                    model.GetModelPart(parameters["solver_settings"]
                                       ["model_part_name"].GetString()))
            self.__check_results(model, results_filename)
Esempio n. 5
0
    def test_custom_scipy_base_solver(self):
        analysis_parameters_scipy = KratosMultiphysics.Parameters("""{
            "problem_data"    : {
                "parallel_type" : "OpenMP",
                "echo_level"    : 1,
                "start_time"    : 0.0,
                "end_time"      : 1.0
            },
            "solver_settings" : {
                "solver_type"              : "KratosMultiphysics.StructuralMechanicsApplication.structural_mechanics_custom_scipy_base_solver",
                "model_part_name"          : "Structure",
                "domain_size"              : 3,
                "model_import_settings"    : {
                    "input_type"     : "use_input_model_part"
                },
                "time_stepping"            : {
                    "time_step" : 1.1
                },
                "rotation_dofs"            : true,
                "builder_and_solver_settings" : {
                    "use_block_builder" : false
                }
            }
        }""")

        analysis_parameters_eigen = KratosMultiphysics.Parameters("""{
            "problem_data"    : {
                "parallel_type" : "OpenMP",
                "echo_level"    : 1,
                "start_time"    : 0.0,
                "end_time"      : 1.0
            },
            "solver_settings" : {
                "solver_type"              : "eigen_value",
                "model_part_name"          : "Structure",
                "domain_size"              : 3,
                "model_import_settings"    : {
                    "input_type"     : "use_input_model_part"
                },
                "time_stepping"            : {
                    "time_step" : 1.1
                },
                "rotation_dofs"            : true,
                "eigensolver_settings"     : {
                   "solver_type"           : "eigen_eigensystem",
                   "number_of_eigenvalues" : 5,
                   "normalize_eigenvectors": true,
                   "max_iteration"         : 10000,
                   "tolerance"             : 1e-6
                },
                "builder_and_solver_settings" : {
                    "use_block_builder" : true
                }
            }
        }""")

        model_scipy = KratosMultiphysics.Model()
        analysis_scipy = StructuralMechanicsAnalysis(
            model_scipy, analysis_parameters_scipy.Clone())
        model_part_scipy = model_scipy["Structure"]
        SetupSystem(model_part_scipy)
        analysis_scipy.Run()

        model_eigen = KratosMultiphysics.Model()
        analysis_eigen = StructuralMechanicsAnalysis(
            model_eigen, analysis_parameters_eigen.Clone())
        model_part_eigen = model_eigen["Structure"]
        SetupSystem(model_part_eigen)
        analysis_eigen.Run()

        self.__CompareEigenSolution(model_part_scipy, model_part_eigen)
from __future__ import print_function, absolute_import, division  #makes KratosMultiphysics backward compatible with python 2.6 and 2.7

import KratosMultiphysics
from KratosMultiphysics.StructuralMechanicsApplication.structural_mechanics_analysis import StructuralMechanicsAnalysis
"""
For user-scripting it is intended that a new class is derived
from StructuralMechanicsAnalysis to do modifications
"""

if __name__ == "__main__":

    with open("ProjectParameters.json", 'r') as parameter_file:
        parameters = KratosMultiphysics.Parameters(parameter_file.read())

    model = KratosMultiphysics.Model()
    simulation = StructuralMechanicsAnalysis(model, parameters)
    simulation.Run()