ANYstructure 5.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anystruct/ANYstructure_documentation.pdf +0 -0
- anystruct/SN_curve_parameters.py +35 -0
- anystruct/__init__.py +0 -0
- anystruct/__main__.py +24 -0
- anystruct/api.py +772 -0
- anystruct/buckling_calc_external.py +120 -0
- anystruct/bulb_anglebar_tbar_flatbar.csv +677 -0
- anystruct/calc_loads.py +526 -0
- anystruct/calc_structure.py +4838 -0
- anystruct/compartment_window.py +176 -0
- anystruct/example_data.py +532 -0
- anystruct/example_data_puls.py +46 -0
- anystruct/excel_inteface.py +244 -0
- anystruct/fatigue_window.py +352 -0
- anystruct/grid_window.py +307 -0
- anystruct/gui.py +24 -0
- anystruct/helper.py +623 -0
- anystruct/images/ANYstructure_logo.jpg +0 -0
- anystruct/images/Buckling_Strength_of_Shells.png +0 -0
- anystruct/images/Panel_geometry_definitions.png +0 -0
- anystruct/images/current_comps_NONE.png +0 -0
- anystruct/images/fls_button.gif +0 -0
- anystruct/images/img_T_L_FB.gif +0 -0
- anystruct/images/img_axial_stresses.gif +0 -0
- anystruct/images/img_ext_pressure_button.gif +0 -0
- anystruct/images/img_ext_pressure_button_def.gif +0 -0
- anystruct/images/img_fixation_parameters.gif +0 -0
- anystruct/images/img_generate_report.gif +0 -0
- anystruct/images/img_int_pressure_button.gif +0 -0
- anystruct/images/img_int_pressure_button_search.gif +0 -0
- anystruct/images/img_multi_opt.gif +0 -0
- anystruct/images/img_optimize.gif +0 -0
- anystruct/images/img_plate_and_stiffener.gif +0 -0
- anystruct/images/img_stf_button.gif +0 -0
- anystruct/images/img_stiffener.gif +0 -0
- anystruct/images/img_stress_button.gif +0 -0
- anystruct/images/img_title.gif +0 -0
- anystruct/images/img_transverse_stress.gif +0 -0
- anystruct/load_factor_window.py +166 -0
- anystruct/load_window.py +721 -0
- anystruct/main_application.py +7918 -0
- anystruct/make_grid_numpy.py +506 -0
- anystruct/make_queue.py +52 -0
- anystruct/make_stack.py +52 -0
- anystruct/ml_files/CL_CSR-Tank_req_cl_predictor.pickle +0 -0
- anystruct/ml_files/CL_CSR-Tank_req_cl_scaler.pickle +0 -0
- anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor.pickle +0 -0
- anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_scaler.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/opt_problem.py +31 -0
- anystruct/optimize.py +1680 -0
- anystruct/optimize_cylinder.py +898 -0
- anystruct/optimize_geometry.py +1708 -0
- anystruct/optimize_multiple_window.py +1507 -0
- anystruct/optimize_window.py +1117 -0
- anystruct/pl_stf_window.py +572 -0
- anystruct/report_generator.py +912 -0
- anystruct/sections.csv +202 -0
- anystruct/sesam_interface.py +115 -0
- anystruct/ship_section_example.txt +1 -0
- anystruct/stresses_window.py +269 -0
- anystruct/testCalc.py +118 -0
- anystructure-5.2.0.dist-info/METADATA +86 -0
- anystructure-5.2.0.dist-info/RECORD +99 -0
- anystructure-5.2.0.dist-info/WHEEL +5 -0
- anystructure-5.2.0.dist-info/entry_points.txt +2 -0
- anystructure-5.2.0.dist-info/licenses/LICENSE +21 -0
- anystructure-5.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
# This is where the optimization is done.
|
|
2
|
+
|
|
3
|
+
import tkinter as tk
|
|
4
|
+
import numpy as np
|
|
5
|
+
import time, os, datetime
|
|
6
|
+
from tkinter import messagebox
|
|
7
|
+
from tkinter.filedialog import askopenfilenames
|
|
8
|
+
from multiprocessing import cpu_count
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
import anystruct.main_application as main_application
|
|
12
|
+
import anystruct.optimize as op
|
|
13
|
+
import anystruct.example_data as test
|
|
14
|
+
import anystruct.helper as hlp
|
|
15
|
+
except ModuleNotFoundError:
|
|
16
|
+
import ANYstructure.anystruct.main_application as main_application
|
|
17
|
+
import ANYstructure.anystruct.optimize as op
|
|
18
|
+
import ANYstructure.anystruct.example_data as test
|
|
19
|
+
import ANYstructure.anystruct.helper as hlp
|
|
20
|
+
|
|
21
|
+
class CreateOptimizeCylinderWindow():
|
|
22
|
+
'''
|
|
23
|
+
This class initiates the single optimization window.
|
|
24
|
+
'''
|
|
25
|
+
|
|
26
|
+
def __init__(self,master,app=None):
|
|
27
|
+
super(CreateOptimizeCylinderWindow,self).__init__()
|
|
28
|
+
if __name__ == '__main__':
|
|
29
|
+
import pickle
|
|
30
|
+
import anystruct.calc_structure as calc
|
|
31
|
+
self._initial_structure_obj = test.get_structure_calc_object(heavy=True)
|
|
32
|
+
self._initial_calc_obj = test.get_structure_calc_object(heavy=True)
|
|
33
|
+
self._fatigue_object = test.get_fatigue_object()
|
|
34
|
+
self._fatigue_pressure = test.get_fatigue_pressures()
|
|
35
|
+
self._slamming_pressure = test.get_slamming_pressure()
|
|
36
|
+
image_dir = os.path.dirname(__file__)+'\\images\\'
|
|
37
|
+
self._PULS_object = None
|
|
38
|
+
self._puls_acceptance = 0.87
|
|
39
|
+
|
|
40
|
+
self._initial_cylinder_obj = calc.CylinderAndCurvedPlate(main_dict=test.shell_main_dict,
|
|
41
|
+
shell=calc.Shell(test.shell_dict),
|
|
42
|
+
long_stf=calc.Structure(test.obj_dict_cyl_long2),
|
|
43
|
+
ring_stf=None,#calc.Structure(test.obj_dict_cyl_ring2),
|
|
44
|
+
ring_frame=None)#calc.Structure(test.obj_dict_cyl_heavy_ring2))
|
|
45
|
+
|
|
46
|
+
self._ML_buckling = dict() # Buckling machine learning algorithm
|
|
47
|
+
for name, file_base in zip(['cl SP buc int predictor', 'cl SP buc int scaler',
|
|
48
|
+
'cl SP ult int predictor', 'cl SP ult int scaler',
|
|
49
|
+
'cl SP buc GLGT predictor', 'cl SP buc GLGT scaler',
|
|
50
|
+
'cl SP ult GLGT predictor', 'cl SP ult GLGT scaler',
|
|
51
|
+
'cl UP buc int predictor', 'cl UP buc int scaler',
|
|
52
|
+
'cl UP ult int predictor', 'cl UP ult int scaler',
|
|
53
|
+
'cl UP buc GLGT predictor', 'cl UP buc GLGT scaler',
|
|
54
|
+
'cl UP ult GLGT predictor', 'cl UP ult GLGT scaler'
|
|
55
|
+
],
|
|
56
|
+
["ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_SP",
|
|
57
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_SP",
|
|
58
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_SP",
|
|
59
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_SP",
|
|
60
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_SP",
|
|
61
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_SP",
|
|
62
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_SP",
|
|
63
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_SP",
|
|
64
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_UP",
|
|
65
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_UP",
|
|
66
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_UP",
|
|
67
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_UP",
|
|
68
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_UP",
|
|
69
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_UP",
|
|
70
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_UP",
|
|
71
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_UP",
|
|
72
|
+
"ml_files\\CL_CSR-Tank_req_cl_predictor",
|
|
73
|
+
"ml_files\\CL_CSR-Tank_req_cl_UP_scaler",
|
|
74
|
+
"ml_files\\CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor",
|
|
75
|
+
"ml_files\\CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_SP_scaler"]):
|
|
76
|
+
self._ML_buckling[name] = None
|
|
77
|
+
if os.path.isfile(file_base + '.pickle'):
|
|
78
|
+
file = open(file_base + '.pickle', 'rb')
|
|
79
|
+
self._ML_buckling[name] = pickle.load(file)
|
|
80
|
+
file.close()
|
|
81
|
+
|
|
82
|
+
self._ML_classes = {0: 'N/A',
|
|
83
|
+
1: 'A negative utilisation factor is found.',
|
|
84
|
+
2: 'At least one of the in-plane loads must be non-zero.',
|
|
85
|
+
3: 'Division by zero',
|
|
86
|
+
4: 'Overflow',
|
|
87
|
+
5: 'The aspect ratio exceeds the PULS code limit',
|
|
88
|
+
6: 'The global slenderness exceeds 4. Please reduce stiffener span or increase stiffener height.',
|
|
89
|
+
7: 'The applied pressure is too high for this plate field.', 8: 'web-flange-ratio',
|
|
90
|
+
9: 'UF below or equal 0.87', 10: 'UF between 0.87 and 1.0', 11: 'UF above 1.0'}
|
|
91
|
+
else:
|
|
92
|
+
self.app = app
|
|
93
|
+
self._initial_structure_obj = app._line_to_struc[app._active_line][0]
|
|
94
|
+
self._initial_calc_obj = app._line_to_struc[app._active_line][1]
|
|
95
|
+
self._initial_cylinder_obj = app._line_to_struc[app._active_line][5]
|
|
96
|
+
self._fatigue_object = app._line_to_struc[app._active_line][2]
|
|
97
|
+
try:
|
|
98
|
+
self._fatigue_pressure = app.get_fatigue_pressures(app._active_line,
|
|
99
|
+
self._fatigue_object.get_accelerations())
|
|
100
|
+
except AttributeError:
|
|
101
|
+
self._fatigue_pressure = None
|
|
102
|
+
try:
|
|
103
|
+
self._lateral_pressure = 0
|
|
104
|
+
except KeyError:
|
|
105
|
+
self._lateral_pressure = 0
|
|
106
|
+
try:
|
|
107
|
+
|
|
108
|
+
if self.app.get_highest_pressure(self.app._active_line)['slamming'] is None:
|
|
109
|
+
self._slamming_pressure = 0
|
|
110
|
+
else:
|
|
111
|
+
self._slamming_pressure = self.app.get_highest_pressure(self.app._active_line)['slamming']
|
|
112
|
+
except KeyError:
|
|
113
|
+
self._slamming_pressure = 0
|
|
114
|
+
image_dir = app._root_dir +'\\images\\'
|
|
115
|
+
self._root_dir = app._root_dir
|
|
116
|
+
self._PULS_object = app._PULS_results
|
|
117
|
+
self._puls_acceptance = self.app._new_puls_uf.get()
|
|
118
|
+
|
|
119
|
+
self._ML_buckling = app._ML_buckling
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
self._frame = master
|
|
124
|
+
self._frame.wm_title("Optimize structure")
|
|
125
|
+
self._frame.geometry('1600x900')
|
|
126
|
+
self._frame.grab_set()
|
|
127
|
+
|
|
128
|
+
'''
|
|
129
|
+
shell_upper_bounds = np.array( [0.03, 3, 5, 5, 10, None, None, None])
|
|
130
|
+
shell_deltas = np.array( [0.005, 0.5, 1, 0.1,1, None, None, None])
|
|
131
|
+
shell_lower_bounds = np.array( [0.02, 2.5, 5, 5, 10, None, None, None])
|
|
132
|
+
|
|
133
|
+
long_upper_bounds = np.array( [0.8, None, 0.5, 0.02, 0.2, 0.03, None, None])
|
|
134
|
+
long_deltas = np.array( [0.1, None, 0.1, 0.01, 0.1, 0.01, None, None])
|
|
135
|
+
long_lower_bounds = np.array( [0.7, None, 0.3, 0.01, 0.1, 0.01, None, None])
|
|
136
|
+
|
|
137
|
+
ring_stf_upper_bounds = np.array( [None, None, 0.5, 0.018, 0.2, 0.03, None, None])
|
|
138
|
+
ring_stf_deltas = np.array( [None, None, 0.1, 0.004, 0.1, 0.01, None, None])
|
|
139
|
+
ring_stf_lower_bounds = np.array( [None, None, 0.3, 0.010, 0.1, 0.010, None, None])
|
|
140
|
+
|
|
141
|
+
ring_frame_upper_bounds = np.array( [None, None, 0.9, 0.04, 0.3, 0.04, None, None])
|
|
142
|
+
ring_frame_deltas = np.array( [None, None, 0.2, 0.01, 0.1, 0.01, None, None])
|
|
143
|
+
ring_frame_lower_bounds = np.array( [None, None, 0.7, 0.02, 0.2, 0.02, None, None])
|
|
144
|
+
'''
|
|
145
|
+
ent_w = 12
|
|
146
|
+
|
|
147
|
+
default_shell_upper_bounds = np.array([0.03, 3, 5, 5, 10, None, None, None])
|
|
148
|
+
default_shell_deltas = np.array([0.005, 0.5, 1, 0.1, 1, None, None, None])
|
|
149
|
+
default_shell_lower_bounds = np.array([0.02, 2.5, 5, 5, 10, None, None, None])
|
|
150
|
+
|
|
151
|
+
default_long_upper_bounds = np.array([0.8, None, 0.5, 0.02, 0.2, 0.03, None, None])
|
|
152
|
+
default_long_deltas = np.array([0.1, None, 0.1, 0.01, 0.1, 0.01, None, None])
|
|
153
|
+
default_long_lower_bounds = np.array([0.7, None, 0.3, 0.01, 0.1, 0.01, None, None])
|
|
154
|
+
|
|
155
|
+
default_ring_stf_upper_bounds = np.array([None, None, 0.5, 0.018, 0.2, 0.03, None, None])
|
|
156
|
+
default_ring_stf_deltas = np.array([None, None, 0.1, 0.004, 0.1, 0.01, None, None])
|
|
157
|
+
default_ring_stf_lower_bounds = np.array([None, None, 0.3, 0.010, 0.1, 0.010, None, None])
|
|
158
|
+
|
|
159
|
+
default_ring_frame_upper_bounds = np.array([None, None, 0.9, 0.04, 0.3, 0.04, None, None])
|
|
160
|
+
default_ring_frame_deltas = np.array([None, None, 0.2, 0.01, 0.1, 0.01, None, None])
|
|
161
|
+
default_ring_frame_lower_bounds = np.array([None, None, 0.7, 0.02, 0.2, 0.02, None, None])
|
|
162
|
+
|
|
163
|
+
self._default_data = [[default_shell_upper_bounds,default_shell_deltas, default_shell_lower_bounds],
|
|
164
|
+
[default_long_upper_bounds, default_long_deltas, default_long_lower_bounds],
|
|
165
|
+
[default_ring_stf_upper_bounds, default_ring_stf_deltas, default_ring_stf_lower_bounds],
|
|
166
|
+
[default_ring_frame_upper_bounds, default_ring_frame_deltas,
|
|
167
|
+
default_ring_frame_lower_bounds]]
|
|
168
|
+
|
|
169
|
+
shell_example = [0.03, 3, 5, 5, 10, None, None, None]
|
|
170
|
+
long_example = ring_stf_example = ring_frame_example = [0.8, None, 0.5, 0.02, 0.2, 0.03, None, None]
|
|
171
|
+
|
|
172
|
+
shell_upper_bounds = [tk.DoubleVar() for dummy in shell_example]
|
|
173
|
+
shell_deltas = [tk.DoubleVar() for dummy in shell_example]
|
|
174
|
+
shell_lower_bounds = [tk.DoubleVar() for dummy in shell_example]
|
|
175
|
+
|
|
176
|
+
long_upper_bounds = [tk.DoubleVar() for dummy in long_example]
|
|
177
|
+
long_deltas = [tk.DoubleVar() for dummy in long_example]
|
|
178
|
+
long_lower_bounds = [tk.DoubleVar() for dummy in long_example]
|
|
179
|
+
|
|
180
|
+
ring_stf_upper_bounds = [tk.DoubleVar() for dummy in ring_stf_example]
|
|
181
|
+
ring_stf_deltas = [tk.DoubleVar() for dummy in ring_stf_example]
|
|
182
|
+
ring_stf_lower_bounds = [tk.DoubleVar() for dummy in ring_stf_example]
|
|
183
|
+
|
|
184
|
+
ring_frame_upper_bounds = [tk.DoubleVar() for dummy in ring_frame_example]
|
|
185
|
+
ring_frame_deltas = [tk.DoubleVar() for dummy in ring_frame_example]
|
|
186
|
+
ring_frame_lower_bounds = [tk.DoubleVar() for dummy in ring_frame_example]
|
|
187
|
+
self._new_geo_data = list()
|
|
188
|
+
|
|
189
|
+
self._new_geo_data = [[shell_upper_bounds,shell_deltas, shell_lower_bounds],
|
|
190
|
+
[long_upper_bounds, long_deltas, long_lower_bounds],
|
|
191
|
+
[ring_stf_upper_bounds, ring_stf_deltas, ring_stf_lower_bounds],
|
|
192
|
+
[ring_frame_upper_bounds, ring_frame_deltas, ring_frame_lower_bounds]]
|
|
193
|
+
|
|
194
|
+
self._new_entries = list()
|
|
195
|
+
map_type = {'shell':0, 'long':1, 'ring stf': 2, 'ring heavy':3}
|
|
196
|
+
map_type_idx = {0: True, 1: self._initial_cylinder_obj.LongStfObj is not None,
|
|
197
|
+
2: self._initial_cylinder_obj.RingStfObj is not None,
|
|
198
|
+
3: self._initial_cylinder_obj.RingFrameObj is not None}
|
|
199
|
+
|
|
200
|
+
for idx_1, geo_i in enumerate(self._new_geo_data):
|
|
201
|
+
all_geos = list()
|
|
202
|
+
if map_type_idx[idx_1] == False:
|
|
203
|
+
continue
|
|
204
|
+
for idx_2, entries in enumerate(geo_i):
|
|
205
|
+
these_ents = list()
|
|
206
|
+
for idx_3, ent_i in enumerate(entries):
|
|
207
|
+
self._new_geo_data[idx_1][idx_2][idx_3].trace('w', self.update_running_time)
|
|
208
|
+
these_ents.append(tk.Entry(self._frame,
|
|
209
|
+
textvariable = self._new_geo_data[idx_1][idx_2][idx_3], width = ent_w))
|
|
210
|
+
self._new_geo_data[idx_1][idx_2][idx_3].set(0 if self._default_data[idx_1][idx_2][idx_3] is None
|
|
211
|
+
else self._default_data[idx_1][idx_2][idx_3]*1000)
|
|
212
|
+
all_geos.append(these_ents)
|
|
213
|
+
self._new_entries.append(all_geos)
|
|
214
|
+
|
|
215
|
+
self._predefined_stiffener_iter = None
|
|
216
|
+
|
|
217
|
+
self._opt_runned = False
|
|
218
|
+
self._opt_results = ()
|
|
219
|
+
self._opt_actual_running_time = tk.Label(self._frame,text='',font='Verdana 12 bold')
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
self._draw_scale = 600
|
|
223
|
+
self._canvas_dim = (550, 500)
|
|
224
|
+
self._canvas_opt = tk.Canvas(self._frame,width=self._canvas_dim[0], height=self._canvas_dim[1],
|
|
225
|
+
background='azure',relief = 'groove', borderwidth=2)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
# tk.Frame(self._frame,width=770,height=5, bg="grey", colormap="new").place(x=20,y=127)
|
|
229
|
+
# tk.Frame(self._frame, width=770, height=5, bg="grey", colormap="new").place(x=20, y=167)
|
|
230
|
+
|
|
231
|
+
self._canvas_opt.place(x=1000,y=350)
|
|
232
|
+
|
|
233
|
+
algorithms = ('anysmart cylinder','random','random_no_delta')
|
|
234
|
+
|
|
235
|
+
tk.Label(self._frame,text='-- Cylinder optimizer --',font='Verdana 15 bold').place(x=10,y=10)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
# upper and lower bounds for optimization
|
|
239
|
+
#[0.6, 0.012, 0.3, 0.01, 0.1, 0.01]
|
|
240
|
+
|
|
241
|
+
self._new_algorithm = tk.StringVar()
|
|
242
|
+
self._new_algorithm_random_trials = tk.IntVar()
|
|
243
|
+
self._new_swarm_size = tk.IntVar()
|
|
244
|
+
self._new_omega = tk.DoubleVar()
|
|
245
|
+
self._new_phip = tk.DoubleVar()
|
|
246
|
+
self._new_phig = tk.DoubleVar()
|
|
247
|
+
self._new_maxiter = tk.IntVar()
|
|
248
|
+
self._new_minstep = tk.DoubleVar()
|
|
249
|
+
self._new_minfunc = tk.DoubleVar()
|
|
250
|
+
self._new_slamming_pressure = tk.DoubleVar()
|
|
251
|
+
self._new_fatigue_int_press = tk.DoubleVar()
|
|
252
|
+
self._new_fatigue_ext_press = tk.DoubleVar()
|
|
253
|
+
|
|
254
|
+
#additional choices for the random and pso algorithm
|
|
255
|
+
self._ent_algorithm = tk.OptionMenu(self._frame,self._new_algorithm,command=self.selected_algorithm,*algorithms)
|
|
256
|
+
self._ent_random_trials = tk.Entry(self._frame,textvariable=self._new_algorithm_random_trials)
|
|
257
|
+
|
|
258
|
+
pso_width = 10
|
|
259
|
+
self._ent_swarm_size = tk.Entry(self._frame,textvariable=self._new_swarm_size, width = pso_width)
|
|
260
|
+
self._ent_omega = tk.Entry(self._frame,textvariable=self._new_omega, width = pso_width)
|
|
261
|
+
self._ent_phip = tk.Entry(self._frame,textvariable=self._new_phip, width = pso_width)
|
|
262
|
+
self._ent_phig = tk.Entry(self._frame,textvariable=self._new_phig, width = pso_width)
|
|
263
|
+
self._ent_maxiter = tk.Entry(self._frame,textvariable=self._new_maxiter, width = pso_width)
|
|
264
|
+
self._ent_minstep = tk.Entry(self._frame,textvariable=self._new_minstep, width = pso_width)
|
|
265
|
+
self._ent_minfunc = tk.Entry(self._frame,textvariable=self._new_minfunc, width = pso_width)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
# stresses in plate and stiffener
|
|
270
|
+
|
|
271
|
+
self._new_sasd = tk.DoubleVar()
|
|
272
|
+
self._new_smsd = tk.DoubleVar()
|
|
273
|
+
self._new_tTsd = tk.DoubleVar()
|
|
274
|
+
self._new_tQsd = tk.DoubleVar()
|
|
275
|
+
self._new_design_pressure = tk.DoubleVar()
|
|
276
|
+
self._new_shsd = tk.DoubleVar()
|
|
277
|
+
|
|
278
|
+
self._new_sasd.set(self._initial_cylinder_obj.sasd)
|
|
279
|
+
self._new_smsd.set(self._initial_cylinder_obj.smsd)
|
|
280
|
+
self._new_tTsd.set(self._initial_cylinder_obj.tTsd)
|
|
281
|
+
self._new_tQsd.set(self._initial_cylinder_obj.tQsd)
|
|
282
|
+
self._new_design_pressure.set(self._initial_cylinder_obj.psd)
|
|
283
|
+
self._new_shsd.set(self._initial_cylinder_obj.shsd)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
self._ent_sasd = tk.Entry(self._frame, textvariable=self._new_sasd, width=ent_w)
|
|
287
|
+
self._ent_smsd = tk.Entry(self._frame, textvariable=self._new_smsd, width=ent_w)
|
|
288
|
+
self._ent_tTsd = tk.Entry(self._frame, textvariable=self._new_tTsd, width=ent_w)
|
|
289
|
+
self._ent_tQsd = tk.Entry(self._frame, textvariable=self._new_tQsd, width=ent_w)
|
|
290
|
+
self._ent_design_pressure = tk.Entry(self._frame, textvariable=self._new_design_pressure, width=ent_w)
|
|
291
|
+
self._ent_shsd = tk.Entry(self._frame, textvariable=self._new_shsd, width=ent_w)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
start_x,start_y,dx,dy = 20,100,100,40
|
|
295
|
+
|
|
296
|
+
self._new_processes = tk.IntVar()
|
|
297
|
+
self._new_processes.set(max(cpu_count() - 1, 1))
|
|
298
|
+
tk.Label(self._frame, text='Processes\n (CPUs)', font='Verdana 9 bold', bg = 'silver')\
|
|
299
|
+
.place(x=start_x + 10 * dx, y=start_y - 1.1 * dy)
|
|
300
|
+
tk.Entry(self._frame, textvariable=self._new_processes, width = 12, bg = 'silver')\
|
|
301
|
+
.place(x=start_x + 10 * dx, y=start_y - 0.3 * dy)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
self._runnig_time_label = tk.Label(self._frame, text='',font='Verdana 12 bold', fg = 'red')
|
|
307
|
+
self._runnig_time_label.place(x=start_x+4.3*dx, y=start_y + 2.8 * dy)
|
|
308
|
+
#tk.Label(self._frame, text='seconds ',font='Verdana 9 bold').place(x=start_x+6*dx, y=start_y + 2.8 * dy)
|
|
309
|
+
self._result_label = tk.Label(self._frame, text = '',font = 'Verdana 9 bold' )
|
|
310
|
+
self._result_label.place(x=start_x, y=start_y + 4.2 * dy)
|
|
311
|
+
|
|
312
|
+
'''
|
|
313
|
+
self._new_geo_data = [[shell_upper_bounds,shell_deltas, shell_lower_bounds],
|
|
314
|
+
[long_upper_bounds, long_deltas, long_lower_bounds],
|
|
315
|
+
[ring_stf_upper_bounds, ring_stf_deltas, ring_stf_lower_bounds],
|
|
316
|
+
[ring_frame_upper_bounds, ring_frame_deltas, ring_frame_lower_bounds]]
|
|
317
|
+
'''
|
|
318
|
+
shell = ['Shell thk. [mm]', 'Shell radius [mm]', 'l rings [mm]', 'L shell [mm]', 'L tot. [mm]', 'N/A - future',
|
|
319
|
+
'N/A - future', 'N/A - future']
|
|
320
|
+
stf_long = ['Spacing [mm]', 'N/A', 'Web height [mm]', 'Web thk. [mm]', 'Flange width [mm]',
|
|
321
|
+
'Flange thk. [mm]', 'N/A - future', 'N/A - future']
|
|
322
|
+
stf_ring = ['N/A', 'N/A', 'Web height [mm]', 'Web thk. [mm]', 'Flange width [mm]',
|
|
323
|
+
'Flange thk. [mm]', 'N/A - future', 'N/A - future']
|
|
324
|
+
all_label = [shell, stf_long, stf_ring, stf_ring]
|
|
325
|
+
text_i = ['Upper bounds [mm]', 'Iteration delta [mm]','Lower bounds [mm]']
|
|
326
|
+
kind = ['Shell or panel', 'Longitudinal stiffener', 'Ring stiffener', 'Ring frame/girder']
|
|
327
|
+
for idx_1, member in enumerate(self._new_entries):
|
|
328
|
+
if map_type_idx[idx_1] == False:
|
|
329
|
+
continue
|
|
330
|
+
for idx_2, bounds in enumerate(member):
|
|
331
|
+
tk.Label(self._frame, text=text_i[idx_2], font='Verdana 9').place(x=start_x,
|
|
332
|
+
y=start_y + dy * idx_1 * 4 + dy * idx_2)
|
|
333
|
+
if idx_2 == 0:
|
|
334
|
+
tk.Label(self._frame, text=kind[idx_1], font='Verdana 10 bold') \
|
|
335
|
+
.place(x=start_x, y=start_y + dy * idx_1 * 4 + dy * idx_2 - dy * 0.5)
|
|
336
|
+
for idx_3, entry_i in enumerate(bounds):
|
|
337
|
+
if idx_2 == 0:
|
|
338
|
+
tk.Label(self._frame, text=all_label[idx_1][idx_3], font='Verdana 7 bold')\
|
|
339
|
+
.place(x = start_x+dx*2 + idx_3*dx, y = start_y+dy*idx_1*4 + dy*idx_2 -dy*0.5)
|
|
340
|
+
|
|
341
|
+
entry_i.place(x = start_x+dx*2 + idx_3*dx, y = start_y+dy*idx_1*4 + dy*idx_2)
|
|
342
|
+
if 'N/A' in all_label[idx_1][idx_3]:
|
|
343
|
+
entry_i.configure(bg = 'grey')
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
###
|
|
348
|
+
|
|
349
|
+
#Labels for the pso
|
|
350
|
+
|
|
351
|
+
self._lb_swarm_size = tk.Label(self._frame,text='swarm size')
|
|
352
|
+
self._lb_omega = tk.Label(self._frame,text='omega')
|
|
353
|
+
self._lb_phip = tk.Label(self._frame,text='phip')
|
|
354
|
+
self._lb_phig = tk.Label(self._frame,text='phig')
|
|
355
|
+
self._lb_maxiter = tk.Label(self._frame,text='maxiter')
|
|
356
|
+
self._lb_minstep = tk.Label(self._frame,text='minstep')
|
|
357
|
+
self._lb_minfunc = tk.Label(self._frame,text='minfunc')
|
|
358
|
+
|
|
359
|
+
###
|
|
360
|
+
dys = 0.9*dy
|
|
361
|
+
tk.Label(self._frame, text='Design axial stress, sa,sd', font='Verdana 9')\
|
|
362
|
+
.place(x=start_x+10*dx,y=start_y+1*dys)
|
|
363
|
+
tk.Label(self._frame, text='Pa', font='Verdana 9')\
|
|
364
|
+
.place(x=start_x+dx*14,y=start_y+1*dys)
|
|
365
|
+
|
|
366
|
+
tk.Label(self._frame, text='Design bending stress, sm,sd', font='Verdana 9')\
|
|
367
|
+
.place(x=start_x+10*dx,y=start_y+2*dys)
|
|
368
|
+
tk.Label(self._frame, text='Pa', font='Verdana 9')\
|
|
369
|
+
.place(x=start_x+dx*14,y=start_y+2*dys)
|
|
370
|
+
|
|
371
|
+
tk.Label(self._frame, text='Design torsional stress, tT,sd', font='Verdana 9')\
|
|
372
|
+
.place(x=start_x+10*dx,y=start_y+3*dys)
|
|
373
|
+
tk.Label(self._frame, text='Pa', font='Verdana 9')\
|
|
374
|
+
.place(x=start_x+dx*14,y=start_y+3*dys)
|
|
375
|
+
|
|
376
|
+
tk.Label(self._frame, text='Design shear stress, tQ,sd', font='Verdana 9')\
|
|
377
|
+
.place(x=start_x+10*dx,y=start_y+4*dys)
|
|
378
|
+
tk.Label(self._frame, text='Pa', font='Verdana 9')\
|
|
379
|
+
.place(x=start_x+dx*14,y=start_y+4*dys)
|
|
380
|
+
|
|
381
|
+
tk.Label(self._frame, text='Design lateral pressure, psd', font='Verdana 9 bold')\
|
|
382
|
+
.place(x=start_x+10*dx,y=start_y+5*dys)
|
|
383
|
+
tk.Label(self._frame, text='Pa', font='Verdana 9')\
|
|
384
|
+
.place(x=start_x+dx*14,y=start_y+5*dys)
|
|
385
|
+
|
|
386
|
+
tk.Label(self._frame, text='Additional hoop stress, sh,sd, psd', font='Verdana 9 bold')\
|
|
387
|
+
.place(x=start_x+10*dx,y=start_y+6*dys)
|
|
388
|
+
tk.Label(self._frame, text='Pa', font='Verdana 9')\
|
|
389
|
+
.place(x=start_x+dx*14,y=start_y+6*dys)
|
|
390
|
+
|
|
391
|
+
self._ent_sasd.place(x=start_x+dx*13,y=start_y+1*dys)
|
|
392
|
+
self._ent_smsd.place(x=start_x+dx*13,y=start_y+2*dys)
|
|
393
|
+
self._ent_tTsd.place(x=start_x+dx*13,y=start_y+3*dys)
|
|
394
|
+
self._ent_tQsd.place(x=start_x + dx * 13, y=start_y + 4 * dys)
|
|
395
|
+
self._ent_design_pressure.place(x=start_x + dx * 13, y=start_y + 5 * dys)
|
|
396
|
+
self._ent_shsd.place(x=start_x + dx * 13, y=start_y +6 * dys)
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
if self._fatigue_pressure is not None:
|
|
400
|
+
tk.Label(self._frame, text='Fatigue pressure: internal= '+str(self._fatigue_pressure['p_int'])+ ' external= '
|
|
401
|
+
+str(self._fatigue_pressure['p_ext']), font='Verdana 7') \
|
|
402
|
+
.place(x=start_x + dx * 5, y=start_y + 19.3 * dy)
|
|
403
|
+
else:
|
|
404
|
+
tk.Label(self._frame, text='Fatigue pressure: internal= '+str(0)+ ' external= '
|
|
405
|
+
+str(0), font='Verdana 7') \
|
|
406
|
+
.place(x=start_x + dx * 5, y=start_y + 19.3 * dy)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
#setting default values
|
|
412
|
+
init_dim = float(10) #mm
|
|
413
|
+
init_thk = float(1) #mm
|
|
414
|
+
|
|
415
|
+
self._new_slamming_pressure.set(self._slamming_pressure)
|
|
416
|
+
if self._fatigue_pressure is None:
|
|
417
|
+
self._new_fatigue_ext_press.set(0), self._new_fatigue_int_press.set(0)
|
|
418
|
+
else:
|
|
419
|
+
self._new_fatigue_int_press.set(self._fatigue_pressure['p_int']), \
|
|
420
|
+
self._new_fatigue_ext_press.set(self._fatigue_pressure['p_ext'])
|
|
421
|
+
|
|
422
|
+
self._new_algorithm.set('anysmart cylinder')
|
|
423
|
+
self._new_algorithm_random_trials.set(100000)
|
|
424
|
+
self._new_swarm_size.set(100)
|
|
425
|
+
self._new_omega.set(0.5)
|
|
426
|
+
self._new_phip.set(0.5)
|
|
427
|
+
self._new_phig.set(0.5)
|
|
428
|
+
self._new_maxiter.set(100)
|
|
429
|
+
self._new_minstep.set(1e-8)
|
|
430
|
+
self._new_minfunc.set(1e-8)
|
|
431
|
+
|
|
432
|
+
self._new_algorithm_random_trials.trace('w',self.update_running_time)
|
|
433
|
+
self._new_algorithm.trace('w',self.update_running_time)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
# self.running_time_per_item = {'PULS':0.2489626556016598, 'RP': 1.009943181818182e-5}
|
|
437
|
+
# self.initial_weight = op.calc_weight([self._spacing,self._pl_thk,self._stf_web_h,self._stf_web_thk,
|
|
438
|
+
# self._fl_w,self._fl_thk,self._new_span.get(),self._new_width_lg.get()])
|
|
439
|
+
|
|
440
|
+
# img_file_name = 'img_plate_and_stiffener.gif'
|
|
441
|
+
# if os.path.isfile('images/' + img_file_name):
|
|
442
|
+
# file_path = 'images/' + img_file_name
|
|
443
|
+
# else:
|
|
444
|
+
# file_path = self._root_dir + '/images/' + img_file_name
|
|
445
|
+
# photo = tk.PhotoImage(file=file_path)
|
|
446
|
+
# label = tk.Label(self._frame,image=photo)
|
|
447
|
+
# label.image = photo # keep a reference!
|
|
448
|
+
# label.place(x=550, y=300)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
# tk.Label(self._frame,text='Select algorithm', font = 'Verdana 8 bold').place(x=start_x+dx*11, y=start_y+7*dy)
|
|
452
|
+
# self._ent_algorithm.place(x=start_x+dx*11, y=start_y+dy*8)
|
|
453
|
+
self.algorithm_random_label = tk.Label(self._frame, text='Number of trials')
|
|
454
|
+
|
|
455
|
+
# tk.Button(self._frame,text='algorith information',command=self.algorithm_info,bg='white')\
|
|
456
|
+
# .place(x=start_x+dx*12.5, y=start_y+dy*7)
|
|
457
|
+
self.run_button = tk.Button(self._frame,text='RUN OPTIMIZATION!', command=self.run_optimizaion, bg='red',
|
|
458
|
+
font='Verdana 10 bold',fg='Yellow', relief="raised")
|
|
459
|
+
self.run_button.place(x=start_x+dx*11.5, y=start_y-dy, relwidth = 0.15)
|
|
460
|
+
# self.run_results = tk.Button(self._frame,text='show calculated', command=self.plot_results, bg='white',
|
|
461
|
+
# font='Verdana 10',fg='black')
|
|
462
|
+
# self.run_results.place(x=start_x+dx*8, y=start_y+dy*1.5)
|
|
463
|
+
self._opt_actual_running_time.place(x=start_x+dx*11, y=start_y)
|
|
464
|
+
|
|
465
|
+
self.close_and_save =tk.Button(self._frame,text='Return and replace initial structure with optimized',
|
|
466
|
+
command=self.save_and_close,bg='green',font='Verdana 10',fg='yellow')
|
|
467
|
+
self.close_and_save.place(x=start_x+dx*5,y=10)
|
|
468
|
+
|
|
469
|
+
tk.Button(self._frame, text='Open predefined stiffeners example',
|
|
470
|
+
command=self.open_example_file, bg='white', font='Verdana 10')\
|
|
471
|
+
.place(x=start_x+dx*10,y=10)
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
# Stress scaling
|
|
475
|
+
self._new_fup = tk.DoubleVar()
|
|
476
|
+
self._new_fup.set(0.5)
|
|
477
|
+
self._new_fdwn = tk.DoubleVar()
|
|
478
|
+
self._new_fdwn.set(1)
|
|
479
|
+
|
|
480
|
+
tk.Label(self._frame, text='Factor when scaling stresses up, fup')\
|
|
481
|
+
.place(x=start_x, y=start_y + 16 * dy)
|
|
482
|
+
ent_fup = tk.Entry(self._frame, textvariable=self._new_fup, width = 10)
|
|
483
|
+
ent_fup.place(x=start_x + dx * 3, y=start_y + 16 * dy)
|
|
484
|
+
tk.Label(self._frame, text='Factor when scaling stresses up, fdown')\
|
|
485
|
+
.place(x=start_x, y=start_y + 17 * dy)
|
|
486
|
+
ent_fdwn = tk.Entry(self._frame, textvariable=self._new_fdwn, width = 10)
|
|
487
|
+
ent_fdwn.place(x=start_x + dx * 3, y=start_y + 17 * dy)
|
|
488
|
+
|
|
489
|
+
# tk.Button(self._frame,text='Iterate predefiened stiffeners',command=self.open_multiple_files ,bg='yellow')\
|
|
490
|
+
# .place(x=start_x, y=start_y - dy * 2)
|
|
491
|
+
# command=lambda id="default": self.set_colors(id)
|
|
492
|
+
self._toggle_btn = tk.Button(self._frame, text="Iterate predefiened stiffeners", relief="raised",
|
|
493
|
+
command=self.toggle, bg = 'salmon')
|
|
494
|
+
self._toggle_btn.place(x= + 3*dx, y=start_y - dy * 2)
|
|
495
|
+
self._toggle_object, self._filez = self._initial_structure_obj, None
|
|
496
|
+
self.draw_properties()
|
|
497
|
+
self.update_running_time()
|
|
498
|
+
|
|
499
|
+
main_application.Application.draw_cylinder(text_size='Verdana 8 bold',
|
|
500
|
+
canvas = self._canvas_opt,
|
|
501
|
+
CylObj=self._initial_cylinder_obj,
|
|
502
|
+
start_x_cyl=350, start_y_cyl=300, text_x=230,
|
|
503
|
+
text_y=120)
|
|
504
|
+
|
|
505
|
+
def selected_algorithm(self,event):
|
|
506
|
+
'''
|
|
507
|
+
Action when selecting an algorithm.
|
|
508
|
+
:return:
|
|
509
|
+
'''
|
|
510
|
+
start_x, start_y, dx, dy = 20, 100, 100, 40
|
|
511
|
+
if self._new_algorithm.get()=='random' or self._new_algorithm.get()=='random_no_delta':
|
|
512
|
+
self._ent_random_trials.place_forget()
|
|
513
|
+
self.algorithm_random_label.place_forget()
|
|
514
|
+
self._lb_swarm_size.place_forget()
|
|
515
|
+
self._lb_omega.place_forget()
|
|
516
|
+
self._lb_phip.place_forget()
|
|
517
|
+
self._lb_phig.place_forget()
|
|
518
|
+
self._lb_maxiter.place_forget()
|
|
519
|
+
self._lb_minstep.place_forget()
|
|
520
|
+
self._lb_minfunc.place_forget()
|
|
521
|
+
self._ent_swarm_size.place_forget()
|
|
522
|
+
self._ent_omega.place_forget()
|
|
523
|
+
self._ent_phip.place_forget()
|
|
524
|
+
self._ent_phig.place_forget()
|
|
525
|
+
self._ent_maxiter.place_forget()
|
|
526
|
+
self._ent_minstep.place_forget()
|
|
527
|
+
self._ent_minfunc.place_forget()
|
|
528
|
+
self._ent_random_trials.place(x=start_x+dx*11.3, y=start_y+1.2*dy)
|
|
529
|
+
self.algorithm_random_label.place(x=start_x+dx*11.3, y=start_y+0.5*dy)
|
|
530
|
+
elif self._new_algorithm.get()=='anysmart' or self._new_algorithm.get()=='anydetail':
|
|
531
|
+
self._ent_random_trials.place_forget()
|
|
532
|
+
self.algorithm_random_label.place_forget()
|
|
533
|
+
self._lb_swarm_size.place_forget()
|
|
534
|
+
self._lb_omega.place_forget()
|
|
535
|
+
self._lb_phip.place_forget()
|
|
536
|
+
self._lb_phig.place_forget()
|
|
537
|
+
self._lb_maxiter.place_forget()
|
|
538
|
+
self._lb_minstep.place_forget()
|
|
539
|
+
self._lb_minfunc.place_forget()
|
|
540
|
+
self._ent_swarm_size.place_forget()
|
|
541
|
+
self._ent_omega.place_forget()
|
|
542
|
+
self._ent_phip.place_forget()
|
|
543
|
+
self._ent_phig.place_forget()
|
|
544
|
+
self._ent_maxiter.place_forget()
|
|
545
|
+
self._ent_minstep.place_forget()
|
|
546
|
+
self._ent_minfunc.place_forget()
|
|
547
|
+
|
|
548
|
+
elif self._new_algorithm.get()=='pso':
|
|
549
|
+
y_place_label =11.2
|
|
550
|
+
y_place = 12.2
|
|
551
|
+
self._ent_random_trials.place_forget()
|
|
552
|
+
|
|
553
|
+
self._lb_swarm_size.place(x=start_x+dx*y_place_label, y=start_y-2*dy)
|
|
554
|
+
self._lb_omega.place(x=start_x+dx*y_place_label, y=start_y-1*dy)
|
|
555
|
+
self._lb_phip.place(x=start_x+dx*y_place_label, y=start_y-0*dy)
|
|
556
|
+
self._lb_phig.place(x=start_x+dx*y_place_label, y=start_y+1*dy)
|
|
557
|
+
self._lb_maxiter.place(x=start_x+dx*y_place_label, y=start_y+2*dy)
|
|
558
|
+
self._lb_minstep.place(x=start_x+dx*y_place_label, y=start_y+3*dy)
|
|
559
|
+
self._lb_minfunc.place(x=start_x+dx*y_place_label, y=start_y+4*dy)
|
|
560
|
+
|
|
561
|
+
self._ent_swarm_size.place(x=start_x+dx*y_place, y=start_y-2*dy)
|
|
562
|
+
self._ent_omega.place(x=start_x+dx*y_place, y=start_y-1*dy)
|
|
563
|
+
self._ent_phip.place(x=start_x+dx*y_place, y=start_y+0*dy)
|
|
564
|
+
self._ent_phig.place(x=start_x+dx*y_place, y=start_y+1*dy)
|
|
565
|
+
self._ent_maxiter.place(x=start_x+dx*y_place, y=start_y+2*dy)
|
|
566
|
+
self._ent_minstep.place(x=start_x+dx*y_place, y=start_y+3*dy)
|
|
567
|
+
self._ent_minfunc.place(x=start_x+dx*y_place, y=start_y+4*dy)
|
|
568
|
+
|
|
569
|
+
def modify_structure_object(self):
|
|
570
|
+
''' Chaning parameters in the structure object before running. '''
|
|
571
|
+
pass
|
|
572
|
+
|
|
573
|
+
def run_optimizaion(self):
|
|
574
|
+
'''
|
|
575
|
+
function for button
|
|
576
|
+
:return:
|
|
577
|
+
'''
|
|
578
|
+
|
|
579
|
+
self.run_button.config(bg = 'white')
|
|
580
|
+
self.run_button.config(fg='red')
|
|
581
|
+
self.run_button.config(text='RUNNING OPTIMIZATION')
|
|
582
|
+
self.run_button.config(relief="sunken")
|
|
583
|
+
self._opt_actual_running_time.config(text='Run started ' + datetime.datetime.now().strftime("%H:%M:%S"))
|
|
584
|
+
self._opt_actual_running_time.update()
|
|
585
|
+
t_start = time.time()
|
|
586
|
+
self._opt_results, self._opt_runned = (), False
|
|
587
|
+
|
|
588
|
+
self.pso_parameters = (self._new_swarm_size.get(),self._new_omega.get(),self._new_phip.get(),
|
|
589
|
+
self._new_phig.get(),
|
|
590
|
+
self._new_maxiter.get(),self._new_minstep.get(),self._new_minfunc.get())
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
if self._fatigue_pressure is not None:
|
|
594
|
+
|
|
595
|
+
fat_press = ((self._fatigue_pressure['p_ext']['loaded'],self._fatigue_pressure['p_ext']['ballast'],
|
|
596
|
+
self._fatigue_pressure['p_ext']['part']),
|
|
597
|
+
(self._fatigue_pressure['p_int']['loaded'],self._fatigue_pressure['p_int']['ballast'],
|
|
598
|
+
self._fatigue_pressure['p_int']['part']))
|
|
599
|
+
else:
|
|
600
|
+
fat_press = None
|
|
601
|
+
|
|
602
|
+
self._new_sasd.set(self._new_sasd.get())
|
|
603
|
+
self._new_smsd.set(self._new_smsd.get())
|
|
604
|
+
self._new_tTsd.set(self._new_tTsd.get())
|
|
605
|
+
self._new_tQsd.set(self._new_tQsd.get())
|
|
606
|
+
self._new_design_pressure.set(self._new_design_pressure.get())
|
|
607
|
+
self._initial_cylinder_obj.psd = self._new_design_pressure.get()
|
|
608
|
+
self._new_shsd.set(self._new_shsd.get())
|
|
609
|
+
|
|
610
|
+
self._opt_results= op.run_optmizataion(initial_structure_obj= self._initial_cylinder_obj,
|
|
611
|
+
min_var= self.get_lower_bounds(),
|
|
612
|
+
max_var=self.get_upper_bounds(),lateral_pressure=
|
|
613
|
+
self._new_design_pressure.get(),
|
|
614
|
+
deltas= self.get_deltas(),algorithm=self._new_algorithm.get(),
|
|
615
|
+
trials=self._new_algorithm_random_trials.get(),
|
|
616
|
+
fatigue_obj=self._fatigue_object,
|
|
617
|
+
fat_press_ext_int=fat_press,
|
|
618
|
+
slamming_press = self._new_slamming_pressure.get(),
|
|
619
|
+
predefined_stiffener_iter=self._predefined_stiffener_iter,
|
|
620
|
+
processes=self._new_processes.get(),
|
|
621
|
+
use_weight_filter = True,
|
|
622
|
+
fdwn = self._new_fdwn.get(), fup = self._new_fdwn.get(),
|
|
623
|
+
cylinder = True)
|
|
624
|
+
|
|
625
|
+
if self._opt_results is not None and self._opt_results[0] is not None:
|
|
626
|
+
self._opt_actual_running_time.config(text='Actual running time: \n'
|
|
627
|
+
+str(round((time.time()-t_start)/60,4))+' min')
|
|
628
|
+
self._opt_actual_running_time.update()
|
|
629
|
+
self._opt_runned = True
|
|
630
|
+
#self._result_label.config(text=self._opt_results[0].__str__)
|
|
631
|
+
self._canvas_opt.delete('all')
|
|
632
|
+
|
|
633
|
+
main_application.Application.draw_cylinder(text_size='Verdana 8 bold',
|
|
634
|
+
canvas = self._canvas_opt,
|
|
635
|
+
CylObj=self._opt_results[0],
|
|
636
|
+
start_x_cyl=350, start_y_cyl=300, text_x=230,
|
|
637
|
+
text_y=120)
|
|
638
|
+
self._new_sasd.set(self._opt_results[0].sasd)
|
|
639
|
+
self._new_smsd.set(self._opt_results[0].smsd)
|
|
640
|
+
self._new_tTsd.set(self._opt_results[0].tTsd)
|
|
641
|
+
self._new_tQsd.set(self._opt_results[0].tQsd)
|
|
642
|
+
self._new_design_pressure.set(self._opt_results[0].psd)
|
|
643
|
+
self._new_shsd.set(self._opt_results[0].shsd)
|
|
644
|
+
#self.draw_properties()
|
|
645
|
+
else:
|
|
646
|
+
messagebox.showinfo(title='Nothing found', message='No better alternatives found. Modify input.\n'
|
|
647
|
+
'There may be no alternative that is acceptable.\n')
|
|
648
|
+
|
|
649
|
+
self.run_button.config(bg='green')
|
|
650
|
+
self.run_button.config(fg='yellow')
|
|
651
|
+
self.run_button.config(text='RUN OPTIMIZATION')
|
|
652
|
+
self.run_button.config(relief="raised")
|
|
653
|
+
|
|
654
|
+
def get_running_time(self):
|
|
655
|
+
'''
|
|
656
|
+
Estimate the running time of the algorithm.
|
|
657
|
+
:return:
|
|
658
|
+
'''
|
|
659
|
+
|
|
660
|
+
pass
|
|
661
|
+
|
|
662
|
+
def get_deltas(self):
|
|
663
|
+
'''
|
|
664
|
+
Return a numpy array of the deltas.
|
|
665
|
+
:return:
|
|
666
|
+
'''
|
|
667
|
+
all_deltas = list()
|
|
668
|
+
for idx_1, geo_i in enumerate(self._new_geo_data):
|
|
669
|
+
these_deltas = list()
|
|
670
|
+
for idx_3, val in enumerate(geo_i[1]):
|
|
671
|
+
these_deltas.append(val.get()/1000)
|
|
672
|
+
all_deltas.append(these_deltas)
|
|
673
|
+
return all_deltas
|
|
674
|
+
|
|
675
|
+
def update_running_time(self,*args):
|
|
676
|
+
'''
|
|
677
|
+
Estimate the running time of the algorithm.
|
|
678
|
+
:return:
|
|
679
|
+
'''
|
|
680
|
+
|
|
681
|
+
pass
|
|
682
|
+
|
|
683
|
+
def get_upper_bounds(self):
|
|
684
|
+
'''
|
|
685
|
+
Return an numpy array of upper bounds.
|
|
686
|
+
:return:
|
|
687
|
+
'''
|
|
688
|
+
all_upper = list()
|
|
689
|
+
for idx_1, geo_i in enumerate(self._new_geo_data):
|
|
690
|
+
these_upper = list()
|
|
691
|
+
for idx_3, val in enumerate(geo_i[0]):
|
|
692
|
+
these_upper.append(val.get()/1000)
|
|
693
|
+
all_upper.append(these_upper)
|
|
694
|
+
return all_upper
|
|
695
|
+
|
|
696
|
+
def get_lower_bounds(self):
|
|
697
|
+
'''
|
|
698
|
+
Return an numpy array of lower bounds.
|
|
699
|
+
:return:
|
|
700
|
+
'''
|
|
701
|
+
all_lower = list()
|
|
702
|
+
for idx_1, geo_i in enumerate(self._new_geo_data):
|
|
703
|
+
these_lower = list()
|
|
704
|
+
for idx_3, val in enumerate(geo_i[2]):
|
|
705
|
+
these_lower.append(val.get()/1000)
|
|
706
|
+
all_lower.append(these_lower)
|
|
707
|
+
return all_lower
|
|
708
|
+
|
|
709
|
+
def get_sigmas(self):
|
|
710
|
+
'''
|
|
711
|
+
Returns the stressess.
|
|
712
|
+
:return:
|
|
713
|
+
'''
|
|
714
|
+
return np.array([self._new_sasd.get(),self._new_smsd.get(),
|
|
715
|
+
self._new_tTsd.get(),self._new_tQsd.get(),
|
|
716
|
+
self._new_design_pressure.get(),self._new_shsd.get()])
|
|
717
|
+
|
|
718
|
+
def checkered(self,line_distance):
|
|
719
|
+
# vertical lines at an interval of "line_distance" pixel
|
|
720
|
+
for x in range(line_distance, self._canvas_dim[0], line_distance):
|
|
721
|
+
self._canvas_opt.create_line(x, 0, x, self._canvas_dim[0], fill="grey",stipple='gray50')
|
|
722
|
+
# horizontal lines at an interval of "line_distance" pixel
|
|
723
|
+
for y in range(line_distance, self._canvas_dim[1], line_distance):
|
|
724
|
+
self._canvas_opt.create_line(0, y, self._canvas_dim[0], y, fill="grey",stipple='gray50')
|
|
725
|
+
|
|
726
|
+
def draw_properties(self):
|
|
727
|
+
'''
|
|
728
|
+
Drawing properties in the canvas.
|
|
729
|
+
:return:
|
|
730
|
+
'''
|
|
731
|
+
self._canvas_opt.delete('all')
|
|
732
|
+
#self.checkered(10)
|
|
733
|
+
ctr_x = self._canvas_dim[0]/2
|
|
734
|
+
ctr_y = self._canvas_dim[1]/2+200
|
|
735
|
+
m = self._draw_scale
|
|
736
|
+
init_color,init_stipple = 'blue','gray12'
|
|
737
|
+
opt_color,opt_stippe = 'red','gray12'
|
|
738
|
+
# self._canvas_opt.create_rectangle(0,0,self._canvas_dim[0]+10,80,fill='white')
|
|
739
|
+
# self._canvas_opt.create_line(10,10,30,10,fill = init_color,width=5)
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
if self._opt_runned:
|
|
743
|
+
|
|
744
|
+
self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].get_s() / 2, ctr_y,
|
|
745
|
+
ctr_x + m * self._opt_results[0].get_s() / 2,
|
|
746
|
+
ctr_y - m * self._opt_results[0].get_pl_thk(), fill=opt_color,
|
|
747
|
+
stipple=opt_stippe)
|
|
748
|
+
|
|
749
|
+
self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].get_web_thk() / 2, ctr_y -
|
|
750
|
+
m * self._opt_results[0].get_pl_thk(),
|
|
751
|
+
ctr_x + m * self._opt_results[0].get_web_thk() / 2,
|
|
752
|
+
ctr_y - m * (self._opt_results[0].get_web_h() + self._opt_results[0].get_pl_thk())
|
|
753
|
+
, fill=opt_color, stipple=opt_stippe)
|
|
754
|
+
if self._opt_results[0].get_stiffener_type() not in ['L', 'L-bulb']:
|
|
755
|
+
self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].get_fl_w() / 2, ctr_y
|
|
756
|
+
- m * (self._opt_results[0].get_pl_thk()+ self._opt_results[0].get_web_h()),
|
|
757
|
+
ctr_x + m * self._opt_results[0].get_fl_w() / 2,ctr_y -
|
|
758
|
+
m * (self._opt_results[0].get_pl_thk() + self._opt_results[0].get_web_h() +
|
|
759
|
+
self._opt_results[0].get_fl_thk()),
|
|
760
|
+
fill=opt_color, stipple=opt_stippe)
|
|
761
|
+
else:
|
|
762
|
+
self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].get_web_thk() / 2, ctr_y
|
|
763
|
+
- m * (self._opt_results[0].get_pl_thk()+ self._opt_results[0].get_web_h()),
|
|
764
|
+
ctr_x + m * self._opt_results[0].get_fl_w() ,ctr_y -
|
|
765
|
+
m * (self._opt_results[0].get_pl_thk() + self._opt_results[0].get_web_h() +
|
|
766
|
+
self._opt_results[0].get_fl_thk()),
|
|
767
|
+
fill=opt_color, stipple=opt_stippe)
|
|
768
|
+
|
|
769
|
+
self._canvas_opt.create_line(10, 50, 30, 50, fill=opt_color, width=5)
|
|
770
|
+
self._canvas_opt.create_text(270,50,text='Optimized - Pl.: '+str(round(self._opt_results[0].get_s()*1000,1))
|
|
771
|
+
+'x'+ str(round(self._opt_results[0].get_pl_thk()*1000,1))+
|
|
772
|
+
' Stf.: '+str(round(self._opt_results[0].get_web_h()*1000,1))+
|
|
773
|
+
'x'+str(round(self._opt_results[0].get_web_thk()*1000,1))+'+'+
|
|
774
|
+
str(round(self._opt_results[0].get_fl_w()*1000,1))+
|
|
775
|
+
'x'+str(round(self._opt_results[0].get_fl_thk()*1000,1)),
|
|
776
|
+
font = 'Verdana 8',fill = opt_color)
|
|
777
|
+
|
|
778
|
+
def save_and_close(self):
|
|
779
|
+
'''
|
|
780
|
+
Save and close
|
|
781
|
+
:return:
|
|
782
|
+
'''
|
|
783
|
+
|
|
784
|
+
if __name__ == '__main__':
|
|
785
|
+
self._frame.destroy()
|
|
786
|
+
return
|
|
787
|
+
|
|
788
|
+
try:
|
|
789
|
+
self.app.on_close_opt_cyl_window(self._opt_results)
|
|
790
|
+
except (IndexError, TypeError):
|
|
791
|
+
messagebox.showinfo(title='Nothing to return',message='No results to return.')
|
|
792
|
+
return
|
|
793
|
+
self._frame.destroy()
|
|
794
|
+
|
|
795
|
+
def algorithm_info(self):
|
|
796
|
+
''' When button is clicked, info is displayed.'''
|
|
797
|
+
|
|
798
|
+
messagebox.showinfo(title='Algorith information',
|
|
799
|
+
message='The algorithms currently included is:\n'
|
|
800
|
+
'ANYSMART: \n'
|
|
801
|
+
' Calculates all alternatives using upper and lower bounds.\n'
|
|
802
|
+
' The step used inside the bounds is defined in deltas.\n'
|
|
803
|
+
' This algoritm uses MULTIPROCESSING and will be faster.\n\n'
|
|
804
|
+
'RANDOM: \n'
|
|
805
|
+
' Uses the same bounds and deltas as in ANYSMART.\n'
|
|
806
|
+
' Number of combinations calculated is defined in "trials",\n'
|
|
807
|
+
' which selects withing the bounds and deltas defined.\n\n'
|
|
808
|
+
'RANDOM_NO_BOUNDS:\n'
|
|
809
|
+
' Same as RANDOM, but does not use the defined deltas.\n'
|
|
810
|
+
' The deltas is set to 1 mm for all dimensions/thicknesses.\n\n'
|
|
811
|
+
'ANYDETAIL:\n'
|
|
812
|
+
' Same as for ANYSMART, but will take some more time and\n'
|
|
813
|
+
' provide a chart of weight development during execution.\n\n'
|
|
814
|
+
'PSO - Particle Swarm Search:\n'
|
|
815
|
+
' The information can be found on \n'
|
|
816
|
+
' http://pythonhosted.org/pyswarm/ \n'
|
|
817
|
+
' For further information google it!\n'
|
|
818
|
+
' Parameters:\n'
|
|
819
|
+
' swarmsize : The number of particles in the swarm (Default: 100)\n'
|
|
820
|
+
' omega : Particle velocity scaling factor (Default: 0.5)\n'
|
|
821
|
+
' phip : Scaling factor to search away from the particle’s \n'
|
|
822
|
+
' best known position (Default: 0.5)\n'
|
|
823
|
+
' phig : Scaling factor to search away from the swarm’s best \n'
|
|
824
|
+
' known position (Default: 0.5)\n'
|
|
825
|
+
' maxiter : The maximum number of iterations for the swarm \n'
|
|
826
|
+
' to search (Default: 100)\n'
|
|
827
|
+
' minstep : The minimum stepsize of swarm’s best position \n'
|
|
828
|
+
' before the search terminates (Default: 1e-8)\n'
|
|
829
|
+
' minfunc : The minimum change of swarm’s best objective value\n'
|
|
830
|
+
' before the search terminates (Default: 1e-8)\n\n'
|
|
831
|
+
|
|
832
|
+
'\n'
|
|
833
|
+
'All algorithms calculates local scantling and buckling requirements')
|
|
834
|
+
|
|
835
|
+
def toggle(self):
|
|
836
|
+
if self._toggle_btn.config('relief')[-1] == 'sunken':
|
|
837
|
+
self._toggle_btn.config(relief="raised")
|
|
838
|
+
self._toggle_btn.config(bg = 'salmon')
|
|
839
|
+
|
|
840
|
+
predefined_stiffener_iter = []
|
|
841
|
+
else:
|
|
842
|
+
self._toggle_btn.config(relief="sunken")
|
|
843
|
+
self._toggle_btn.config(bg = 'salmon')
|
|
844
|
+
self._toggle_btn.config(bg='lightgreen')
|
|
845
|
+
|
|
846
|
+
predefined_stiffener_iter = []
|
|
847
|
+
open_files = askopenfilenames(parent=self._frame, title='Choose files to open', initialdir=self._root_dir)
|
|
848
|
+
if self._initial_cylinder_obj.LongStfObj is not None:
|
|
849
|
+
predefined_stiffener_iter = hlp.helper_read_section_file(files=list(open_files),
|
|
850
|
+
obj=self._initial_cylinder_obj.LongStfObj)
|
|
851
|
+
|
|
852
|
+
if predefined_stiffener_iter == []:
|
|
853
|
+
self._toggle_btn.config(relief="raised")
|
|
854
|
+
self._toggle_btn.config(bg = 'salmon')
|
|
855
|
+
|
|
856
|
+
self._predefined_stiffener_iter = None
|
|
857
|
+
else:
|
|
858
|
+
self._predefined_stiffener_iter = predefined_stiffener_iter
|
|
859
|
+
|
|
860
|
+
self.update_running_time()
|
|
861
|
+
|
|
862
|
+
def open_example_file(self):
|
|
863
|
+
import os
|
|
864
|
+
if os.path.isfile('sections.csv'):
|
|
865
|
+
os.startfile('sections.csv')
|
|
866
|
+
else:
|
|
867
|
+
os.startfile(self._root_dir + '/' + 'sections.csv')
|
|
868
|
+
|
|
869
|
+
def show_calculated(self):
|
|
870
|
+
''' '''
|
|
871
|
+
pass
|
|
872
|
+
|
|
873
|
+
def plot_results(self):
|
|
874
|
+
if len(self._opt_results) != 0:
|
|
875
|
+
op.plot_optimization_results(self._opt_results)
|
|
876
|
+
|
|
877
|
+
def write_result_csv(self):
|
|
878
|
+
if len(self._opt_results) != 0:
|
|
879
|
+
print(self._opt_results)
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
def receive_progress_info():
|
|
883
|
+
'''
|
|
884
|
+
Get progress info from optimization algorithm.
|
|
885
|
+
:return:
|
|
886
|
+
'''
|
|
887
|
+
print('hi')
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
if __name__ == '__main__':
|
|
892
|
+
root = tk.Tk()
|
|
893
|
+
my_app = CreateOptimizeCylinderWindow(master=root)
|
|
894
|
+
root.mainloop()
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|