Exemple #1
0
    def _create_linear_solver(self):
        """Create the eigensolver.

        This overrides the base class method and replaces the usual linear solver
        with an eigenvalue problem solver.
        """
        if self.eigensolver_settings["solver_type"].GetString() == "FEAST":
            feast_system_solver_settings = self.eigensolver_settings[
                "linear_solver_settings"]
            if feast_system_solver_settings["solver_type"].GetString(
            ) == "complex_skyline_lu_solver":
                # default built-in feast system solver
                linear_solver = ExternalSolversApplication.FEASTSolver(
                    self.eigensolver_settings)
            elif feast_system_solver_settings["solver_type"].GetString(
            ) == "pastix":
                feast_system_solver = ExternalSolversApplication.PastixComplexSolver(
                    feast_system_solver_settings)
                linear_solver = ExternalSolversApplication.FEASTSolver(
                    self.eigensolver_settings, feast_system_solver)
            else:
                raise Exception(
                    "Unsupported FEAST system solver_type: " +
                    feast_system_solver_settings["solver_type"].GetString())
        else:
            raise Exception(
                "Unsupported eigensolver solver_type: " +
                self.eigensolver_settings["solver_type"].GetString())
        return linear_solver
Exemple #2
0
    def _solve_eigen(self, mp, echo=0):
        feast_system_solver_settings = KratosMultiphysics.Parameters("""{ }""")

        eigensolver_settings = KratosMultiphysics.Parameters("""
        {
                "perform_stochastic_estimate": false,
                "lambda_min": 1.0e-2,
                "lambda_max": 25.0,
                "search_dimension": 7
        }
        """)
        if not (hasattr(KratosMultiphysics.ExternalSolversApplication,
                        "PastixComplexSolver")):
            self.skipTest('"PastixComplexSolver" not available')

        feast_system_solver = ExternalSolversApplication.PastixComplexSolver(
            feast_system_solver_settings)
        eigen_solver = ExternalSolversApplication.FEASTSolver(
            eigensolver_settings, feast_system_solver)
        builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(
            eigen_solver)

        eigen_scheme = StructuralMechanicsApplication.EigensolverDynamicScheme(
        )
        eig_strategy = StructuralMechanicsApplication.EigensolverStrategy(
            mp, eigen_scheme, builder_and_solver)

        eig_strategy.SetEchoLevel(echo)
        eig_strategy.Solve()
    def test_undamped_mdof_system_eigen(self):
        import KratosMultiphysics.ExternalSolversApplication as ExternalSolversApplication
        # FEAST is available otherwise this test is not being called
        if not hasattr(KratosMultiphysics.ExternalSolversApplication,
                       "PastixSolver"):
            self.skipTest("Pastix Solver is not available")

        current_model = KratosMultiphysics.Model()

        mp = self._set_up_mdof_system(current_model)

        #set parameters
        mp.Elements[1].SetValue(KratosMultiphysics.NODAL_MASS, 20.0)
        mp.Elements[2].SetValue(
            StructuralMechanicsApplication.NODAL_DISPLACEMENT_STIFFNESS,
            [200.0, 200.0, 200.0])
        mp.Elements[3].SetValue(KratosMultiphysics.NODAL_MASS, 40.0)
        mp.Elements[4].SetValue(
            StructuralMechanicsApplication.NODAL_DISPLACEMENT_STIFFNESS,
            [400.0, 400.0, 400.0])

        #create solver
        eigen_solver_parameters = KratosMultiphysics.Parameters("""
            {
                "solver_type": "FEAST",
                "print_feast_output": false,
                "perform_stochastic_estimate": false,
                "solve_eigenvalue_problem": true,
                "lambda_min": 0.0,
                "lambda_max": 4.0e5,
                "number_of_eigenvalues": 2,
                "search_dimension": 18,
                "linear_solver_settings": {
                    "solver_type" : "pastix",
                    "echo_level" : 0
                }
            }""")
        feast_system_solver = ExternalSolversApplication.PastixComplexSolver(
            eigen_solver_parameters["linear_solver_settings"])
        eigen_solver = ExternalSolversApplication.FEASTSolver(
            eigen_solver_parameters, feast_system_solver)
        scheme = StructuralMechanicsApplication.EigensolverDynamicScheme()
        builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(
            eigen_solver)

        solver = StructuralMechanicsApplication.EigensolverStrategy(
            mp, scheme, builder_and_solver)

        solver.Solve()

        current_eigenvalues = [
            ev for ev in mp.ProcessInfo[
                StructuralMechanicsApplication.EIGENVALUE_VECTOR]
        ]
        analytical_eigenvalues = [5, 20]
        for ev in range(len(analytical_eigenvalues)):
            self.assertAlmostEqual(current_eigenvalues[ev],
                                   analytical_eigenvalues[ev])
Exemple #4
0
    def _GetFEASTSystemSolver(self, settings):

        if (settings["solver_type"].GetString() == "pastix"):
            return ExternalSolversApplication.PastixComplexSolver(settings)
        else:
            raise Exception("Unsupported feast system solver: " + settings["solver_type"].GetString())