forked from dlubal-software/RFEM_Python_Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_zCalculate.py
More file actions
72 lines (58 loc) · 3.35 KB
/
Copy pathtest_zCalculate.py
File metadata and controls
72 lines (58 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 SurfacesShapeOfFiniteElements, OptimizeOnType, Optimizer
from RFEM.initModel import Model, client
from RFEM.Calculate.meshSettings import GetMeshSettings, MeshSettings, GetModelInfo
from RFEM.Calculate.optimizationSettings import OptimizationSettings
from UnitTests.test_solids import test_solids_and_solid_sets
if Model.clientModel is None:
Model()
# CAUTION:
# These tests needs to be executed last because they change global settings.
# At the end of the script the model is closed.
def test_mesh_settings():
Model.clientModel.service.delete_all()
Model.clientModel.service.begin_modification()
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['QualityCriteriaConfigForSurfaces']['quality_criterion_check_aspect_ratio_warning'] = 22
solid = dict(MeshSettings.SolidsMeshQualityConfig)
solid['QualityCriteriaConfigForSolids']['quality_criterion_parallel_deviations_warning'] = 1.7
wind = dict(MeshSettings.WindSimulationMeshConfig)
MeshSettings(common, surf, solid, wind)
control_mesh = GetMeshSettings()
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']['QualityCriteriaConfigForSurfaces']['quality_criterion_check_aspect_ratio_warning'] == 22
assert control_mesh['SolidsMeshQualityConfig']['QualityCriteriaConfigForSolids']['quality_criterion_parallel_deviations_warning'] == 1.7
control_mesh['general_maximum_distance_between_node_and_line'] = 0.003
MeshSettings.set_mesh_settings(control_mesh)
control_mesh = GetMeshSettings()
assert control_mesh['general_maximum_distance_between_node_and_line'] == 0.003
Model.clientModel.service.finish_modification()
test_solids_and_solid_sets()
count = GetModelInfo()
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()
assert opt_sett.general_optimization_active
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
opt_sett.general_keep_best_number_model_mutations = 15
OptimizationSettings.set(opt_sett)
# Testing model is closed at the end of the testing session to enable easier and cleaned restart of the unit tests.
client.service.close_model(0, False)