def _solve_eigenvalue_problem(self, mp, use_block_builder, echo=0): eigensolver_settings = KratosMultiphysics.Parameters(""" { "max_iteration" : 1000, "tolerance" : 1e-6, "number_of_eigenvalues" : 2, "echo_level" : 0, "normalize_eigenvectors": true } """) eigen_solver = LinearSolversApplication.EigensystemSolver(eigensolver_settings) if use_block_builder: builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(eigen_solver) else: builder_and_solver = KratosMultiphysics.ResidualBasedEliminationBuilderAndSolver(eigen_solver) eigen_scheme = StructuralMechanicsApplication.EigensolverDynamicScheme() compute_modal_decomposition = True # see "structural_mechanics_eigensolver.py", values are for the "EigensystemSolver" mass_matrix_diagonal_value = 0.0 stiffness_matrix_diagonal_value = 1.0 eig_strategy = StructuralMechanicsApplication.EigensolverStrategy(mp, eigen_scheme, builder_and_solver, mass_matrix_diagonal_value, stiffness_matrix_diagonal_value, compute_modal_decomposition) eig_strategy.SetEchoLevel(echo) eig_strategy.Solve()
def _solve_prebuckling_problem(self,mp,NumOfNodes,iterations,echo=0): eigensolver_settings = KratosMultiphysics.Parameters(""" { "max_iteration" : 1000, "tolerance" : 1e-6, "number_of_eigenvalues" : 1, "echo_level" : 0, "normalize_eigenvectors": false } """) buckling_settings = KratosMultiphysics.Parameters(""" { "initial_load_increment" : 1.0, "small_load_increment" : 0.0005, "path_following_step" : 0.5, "convergence_ratio" : 0.005, "make_matrices_symmetric" : true } """) eigen_solver = LinearSolversApplication.EigensystemSolver(eigensolver_settings) eigen_solver_ = KratosMultiphysics.ResidualBasedEliminationBuilderAndSolver(eigen_solver) convergence_criterion = KratosMultiphysics.DisplacementCriteria(1e-4,1e-9) scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticScheme() linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver() builder_and_solver = KratosMultiphysics.ResidualBasedEliminationBuilderAndSolver(linear_solver) convergence_criterion.SetEchoLevel(echo) eig_strategy = StructuralMechanicsApplication.PrebucklingStrategy( mp, scheme, eigen_solver_, builder_and_solver, convergence_criterion, 10, buckling_settings ) eig_strategy.SetEchoLevel(echo) LoadFactor = [] for i in range(iterations): eig_strategy.Solve() if( i%2 == 1): LoadFactor.append( mp.ProcessInfo[StructuralMechanicsApplication.EIGENVALUE_VECTOR][0] ) self._updateConditions(mp,NumOfNodes) return LoadFactor
def ConstructSolver(settings): if not isinstance(settings, KM.Parameters): raise Exception("Input is expected to be provided as a Kratos Parameters object") solver_type = settings["solver_type"].GetString() if solver_type == "eigen_eigensystem": if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"): from KratosMultiphysics import LinearSolversApplication eigen_solver = LinearSolversApplication.EigensystemSolver(settings) return eigen_solver else: raise Exception("LinearSolversApplication not available") if solver_type == "spectra_sym_g_eigs_shift": if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"): from KratosMultiphysics import LinearSolversApplication eigen_solver = LinearSolversApplication.SpectraSymGEigsShiftSolver(settings) return eigen_solver else: raise Exception("LinearSolversApplication not available") elif solver_type == "dense_eigensolver": if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"): from KratosMultiphysics import LinearSolversApplication eigen_solver = LinearSolversApplication.DenseEigenvalueSolver(settings) return eigen_solver else: raise Exception("LinearSolversApplication not available") elif solver_type == "feast": if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"): from KratosMultiphysics import LinearSolversApplication if LinearSolversApplication.HasFEAST(): is_symmetric = settings["symmetric"].GetBool() if settings.Has("symmetric") else True eigen_solver = LinearSolversApplication.FEASTSymmetricEigensystemSolver(settings) if is_symmetric else LinearSolversApplication.FEASTGeneralEigensystemSolver(settings) return eigen_solver else: raise Exception("FEAST not available in LinearSolversApplication") else: raise Exception("LinearSolversApplication not available") elif solver_type == "feast_complex": if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"): from KratosMultiphysics import LinearSolversApplication if LinearSolversApplication.HasFEAST(): is_symmetric = settings["symmetric"].GetBool() if settings.Has("symmetric") else True eigen_solver = LinearSolversApplication.ComplexFEASTSymmetricEigensystemSolver(settings) if is_symmetric else LinearSolversApplication.ComplexFEASTGeneralEigensystemSolver(settings) return eigen_solver else: raise Exception("FEAST not available in LinearSolversApplication") else: raise Exception("LinearSolversApplication not available") linear_solver_configuration = settings["linear_solver_settings"] if linear_solver_configuration.Has("solver_type"): # user specified a linear solver linear_solver = linear_solver_factory.ConstructSolver(linear_solver_configuration) else: linear_solver = linear_solver_factory.CreateFastestAvailableDirectLinearSolver() if solver_type == "power_iteration_eigenvalue_solver": eigen_solver = KM.PowerIterationEigenvalueSolver( settings, linear_solver) elif solver_type == "power_iteration_highest_eigenvalue_solver": eigen_solver = KM.PowerIterationHighestEigenvalueSolver( settings, linear_solver) elif solver_type == "rayleigh_quotient_iteration_eigenvalue_solver": eigen_solver = KM.RayleighQuotientIterationEigenvalueSolver( settings, linear_solver) else: raise Exception("Solver type not found. Asking for :" + solver_type) return eigen_solver