diff --git a/Examples/Cantilever/Demo1.py b/Examples/Cantilever/Demo1.py index 9a842f77..2357bd6e 100644 --- a/Examples/Cantilever/Demo1.py +++ b/Examples/Cantilever/Demo1.py @@ -9,7 +9,7 @@ sys.path.append(dirName + r'/../..') # Import der Bibliotheken -from RFEM.enums import NodalSupportType, StaticAnalysisType, LoadDirectionType +from RFEM.enums import NodalSupportType, LoadDirectionType from RFEM.initModel import Model, Calculate_all from RFEM.BasicObjects.material import Material from RFEM.BasicObjects.section import Section diff --git a/Examples/main.py b/Examples/main.py index 19256213..4c741770 100644 --- a/Examples/main.py +++ b/Examples/main.py @@ -122,6 +122,7 @@ def main(hall_width_L, hall_height_h_o, hall_height_h_m, number_frames, frame_sp # ------------------------------------------------------------- # Members + member = Member() # Frames i = 1 while i <= number_frames: @@ -147,19 +148,19 @@ def main(hall_width_L, hall_height_h_o, hall_height_h_m, number_frames, frame_sp j = 4*number_frames + 3*(number_frames-1) while i <= number_frames-1: k = j + (i-1)*4 - Member.Tension(0,k+1, (i-1)*5+1, (i-1)*5+7 , MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) - Member.Tension(0,k+2, (i-1)*5+2, (i-1)*5+6 , MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) - Member.Tension(0,k+3, (i-1)*5+5, (i-1)*5+9 , MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) - Member.Tension(0,k+4, (i-1)*5+4, (i-1)*5+10, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(k+1, (i-1)*5+1, (i-1)*5+7 , MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(k+2, (i-1)*5+2, (i-1)*5+6 , MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(k+3, (i-1)*5+5, (i-1)*5+9 , MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(k+4, (i-1)*5+4, (i-1)*5+10, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) i += 1 # Diagonals on the roof j += 4*(number_frames-1) if number_frames > 1: - Member.Tension(0,j+1, 2, 8, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) - Member.Tension(0,j+2, 7, 3, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) - Member.Tension(0,j+3, 3, 9, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) - Member.Tension(0,j+4, 4, 8, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(j+1, 2, 8, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(j+2, 7, 3, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(j+3, 3, 9, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) + member.Tension(j+4, 4, 8, MemberRotationSpecificationType.COORDINATE_SYSTEM_ROTATION_VIA_ANGLE, [0], 4) # ------------------------------------------------------------- # Surfaces @@ -234,43 +235,45 @@ def main(hall_width_L, hall_height_h_o, hall_height_h_m, number_frames, frame_sp # ------------------------------------------------------------- # Member Loads - MemberLoad.Force(0, 2, 1, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[5000]) + memberLoad = MemberLoad() + + memberLoad.Force(2, 1, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[5000]) ## Force Type Member Load with LOAD_DISTRIBUTION_UNIFORM with Eccentricity ## - MemberLoad.Force(0, 3, 2, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[5000], force_eccentricity=True, params={'eccentricity_y_at_start' : 0.01, 'eccentricity_z_at_start': 0.02}) + memberLoad.Force(3, 2, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[5000], force_eccentricity=True, params={'eccentricity_y_at_start' : 0.01, 'eccentricity_z_at_start': 0.02}) ## Force Type Member Load with LOAD_DISTRIBUTION_UNIFORM_TOTAL ## - MemberLoad.Force(0, 4, 3, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM_TOTAL, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[5000]) + memberLoad.Force(4, 3, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM_TOTAL, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[5000]) ## Force Type Member Load with LOAD_DISTRIBUTION_CONCENTRATED_1 ## - MemberLoad.Force(0, 5, 4, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_1, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, 5000, 1.2]) + memberLoad.Force(5, 4, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_1, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, 5000, 1.2]) ## Force Type Member Load with LOAD_DISTRIBUTION_CONCENTRATED_N ## - MemberLoad.Force(0, 6, 5, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_N, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 5000, 2, 1, 2]) + memberLoad.Force(6, 5, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_N, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 5000, 2, 1, 2]) ## Force Type Member Load with LOAD_DISTRIBUTION_CONCENTRATED_2x2 ## - MemberLoad.Force(0, 7, 6, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_2x2, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, False, 5000, 1, 2, 3]) + memberLoad.Force(7, 6, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_2x2, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, False, 5000, 1, 2, 3]) ## Force Type Member Load with LOAD_DISTRIBUTION_CONCENTRATED_2x ## - MemberLoad.Force(0, 8, 7, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_2, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 5000, 6000, 1, 2]) + memberLoad.Force(8, 7, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_2, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 5000, 6000, 1, 2]) ## Force Type Member Load with LOAD_DISTRIBUTION_CONCENTRATED_VARYING ## - MemberLoad.Force(0, 9, 8, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_VARYING, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[[1, 1, 4000], [2, 1, 5000]]) + memberLoad.Force(9, 8, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_VARYING, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[[1, 1, 4000], [2, 1, 5000]]) ## Force Type Member Load with LOAD_DISTRIBUTION_TRAPEZOIDAL ## - MemberLoad.Force(0, 10, 9, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_TRAPEZOIDAL, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 4000, 8000, 1, 2]) + memberLoad.Force(10, 9, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_TRAPEZOIDAL, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 4000, 8000, 1, 2]) ## Force Type Member Load with LOAD_DISTRIBUTION_TAPERED ## - MemberLoad.Force(0, 11, 10, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_TAPERED, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 4000, 8000, 1, 2]) + memberLoad.Force(11, 10, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_TAPERED, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[False, False, 4000, 8000, 1, 2]) ## Force Type Member Load with LOAD_DISTRIBUTION_PARABOLIC ## - MemberLoad.Force(0, 12, 11, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_PARABOLIC, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[4000, 8000, 12000]) + memberLoad.Force(12, 11, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_PARABOLIC, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[4000, 8000, 12000]) ## Force Type Member Load with LOAD_DISTRIBUTION_VARYING ## - MemberLoad.Force(0, 13, 12, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_VARYING, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[[1, 1, 4000], [2, 1, 5000]]) + memberLoad.Force(13, 12, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_VARYING, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[[1, 1, 4000], [2, 1, 5000]]) ## Force Type Member Load with LOAD_DISTRIBUTION_VARYING_IN_Z ## - MemberLoad.Force(0, 14, 13, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_VARYING_IN_Z, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[[1, 1, 4000], [2, 1, 5000]]) + memberLoad.Force(14, 13, "2 3 6 7", MemberLoadDistribution.LOAD_DISTRIBUTION_VARYING_IN_Z, MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, load_parameter=[[1, 1, 4000], [2, 1, 5000]]) # ------------------------------------------------------------- # Surface Loads diff --git a/RFEM/Calculate/meshSettings.py b/RFEM/Calculate/meshSettings.py new file mode 100644 index 00000000..6994f641 --- /dev/null +++ b/RFEM/Calculate/meshSettings.py @@ -0,0 +1,170 @@ +from RFEM.initModel import Model, CheckAddonStatus, SetAddonStatus, clearAtributes + +class MeshSettings(): + ComonMeshConfig: dict = { + 'general_target_length_of_fe': None, + 'general_maximum_distance_between_node_and_line': None, + 'general_maximum_number_of_mesh_nodes': None, + 'members_number_of_divisions_for_special_types': None, + 'members_activate_division_for_large_deformation_and_post_critical_analysis': None, + 'members_number_of_divisions_for_result_diagram': None, + 'members_number_of_divisions_for_min_max_values': None, + 'members_use_division_for_concrete_members': None, + 'members_number_of_divisions_for_concrete_members': None, + 'members_use_division_for_straight_members': None, + 'members_division_for_straight_members_type': None, + 'members_length_of_fe': None, + 'members_minimum_number_of_divisions': None, + 'members_use_division_for_members_with_nodes': None, + 'surfaces_maximum_ratio_of_fe': None, + 'surfaces_maximum_out_of_plane_inclination': None, + 'surfaces_mesh_refinement': None, + 'surfaces_relationship': None, + 'surfaces_integrate_also_unutilized_objects': None, + 'surfaces_shape_of_finite_elements': None, + 'surfaces_same_squares': None, + 'surfaces_triangles_for_membranes': None, + 'surfaces_mapped_mesh_preferred': None, + 'solids_use_refinement_if_containing_close_nodes': None, + 'solids_maximum_number_of_elements': None} + SurfacesMeshQualityConfig: dict = { + 'mesh_quality_color_indicator_ok_color': None, + 'mesh_quality_color_indicator_warning_color': None, + 'mesh_quality_color_indicator_failure_color': None, + 'QualityCriteriaConfig': { + 'quality_criterion_check_aspect_ratio': None, + 'quality_criterion_check_aspect_ratio_warning': None, + 'quality_criterion_check_aspect_ratio_failure': None, + 'quality_criterion_parallel_deviations': None, + 'quality_criterion_parallel_deviations_warning': None, + 'quality_criterion_parallel_deviations_failure': None, + 'quality_criterion_corner_angles_of_triangle_elements': None, + 'quality_criterion_corner_angles_of_triangle_elements_warning': None, + 'quality_criterion_corner_angles_of_triangle_elements_failure': None, + 'quality_criterion_corner_angles_of_quadrangle_elements': None, + 'quality_criterion_corner_angles_of_quadrangle_elements_warning': None, + 'quality_criterion_corner_angles_of_quadrangle_elements_failure': None, + 'quality_criterion_warping_of_membrane_elements': None, + 'quality_criterion_warping_of_membrane_elements_warning': None, + 'quality_criterion_warping_of_membrane_elements_failure': None, + 'quality_criterion_warping_of_non_membrane_elements': None, + 'quality_criterion_warping_of_non_membrane_elements_warning': None, + 'quality_criterion_warping_of_non_membrane_elements_failure': None, + 'quality_criterion_jacobian_ratio': None, + 'quality_criterion_jacobian_ratio_warning': None, + 'quality_criterion_jacobian_ratio_failure': None}} + SolidsMeshQualityConfig: dict = { + 'mesh_quality_color_indicator_ok_color': None, + 'mesh_quality_color_indicator_warning_color': None, + 'mesh_quality_color_indicator_failure_color': None, + 'QualityCriteriaConfig': { + 'quality_criterion_check_aspect_ratio': None, + 'quality_criterion_check_aspect_ratio_warning': None, + 'quality_criterion_check_aspect_ratio_failure': None, + 'quality_criterion_parallel_deviations': None, + 'quality_criterion_parallel_deviations_warning': None, + 'quality_criterion_parallel_deviations_failure': None, + 'quality_criterion_corner_angles_of_triangle_elements': None, + 'quality_criterion_corner_angles_of_triangle_elements_warning': None, + 'quality_criterion_corner_angles_of_triangle_elements_failure': None, + 'quality_criterion_corner_angles_of_quadrangle_elements': None, + 'quality_criterion_corner_angles_of_quadrangle_elements_warning': None, + 'quality_criterion_corner_angles_of_quadrangle_elements_failure': None, + 'quality_criterion_warping': None, + 'quality_criterion_warping_warning': None, + 'quality_criterion_warping_failure': None, + 'quality_criterion_jacobian_ratio': None, + 'quality_criterion_jacobian_ratio_warning': None, + 'quality_criterion_jacobian_ratio_failure': None}} + WindSimulationMeshConfig: dict = { + 'windsimulation_mesh_config_value_simplify_model': None, + 'windsimulation_mesh_config_value_determine_details_by': None, + 'windsimulation_mesh_config_value_level_of_details': None, + 'windsimulation_mesh_config_value_detail_size': None, + 'windsimulation_mesh_config_value_small_openings_closure_type': None, + 'windsimulation_mesh_config_value_small_openings_closure_value': None, + 'windsimulation_mesh_config_value_optimized_member_topology': None, + 'windsimulation_mesh_config_value_optimized_member_topo_value': None, + 'windsimulation_mesh_config_value_active_objects_only': None, + 'windsimulation_mesh_config_value_terrain': None, + 'windsimulation_mesh_config_value_terrain_from_model': None, + 'windsimulation_mesh_config_value_terrain_objects_id': None, + 'windsimulation_mesh_config_value_terrain_objects_all': None, + 'windsimulation_mesh_config_value_surrounding_model': None, + 'windsimulation_mesh_config_value_surrounding_model_ifc_objects_id': None, + 'windsimulation_mesh_config_value_surrounding_model_ifc_objects_all': None, + 'windsimulation_mesh_config_value_surrounding_model_visual_objects_id': None, + 'windsimulation_mesh_config_value_surrounding_model_visual_objects_all': None, + 'windsimulation_mesh_config_value_keep_results_if_mesh_deleted': None, + 'windsimulation_mesh_config_value_consider_surface_thickness': None, + 'windsimulation_mesh_config_value_run_rwind_silent': None} + + def __init__(self, + commonConfig: dict = ComonMeshConfig, + surfaceConfig: dict = SurfacesMeshQualityConfig, + solidConfig: dict = SolidsMeshQualityConfig, + windConfig: dict = WindSimulationMeshConfig): + """ + The object is automaticaly created therefore we can assume that it will not be created but only updated. + Only posititve values are recognized. + + Args: + commonConfig: common parameters settings + surfaceConfig: surface specific parameters + solidConfig: solid specific parameters + windConfig: wind specific parameters; use only when Wind Simulation Add-on is active + """ + # Get current mesh settings + config = Model.clientModel.service.get_mesh_settings() + + clientObject = {} + for i in config: + if i[0] == 'windSimulationMeshConfig': + if CheckAddonStatus(Model.clientModel, 'wind_simulation_active'): + clientObject[i[0]] = config[i[0]] + else: + clientObject[i[0]] = config[i[0]] + + # No parameter can be set to None + for key in commonConfig: + if commonConfig[key]: + clientObject[key] = commonConfig[key] + for key in surfaceConfig: + if key == 'QualityCriteriaConfig': + for key_ in surfaceConfig['QualityCriteriaConfig']: + if surfaceConfig['QualityCriteriaConfig'][key_]: + clientObject['SurfacesMeshQualityConfig']['QualityCriteriaConfig'][key_] = surfaceConfig['QualityCriteriaConfig'][key_] + elif surfaceConfig[key]: + clientObject['SurfacesMeshQualityConfig'][key] = surfaceConfig[key] + for key in solidConfig: + if key == 'QualityCriteriaConfig': + for key_ in solidConfig['QualityCriteriaConfig']: + if solidConfig['QualityCriteriaConfig'][key_]: + clientObject['SolidsMeshQualityConfig']['QualityCriteriaConfig'][key_] = solidConfig['QualityCriteriaConfig'][key_] + elif solidConfig[key]: + clientObject['SolidsMeshQualityConfig'][key] = solidConfig[key] + if CheckAddonStatus(Model.clientModel, 'wind_simulation_active'): + for key in windConfig: + if windConfig[key]: + clientObject['windSimulationMeshConfig'][key] = windConfig[key] + + # Add Mesh Settings to client model + Model.clientModel.service.set_mesh_settings(clientObject) + + def get_mesh_settings(self): + return Model.clientModel.service.get_mesh_settings() + + def set_mesh_settings(self, all_settings): + new_sett = {} + + for i in all_settings: + if i[0] == 'windSimulationMeshConfig': + if CheckAddonStatus(Model.clientModel, 'wind_simulation_active'): + new_sett['wind_simulation_active'] = all_settings['wind_simulation_active'] + else: + new_sett[i[0]] = all_settings[i[0]] + + Model.clientModel.service.set_mesh_settings(new_sett) + + def get_model_info(self): + return Model.clientModel.service.get_model_info() diff --git a/RFEM/Calculate/optimizationSettings.py b/RFEM/Calculate/optimizationSettings.py new file mode 100644 index 00000000..a3a028d9 --- /dev/null +++ b/RFEM/Calculate/optimizationSettings.py @@ -0,0 +1,37 @@ +from RFEM.initModel import Model +from RFEM.enums import * + +class OptimizationSettings(): + def __init__(self, + general_optimization_active = True, + general_keep_best_number_model_mutations = 10, + general_optimize_on = OptimizeOnType.E_OPTIMIZE_ON_TYPE_MIN_WHOLE_WEIGHT, + general_optimizer = Optimizer.E_OPTIMIZER_TYPE_ALL_MUTATIONS, + general_number_random_mutations = 0.2): + """ + The object is automaticaly created therefore we can assume, + that it will not be created but only updated/changed. + + Args: + general_optimization_active (bool): Set Optimization Active + general_keep_best_number_model_mutations (int): Keep best number of model mutations + general_optimize_on (enum): Optimize on + general_optimizer (enum): Optimizer + general_number_random_mutations (float): Number of random mutations + """ + + opt_settings = Model.clientModel.service.get_optimization_settings() + opt_settings.general_optimization_active = general_optimization_active + opt_settings.general_keep_best_number_model_mutations = general_keep_best_number_model_mutations + opt_settings.general_optimize_on = general_optimize_on.name + opt_settings.general_optimizer = general_optimizer.name + opt_settings.general_number_random_mutations = general_number_random_mutations + + # Set Optimization settings to client model + Model.clientModel.service.set_optimization_settings(opt_settings) + + def get_optimization_settings(self): + return Model.clientModel.service.get_optimization_settings() + + def set_optimization_settings(self, opt_settings): + Model.clientModel.service.set_optimization_settings(opt_settings) \ No newline at end of file diff --git a/RFEM/TypesForBracings/singleBracing.py b/RFEM/TypesForBracings/singleBracing.py deleted file mode 100644 index 8b137891..00000000 --- a/RFEM/TypesForBracings/singleBracing.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/RFEM/enums.py b/RFEM/enums.py index 02cc85e1..aa103395 100644 --- a/RFEM/enums.py +++ b/RFEM/enums.py @@ -1205,3 +1205,23 @@ class ModelCheckProcessOptionType(Enum): Model Check Process Object Groups Option Type ''' CROSS_LINES, CROSS_MEMBERS, DELETE_UNUSED_NODES, UNITE_NODES_AND_DELETE_UNUSED_NODES = range(4) + +class OptimizeOnType(Enum): + ''' + Optimization Settings Optimize On Type + ''' + E_OPTIMIZE_ON_TYPE_MIN_WHOLE_WEIGHT, E_OPTIMIZE_ON_TYPE_MIN_VECTORIAL_DISPLACEMENT, E_OPTIMIZE_ON_TYPE_MIN_MEMBER_DEFORMATION, \ + E_OPTIMIZE_ON_TYPE_MIN_SURFACE_DEFORMATION, E_OPTIMIZE_ON_TYPE_MIN_COST, E_OPTIMIZE_ON_TYPE_MIN_CO2_EMISSIONS = range(6) + +class Optimizer(Enum): + ''' + Optimization Settings Optimizer + ''' + E_OPTIMIZER_TYPE_ALL_MUTATIONS, E_OPTIMIZER_TYPE_PERCENTS_OF_RANDOM_MUTATIONS, E_OPTIMIZER_TYPE_PARTICLE_SWARM = range(3) + +class SurfacesShapeOfFiniteElements(Enum): + ''' + Surfaces Shape of Finite Elements + ''' + E_SHAPE_OF_FINITE_ELEMENTS_FOR_SURFACES__TRIANGLES_AND_QUADRANGLES, E_SHAPE_OF_FINITE_ELEMENTS_FOR_SURFACES__QUADRANGLES_ONLY, \ + E_SHAPE_OF_FINITE_ELEMENTS_FOR_SURFACES__TRIANGLES_ONLY = range(3) diff --git a/RFEM/initModel.py b/RFEM/initModel.py index b14670ee..660a3177 100644 --- a/RFEM/initModel.py +++ b/RFEM/initModel.py @@ -428,7 +428,7 @@ def GenerateMesh(): Model.clientModel.service.generate_mesh() -def GetMeshStatics(): +def GetMeshStatistics(): mesh_stats = Model.clientModel.service.get_mesh_statistics() return Model.clientModel.dict(mesh_stats) diff --git a/UnitTests/test_Calculate.py b/UnitTests/test_Calculate.py new file mode 100644 index 00000000..f49b7d5c --- /dev/null +++ b/UnitTests/test_Calculate.py @@ -0,0 +1,59 @@ +import sys +import os +PROJECT_ROOT = os.path.abspath(os.path.join( + os.path.dirname(__file__), + os.pardir) +) +sys.path.append(PROJECT_ROOT) +from RFEM.enums import * +from RFEM.initModel import Model +from RFEM.Calculate.meshSettings import MeshSettings +from RFEM.Calculate.optimizationSettings import OptimizationSettings +from UnitTests.test_solids import test_solids_and_solid_sets + +if Model.clientModel is None: + Model() + +def test_mesh_settings(): + + common = MeshSettings.ComonMeshConfig + common['general_target_length_of_fe'] = 0.4321 + common['members_number_of_divisions_for_special_types'] = 12 + common['surfaces_shape_of_finite_elements'] = SurfacesShapeOfFiniteElements.E_SHAPE_OF_FINITE_ELEMENTS_FOR_SURFACES__TRIANGLES_ONLY.name + surf = MeshSettings.SurfacesMeshQualityConfig + surf['QualityCriteriaConfig']['quality_criterion_check_aspect_ratio_warning'] = 22 + solid = dict(MeshSettings.SolidsMeshQualityConfig) + solid['QualityCriteriaConfig']['quality_criterion_parallel_deviations_warning'] = 1.7 + wind = dict(MeshSettings.WindSimulationMeshConfig) + + mesh = MeshSettings(common, surf, solid, wind) + + control_mesh = mesh.get_mesh_settings() + assert control_mesh['general_target_length_of_fe'] == 0.4321 + assert control_mesh['members_number_of_divisions_for_special_types'] == 12 + assert control_mesh['surfaces_shape_of_finite_elements'] == SurfacesShapeOfFiniteElements.E_SHAPE_OF_FINITE_ELEMENTS_FOR_SURFACES__TRIANGLES_ONLY.name + assert control_mesh['SurfacesMeshQualityConfig']['QualityCriteriaConfig']['quality_criterion_check_aspect_ratio_warning'] == 22 + assert control_mesh['SolidsMeshQualityConfig']['QualityCriteriaConfig']['quality_criterion_parallel_deviations_warning'] == 1.7 + + control_mesh['general_maximum_distance_between_node_and_line'] = 0.003 + mesh.set_mesh_settings(control_mesh) + control_mesh = mesh.get_mesh_settings() + assert control_mesh['general_maximum_distance_between_node_and_line'] == 0.003 + + test_solids_and_solid_sets() + + info = MeshSettings() + count = info.get_model_info() + assert count['property_node_count'] == 28 + +def test_optimization_settings(): + + OptimizationSettings(True, 11, OptimizeOnType.E_OPTIMIZE_ON_TYPE_MIN_COST, + Optimizer.E_OPTIMIZER_TYPE_PERCENTS_OF_RANDOM_MUTATIONS, + 0.3) + opt_sett = OptimizationSettings.get_optimization_settings(OptimizationSettings) + assert opt_sett.general_optimization_active == True + assert opt_sett.general_keep_best_number_model_mutations == 11 + assert opt_sett.general_optimize_on == OptimizeOnType.E_OPTIMIZE_ON_TYPE_MIN_COST.name + assert opt_sett.general_optimizer == Optimizer.E_OPTIMIZER_TYPE_PERCENTS_OF_RANDOM_MUTATIONS.name + assert opt_sett.general_number_random_mutations == 0.3 diff --git a/UnitTests/test_MeshGenerationStatistics.py b/UnitTests/test_MeshGenerationStatistics.py index 9fb3e782..db39511c 100644 --- a/UnitTests/test_MeshGenerationStatistics.py +++ b/UnitTests/test_MeshGenerationStatistics.py @@ -12,7 +12,7 @@ from RFEM.BasicObjects.node import Node from RFEM.BasicObjects.thickness import Thickness from RFEM.BasicObjects.material import Material -from RFEM.initModel import Model, CheckIfMethodOrTypeExists, GenerateMesh, GetMeshStatics +from RFEM.initModel import Model, CheckIfMethodOrTypeExists, GenerateMesh, GetMeshStatistics from RFEM.enums import * if Model.clientModel is None: @@ -48,4 +48,4 @@ def test_generation_of_mesh_statistics(): Model.clientModel.service.finish_modification() # Missing validation - mesh_stats = GetMeshStatics() + mesh_stats = GetMeshStatistics()