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.
Files changed (99) hide show
  1. anystruct/ANYstructure_documentation.pdf +0 -0
  2. anystruct/SN_curve_parameters.py +35 -0
  3. anystruct/__init__.py +0 -0
  4. anystruct/__main__.py +24 -0
  5. anystruct/api.py +772 -0
  6. anystruct/buckling_calc_external.py +120 -0
  7. anystruct/bulb_anglebar_tbar_flatbar.csv +677 -0
  8. anystruct/calc_loads.py +526 -0
  9. anystruct/calc_structure.py +4838 -0
  10. anystruct/compartment_window.py +176 -0
  11. anystruct/example_data.py +532 -0
  12. anystruct/example_data_puls.py +46 -0
  13. anystruct/excel_inteface.py +244 -0
  14. anystruct/fatigue_window.py +352 -0
  15. anystruct/grid_window.py +307 -0
  16. anystruct/gui.py +24 -0
  17. anystruct/helper.py +623 -0
  18. anystruct/images/ANYstructure_logo.jpg +0 -0
  19. anystruct/images/Buckling_Strength_of_Shells.png +0 -0
  20. anystruct/images/Panel_geometry_definitions.png +0 -0
  21. anystruct/images/current_comps_NONE.png +0 -0
  22. anystruct/images/fls_button.gif +0 -0
  23. anystruct/images/img_T_L_FB.gif +0 -0
  24. anystruct/images/img_axial_stresses.gif +0 -0
  25. anystruct/images/img_ext_pressure_button.gif +0 -0
  26. anystruct/images/img_ext_pressure_button_def.gif +0 -0
  27. anystruct/images/img_fixation_parameters.gif +0 -0
  28. anystruct/images/img_generate_report.gif +0 -0
  29. anystruct/images/img_int_pressure_button.gif +0 -0
  30. anystruct/images/img_int_pressure_button_search.gif +0 -0
  31. anystruct/images/img_multi_opt.gif +0 -0
  32. anystruct/images/img_optimize.gif +0 -0
  33. anystruct/images/img_plate_and_stiffener.gif +0 -0
  34. anystruct/images/img_stf_button.gif +0 -0
  35. anystruct/images/img_stiffener.gif +0 -0
  36. anystruct/images/img_stress_button.gif +0 -0
  37. anystruct/images/img_title.gif +0 -0
  38. anystruct/images/img_transverse_stress.gif +0 -0
  39. anystruct/load_factor_window.py +166 -0
  40. anystruct/load_window.py +721 -0
  41. anystruct/main_application.py +7918 -0
  42. anystruct/make_grid_numpy.py +506 -0
  43. anystruct/make_queue.py +52 -0
  44. anystruct/make_stack.py +52 -0
  45. anystruct/ml_files/CL_CSR-Tank_req_cl_predictor.pickle +0 -0
  46. anystruct/ml_files/CL_CSR-Tank_req_cl_scaler.pickle +0 -0
  47. anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor.pickle +0 -0
  48. anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_scaler.pickle +0 -0
  49. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  50. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  51. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  52. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  53. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  54. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  55. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  56. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  57. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  58. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  59. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  60. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  61. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  62. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  63. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  64. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  65. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  66. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  67. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  68. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  69. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  70. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  71. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  72. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  73. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  74. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  75. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  76. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  77. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  78. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  79. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  80. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  81. anystruct/opt_problem.py +31 -0
  82. anystruct/optimize.py +1680 -0
  83. anystruct/optimize_cylinder.py +898 -0
  84. anystruct/optimize_geometry.py +1708 -0
  85. anystruct/optimize_multiple_window.py +1507 -0
  86. anystruct/optimize_window.py +1117 -0
  87. anystruct/pl_stf_window.py +572 -0
  88. anystruct/report_generator.py +912 -0
  89. anystruct/sections.csv +202 -0
  90. anystruct/sesam_interface.py +115 -0
  91. anystruct/ship_section_example.txt +1 -0
  92. anystruct/stresses_window.py +269 -0
  93. anystruct/testCalc.py +118 -0
  94. anystructure-5.2.0.dist-info/METADATA +86 -0
  95. anystructure-5.2.0.dist-info/RECORD +99 -0
  96. anystructure-5.2.0.dist-info/WHEEL +5 -0
  97. anystructure-5.2.0.dist-info/entry_points.txt +2 -0
  98. anystructure-5.2.0.dist-info/licenses/LICENSE +21 -0
  99. anystructure-5.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1117 @@
