From be9aa3b30107ce9bc5a2e7d0a79701e20cf6af26 Mon Sep 17 00:00:00 2001 From: Armin Geiser Date: Tue, 4 Jan 2022 12:19:06 +0100 Subject: [PATCH] Shapeopt/update for kratos 9 (#97) * update examples for Kratos version 9.0 * clean python scripts --- .../run_optimization.py | 3 --- .../primal_parameters.json | 18 ------------------ .../run_optimization.py | 3 --- .../primal_parameters.json | 12 ------------ .../run_optimization.py | 3 --- .../optimization_parameters.json | 7 +------ .../primal_parameters.json | 3 +-- .../run_optimization.py | 3 --- .../optimization_parameters.json | 2 +- .../primal_parameters.json | 10 ---------- .../run_optimization.py | 5 +---- .../analysis_parameters.json | 12 ------------ .../optimization_parameters.json | 4 ++-- .../analysis_parameters.json | 12 ------------ .../run_optimization.py | 3 --- .../09_Packaging_3D_Shell/run_optimization.py | 5 +---- .../primal_parameters_main.json | 16 ---------------- .../run_optimization.py | 7 ++----- .../run_optimization.py | 4 ---- 19 files changed, 9 insertions(+), 123 deletions(-) diff --git a/shape_optimization/use_cases/01_Strain_Energy_Minimization_3D_Hook/run_optimization.py b/shape_optimization/use_cases/01_Strain_Energy_Minimization_3D_Hook/run_optimization.py index 15bf2bca..cdf37e84 100644 --- a/shape_optimization/use_cases/01_Strain_Energy_Minimization_3D_Hook/run_optimization.py +++ b/shape_optimization/use_cases/01_Strain_Energy_Minimization_3D_Hook/run_optimization.py @@ -1,6 +1,3 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM diff --git a/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/primal_parameters.json b/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/primal_parameters.json index 8069a62f..e2e970c3 100644 --- a/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/primal_parameters.json +++ b/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/primal_parameters.json @@ -21,18 +21,6 @@ "material_import_settings": { "materials_filename": "materials_2D.json" }, - "line_search": false, - "convergence_criterion": "residual_criterion", - "displacement_relative_tolerance": 0.0001, - "displacement_absolute_tolerance": 1e-9, - "residual_relative_tolerance": 0.0001, - "residual_absolute_tolerance": 1e-9, - "max_iteration": 10, - "linear_solver_settings": { - "solver_type": "EigenSolversApplication.sparse_lu", - "scaling": false, - "verbosity": 0 - }, "rotation_dofs": true }, "processes": { @@ -140,13 +128,7 @@ "help": "This process writes postprocessing files for VTK", "Parameters": { "model_part_name": "3D_Shell", - "file_format": "binary", - "output_precision": 7, - "output_control_type": "step", - "output_interval": 1.0, - "output_sub_model_parts": false, "folder_name": "Primal_Results", - "save_output_files_in_folder": true, "nodal_solution_step_data_variables": [ "DISPLACEMENT", "REACTION", diff --git a/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/run_optimization.py b/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/run_optimization.py index 15bf2bca..cdf37e84 100644 --- a/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/run_optimization.py +++ b/shape_optimization/use_cases/02_Strain_Energy_Minimization_3D_Shell/run_optimization.py @@ -1,6 +1,3 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM diff --git a/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/primal_parameters.json b/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/primal_parameters.json index 3c5755be..62ede1cb 100644 --- a/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/primal_parameters.json +++ b/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/primal_parameters.json @@ -21,18 +21,6 @@ "material_import_settings" :{ "materials_filename": "materials_2D.json" }, - "line_search" : false, - "convergence_criterion" : "residual_criterion", - "displacement_relative_tolerance" : 0.0001, - "displacement_absolute_tolerance" : 1e-9, - "residual_relative_tolerance" : 0.0001, - "residual_absolute_tolerance" : 1e-9, - "max_iteration" : 10, - "linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu", - "scaling" : false, - "verbosity" : 0 - }, "rotation_dofs" : true }, "processes": { diff --git a/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/run_optimization.py b/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/run_optimization.py index 15bf2bca..cdf37e84 100644 --- a/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/run_optimization.py +++ b/shape_optimization/use_cases/03_mesh_independent_optimization_3D_Shell/run_optimization.py @@ -1,6 +1,3 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM diff --git a/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/optimization_parameters.json b/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/optimization_parameters.json index da0727fa..6a459f01 100644 --- a/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/optimization_parameters.json +++ b/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/optimization_parameters.json @@ -38,11 +38,6 @@ "time_step" : 1.0 }, "domain_size" : 3, - "mesh_motion_linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu", - "scaling" : false, - "verbosity" : 0 - }, "compute_reactions" : true } } @@ -111,7 +106,7 @@ "SHAPE_UPDATE", "SHAPE_CHANGE" ], "output_format" : { - "name": "gid" + "name": "vtk" } } } diff --git a/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/primal_parameters.json b/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/primal_parameters.json index 82ee6603..ddfb05dd 100644 --- a/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/primal_parameters.json +++ b/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/primal_parameters.json @@ -22,10 +22,9 @@ "materials_filename": "materials.json" }, "eigensolver_settings":{ - "solver_type": "eigen_eigensystem", + "solver_type": "spectra_sym_g_eigs_shift", "number_of_eigenvalues": 2, "max_iteration": 1000, - "tolerance": 1e-6, "echo_level": 1 }, "rotation_dofs" : false diff --git a/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/run_optimization.py b/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/run_optimization.py index 15bf2bca..cdf37e84 100644 --- a/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/run_optimization.py +++ b/shape_optimization/use_cases/04_Eigenfrequency_Maximization_3D_Cantilever/run_optimization.py @@ -1,6 +1,3 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM diff --git a/shape_optimization/use_cases/05_Constrained_Shell_Opt/optimization_parameters.json b/shape_optimization/use_cases/05_Constrained_Shell_Opt/optimization_parameters.json index f60bfa5b..d6136211 100644 --- a/shape_optimization/use_cases/05_Constrained_Shell_Opt/optimization_parameters.json +++ b/shape_optimization/use_cases/05_Constrained_Shell_Opt/optimization_parameters.json @@ -117,7 +117,7 @@ "SHAPE_UPDATE", "SHAPE_CHANGE" ], "output_format" : { - "name": "gid" + "name": "vtk" } } } diff --git a/shape_optimization/use_cases/05_Constrained_Shell_Opt/primal_parameters.json b/shape_optimization/use_cases/05_Constrained_Shell_Opt/primal_parameters.json index 38832a6e..a7275118 100644 --- a/shape_optimization/use_cases/05_Constrained_Shell_Opt/primal_parameters.json +++ b/shape_optimization/use_cases/05_Constrained_Shell_Opt/primal_parameters.json @@ -21,16 +21,6 @@ "material_import_settings" :{ "materials_filename": "materials_2D.json" }, - "line_search" : false, - "convergence_criterion" : "residual_criterion", - "displacement_relative_tolerance" : 0.0001, - "displacement_absolute_tolerance" : 1e-9, - "residual_relative_tolerance" : 0.0001, - "residual_absolute_tolerance" : 1e-9, - "max_iteration" : 10, - "linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu" - }, "rotation_dofs" : true }, "processes": { diff --git a/shape_optimization/use_cases/05_Constrained_Shell_Opt/run_optimization.py b/shape_optimization/use_cases/05_Constrained_Shell_Opt/run_optimization.py index 6316536b..9c98641c 100644 --- a/shape_optimization/use_cases/05_Constrained_Shell_Opt/run_optimization.py +++ b/shape_optimization/use_cases/05_Constrained_Shell_Opt/run_optimization.py @@ -1,12 +1,9 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM # Additional imports from KratosMultiphysics.ShapeOptimizationApplication import optimizer_factory -from KratosMultiphysics.ShapeOptimizationApplication.analyzer_base import AnalyzerBaseClass +from KratosMultiphysics.ShapeOptimizationApplication.analyzers.analyzer_base import AnalyzerBaseClass # Read parameters with open("optimization_parameters.json",'r') as parameter_file: diff --git a/shape_optimization/use_cases/06_bead_optimization_plate/analysis_parameters.json b/shape_optimization/use_cases/06_bead_optimization_plate/analysis_parameters.json index 4173d27b..1d1f113a 100644 --- a/shape_optimization/use_cases/06_bead_optimization_plate/analysis_parameters.json +++ b/shape_optimization/use_cases/06_bead_optimization_plate/analysis_parameters.json @@ -22,18 +22,6 @@ "material_import_settings": { "materials_filename": "2D_material.json" }, - "line_search": false, - "convergence_criterion": "residual_criterion", - "displacement_relative_tolerance": 0.0001, - "displacement_absolute_tolerance": 1e-9, - "residual_relative_tolerance": 0.0001, - "residual_absolute_tolerance": 1e-9, - "max_iteration": 10, - "linear_solver_settings": { - "solver_type": "EigenSolversApplication.sparse_lu", - "scaling": false, - "verbosity": 0 - }, "rotation_dofs": true }, "processes": { diff --git a/shape_optimization/use_cases/06_bead_optimization_plate/optimization_parameters.json b/shape_optimization/use_cases/06_bead_optimization_plate/optimization_parameters.json index 610b00bf..2ac4b04b 100644 --- a/shape_optimization/use_cases/06_bead_optimization_plate/optimization_parameters.json +++ b/shape_optimization/use_cases/06_bead_optimization_plate/optimization_parameters.json @@ -44,8 +44,7 @@ "type": "vertex_morphing", "filter": { "filter_function_type": "linear", - "filter_radius": 0.075, - "max_nodes_in_filter_radius": 1000 + "filter_radius": 0.075 } }, "optimization_algorithm": { @@ -71,6 +70,7 @@ "DF1DALPHA", "DF1DALPHA_MAPPED", "DPDALPHA", + "DLDALPHA", "ALPHA", "ALPHA_MAPPED", "CONTROL_POINT_CHANGE", diff --git a/shape_optimization/use_cases/07_optimization_plate_with_step_adaption/analysis_parameters.json b/shape_optimization/use_cases/07_optimization_plate_with_step_adaption/analysis_parameters.json index bea80ce2..4472e2ab 100644 --- a/shape_optimization/use_cases/07_optimization_plate_with_step_adaption/analysis_parameters.json +++ b/shape_optimization/use_cases/07_optimization_plate_with_step_adaption/analysis_parameters.json @@ -22,18 +22,6 @@ "material_import_settings" :{ "materials_filename": "2D_material.json" }, - "line_search" : false, - "convergence_criterion" : "residual_criterion", - "displacement_relative_tolerance" : 0.0001, - "displacement_absolute_tolerance" : 1e-9, - "residual_relative_tolerance" : 0.0001, - "residual_absolute_tolerance" : 1e-9, - "max_iteration" : 10, - "linear_solver_settings" : { - "solver_type" : "ExternalSolversApplication.super_lu", - "scaling" : false, - "verbosity" : 0 - }, "rotation_dofs" : true }, "processes" : { diff --git a/shape_optimization/use_cases/08_Optimization_3D_Hook_plane_constraint/run_optimization.py b/shape_optimization/use_cases/08_Optimization_3D_Hook_plane_constraint/run_optimization.py index 15bf2bca..cdf37e84 100644 --- a/shape_optimization/use_cases/08_Optimization_3D_Hook_plane_constraint/run_optimization.py +++ b/shape_optimization/use_cases/08_Optimization_3D_Hook_plane_constraint/run_optimization.py @@ -1,6 +1,3 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM diff --git a/shape_optimization/use_cases/09_Packaging_3D_Shell/run_optimization.py b/shape_optimization/use_cases/09_Packaging_3D_Shell/run_optimization.py index 8693b476..6a8a166a 100644 --- a/shape_optimization/use_cases/09_Packaging_3D_Shell/run_optimization.py +++ b/shape_optimization/use_cases/09_Packaging_3D_Shell/run_optimization.py @@ -1,12 +1,9 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM # Additional imports from KratosMultiphysics.ShapeOptimizationApplication import optimizer_factory -from KratosMultiphysics.ShapeOptimizationApplication.analyzer_base import AnalyzerBaseClass +from KratosMultiphysics.ShapeOptimizationApplication.analyzers.analyzer_base import AnalyzerBaseClass # Read parameters with open("optimization_parameters.json",'r') as parameter_file: diff --git a/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/primal_parameters_main.json b/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/primal_parameters_main.json index 7883bb33..e323ab20 100644 --- a/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/primal_parameters_main.json +++ b/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/primal_parameters_main.json @@ -22,16 +22,6 @@ "material_import_settings" :{ "materials_filename": "materials_3D.json" }, - "line_search" : false, - "convergence_criterion" : "Residual_criterion", - "displacement_relative_tolerance" : 0.0001, - "displacement_absolute_tolerance" : 1e-9, - "residual_relative_tolerance" : 0.0001, - "residual_absolute_tolerance" : 1e-9, - "max_iteration" : 10, - "linear_solver_settings" : { - "solver_type" : "LinearSolversApplication.pardiso_llt" - }, "rotation_dofs" : false }, "processes": { @@ -78,13 +68,7 @@ "process_name" : "VTKOutputProcess", "Parameters" : { "model_part_name": "3D_Hook", - "file_format": "binary", - "output_precision": 7, - "output_control_type": "step", - "output_interval": 1.0, - "output_sub_model_parts": false, "folder_name": "Primal_Results_main", - "save_output_files_in_folder": true, "nodal_solution_step_data_variables": ["DISPLACEMENT","REACTION"], "nodal_data_value_variables": [], "element_data_value_variables": [], diff --git a/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/run_optimization.py b/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/run_optimization.py index 0095dbf9..a4b92f8a 100644 --- a/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/run_optimization.py +++ b/shape_optimization/use_cases/10_Multi_Constraint_Optimization_3D_Hook/run_optimization.py @@ -1,14 +1,11 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM # Additional imports import KratosMultiphysics.ShapeOptimizationApplication as KSO -from KratosMultiphysics.ShapeOptimizationApplication import optimizer_factory, analyzer_base +from KratosMultiphysics.ShapeOptimizationApplication import optimizer_factory from KratosMultiphysics.StructuralMechanicsApplication import structural_response_function_factory as csm_response_factory -from KratosMultiphysics.ShapeOptimizationApplication.analyzer_base import AnalyzerBaseClass +from KratosMultiphysics.ShapeOptimizationApplication.analyzers.analyzer_base import AnalyzerBaseClass # Read parameters with open("optimization_parameters.json", 'r') as parameter_file: diff --git a/shape_optimization/use_cases/11_Shape_Update_Optimization_Stanford_Bunny/run_optimization.py b/shape_optimization/use_cases/11_Shape_Update_Optimization_Stanford_Bunny/run_optimization.py index 6c8606b8..1ff4ba9f 100644 --- a/shape_optimization/use_cases/11_Shape_Update_Optimization_Stanford_Bunny/run_optimization.py +++ b/shape_optimization/use_cases/11_Shape_Update_Optimization_Stanford_Bunny/run_optimization.py @@ -1,11 +1,7 @@ -# Making KratosMultiphysics backward compatible with python 2.6 and 2.7 -from __future__ import print_function, absolute_import, division - # Import Kratos core and apps import KratosMultiphysics as KM # Additional imports -import KratosMultiphysics.ShapeOptimizationApplication as KSO from KratosMultiphysics.ShapeOptimizationApplication import optimizer_factory # Read parameters