1
+ # This is where the optimization is done.
2
+ import tkinter as tk
3
+ from _tkinter import TclError
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
+ from anystruct.calc_structure import CalcScantlings, AllStructure
12
+ import anystruct.example_data as test
13
+ import anystruct.example_data as ex
14
+ import anystruct.helper as hlp
15
+ import anystruct.optimize as op
16
+ except ModuleNotFoundError:
17
+ from ANYstructure.anystruct.calc_structure import CalcScantlings, AllStructure
18
+ import ANYstructure.anystruct.example_data as test
19
+ import ANYstructure.anystruct.example_data as ex
20
+ import ANYstructure.anystruct.helper as hlp
21
+ import ANYstructure.anystruct.optimize as op
22
+ class CreateOptimizeWindow():
23
+ '''
24
+ This class initiates the single optimization window.
25
+ '''
26
+
27
+ def __init__(self,master,app=None):
28
+ super(CreateOptimizeWindow,self).__init__()
29
+ if __name__ == '__main__':
30
+ import pickle
31
+ Plate = CalcScantlings(ex.obj_dict)
32
+ Stiffener = None#CalcScantlings(ex.obj_dict)
33
+ Girder = None # CalcScantlings(ex.obj_dict_heavy)
34
+ self._initial_calc_obj = AllStructure(Plate=Plate, Stiffener=Stiffener, Girder=Girder,
35
+ main_dict=ex.prescriptive_main_dict)
36
+
37
+ #self._initial_calc_obj = test.get_structure_calc_object(heavy=True)
38
+ self._lateral_pressure = 0.2
39
+ self._fatigue_object = test.get_fatigue_object()
40
+ self._fatigue_pressure = test.get_fatigue_pressures()
41
+ self._slamming_pressure = test.get_slamming_pressure()
42
+ image_dir = os.path.dirname(__file__)+'\\images\\'
43
+ self._PULS_object = None
44
+ self._puls_acceptance = 0.87
45
+ self._initial_calc_obj.lat_press = self._lateral_pressure/1000
46
+ self._ML_buckling = dict() # Buckling machine learning algorithm
47
+ self._root_dir = '/\\'
48
+ for name, file_base in zip(['cl SP buc int predictor', 'cl SP buc int scaler',
49
+ 'cl SP ult int predictor', 'cl SP ult int scaler',
50
+ 'cl SP buc GLGT predictor', 'cl SP buc GLGT scaler',
51
+ 'cl SP ult GLGT predictor', 'cl SP ult GLGT scaler',
52
+ 'cl UP buc int predictor', 'cl UP buc int scaler',
53
+ 'cl UP ult int predictor', 'cl UP ult int scaler',
54
+ 'cl UP buc GLGT predictor', 'cl UP buc GLGT scaler',
55
+ 'cl UP ult GLGT predictor', 'cl UP ult GLGT scaler'
56
+ ],
57
+ ["ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_SP",
58
+ "ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_SP",
59
+ "ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_SP",
60
+ "ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_SP",
61
+ "ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_SP",
62
+ "ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_SP",
63
+ "ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_SP",
64
+ "ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_SP",
65
+ "ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_UP",
66
+ "ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_UP",
67
+ "ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_UP",
68
+ "ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_UP",
69
+ "ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_UP",
70
+ "ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_UP",
71
+ "ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_UP",
72
+ "ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_UP",
73
+ "CL_CSR-Tank_req_cl_predictor",
74
+ "CL_CSR-Tank_req_cl_UP_scaler",
75
+ "CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor",
76
+ "CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_SP_scaler"]):
77
+ self._ML_buckling[name] = None
78
+ if os.path.isfile(file_base + '.pickle'):
79
+ file = open(file_base + '.pickle', 'rb')
80
+ from sklearn.neural_network import MLPClassifier
81
+ from sklearn.preprocessing import StandardScaler
82
+ self._ML_buckling[name] = pickle.load(file)
83
+ file.close()
84
+
85
+ self._ML_classes = {0: 'N/A',
86
+ 1: 'A negative utilisation factor is found.',
87
+ 2: 'At least one of the in-plane loads must be non-zero.',
88
+ 3: 'Division by zero',
89
+ 4: 'Overflow',
90
+ 5: 'The aspect ratio exceeds the PULS code limit',
91
+ 6: 'The global slenderness exceeds 4. Please reduce stiffener span or increase stiffener height.',
92
+ 7: 'The applied pressure is too high for this plate field.', 8: 'web-flange-ratio',
93
+ 9: 'UF below or equal 0.87', 10: 'UF between 0.87 and 1.0', 11: 'UF above 1.0'}
94
+ else:
95
+ self.app = app
96
+
97
+ self._initial_calc_obj = app._line_to_struc[app._active_line][0]
98
+ self._fatigue_object = app._line_to_struc[app._active_line][2]
99
+ try:
100
+ self._fatigue_pressure = app.get_fatigue_pressures(app._active_line,
101
+ self._fatigue_object.get_accelerations())
102
+ except AttributeError:
103
+ self._fatigue_pressure = None
104
+ try:
105
+ self._lateral_pressure = self.app.get_highest_pressure(self.app._active_line)['normal'] / 1e6
106
+ except KeyError:
107
+ self._lateral_pressure = 0
108
+ try:
109
+
110
+ if self.app.get_highest_pressure(self.app._active_line)['slamming'] is None:
111
+ self._slamming_pressure = 0
112
+ else:
113
+ self._slamming_pressure = self.app.get_highest_pressure(self.app._active_line)['slamming']
114
+ except KeyError:
115
+ self._slamming_pressure = 0
116
+ image_dir = app._root_dir +'\\images\\'
117
+ self._root_dir = app._root_dir
118
+ self._PULS_object = app._PULS_results
119
+ self._puls_acceptance = self.app._new_puls_uf.get()
120
+
121
+ self._ML_buckling = app._ML_buckling
122
+
123
+ self._predefined_stiffener_iter = None
124
+
125
+ self._frame = master
126
+ self._frame.wm_title("Optimize structure")
127
+ self._frame.geometry('1400x900')
128
+ self._frame.grab_set()
129
+
130
+ self._opt_runned = False
131
+ self._opt_results = ()
132
+ self._opt_actual_running_time = tk.Label(self._frame,text='',font='Verdana 12 bold')
133
+
134
+
135
+ self._draw_scale = 500
136
+ self._canvas_dim = (500, 450)
137
+ self._canvas_opt = tk.Canvas(self._frame,width=self._canvas_dim[0], height=self._canvas_dim[1],
138
+ background='azure',relief = 'groove', borderwidth=2)
139
+
140
+ tk.Frame(self._frame,width=770,height=5, bg="grey", colormap="new").place(x=20,y=127)
141
+ tk.Frame(self._frame, width=770, height=5, bg="grey", colormap="new").place(x=20, y=167)
142
+
143
+ self._canvas_opt.place(x=10,y=300)
144
+
145
+ algorithms = ('anysmart','random','random_no_delta', 'anydetail')
146
+
147
+ tk.Label(self._frame,text='-- Structural optimizer --',font='Verdana 15 bold').place(x=10,y=10)
148
+
149
+ if self._initial_calc_obj.Stiffener is not None:
150
+ self._spacing = self._initial_calc_obj.Plate.get_s()
151
+ self._pl_thk = self._initial_calc_obj.Plate.get_pl_thk()
152
+ self._stf_web_h = self._initial_calc_obj.Stiffener.get_web_h()
153
+ self._stf_web_thk =self._initial_calc_obj.Stiffener.get_web_thk()
154
+ self._fl_w = self._initial_calc_obj.Stiffener.get_fl_w()
155
+ self._fl_thk =self._initial_calc_obj.Stiffener.get_fl_thk()
156
+ else:
157
+ self._spacing = self._initial_calc_obj.Plate.get_s()
158
+ self._pl_thk = self._initial_calc_obj.Plate.get_pl_thk()
159
+ self._stf_web_h = 0
160
+ self._stf_web_thk =0
161
+ self._fl_w = 0
162
+ self._fl_thk =0
163
+
164
+ # upper and lower bounds for optimization
165
+ #[0.6, 0.012, 0.3, 0.01, 0.1, 0.01]
166
+ self._new_spacing_upper = tk.DoubleVar()
167
+ self._new_spacing_lower = tk.DoubleVar()
168
+ self._new_pl_thk_upper = tk.DoubleVar()
169
+ self._new_pl_thk_lower = tk.DoubleVar()
170
+ self._new_web_h_upper = tk.DoubleVar()
171
+ self._new_web_h_lower = tk.DoubleVar()
172
+ self._new_web_thk_upper = tk.DoubleVar()
173
+ self._new_web_thk_lower = tk.DoubleVar()
174
+ self._new_fl_w_upper = tk.DoubleVar()
175
+ self._new_fl_w_lower = tk.DoubleVar()
176
+ self._new_fl_thk_upper = tk.DoubleVar()
177
+ self._new_fl_thk_lower = tk.DoubleVar()
178
+ self._new_span = tk.DoubleVar()
179
+ self._new_width_lg = tk.DoubleVar()
180
+ self._new_algorithm = tk.StringVar()
181
+ self._new_algorithm_random_trials = tk.IntVar()
182
+ self._new_swarm_size = tk.IntVar()
183
+ self._new_omega = tk.DoubleVar()
184
+ self._new_phip = tk.DoubleVar()
185
+ self._new_phig = tk.DoubleVar()
186
+ self._new_maxiter = tk.IntVar()
187
+ self._new_minstep = tk.DoubleVar()
188
+ self._new_minfunc = tk.DoubleVar()
189
+ self._new_slamming_pressure = tk.DoubleVar()
190
+ self._new_fatigue_int_press = tk.DoubleVar()
191
+ self._new_fatigue_ext_press = tk.DoubleVar()
192
+
193
+
194
+ ent_w = 10
195
+ self._ent_spacing_upper = tk.Entry(self._frame, textvariable = self._new_spacing_upper, width = ent_w)
196
+ self._ent_spacing_lower = tk.Entry(self._frame, textvariable=self._new_spacing_lower, width=ent_w)
197
+
198
+ self._ent_pl_thk_upper= tk.Entry(self._frame, textvariable=self._new_pl_thk_upper, width=ent_w)
199
+ self._ent_pl_thk_lower= tk.Entry(self._frame, textvariable=self._new_pl_thk_lower, width=ent_w)
200
+
201
+ self._ent_web_h_upper = tk.Entry(self._frame, textvariable=self._new_web_h_upper, width=ent_w)
202
+ self._ent_web_h_lower = tk.Entry(self._frame, textvariable=self._new_web_h_lower, width=ent_w)
203
+
204
+ self._ent_web_thk_upper = tk.Entry(self._frame, textvariable=self._new_web_thk_upper, width=ent_w)
205
+ self._ent_web_thk_lower = tk.Entry(self._frame, textvariable=self._new_web_thk_lower, width=ent_w)
206
+
207
+ self._ent_fl_w_upper = tk.Entry(self._frame, textvariable=self._new_fl_w_upper, width=ent_w)
208
+ self._ent_fl_w_lower = tk.Entry(self._frame, textvariable=self._new_fl_w_lower, width=ent_w)
209
+
210
+ self._ent_fl_thk_upper = tk.Entry(self._frame, textvariable=self._new_fl_thk_upper, width=ent_w)
211
+ self._ent_fl_thk_lower = tk.Entry(self._frame, textvariable=self._new_fl_thk_lower, width=ent_w)
212
+
213
+ self._ent_span = tk.Entry(self._frame, textvariable=self._new_span, width=ent_w)
214
+ self._ent_width_lg = tk.Entry(self._frame, textvariable=self._new_width_lg, width=ent_w)
215
+ self._ent_slamming_pressure = tk.Entry(self._frame, textvariable=self._new_slamming_pressure, width=ent_w)
216
+
217
+ #additional choices for the random and pso algorithm
218
+ self._ent_algorithm = tk.OptionMenu(self._frame,self._new_algorithm,command=self.selected_algorithm,*algorithms)
219
+ self._ent_random_trials = tk.Entry(self._frame,textvariable=self._new_algorithm_random_trials)
220
+
221
+ pso_width = 10
222
+ self._ent_swarm_size = tk.Entry(self._frame,textvariable=self._new_swarm_size, width = pso_width)
223
+ self._ent_omega = tk.Entry(self._frame,textvariable=self._new_omega, width = pso_width)
224
+ self._ent_phip = tk.Entry(self._frame,textvariable=self._new_phip, width = pso_width)
225
+ self._ent_phig = tk.Entry(self._frame,textvariable=self._new_phig, width = pso_width)
226
+ self._ent_maxiter = tk.Entry(self._frame,textvariable=self._new_maxiter, width = pso_width)
227
+ self._ent_minstep = tk.Entry(self._frame,textvariable=self._new_minstep, width = pso_width)
228
+ self._ent_minfunc = tk.Entry(self._frame,textvariable=self._new_minfunc, width = pso_width)
229
+
230
+ self._new_delta_spacing = tk.DoubleVar()
231
+ self._new_delta_pl_thk = tk.DoubleVar()
232
+ self._new_delta_web_h = tk.DoubleVar()
233
+ self._new_delta_web_thk = tk.DoubleVar()
234
+ self._new_delta_fl_w = tk.DoubleVar()
235
+ self._new_delta_fl_thk = tk.DoubleVar()
236
+
237
+ self._new_opt_spacing = tk.DoubleVar()
238
+ self._new_opt_pl_thk = tk.DoubleVar()
239
+ self._new_opt_web_h = tk.DoubleVar()
240
+ self._new_opt_web_thk = tk.DoubleVar()
241
+ self._new_opt_fl_w = tk.DoubleVar()
242
+ self._new_opt_fl_thk = tk.DoubleVar()
243
+
244
+ self._ent_delta_spacing = tk.Entry(self._frame, textvariable = self._new_delta_spacing, width = ent_w)
245
+ self._ent_delta_pl_thk = tk.Entry(self._frame, textvariable = self._new_delta_pl_thk, width = ent_w)
246
+ self._ent_delta_web_h = tk.Entry(self._frame, textvariable = self._new_delta_web_h, width = ent_w)
247
+ self._ent_delta_web_thk = tk.Entry(self._frame, textvariable = self._new_delta_web_thk, width = ent_w)
248
+ self._ent_delta_fl_w = tk.Entry(self._frame, textvariable = self._new_delta_fl_w, width = ent_w)
249
+ self._ent_delta_fl_thk = tk.Entry(self._frame, textvariable = self._new_delta_fl_thk, width = ent_w)
250
+
251
+ bg_col = 'pink'
252
+ self._ent_opt_spacing = tk.Entry(self._frame, textvariable=self._new_opt_spacing, width=ent_w,bg=bg_col)
253
+ self._ent_opt_pl_thk = tk.Entry(self._frame, textvariable=self._new_opt_pl_thk, width=ent_w,bg=bg_col)
254
+ self._ent_opt_web_h = tk.Entry(self._frame, textvariable=self._new_opt_web_h, width=ent_w,bg=bg_col)
255
+ self._ent_opt_web_thk = tk.Entry(self._frame, textvariable=self._new_opt_web_thk, width=ent_w,bg=bg_col)
256
+ self._ent_opt_fl_w = tk.Entry(self._frame, textvariable=self._new_opt_fl_w, width=ent_w,bg=bg_col)
257
+ self._ent_opt_fl_thk = tk.Entry(self._frame, textvariable=self._new_opt_fl_thk, width=ent_w,bg=bg_col)
258
+
259
+
260
+
261
+ # stresses in plate and stiffener
262
+
263
+ self._new_trans_stress_high = tk.DoubleVar()
264
+ self._new_trans_stress_low = tk.DoubleVar()
265
+ self._new_axial_stress = tk.DoubleVar()
266
+ self._new_shear_stress = tk.DoubleVar()
267
+ self._new_design_pressure = tk.DoubleVar()
268
+ self._new_pressure_side = tk.StringVar()
269
+
270
+
271
+ self._ent_trans_stress_high = tk.Entry(self._frame, textvariable=self._new_trans_stress_high, width=ent_w)
272
+ self._ent_trans_stress_low = tk.Entry(self._frame, textvariable=self._new_trans_stress_low, width=ent_w)
273
+ self._ent_axial_stress = tk.Entry(self._frame, textvariable=self._new_axial_stress, width=ent_w)
274
+ self._ent_design_pressure = tk.Entry(self._frame, textvariable=self._new_design_pressure, width=ent_w)
275
+ self._ent_design_pressure_side = tk.OptionMenu(self._frame,self._new_pressure_side,*('p','s'))
276
+ self._ent_shear_stress = tk.Entry(self._frame, textvariable=self._new_shear_stress, width=ent_w)
277
+
278
+ start_x,start_y,dx,dy = 20,100,100,40
279
+
280
+ self._new_processes = tk.IntVar()
281
+ self._new_processes.set(max(cpu_count() - 1, 1))
282
+ tk.Label(self._frame, text='Processes\n (CPUs)', font='Verdana 9 bold', bg = 'silver')\
283
+ .place(x=start_x + 8.3 * dx, y=start_y - 1.1 * dy)
284
+ tk.Entry(self._frame, textvariable=self._new_processes, width = 12, bg = 'silver')\
285
+ .place(x=start_x + 8.3 * dx, y=start_y - 0.3 * dy)
286
+
287
+
288
+ tk.Label(self._frame,text='Upper bounds [mm]',font='Verdana 9').place(x=start_x,y=start_y)
289
+ tk.Label(self._frame, text='Iteration delta [mm]',font='Verdana 9').place(x=start_x, y=start_y+dy)
290
+ tk.Label(self._frame, text='Lower bounds [mm]',font='Verdana 9').place(x=start_x, y=start_y+2*dy)
291
+ tk.Label(self._frame, text='Spacing [mm]', font='Verdana 7 bold').place(x=start_x + 1.97 * dx, y=start_y-0.6*dy)
292
+ tk.Label(self._frame, text='Plate thk. [mm]', font='Verdana 7 bold').place(x=start_x + 2.97 * dx, y=start_y-0.6*dy)
293
+ tk.Label(self._frame, text='Web height [mm]', font='Verdana 7 bold').place(x=start_x + 3.97 * dx, y=start_y-0.6*dy)
294
+ tk.Label(self._frame, text='Web thk. [mm]', font='Verdana 7 bold').place(x=start_x + 4.97 * dx, y=start_y-0.6*dy)
295
+ tk.Label(self._frame, text='Flange width [mm]', font='Verdana 7 bold').place(x=start_x + 5.97 * dx, y=start_y-0.6*dy)
296
+ tk.Label(self._frame, text='Flange thk. [mm]', font='Verdana 7 bold').place(x=start_x + 6.97 * dx, y=start_y-0.6*dy)
297
+ tk.Label(self._frame, text='--------- Number of combinations to run --------->\n'
298
+ 'PULS buckling is time consuming, about 0.2 sec. per comb.\n'
299
+ 'RP-C203 is much faster and can run many more combinations, 1M+.\n'
300
+ 'ML-CL is about as fast as RP-C203.',
301
+ font='Verdana 9 bold').place(x=start_x+0.1*dx, y=start_y + 2.8 * dy, anchor = tk.NW)
302
+
303
+ self._runnig_time_label = tk.Label(self._frame, text='',font='Verdana 12 bold', fg = 'red')
304
+ self._runnig_time_label.place(x=start_x+4.3*dx, y=start_y + 2.8 * dy)
305
+ #tk.Label(self._frame, text='seconds ',font='Verdana 9 bold').place(x=start_x+6*dx, y=start_y + 2.8 * dy)
306
+ self._result_label = tk.Label(self._frame, text = '',font = 'Verdana 9 bold' )
307
+ self._result_label.place(x=start_x, y=start_y + 4.2 * dy)
308
+
309
+ self._ent_spacing_upper.place(x=start_x+dx*2,y=start_y)
310
+ self._ent_delta_spacing.place(x=start_x+dx*2,y=start_y+dy)
311
+ self._ent_spacing_lower.place(x=start_x+dx*2,y=start_y+2*dy)
312
+
313
+ self._ent_pl_thk_upper.place(x=start_x+dx*3,y=start_y)
314
+ self._ent_delta_pl_thk.place(x=start_x+dx*3,y=start_y+dy)
315
+ self._ent_pl_thk_lower.place(x=start_x+dx*3,y=start_y+2*dy)
316
+
317
+ self._ent_web_h_upper.place(x=start_x+dx*4,y=start_y)
318
+ self._ent_delta_web_h.place(x=start_x+dx*4,y=start_y+dy)
319
+ self._ent_web_h_lower.place(x=start_x+dx*4,y=start_y+2*dy)
320
+
321
+ self._ent_web_thk_upper.place(x=start_x+dx*5,y=start_y)
322
+ self._ent_delta_web_thk.place(x=start_x+dx*5,y=start_y+dy)
323
+ self._ent_web_thk_lower.place(x=start_x+dx*5,y=start_y+2*dy)
324
+
325
+ self._ent_fl_w_upper.place(x=start_x+dx*6,y=start_y)
326
+ self._ent_delta_fl_w.place(x=start_x+dx*6,y=start_y+dy)
327
+ self._ent_fl_w_lower.place(x=start_x+dx*6,y=start_y+2*dy)
328
+
329
+ self._ent_fl_thk_upper.place(x=start_x+dx*7,y=start_y)
330
+ self._ent_delta_fl_thk.place(x=start_x+dx*7,y=start_y+dy)
331
+ self._ent_fl_thk_lower.place(x=start_x+dx*7,y=start_y+2*dy)
332
+
333
+ ###
334
+
335
+ # tk.Label(self._frame,text='Optimized result:\n')\
336
+ # .place(x=start_x,y=start_y+ver_mult*dy*0.9)
337
+ dx_mult = 0.7
338
+ tk.Label(self._frame,text='Optimized values').place(x=start_x,y=start_y+17*dy)
339
+
340
+ tk.Label(self._frame, text='s').place(x=start_x, y=start_y + 18 * dy)
341
+ tk.Label(self._frame, text='pl_thk').place(x=start_x, y=start_y + 19 * dy)
342
+ self._ent_opt_spacing.place(x=start_x+dx_mult*dx,y=start_y+18*dy)
343
+ self._ent_opt_pl_thk.place(x=start_x+dx_mult*dx,y=start_y+19*dy)
344
+
345
+ tk.Label(self._frame, text='web_h').place(x=start_x+2*dx_mult*dx, y=start_y + 18 * dy)
346
+ tk.Label(self._frame, text='web_htk').place(x=start_x+2*dx_mult*dx, y=start_y + 19 * dy)
347
+ self._ent_opt_web_h.place(x=start_x+3*dx_mult*dx,y=start_y+18*dy)
348
+ self._ent_opt_web_thk.place(x=start_x+3*dx_mult*dx,y=start_y+19*dy)
349
+
350
+ tk.Label(self._frame, text='fl_thk').place(x=start_x+4*dx_mult*dx, y=start_y + 18 * dy)
351
+ tk.Label(self._frame, text='fl_ttk.').place(x=start_x+4*dx_mult*dx, y=start_y + 19 * dy)
352
+ self._ent_opt_fl_w.place(x=start_x+5*dx_mult*dx,y=start_y+18*dy)
353
+ self._ent_opt_fl_thk.place(x=start_x+5*dx_mult*dx,y=start_y+19*dy)
354
+
355
+ #Labels for the pso
356
+
357
+ self._lb_swarm_size = tk.Label(self._frame,text='swarm size')
358
+ self._lb_omega = tk.Label(self._frame,text='omega')
359
+ self._lb_phip = tk.Label(self._frame,text='phip')
360
+ self._lb_phig = tk.Label(self._frame,text='phig')
361
+ self._lb_maxiter = tk.Label(self._frame,text='maxiter')
362
+ self._lb_minstep = tk.Label(self._frame,text='minstep')
363
+ self._lb_minfunc = tk.Label(self._frame,text='minfunc')
364
+
365
+ ###
366
+
367
+ tk.Label(self._frame, text='Sigma,y1_Sd - large transversal stress', font='Verdana 9')\
368
+ .place(x=start_x+dx*5,y=start_y+11.5*dy)
369
+ tk.Label(self._frame, text='MPa', font='Verdana 9')\
370
+ .place(x=start_x+dx*9,y=start_y+11.5*dy)
371
+
372
+ tk.Label(self._frame, text='Sigma,y2_Sd - small transversal stress', font='Verdana 9')\
373
+ .place(x=start_x+dx*5,y=start_y+12.5*dy)
374
+ tk.Label(self._frame, text='MPa', font='Verdana 9')\
375
+ .place(x=start_x+dx*9,y=start_y+12.5*dy)
376
+
377
+ tk.Label(self._frame, text='Sigma,x_Sd - axial stress', font='Verdana 9')\
378
+ .place(x=start_x+dx*5,y=start_y+13.5*dy)
379
+ tk.Label(self._frame, text='MPa', font='Verdana 9')\
380
+ .place(x=start_x+dx*9,y=start_y+13.5*dy)
381
+
382
+ tk.Label(self._frame, text='Tau,xy - shear stress', font='Verdana 9')\
383
+ .place(x=start_x+dx*5,y=start_y+14.5*dy)
384
+ tk.Label(self._frame, text='MPa', font='Verdana 9')\
385
+ .place(x=start_x+dx*9,y=start_y+14.5*dy)
386
+
387
+ tk.Label(self._frame, text='Applied pressure ', font='Verdana 9 bold')\
388
+ .place(x=start_x+dx*5,y=start_y+15.5*dy)
389
+ tk.Label(self._frame, text='kPa', font='Verdana 9')\
390
+ .place(x=start_x+dx*9,y=start_y+15.5*dy)
391
+ tk.Label(self._frame, text='Plate or stiffener side (p/s): ', font='Verdana 9 bold')\
392
+ .place(x=start_x+dx*9.5,y=start_y+15.5*dy)
393
+
394
+ tk.Label(self._frame, text='Span: ', font='Verdana 9') \
395
+ .place(x=start_x + dx * 5, y=start_y + 16.5 * dy)
396
+ tk.Label(self._frame, text='m', font='Verdana 9')\
397
+ .place(x=start_x+dx*9,y=start_y+16.5*dy)
398
+
399
+ tk.Label(self._frame, text='Girder length,Lg: ', font='Verdana 9') \
400
+ .place(x=start_x + dx * 5, y=start_y + 17.5 * dy)
401
+ tk.Label(self._frame, text='m', font='Verdana 9')\
402
+ .place(x=start_x+dx*9,y=start_y+17.5*dy)
403
+
404
+ tk.Label(self._frame, text='Slamming pressure ', font='Verdana 9') \
405
+ .place(x=start_x + dx * 5, y=start_y + 18.5 * dy)
406
+ tk.Label(self._frame, text='Pa', font='Verdana 9')\
407
+ .place(x=start_x+dx*9,y=start_y+18.5*dy)
408
+
409
+ if self._fatigue_pressure is not None:
410
+ tk.Label(self._frame, text='Fatigue pressure: internal= '+str(self._fatigue_pressure['p_int'])+ ' external= '
411
+ +str(self._fatigue_pressure['p_ext']), font='Verdana 7') \
412
+ .place(x=start_x + dx * 5, y=start_y + 19.3 * dy)
413
+ else:
414
+ tk.Label(self._frame, text='Fatigue pressure: internal= '+str(0)+ ' external= '
415
+ +str(0), font='Verdana 7') \
416
+ .place(x=start_x + dx * 5, y=start_y + 19.3 * dy)
417
+
418
+
419
+ self._ent_trans_stress_high.place(x=start_x+dx*8,y=start_y+11.5*dy)
420
+ self._ent_trans_stress_low.place(x=start_x+dx*8,y=start_y+12.5*dy)
421
+ self._ent_axial_stress.place(x=start_x+dx*8,y=start_y+13.5*dy)
422
+ self._ent_shear_stress.place(x=start_x + dx * 8, y=start_y + 14.5 * dy)
423
+ self._ent_design_pressure.place(x=start_x + dx * 8, y=start_y + 15.5 * dy)
424
+ self._ent_design_pressure_side.place(x=start_x + dx * 12, y=start_y + 15.5 * dy)
425
+ self._ent_span.place(x=start_x + dx * 8, y=start_y + 16.5 * dy)
426
+ self._ent_width_lg.place(x=start_x + dx * 8, y=start_y + 17.5 * dy)
427
+ self._ent_slamming_pressure.place(x=start_x + dx * 8, y=start_y + 18.5 * dy)
428
+
429
+ #setting default values
430
+ init_dim = float(10) #mm
431
+ init_thk = float(1) #mm
432
+ self._new_delta_spacing.set(init_dim)
433
+ self._new_delta_pl_thk.set(init_thk)
434
+ self._new_delta_web_h.set(init_dim)
435
+ self._new_delta_web_thk.set(init_thk)
436
+ self._new_delta_fl_w.set(init_dim)
437
+ self._new_delta_fl_thk.set(init_thk)
438
+ self._new_trans_stress_high.set(self._initial_calc_obj.Plate.sigma_y1)
439
+ self._new_trans_stress_low.set(self._initial_calc_obj.Plate.sigma_y2)
440
+ self._new_axial_stress.set(self._initial_calc_obj.Plate.sigma_x1)
441
+
442
+ self._new_shear_stress.set(self._initial_calc_obj.Plate.tau_xy)
443
+
444
+ self._new_design_pressure.set(self._lateral_pressure)
445
+ self._new_slamming_pressure.set(self._slamming_pressure)
446
+ if self._fatigue_pressure is None:
447
+ self._new_fatigue_ext_press.set(0), self._new_fatigue_int_press.set(0)
448
+ else:
449
+ self._new_fatigue_int_press.set(self._fatigue_pressure['p_int']), \
450
+ self._new_fatigue_ext_press.set(self._fatigue_pressure['p_ext'])
451
+
452
+ self._new_spacing_upper.set(round(self._spacing*1000,5))
453
+ self._new_spacing_lower.set(round(max(self._spacing*1000,0),5))
454
+ self._new_pl_thk_upper.set(round(self._pl_thk*1000+10,5))
455
+ self._new_pl_thk_lower.set(round(max(self._pl_thk*1000-10,float(10)),5))
456
+ self._new_web_h_upper.set(round(self._stf_web_h*1000+100,5))
457
+ self._new_web_h_lower.set(round(max(self._stf_web_h*1000-100,100),5))
458
+ self._new_web_thk_upper.set(round(self._stf_web_thk*1000+10,5))
459
+ self._new_web_thk_lower.set(round(max(self._stf_web_thk*1000-10,float(10)),5))
460
+ if self._initial_calc_obj.Stiffener is not None:
461
+ if self._initial_calc_obj.Stiffener.get_stiffener_type() != 'FB':
462
+ self._new_fl_w_upper.set(min(round(self._fl_w*1000+100,5), 200))
463
+ self._new_fl_w_lower.set(round(max(self._fl_w*1000-100,100),5))
464
+ self._new_fl_thk_upper.set(round(self._fl_thk*1000+10,15))
465
+ self._new_fl_thk_lower.set(round(max(self._fl_thk*1000-10,10),15))
466
+
467
+ else:
468
+ self._new_fl_w_upper.set(0)
469
+ self._new_fl_w_lower.set(0)
470
+ self._new_fl_thk_upper.set(0)
471
+ self._new_fl_thk_lower.set(0)
472
+
473
+ self._new_pressure_side.set('p')
474
+ self._new_width_lg.set(10)
475
+ self._new_span.set(round(self._initial_calc_obj.Plate.span,5))
476
+ self._new_algorithm.set('anysmart')
477
+ self._new_algorithm_random_trials.set(100000)
478
+ self._new_swarm_size.set(100)
479
+ self._new_omega.set(0.5)
480
+ self._new_phip.set(0.5)
481
+ self._new_phig.set(0.5)
482
+ self._new_maxiter.set(100)
483
+ self._new_minstep.set(1e-8)
484
+ self._new_minfunc.set(1e-8)
485
+
486
+
487
+ self._new_delta_spacing.trace('w',self.update_running_time)
488
+ self._new_delta_pl_thk.trace('w',self.update_running_time)
489
+ self._new_delta_web_h.trace('w',self.update_running_time)
490
+ self._new_delta_web_thk.trace('w',self.update_running_time)
491
+ self._new_delta_fl_w.trace('w',self.update_running_time)
492
+ self._new_delta_fl_thk.trace('w',self.update_running_time)
493
+ self._new_spacing_upper.trace('w',self.update_running_time)
494
+ self._new_spacing_lower.trace('w',self.update_running_time)
495
+ self._new_pl_thk_upper.trace('w',self.update_running_time)
496
+ self._new_pl_thk_lower.trace('w',self.update_running_time)
497
+ self._new_web_h_upper.trace('w',self.update_running_time)
498
+ self._new_web_h_lower.trace('w',self.update_running_time)
499
+ self._new_web_thk_upper.trace('w',self.update_running_time)
500
+ self._new_web_thk_lower.trace('w',self.update_running_time)
501
+ self._new_fl_w_upper.trace('w',self.update_running_time)
502
+ self._new_fl_w_lower.trace('w',self.update_running_time)
503
+ self._new_fl_thk_upper.trace('w',self.update_running_time)
504
+ self._new_fl_thk_lower.trace('w',self.update_running_time)
505
+ self._new_algorithm_random_trials.trace('w',self.update_running_time)
506
+ self._new_algorithm.trace('w',self.update_running_time)
507
+
508
+
509
+ self.running_time_per_item = {'PULS':0.2489626556016598, 'RP': 1.009943181818182e-5}
510
+ self.initial_weight = op.calc_weight([self._spacing,self._pl_thk,self._stf_web_h,self._stf_web_thk,
511
+ self._fl_w,self._fl_thk,self._new_span.get(),self._new_width_lg.get()])
512
+
513
+ img_file_name = 'img_plate_and_stiffener.gif'
514
+ if os.path.isfile('images/' + img_file_name):
515
+ file_path = 'images/' + img_file_name
516
+ else:
517
+ file_path = self._root_dir + '/images/' + img_file_name
518
+ photo = tk.PhotoImage(file=file_path)
519
+ label = tk.Label(self._frame,image=photo)
520
+ label.image = photo # keep a reference!
521
+ label.place(x=550, y=300)
522
+
523
+
524
+ tk.Label(self._frame,text='Select algorithm', font = 'Verdana 8 bold').place(x=start_x+dx*11, y=start_y+0.5*dy)
525
+ self._ent_algorithm.place(x=start_x+dx*11, y=start_y+dy)
526
+ self.algorithm_random_label = tk.Label(self._frame, text='Number of trials')
527
+
528
+ tk.Button(self._frame,text='algorith information',command=self.algorithm_info,bg='white')\
529
+ .place(x=start_x+dx*11, y=start_y+dy*2)
530
+ self.run_button = tk.Button(self._frame,text='RUN OPTIMIZATION!', command=self.run_optimizaion, bg='red',
531
+ font='Verdana 10 bold',fg='Yellow', relief="raised")
532
+ self.run_button.place(x=start_x+dx*8, y=start_y+dy*0.5, relwidth = 0.15)
533
+ self.run_results = tk.Button(self._frame,text='show calculated', command=self.plot_results, bg='white',
534
+ font='Verdana 10',fg='black')
535
+ self.run_results.place(x=start_x+dx*8, y=start_y+dy*1.5)
536
+ self._opt_actual_running_time.place(x=start_x+dx*9.5, y=start_y-dy)
537
+
538
+ self.close_and_save =tk.Button(self._frame,text='Return and replace initial structure with optimized',
539
+ command=self.save_and_close,bg='green',font='Verdana 10',fg='yellow')
540
+ self.close_and_save.place(x=start_x+dx*5,y=10)
541
+
542
+ tk.Button(self._frame, text='Open predefined stiffeners example',
543
+ command=self.open_example_file, bg='white', font='Verdana 10')\
544
+ .place(x=start_x+dx*10,y=10)
545
+
546
+ # Selection of constraints
547
+ self._new_check_sec_mod = tk.BooleanVar()
548
+ self._new_check_min_pl_thk = tk.BooleanVar()
549
+ self._new_check_shear_area = tk.BooleanVar()
550
+ self._new_check_buckling = tk.BooleanVar()
551
+ self._new_check_buckling_puls = tk.BooleanVar()
552
+ self._new_check_buckling_ml_cl = tk.BooleanVar()
553
+ self._new_check_fatigue = tk.BooleanVar()
554
+ self._new_check_slamming = tk.BooleanVar()
555
+ self._new_check_local_buckling = tk.BooleanVar()
556
+ self._new_use_weight_filter = tk.BooleanVar()
557
+ self._new_check_sec_mod.set(True)
558
+ self._new_check_min_pl_thk.set(True)
559
+ self._new_check_shear_area.set(True)
560
+ self._new_check_buckling.set(True)
561
+ self._new_check_fatigue.set(True)
562
+ self._new_check_slamming.set(False)
563
+ self._new_check_local_buckling.set(True)
564
+ self._new_use_weight_filter.set(True)
565
+ self._new_check_buckling_puls.set(False)
566
+ self._new_check_buckling_ml_cl.set(False)
567
+ self._new_check_buckling_puls.trace('w', self.update_running_time)
568
+ self._new_check_buckling_ml_cl.trace('w', self.update_running_time)
569
+
570
+
571
+ start_y = 140
572
+ tk.Label(self._frame,text='Check for minimum section mofdulus').place(x=start_x+dx*9.7,y=start_y+4*dy)
573
+ tk.Label(self._frame, text='Check for minimum plate thk.').place(x=start_x+dx*9.7,y=start_y+5*dy)
574
+ tk.Label(self._frame, text='Check for minimum shear area').place(x=start_x+dx*9.7,y=start_y+6*dy)
575
+ tk.Label(self._frame, text='Check for buckling (RP-C201)').place(x=start_x+dx*9.7,y=start_y+7*dy)
576
+ tk.Label(self._frame, text='Check for fatigue (RP-C203)').place(x=start_x + dx * 9.7, y=start_y + 8 * dy)
577
+ tk.Label(self._frame, text='Check for bow slamming').place(x=start_x + dx * 9.7, y=start_y + 9 * dy)
578
+ tk.Label(self._frame, text='Check for local stf. buckling').place(x=start_x + dx * 9.7, y=start_y + 10 * dy)
579
+ tk.Label(self._frame, text='Use weight filter (for speed)').place(x=start_x + dx * 9.7, y=start_y + 11 * dy)
580
+ tk.Label(self._frame, text='Check for buckling (PULS)').place(x=start_x + dx * 9.7, y=start_y + 12 * dy)
581
+ tk.Label(self._frame, text='Check for buckling (ML-CL)').place(x=start_x + dx * 9.7, y=start_y + 13 * dy)
582
+
583
+ tk.Checkbutton(self._frame,variable=self._new_check_sec_mod).place(x=start_x+dx*12,y=start_y+4*dy)
584
+ tk.Checkbutton(self._frame, variable=self._new_check_min_pl_thk).place(x=start_x+dx*12,y=start_y+5*dy)
585
+ tk.Checkbutton(self._frame, variable=self._new_check_shear_area).place(x=start_x+dx*12,y=start_y+6*dy)
586
+ tk.Checkbutton(self._frame, variable=self._new_check_buckling).place(x=start_x+dx*12,y=start_y+7*dy)
587
+ tk.Checkbutton(self._frame, variable=self._new_check_fatigue).place(x=start_x + dx * 12, y=start_y + 8 * dy)
588
+ tk.Checkbutton(self._frame, variable=self._new_check_slamming).place(x=start_x + dx * 12, y=start_y + 9 * dy)
589
+ tk.Checkbutton(self._frame, variable=self._new_check_local_buckling).place(x=start_x + dx * 12,
590
+ y=start_y + 10 * dy)
591
+ tk.Checkbutton(self._frame, variable=self._new_use_weight_filter).place(x=start_x + dx * 12,
592
+ y=start_y + 11 * dy)
593
+ tk.Checkbutton(self._frame, variable=self._new_check_buckling_puls).place(x=start_x + dx * 12,
594
+ y=start_y + 12 * dy)
595
+ tk.Checkbutton(self._frame, variable=self._new_check_buckling_ml_cl).place(x=start_x + dx * 12,
596
+ y=start_y + 13 * dy)
597
+
598
+ # Stress scaling
599
+ self._new_fup = tk.DoubleVar()
600
+ self._new_fup.set(0.5)
601
+ self._new_fdwn = tk.DoubleVar()
602
+ self._new_fdwn.set(1)
603
+
604
+ tk.Label(self._frame, text='Factor when scaling stresses up, fup')\
605
+ .place(x=start_x + dx * 9.7, y=start_y + 16 * dy)
606
+ ent_fup = tk.Entry(self._frame, textvariable=self._new_fup, width = 10)
607
+ ent_fup.place(x=start_x + dx * 12, y=start_y + 16 * dy)
608
+ tk.Label(self._frame, text='Factor when scaling stresses up, fdown')\
609
+ .place(x=start_x + dx * 9.7, y=start_y + 17 * dy)
610
+ ent_fdwn = tk.Entry(self._frame, textvariable=self._new_fdwn, width = 10)
611
+ ent_fdwn.place(x=start_x + dx * 12, y=start_y + 17 * dy)
612
+
613
+ # tk.Button(self._frame,text='Iterate predefiened stiffeners',command=self.open_multiple_files ,bg='yellow')\
614
+ # .place(x=start_x, y=start_y - dy * 2)
615
+ self._toggle_btn = tk.Button(self._frame, text="Iterate predefiened stiffeners", relief="raised",
616
+ command=self.toggle, bg = 'salmon')
617
+ self._toggle_btn.place(x=start_x, y=start_y - dy * 2)
618
+ self._toggle_object, self._filez = self._initial_calc_obj, None
619
+ self.draw_properties()
620
+ self.update_running_time()
621
+
622
+ def selected_algorithm(self,event):
623
+ '''
624
+ Action when selecting an algorithm.
625
+ :return:
626
+ '''
627
+ start_x, start_y, dx, dy = 20, 100, 100, 40
628
+ if self._new_algorithm.get()=='random' or self._new_algorithm.get()=='random_no_delta':
629
+ self._ent_random_trials.place_forget()
630
+ self.algorithm_random_label.place_forget()
631
+ self._lb_swarm_size.place_forget()
632
+ self._lb_omega.place_forget()
633
+ self._lb_phip.place_forget()
634
+ self._lb_phig.place_forget()
635
+ self._lb_maxiter.place_forget()
636
+ self._lb_minstep.place_forget()
637
+ self._lb_minfunc.place_forget()
638
+ self._ent_swarm_size.place_forget()
639
+ self._ent_omega.place_forget()
640
+ self._ent_phip.place_forget()
641
+ self._ent_phig.place_forget()
642
+ self._ent_maxiter.place_forget()
643
+ self._ent_minstep.place_forget()
644
+ self._ent_minfunc.place_forget()
645
+ self._ent_random_trials.place(x=start_x+dx*11.3, y=start_y+1.2*dy)
646
+ self.algorithm_random_label.place(x=start_x+dx*11.3, y=start_y+0.5*dy)
647
+ elif self._new_algorithm.get()=='anysmart' or self._new_algorithm.get()=='anydetail':
648
+ self._ent_random_trials.place_forget()
649
+ self.algorithm_random_label.place_forget()
650
+ self._lb_swarm_size.place_forget()
651
+ self._lb_omega.place_forget()
652
+ self._lb_phip.place_forget()
653
+ self._lb_phig.place_forget()
654
+ self._lb_maxiter.place_forget()
655
+ self._lb_minstep.place_forget()
656
+ self._lb_minfunc.place_forget()
657
+ self._ent_swarm_size.place_forget()
658
+ self._ent_omega.place_forget()
659
+ self._ent_phip.place_forget()
660
+ self._ent_phig.place_forget()
661
+ self._ent_maxiter.place_forget()
662
+ self._ent_minstep.place_forget()
663
+ self._ent_minfunc.place_forget()
664
+
665
+ elif self._new_algorithm.get()=='pso':
666
+ y_place_label =11.2
667
+ y_place = 12.2
668
+ self._ent_random_trials.place_forget()
669
+
670
+ self._lb_swarm_size.place(x=start_x+dx*y_place_label, y=start_y-2*dy)
671
+ self._lb_omega.place(x=start_x+dx*y_place_label, y=start_y-1*dy)
672
+ self._lb_phip.place(x=start_x+dx*y_place_label, y=start_y-0*dy)
673
+ self._lb_phig.place(x=start_x+dx*y_place_label, y=start_y+1*dy)
674
+ self._lb_maxiter.place(x=start_x+dx*y_place_label, y=start_y+2*dy)
675
+ self._lb_minstep.place(x=start_x+dx*y_place_label, y=start_y+3*dy)
676
+ self._lb_minfunc.place(x=start_x+dx*y_place_label, y=start_y+4*dy)
677
+
678
+ self._ent_swarm_size.place(x=start_x+dx*y_place, y=start_y-2*dy)
679
+ self._ent_omega.place(x=start_x+dx*y_place, y=start_y-1*dy)
680
+ self._ent_phip.place(x=start_x+dx*y_place, y=start_y+0*dy)
681
+ self._ent_phig.place(x=start_x+dx*y_place, y=start_y+1*dy)
682
+ self._ent_maxiter.place(x=start_x+dx*y_place, y=start_y+2*dy)
683
+ self._ent_minstep.place(x=start_x+dx*y_place, y=start_y+3*dy)
684
+ self._ent_minfunc.place(x=start_x+dx*y_place, y=start_y+4*dy)
685
+
686
+ def modify_structure_object(self):
687
+ ''' Chaning parameters in the structure object before running. '''
688
+ pass
689
+
690
+ def run_optimizaion(self):
691
+ '''
692
+ function for button
693
+ :return:
694
+ '''
695
+
696
+ self.run_button.config(bg = 'white')
697
+ self.run_button.config(fg='red')
698
+ self.run_button.config(text='RUNNING OPTIMIZATION')
699
+ self.run_button.config(relief="sunken")
700
+ self._opt_actual_running_time.config(text='Run started ' + datetime.datetime.now().strftime("%H:%M:%S"))
701
+ self._opt_actual_running_time.update()
702
+ t_start = time.time()
703
+ self._opt_results, self._opt_runned = (), False
704
+ if self._PULS_object is not None:
705
+ puls_sheet_location = self._PULS_object.puls_sheet_location
706
+ puls_acceptance = self._puls_acceptance
707
+ if self._new_check_buckling_puls.get() == True:
708
+ if puls_sheet_location is None or not os.path.isfile(
709
+ puls_sheet_location):
710
+ tk.messagebox.showerror('No PULS excel sheet located', 'Set location of PULS excel sheet.\n'
711
+ 'Note that PULS excel may require 32 bit '
712
+ 'office.\n\n'
713
+ 'A sheet may be provided but does not exist'
714
+ ' in :\n'
715
+ + self._PULS_results.puls_sheet_location +
716
+ '\n\n Return to main window an run one or more lines in PULS.')
717
+ else:
718
+ puls_sheet_location = None
719
+ puls_acceptance =0.87
720
+
721
+
722
+ self.pso_parameters = (self._new_swarm_size.get(),self._new_omega.get(),self._new_phip.get(),
723
+ self._new_phig.get(),
724
+ self._new_maxiter.get(),self._new_minstep.get(),self._new_minfunc.get())
725
+
726
+ contraints = (self._new_check_sec_mod.get(),self._new_check_min_pl_thk.get(),
727
+ self._new_check_shear_area.get(), self._new_check_buckling.get(),
728
+ self._new_check_fatigue.get(), self._new_check_slamming.get(),
729
+ self._new_check_local_buckling.get(), self._new_check_buckling_puls.get(),
730
+ self._new_check_buckling_ml_cl.get(), False)
731
+ self._initial_calc_obj.Plate.set_span(self._new_span.get())
732
+
733
+ if self._fatigue_pressure is not None:
734
+
735
+ fat_press = ((self._fatigue_pressure['p_ext']['loaded'],self._fatigue_pressure['p_ext']['ballast'],
736
+ self._fatigue_pressure['p_ext']['part']),
737
+ (self._fatigue_pressure['p_int']['loaded'],self._fatigue_pressure['p_int']['ballast'],
738
+ self._fatigue_pressure['p_int']['part']))
739
+ else:
740
+ fat_press = None
741
+
742
+ self._opt_results= op.run_optmizataion(self._initial_calc_obj,self.get_lower_bounds(),
743
+ self.get_upper_bounds(),self._new_design_pressure.get(),
744
+ self.get_deltas(),algorithm=self._new_algorithm.get(),
745
+ trials=self._new_algorithm_random_trials.get(),
746
+ side=self._new_pressure_side.get(),
747
+ const_chk=contraints,pso_options = self.pso_parameters,
748
+ fatigue_obj=self._fatigue_object,
749
+ fat_press_ext_int=fat_press,
750
+ slamming_press = self._new_slamming_pressure.get(),
751
+ predefined_stiffener_iter=self._predefined_stiffener_iter,
752
+ processes=self._new_processes.get(),
753
+ use_weight_filter = False if self._new_check_buckling_puls.get()
754
+ else self._new_use_weight_filter.get(),
755
+ puls_sheet = puls_sheet_location, puls_acceptance = puls_acceptance,
756
+ fdwn = self._new_fdwn.get(), fup = self._new_fdwn.get(),
757
+ ml_algo= self._ML_buckling)
758
+
759
+ if self._opt_results is not None and self._opt_results[0] is not None:
760
+ self._opt_actual_running_time.config(text='Actual running time: \n'
761
+ +str(round((time.time()-t_start)/60,4))+' min')
762
+ self._opt_actual_running_time.update()
763
+ self._opt_runned = True
764
+ if self._opt_results[0].Stiffener is not None:
765
+ text = 'Optimization result | Spacing: ' + str(round(self._opt_results[0].Plate.get_s(), 10) * 1000) +\
766
+ ' Plate thickness: ' + str(round(self._opt_results[0].Plate.get_pl_thk() * 1000, 10)) +\
767
+ ' Stiffener - T' + str(round(self._opt_results[0].Stiffener.get_web_h() * 1000, 10)) + 'x'\
768
+ +str(round(self._opt_results[0].Stiffener.get_web_thk() * 1000, 10)) +\
769
+ '+' + str(round(self._opt_results[0].Stiffener.get_fl_w() * 1000, 10)) + 'x'\
770
+ +str(round(self._opt_results[0].Stiffener.get_fl_thk() * 1000, 10))
771
+ else:
772
+ text = 'Optimization result | Spacing: ' + str(round(self._opt_results[0].Plate.get_s(), 10) * 1000) +\
773
+ ' Plate thickness: ' + str(round(self._opt_results[0].Plate.get_pl_thk() * 1000, 10))
774
+
775
+ self._result_label.config(text= text)
776
+
777
+ self._new_opt_spacing.set(round(self._opt_results[0].Plate.get_s(),5))
778
+ self._new_opt_pl_thk.set(round(self._opt_results[0].Plate.get_pl_thk(),5))
779
+ if self._opt_results[0].Stiffener is not None:
780
+ self._new_opt_web_h.set(round(self._opt_results[0].Stiffener.get_web_h(),5))
781
+ self._new_opt_web_thk.set(round(self._opt_results[0].Stiffener.get_web_thk(),5))
782
+ self._new_opt_fl_w.set(round(self._opt_results[0].Stiffener.get_fl_w(),5))
783
+ self._new_opt_fl_thk.set(round(self._opt_results[0].Stiffener.get_fl_thk(),5))
784
+ self.draw_properties()
785
+ else:
786
+ messagebox.showinfo(title='Nothing found', message='No better alternatives found. Modify input.\n'
787
+ 'There may be no alternative that is acceptable.\n')
788
+
789
+ self.run_button.config(bg='green')
790
+ self.run_button.config(fg='yellow')
791
+ self.run_button.config(text='RUN OPTIMIZATION')
792
+ self.run_button.config(relief="raised")
793
+
794
+ def get_running_time(self):
795
+ '''
796
+ Estimate the running time of the algorithm.
797
+ :return:
798
+ '''
799
+
800
+ if self._new_algorithm.get() in ['anysmart','anydetail']:
801
+ all_combs = op.any_get_all_combs(self.get_lower_bounds(), self.get_upper_bounds(), self.get_deltas(),
802
+ predef_stiffeners=None if self._predefined_stiffener_iter is None else
803
+ [item.get_tuple() for item in self._predefined_stiffener_iter])
804
+ number_of_combinations = len([val for val in all_combs])
805
+ return int(number_of_combinations * self.running_time_per_item['PULS' if self._new_check_buckling_puls.get()
806
+ else 'RP']), number_of_combinations
807
+
808
+ elif self._new_algorithm.get() in ['pso','random','random_no_delta']:
809
+ try:
810
+ number_of_combinations = \
811
+ max((self._new_spacing_upper.get()-self._new_spacing_lower.get())/self._new_delta_spacing.get(),1)* \
812
+ max((self._new_pl_thk_upper.get()-self._new_pl_thk_lower.get())/self._new_delta_pl_thk.get(),1)*\
813
+ max((self._new_web_h_upper.get()-self._new_web_h_lower.get())/self._new_delta_web_h.get(),1)*\
814
+ max((self._new_web_thk_upper.get()-self._new_web_thk_lower.get())/self._new_delta_web_thk.get(),1)*\
815
+ max((self._new_fl_w_upper.get()-self._new_fl_w_lower.get())/self._new_delta_fl_w.get(),1)*\
816
+ max((self._new_fl_thk_upper.get()-self._new_fl_thk_lower.get())/self._new_delta_fl_thk.get(),1)
817
+ return int(number_of_combinations*self.running_time_per_item['PULS' if self._new_check_buckling_puls.get()
818
+ else 'RP']),number_of_combinations
819
+ except TclError:
820
+ return 0,0
821
+ else:
822
+ try:
823
+ return int(self._new_algorithm_random_trials.get() * self.running_time_per_item['PULS' if self._new_check_buckling_puls.get()
824
+ else 'RP']),\
825
+ self._new_algorithm_random_trials.get()
826
+ except TclError:
827
+ return 0,0
828
+
829
+ def get_deltas(self):
830
+ '''
831
+ Return a numpy array of the deltas.
832
+ :return:
833
+ '''
834
+ return np.array([float(self._new_delta_spacing.get())/1000,float(self._new_delta_pl_thk.get())/1000,
835
+ float(self._new_delta_web_h.get())/1000,float(self._new_delta_web_thk.get())/1000,
836
+ float(self._new_delta_fl_w.get())/1000,float(self._new_delta_fl_thk.get())/1000])
837
+
838
+ def update_running_time(self,*args):
839
+ '''
840
+ Estimate the running time of the algorithm.
841
+ :return:
842
+ '''
843
+
844
+ try:
845
+ self._runnig_time_label.config(text=str(int(self.get_running_time()[1])) + ' (about '+
846
+ str(max(round(self.get_running_time()[1]*self.running_time_per_item['PULS'
847
+ if self._new_check_buckling_puls.get()
848
+ else 'RP']/60,2), 0.1))+ ' min.)')
849
+
850
+ except (ZeroDivisionError, TclError):
851
+ pass# _tkinter.TclError: pass
852
+
853
+ if [self._new_check_buckling_ml_cl.get(),self._new_check_buckling_puls.get(),
854
+ self._new_check_buckling.get()].count(True) > 1:
855
+ tk.messagebox.showerror('You can only select one buckling type. Reselect.')
856
+ if self._new_check_buckling_puls.get():
857
+ self._new_check_buckling_puls.set(False)
858
+ if self._new_check_buckling_ml_cl.get():
859
+ self._new_check_buckling_ml_cl.set(False)
860
+ if self._new_check_buckling.get():
861
+ self._new_check_buckling.set(False)
862
+ self._new_check_local_buckling.set(False)
863
+
864
+
865
+ if self._new_check_buckling_puls.get():
866
+ if self._PULS_object is None or self._PULS_object.puls_sheet_location is None:
867
+ tk.messagebox.showerror('Missing PULS sheet', 'Go back to main window and set a PULS sheet location\n'
868
+ 'by running one or more lines.')
869
+ self._new_check_buckling_puls.set(False)
870
+
871
+ def get_upper_bounds(self):
872
+ '''
873
+ Return an numpy array of upper bounds.
874
+ :return:
875
+ '''
876
+ return np.array([self._new_spacing_upper.get()/1000,self._new_pl_thk_upper.get()/1000,
877
+ self._new_web_h_upper.get()/1000,self._new_web_thk_upper.get()/1000,
878
+ self._new_fl_w_upper.get()/1000,self._new_fl_thk_upper.get()/1000,
879
+ self._new_span.get(),self._new_width_lg.get()])
880
+
881
+ def get_lower_bounds(self):
882
+ '''
883
+ Return an numpy array of lower bounds.
884
+ :return:
885
+ '''
886
+ return np.array([self._new_spacing_lower.get()/1000,self._new_pl_thk_lower.get()/1000,
887
+ self._new_web_h_lower.get()/1000,self._new_web_thk_lower.get()/1000,
888
+ self._new_fl_w_lower.get()/1000,self._new_fl_thk_lower.get()/1000,
889
+ self._new_span.get(), self._new_width_lg.get()])
890
+
891
+ def checkered(self,line_distance):
892
+ # vertical lines at an interval of "line_distance" pixel
893
+ for x in range(line_distance, self._canvas_dim[0], line_distance):
894
+ self._canvas_opt.create_line(x, 0, x, self._canvas_dim[0], fill="grey",stipple='gray50')
895
+ # horizontal lines at an interval of "line_distance" pixel
896
+ for y in range(line_distance, self._canvas_dim[1], line_distance):
897
+ self._canvas_opt.create_line(0, y, self._canvas_dim[0], y, fill="grey",stipple='gray50')
898
+
899
+ def draw_properties(self):
900
+ '''
901
+ Drawing properties in the canvas.
902
+ :return:
903
+ '''
904
+ self._canvas_opt.delete('all')
905
+ self.checkered(10)
906
+ ctr_x = self._canvas_dim[0]/2
907
+ ctr_y = self._canvas_dim[1]/2+200
908
+ m = self._draw_scale
909
+ init_color,init_stipple = 'blue','gray12'
910
+ opt_color,opt_stippe = 'red','gray12'
911
+ self._canvas_opt.create_rectangle(0,0,self._canvas_dim[0]+10,80,fill='white')
912
+ self._canvas_opt.create_line(10,10,30,10,fill = init_color,width=5)
913
+ self._canvas_opt.create_text(270,10,text='Initial - Pl.: '+str(self._spacing*1000) +'x'+str(self._pl_thk*1000)+
914
+ ' Stf.: '+str(self._stf_web_h*1000)+'x'+str(self._stf_web_thk*1000)+'+'+
915
+ str(self._fl_w*1000)+'x'+str(self._fl_thk*1000), font = 'Verdana 8',
916
+ fill = init_color)
917
+ self._canvas_opt.create_text(120,30,text='Weight (per Lg width): '+str(int(self.initial_weight)),
918
+ font = 'Verdana 8',fill = init_color)
919
+
920
+ self._canvas_opt.create_rectangle(ctr_x-m*self._spacing/2, ctr_y,ctr_x+m*self._spacing/2,
921
+ ctr_y-m*self._pl_thk, fill=init_color, stipple=init_stipple )
922
+ self._canvas_opt.create_rectangle(ctr_x - m * self._stf_web_thk / 2, ctr_y-m* self._pl_thk,
923
+ ctr_x + m * self._stf_web_thk / 2, ctr_y - m *(self._stf_web_h+self._pl_thk)
924
+ , fill=init_color, stipple=init_stipple )
925
+ if self._initial_calc_obj.Stiffener is None:
926
+ return
927
+
928
+ if self._initial_calc_obj.Stiffener.get_stiffener_type() not in ['L', 'L-bulb']:
929
+ self._canvas_opt.create_rectangle(ctr_x-m*self._fl_w/2, ctr_y-m*(self._pl_thk+self._stf_web_h),
930
+ ctr_x+m*self._fl_w/2, ctr_y-m*(self._pl_thk+self._stf_web_h+self._fl_thk),
931
+ fill=init_color, stipple=init_stipple)
932
+ else:
933
+ self._canvas_opt.create_rectangle(ctr_x-m*self._stf_web_thk/2, ctr_y-m*(self._pl_thk+self._stf_web_h),
934
+ ctr_x+m*self._fl_w, ctr_y-m*(self._pl_thk+self._stf_web_h+self._fl_thk),
935
+ fill=init_color, stipple=init_stipple)
936
+
937
+ if self._opt_runned:
938
+
939
+ self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].Stiffener.get_s() / 2, ctr_y,
940
+ ctr_x + m * self._opt_results[0].Stiffener.get_s() / 2,
941
+ ctr_y - m * self._opt_results[0].Stiffener.get_pl_thk(), fill=opt_color,
942
+ stipple=opt_stippe)
943
+
944
+ self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].Stiffener.get_web_thk() / 2, ctr_y -
945
+ m * self._opt_results[0].Stiffener.get_pl_thk(),
946
+ ctr_x + m * self._opt_results[0].Stiffener.get_web_thk() / 2,
947
+ ctr_y - m * (self._opt_results[0].Stiffener.get_web_h() + self._opt_results[0].Stiffener.get_pl_thk())
948
+ , fill=opt_color, stipple=opt_stippe)
949
+ if self._opt_results[0].Stiffener.get_stiffener_type() not in ['L', 'L-bulb']:
950
+ self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].Stiffener.get_fl_w() / 2, ctr_y
951
+ - m * (self._opt_results[0].Stiffener.get_pl_thk()+ self._opt_results[0].Stiffener.get_web_h()),
952
+ ctr_x + m * self._opt_results[0].Stiffener.get_fl_w() / 2,ctr_y -
953
+ m * (self._opt_results[0].Stiffener.get_pl_thk() + self._opt_results[0].Stiffener.get_web_h() +
954
+ self._opt_results[0].Stiffener.get_fl_thk()),
955
+ fill=opt_color, stipple=opt_stippe)
956
+ else:
957
+ self._canvas_opt.create_rectangle(ctr_x - m * self._opt_results[0].Stiffener.get_web_thk() / 2, ctr_y
958
+ - m * (self._opt_results[0].Stiffener.get_pl_thk()+ self._opt_results[0].Stiffener.get_web_h()),
959
+ ctr_x + m * self._opt_results[0].Stiffener.get_fl_w() ,ctr_y -
960
+ m * (self._opt_results[0].Stiffener.get_pl_thk() + self._opt_results[0].Stiffener.get_web_h() +
961
+ self._opt_results[0].Stiffener.get_fl_thk()),
962
+ fill=opt_color, stipple=opt_stippe)
963
+
964
+ self._canvas_opt.create_line(10, 50, 30, 50, fill=opt_color, width=5)
965
+ self._canvas_opt.create_text(270,50,text='Optimized - Pl.: '+str(round(self._opt_results[0].Stiffener.get_s()*1000,1))
966
+ +'x'+ str(round(self._opt_results[0].Stiffener.get_pl_thk()*1000,1))+
967
+ ' Stf.: '+str(round(self._opt_results[0].Stiffener.get_web_h()*1000,1))+
968
+ 'x'+str(round(self._opt_results[0].Stiffener.get_web_thk()*1000,1))+'+'+
969
+ str(round(self._opt_results[0].Stiffener.get_fl_w()*1000,1))+
970
+ 'x'+str(round(self._opt_results[0].Stiffener.get_fl_thk()*1000,1)),
971
+ font = 'Verdana 8',fill = opt_color)
972
+ self._canvas_opt.create_text(120, 70, text='Weight (per Lg width): '
973
+ + str(int(op.calc_weight([self._opt_results[0].Stiffener.get_s(),
974
+ self._opt_results[0].Stiffener.get_pl_thk(),
975
+ self._opt_results[0].Stiffener.get_web_h(),
976
+ self._opt_results[0].Stiffener.get_web_thk(),
977
+ self._opt_results[0].Stiffener.get_fl_w(),
978
+ self._opt_results[0].Stiffener.get_fl_thk(),
979
+ self._new_span.get(),
980
+ self._new_width_lg.get()]))),
981
+ font='Verdana 8', fill=opt_color)
982
+
983
+ def save_and_close(self):
984
+ '''
985
+ Save and close
986
+ :return:
987
+ '''
988
+
989
+ if __name__ == '__main__':
990
+ self._frame.destroy()
991
+ return
992
+
993
+ try:
994
+ self.app.on_close_opt_window(self._opt_results)
995
+ except (IndexError, TypeError):
996
+ messagebox.showinfo(title='Nothing to return',message='No results to return.')
997
+ return
998
+ self._frame.destroy()
999
+
1000
+ def algorithm_info(self):
1001
+ ''' When button is clicked, info is displayed.'''
1002
+
1003
+ messagebox.showinfo(title='Algorith information',
1004
+ message='The algorithms currently included is:\n'
1005
+ 'ANYSMART: \n'
1006
+ ' Calculates all alternatives using upper and lower bounds.\n'
1007
+ ' The step used inside the bounds is defined in deltas.\n'
1008
+ ' This algoritm uses MULTIPROCESSING and will be faster.\n\n'
1009
+ 'RANDOM: \n'
1010
+ ' Uses the same bounds and deltas as in ANYSMART.\n'
1011
+ ' Number of combinations calculated is defined in "trials",\n'
1012
+ ' which selects withing the bounds and deltas defined.\n\n'
1013
+ 'RANDOM_NO_BOUNDS:\n'
1014
+ ' Same as RANDOM, but does not use the defined deltas.\n'
1015
+ ' The deltas is set to 1 mm for all dimensions/thicknesses.\n\n'
1016
+ 'ANYDETAIL:\n'
1017
+ ' Same as for ANYSMART, but will take some more time and\n'
1018
+ ' provide a chart of weight development during execution.\n\n'
1019
+ 'PSO - Particle Swarm Search:\n'
1020
+ ' The information can be found on \n'
1021
+ ' http://pythonhosted.org/pyswarm/ \n'
1022
+ ' For further information google it!\n'
1023
+ ' Parameters:\n'
1024
+ ' swarmsize : The number of particles in the swarm (Default: 100)\n'
1025
+ ' omega : Particle velocity scaling factor (Default: 0.5)\n'
1026
+ ' phip : Scaling factor to search away from the particle’s \n'
1027
+ ' best known position (Default: 0.5)\n'
1028
+ ' phig : Scaling factor to search away from the swarm’s best \n'
1029
+ ' known position (Default: 0.5)\n'
1030
+ ' maxiter : The maximum number of iterations for the swarm \n'
1031
+ ' to search (Default: 100)\n'
1032
+ ' minstep : The minimum stepsize of swarm’s best position \n'
1033
+ ' before the search terminates (Default: 1e-8)\n'
1034
+ ' minfunc : The minimum change of swarm’s best objective value\n'
1035
+ ' before the search terminates (Default: 1e-8)\n\n'
1036
+
1037
+ '\n'
1038
+ 'All algorithms calculates local scantling and buckling requirements')
1039
+
1040
+ def toggle(self):
1041
+ if self._toggle_btn.config('relief')[-1] == 'sunken':
1042
+ self._toggle_btn.config(relief="raised")
1043
+ self._toggle_btn.config(bg = 'salmon')
1044
+ self._ent_spacing_upper.config(bg = 'white')
1045
+ self._ent_spacing_lower.config(bg = 'white')
1046
+ self._ent_delta_spacing.config(bg = 'white')
1047
+ predefined_stiffener_iter = []
1048
+ else:
1049
+ self._toggle_btn.config(relief="sunken")
1050
+ self._toggle_btn.config(bg = 'salmon')
1051
+ self._toggle_btn.config(bg='lightgreen')
1052
+ self._ent_spacing_upper.config(bg = 'lightgreen')
1053
+ self._ent_spacing_lower.config(bg = 'lightgreen')
1054
+ self._ent_delta_spacing.config(bg = 'lightgreen')
1055
+ self._ent_pl_thk_upper.config(bg = 'lightgreen')
1056
+ self._ent_pl_thk_lower.config(bg = 'lightgreen')
1057
+ self._ent_delta_pl_thk.config(bg = 'lightgreen')
1058
+
1059
+ open_files = askopenfilenames(parent=self._frame, title='Choose files to open',
1060
+ initialdir=self._root_dir)
1061
+ # TODO for both stiffeners and girders
1062
+
1063
+ self._initial_calc_obj.Stiffener.t = self._initial_calc_obj.Plate.t
1064
+ self._initial_calc_obj.Stiffener.s = self._initial_calc_obj.Plate.spacing
1065
+ predefined_stiffener_iter = hlp.helper_read_section_file(files=list(open_files),
1066
+ obj=self._initial_calc_obj.Stiffener)
1067
+ if predefined_stiffener_iter == []:
1068
+ self._toggle_btn.config(relief="raised")
1069
+ self._toggle_btn.config(bg = 'salmon')
1070
+ self._ent_spacing_upper.config(bg = 'white')
1071
+ self._ent_spacing_lower.config(bg = 'white')
1072
+ self._ent_delta_spacing.config(bg = 'white')
1073
+ self._ent_pl_thk_upper.config(bg = 'white')
1074
+ self._ent_pl_thk_lower.config(bg = 'white')
1075
+ self._ent_delta_pl_thk.config(bg = 'white')
1076
+ self._predefined_stiffener_iter = None
1077
+ else:
1078
+ self._predefined_stiffener_iter = predefined_stiffener_iter
1079
+ self.update_running_time()
1080
+
1081
+ def open_example_file(self):
1082
+ import os
1083
+ if os.path.isfile('sections.csv'):
1084
+ os.startfile('sections.csv')
1085
+ else:
1086
+ os.startfile(self._root_dir + '/' + 'sections.csv')
1087
+
1088
+ def show_calculated(self):
1089
+ ''' '''
1090
+ pass
1091
+
1092
+ def plot_results(self):
1093
+ if len(self._opt_results) != 0:
1094
+ op.plot_optimization_results(self._opt_results)
1095
+
1096
+ def write_result_csv(self):
1097
+ if len(self._opt_results) != 0:
1098
+ print(self._opt_results)
1099
+
1100
+
1101
+ def receive_progress_info():
1102
+ '''
1103
+ Get progress info from optimization algorithm.
1104
+ :return:
1105
+ '''
1106
+ print('hi')
1107
+
1108
+
1109
+
1110
+ if __name__ == '__main__':
1111
+ root = tk.Tk()
1112
+ my_app = CreateOptimizeWindow(master=root)
1113
+ root.mainloop()
1114
+
1115
+
1116
+
1117
+