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,1708 @@
|
|
|
1
|
+
# This is where the optimization is done.
|
|
2
|
+
import tkinter as tk
|
|
3
|
+
from _tkinter import TclError
|
|
4
|
+
from tkinter.ttk import Progressbar
|
|
5
|
+
from tkinter import messagebox
|
|
6
|
+
import pickle
|
|
7
|
+
from tkinter.filedialog import askopenfilenames
|
|
8
|
+
from multiprocessing import cpu_count
|
|
9
|
+
from tkinter import filedialog
|
|
10
|
+
from matplotlib import pyplot as plt
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
import anystruct.main_application
|
|
14
|
+
import anystruct.optimize as op
|
|
15
|
+
import anystruct.example_data as test
|
|
16
|
+
from anystruct.calc_structure import *
|
|
17
|
+
import anystruct.calc_structure
|
|
18
|
+
from anystruct.helper import *
|
|
19
|
+
except ModuleNotFoundError:
|
|
20
|
+
import ANYstructure.anystruct.main_application
|
|
21
|
+
import ANYstructure.anystruct.optimize as op
|
|
22
|
+
import ANYstructure.anystruct.example_data as test
|
|
23
|
+
from ANYstructure.anystruct.calc_structure import *
|
|
24
|
+
import ANYstructure.anystruct.calc_structure
|
|
25
|
+
from ANYstructure.anystruct.helper import *
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CreateOptGeoWindow():
|
|
29
|
+
'''
|
|
30
|
+
This class initiates the MultiOpt window.
|
|
31
|
+
'''
|
|
32
|
+
|
|
33
|
+
def __init__(self, master, app=None):
|
|
34
|
+
super(CreateOptGeoWindow, self).__init__()
|
|
35
|
+
if __name__ == '__main__':
|
|
36
|
+
self._load_objects = {}
|
|
37
|
+
self._load_comb_dict = {}
|
|
38
|
+
self._line_dict = test.get_line_dict()
|
|
39
|
+
self._load_count = 0
|
|
40
|
+
self._point_dict = test.get_point_dict()
|
|
41
|
+
self._canvas_scale = 20
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
self._line_to_struc = test.get_line_to_struc()
|
|
45
|
+
|
|
46
|
+
self._opt_frames = {}
|
|
47
|
+
self._active_points = ['point1','point4','point8','point5']
|
|
48
|
+
self._ML_buckling = dict() # Buckling machine learning algorithm
|
|
49
|
+
for name, file_base in zip(['cl SP buc int predictor', 'cl SP buc int scaler',
|
|
50
|
+
'cl SP ult int predictor', 'cl SP ult int scaler',
|
|
51
|
+
'cl SP buc GLGT predictor', 'cl SP buc GLGT scaler',
|
|
52
|
+
'cl SP ult GLGT predictor', 'cl SP ult GLGT scaler',
|
|
53
|
+
'cl UP buc int predictor', 'cl UP buc int scaler',
|
|
54
|
+
'cl UP ult int predictor', 'cl UP ult int scaler',
|
|
55
|
+
'cl UP buc GLGT predictor', 'cl UP buc GLGT scaler',
|
|
56
|
+
'cl UP ult GLGT predictor', 'cl UP ult GLGT scaler',
|
|
57
|
+
'CSR predictor', 'CSR scaler'
|
|
58
|
+
],
|
|
59
|
+
["ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_SP",
|
|
60
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_SP",
|
|
61
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_SP",
|
|
62
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_SP",
|
|
63
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_SP",
|
|
64
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_SP",
|
|
65
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_SP",
|
|
66
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_SP",
|
|
67
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_UP",
|
|
68
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_UP",
|
|
69
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_UP",
|
|
70
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_UP",
|
|
71
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_UP",
|
|
72
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_UP",
|
|
73
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_UP",
|
|
74
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_UP",
|
|
75
|
+
"CL_CSR-Tank_req_cl_predictor",
|
|
76
|
+
"CL_CSR-Tank_req_cl_UP_scaler",
|
|
77
|
+
"CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor",
|
|
78
|
+
"CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_SP_scaler"]):
|
|
79
|
+
self._ML_buckling[name] = None
|
|
80
|
+
if os.path.isfile(file_base + '.pickle'):
|
|
81
|
+
file = open(file_base + '.pickle', 'rb')
|
|
82
|
+
self._ML_buckling[name] = pickle.load(file)
|
|
83
|
+
file.close()
|
|
84
|
+
else:
|
|
85
|
+
self.app = app
|
|
86
|
+
self._load_objects = app._load_dict
|
|
87
|
+
self._load_comb_dict = app._new_load_comb_dict
|
|
88
|
+
self._line_dict = app._line_dict
|
|
89
|
+
self._load_count = 0
|
|
90
|
+
self._point_dict = app._point_dict
|
|
91
|
+
self._canvas_scale = app._canvas_scale
|
|
92
|
+
self._line_to_struc = app._line_to_struc
|
|
93
|
+
self._opt_frames = {}
|
|
94
|
+
self._active_points = []
|
|
95
|
+
self._root_dir = app._root_dir
|
|
96
|
+
self._ML_buckling = app._ML_buckling
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
self._opt_structure = {}
|
|
100
|
+
self._opt_frames_obj = []
|
|
101
|
+
self._frame = master
|
|
102
|
+
self._frame.wm_title("Optimize structure")
|
|
103
|
+
self._frame.geometry('1800x950')
|
|
104
|
+
self._frame.grab_set()
|
|
105
|
+
self._canvas_origo = (50, 720 - 50)
|
|
106
|
+
|
|
107
|
+
self._canvas_base_origo = self._canvas_origo
|
|
108
|
+
self._canvas_draw_origo = list(self._canvas_base_origo)
|
|
109
|
+
self._previous_drag_mouse = list(self._canvas_draw_origo)
|
|
110
|
+
|
|
111
|
+
self._active_lines = []
|
|
112
|
+
self._add_to_lines = True
|
|
113
|
+
self._lines_add_to_load = []
|
|
114
|
+
self._active_point = None
|
|
115
|
+
self._point_is_active = False
|
|
116
|
+
|
|
117
|
+
# ----------------------------------COPIED FROM OPTIMIZE_WINDOW----------------------------------------------- #
|
|
118
|
+
|
|
119
|
+
self._opt_resutls = {}
|
|
120
|
+
self._geo_results = None
|
|
121
|
+
self._opt_actual_running_time = tk.Label(self._frame, text='')
|
|
122
|
+
|
|
123
|
+
tk.Frame(self._frame, width=770, height=5, bg="grey", colormap="new").place(x=20, y=95)
|
|
124
|
+
tk.Frame(self._frame, width=770, height=5, bg="grey", colormap="new").place(x=20, y=135)
|
|
125
|
+
|
|
126
|
+
algorithms = ('anysmart',' ')
|
|
127
|
+
|
|
128
|
+
tk.Label(self._frame, text='-- Plate field span optimizer for plate fields separated by frames. --',
|
|
129
|
+
font='Verdana 15 bold').place(x=10, y=10)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# upper and lower bounds for optimization
|
|
133
|
+
# [0.6, 0.012, 0.3, 0.01, 0.1, 0.01]
|
|
134
|
+
self._new_spacing_upper = tk.DoubleVar()
|
|
135
|
+
self._new_spacing_lower = tk.DoubleVar()
|
|
136
|
+
self._new_pl_thk_upper = tk.DoubleVar()
|
|
137
|
+
self._new_pl_thk_lower = tk.DoubleVar()
|
|
138
|
+
self._new_web_h_upper = tk.DoubleVar()
|
|
139
|
+
self._new_web_h_lower = tk.DoubleVar()
|
|
140
|
+
self._new_web_thk_upper = tk.DoubleVar()
|
|
141
|
+
self._new_web_thk_lower = tk.DoubleVar()
|
|
142
|
+
self._new_fl_w_upper = tk.DoubleVar()
|
|
143
|
+
self._new_fl_w_lower = tk.DoubleVar()
|
|
144
|
+
self._new_fl_thk_upper = tk.DoubleVar()
|
|
145
|
+
self._new_fl_thk_lower = tk.DoubleVar()
|
|
146
|
+
self._new_span = tk.DoubleVar()
|
|
147
|
+
self._new_width_lg = tk.DoubleVar()
|
|
148
|
+
self._new_algorithm = tk.StringVar()
|
|
149
|
+
self._new_algorithm_random_trials = tk.IntVar()
|
|
150
|
+
self._new_delta_spacing = tk.DoubleVar()
|
|
151
|
+
self._new_delta_pl_thk = tk.DoubleVar()
|
|
152
|
+
self._new_delta_web_h = tk.DoubleVar()
|
|
153
|
+
self._new_delta_web_thk = tk.DoubleVar()
|
|
154
|
+
self._new_delta_fl_w = tk.DoubleVar()
|
|
155
|
+
self._new_delta_fl_thk = tk.DoubleVar()
|
|
156
|
+
self._new_swarm_size = tk.IntVar()
|
|
157
|
+
self._new_omega = tk.DoubleVar()
|
|
158
|
+
self._new_phip = tk.DoubleVar()
|
|
159
|
+
self._new_phig = tk.DoubleVar()
|
|
160
|
+
self._new_maxiter = tk.IntVar()
|
|
161
|
+
self._new_minstep = tk.DoubleVar()
|
|
162
|
+
self._new_minfunc = tk.DoubleVar()
|
|
163
|
+
self._new_processes = tk.IntVar()
|
|
164
|
+
self._new_opt_girder_thk = tk.DoubleVar()
|
|
165
|
+
self._new_opt_girder_stf_web_h = tk.DoubleVar()
|
|
166
|
+
self._new_opt_girder_stf_web_thk = tk.DoubleVar()
|
|
167
|
+
self._new_opt_girder_stf_flange_b = tk.DoubleVar()
|
|
168
|
+
self._new_opt_girder_stf_flange_thk = tk.DoubleVar()
|
|
169
|
+
self._new_opt_girder_scale_high = tk.DoubleVar()
|
|
170
|
+
self._new_opt_girder_scale_low = tk.DoubleVar()
|
|
171
|
+
self._new_opt_span_max = tk.DoubleVar()
|
|
172
|
+
self._new_opt_span_min = tk.DoubleVar()
|
|
173
|
+
self._new_option_fraction = tk.IntVar()
|
|
174
|
+
self._new_option_panel = tk.IntVar()
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
ent_w = 10
|
|
178
|
+
self._ent_spacing_upper = tk.Entry(self._frame, textvariable=self._new_spacing_upper, width=ent_w)
|
|
179
|
+
self._ent_spacing_lower = tk.Entry(self._frame, textvariable=self._new_spacing_lower, width=ent_w)
|
|
180
|
+
self._ent_pl_thk_upper = tk.Entry(self._frame, textvariable=self._new_pl_thk_upper, width=ent_w)
|
|
181
|
+
self._ent_pl_thk_lower = tk.Entry(self._frame, textvariable=self._new_pl_thk_lower, width=ent_w)
|
|
182
|
+
self._ent_web_h_upper = tk.Entry(self._frame, textvariable=self._new_web_h_upper, width=ent_w)
|
|
183
|
+
self._ent_web_h_lower = tk.Entry(self._frame, textvariable=self._new_web_h_lower, width=ent_w)
|
|
184
|
+
self._ent_web_thk_upper = tk.Entry(self._frame, textvariable=self._new_web_thk_upper, width=ent_w)
|
|
185
|
+
self._ent_web_thk_lower = tk.Entry(self._frame, textvariable=self._new_web_thk_lower, width=ent_w)
|
|
186
|
+
self._ent_fl_w_upper = tk.Entry(self._frame, textvariable=self._new_fl_w_upper, width=ent_w)
|
|
187
|
+
self._ent_fl_w_lower = tk.Entry(self._frame, textvariable=self._new_fl_w_lower, width=ent_w)
|
|
188
|
+
self._ent_fl_thk_upper = tk.Entry(self._frame, textvariable=self._new_fl_thk_upper, width=ent_w)
|
|
189
|
+
self._ent_fl_thk_lower = tk.Entry(self._frame, textvariable=self._new_fl_thk_lower, width=ent_w)
|
|
190
|
+
self._ent_span = tk.Entry(self._frame, textvariable=self._new_span, width=ent_w)
|
|
191
|
+
self._ent_width_lg = tk.Entry(self._frame, textvariable=self._new_width_lg, width=ent_w)
|
|
192
|
+
self._ent_algorithm = tk.OptionMenu(self._frame, self._new_algorithm, command=self.selected_algorithm,
|
|
193
|
+
*algorithms)
|
|
194
|
+
self._ent_random_trials = tk.Entry(self._frame, textvariable=self._new_algorithm_random_trials)
|
|
195
|
+
self._ent_delta_spacing = tk.Entry(self._frame, textvariable=self._new_delta_spacing, width=ent_w)
|
|
196
|
+
self._ent_delta_pl_thk = tk.Entry(self._frame, textvariable=self._new_delta_pl_thk, width=ent_w)
|
|
197
|
+
self._ent_delta_web_h = tk.Entry(self._frame, textvariable=self._new_delta_web_h, width=ent_w)
|
|
198
|
+
self._ent_delta_web_thk = tk.Entry(self._frame, textvariable=self._new_delta_web_thk, width=ent_w)
|
|
199
|
+
self._ent_delta_fl_w = tk.Entry(self._frame, textvariable=self._new_delta_fl_w, width=ent_w)
|
|
200
|
+
self._ent_delta_fl_thk = tk.Entry(self._frame, textvariable=self._new_delta_fl_thk, width=ent_w)
|
|
201
|
+
|
|
202
|
+
pso_width = 10
|
|
203
|
+
self._ent_swarm_size = tk.Entry(self._frame, textvariable=self._new_swarm_size, width=pso_width)
|
|
204
|
+
self._ent_omega = tk.Entry(self._frame, textvariable=self._new_omega, width=pso_width)
|
|
205
|
+
self._ent_phip = tk.Entry(self._frame, textvariable=self._new_phip, width=pso_width)
|
|
206
|
+
self._ent_phig = tk.Entry(self._frame, textvariable=self._new_phig, width=pso_width)
|
|
207
|
+
self._ent_maxiter = tk.Entry(self._frame, textvariable=self._new_maxiter, width=pso_width)
|
|
208
|
+
self._ent_minstep = tk.Entry(self._frame, textvariable=self._new_minstep, width=pso_width)
|
|
209
|
+
self._ent_minfunc = tk.Entry(self._frame, textvariable=self._new_minfunc, width=pso_width)
|
|
210
|
+
|
|
211
|
+
self._ent_opt_girder_thk = tk.Entry(self._frame, textvariable=self._new_opt_girder_thk, width=ent_w)
|
|
212
|
+
self._ent_opt_girder_stf_web_h = tk.Entry(self._frame, textvariable=self._new_opt_girder_stf_web_h,
|
|
213
|
+
width=ent_w)
|
|
214
|
+
self._ent_opt_girder_stf_web_thk = tk.Entry(self._frame, textvariable=self._new_opt_girder_stf_web_thk,
|
|
215
|
+
width=ent_w)
|
|
216
|
+
self._ent_opt_girder_stf_fl_b = tk.Entry(self._frame, textvariable=self._new_opt_girder_stf_flange_b,
|
|
217
|
+
width=ent_w)
|
|
218
|
+
self._ent_opt_girder_stf_fl_thk = tk.Entry(self._frame, textvariable=self._new_opt_girder_stf_flange_thk,
|
|
219
|
+
width=ent_w)
|
|
220
|
+
|
|
221
|
+
self._ent_opt_girder_scale_high = tk.Entry(self._frame, textvariable=self._new_opt_girder_scale_high,
|
|
222
|
+
width=int(ent_w/2))
|
|
223
|
+
self._ent_opt_girder_scale_low = tk.Entry(self._frame, textvariable=self._new_opt_girder_scale_low,
|
|
224
|
+
width=int(ent_w/2))
|
|
225
|
+
|
|
226
|
+
self._ent_opt_max_span = tk.Entry(self._frame, textvariable=self._new_opt_span_max,
|
|
227
|
+
width=int(ent_w/2))
|
|
228
|
+
self._ent_opt_min_span = tk.Entry(self._frame, textvariable=self._new_opt_span_min,
|
|
229
|
+
width=int(ent_w/2))
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
start_x, start_y, dx, dy = 20, 70, 100, 40
|
|
233
|
+
|
|
234
|
+
tk.Label(self._frame, text='Processes\n (CPUs)', font='Verdana 9 bold', bg = 'silver')\
|
|
235
|
+
.place(x=start_x + 8 * dx, y=start_y + 0.5 * dy)
|
|
236
|
+
tk.Entry(self._frame, textvariable=self._new_processes, width = 12, bg = 'silver')\
|
|
237
|
+
.place(x=start_x + 8 * dx, y=start_y + 1.4 * dy)
|
|
238
|
+
|
|
239
|
+
self._prop_canvas_dim = (500, 450)
|
|
240
|
+
self._draw_scale = 500
|
|
241
|
+
self._canvas_opt = tk.Canvas(self._frame, width=self._prop_canvas_dim[0], height=self._prop_canvas_dim[1],
|
|
242
|
+
background='azure', relief='groove', borderwidth=2)
|
|
243
|
+
self._canvas_opt.place(x=start_x + 10.5 * dx, y=start_y + 3.5 * dy)
|
|
244
|
+
self._select_canvas_dim = (1000, 720)
|
|
245
|
+
self._canvas_select = tk.Canvas(self._frame, width=self._select_canvas_dim[0],
|
|
246
|
+
height=self._select_canvas_dim[1],
|
|
247
|
+
background='azure', relief='groove', borderwidth=2)
|
|
248
|
+
self._canvas_select.place(x=start_x + 0 * dx, y=start_y + 3.5 * dy)
|
|
249
|
+
|
|
250
|
+
# Labels for the pso
|
|
251
|
+
self._lb_swarm_size = tk.Label(self._frame, text='swarm size')
|
|
252
|
+
self._lb_omega = tk.Label(self._frame, text='omega')
|
|
253
|
+
self._lb_phip = tk.Label(self._frame, text='phip')
|
|
254
|
+
self._lb_phig = tk.Label(self._frame, text='phig')
|
|
255
|
+
self._lb_maxiter = tk.Label(self._frame, text='maxiter')
|
|
256
|
+
self._lb_minstep = tk.Label(self._frame, text='minstep')
|
|
257
|
+
self._lb_minfunc = tk.Label(self._frame, text='minfunc')
|
|
258
|
+
|
|
259
|
+
tk.Label(self._frame, text='Upper bounds [mm]', font='Verdana 9').place(x=start_x, y=start_y)
|
|
260
|
+
tk.Label(self._frame, text='Iteration delta [mm]', font='Verdana 9').place(x=start_x, y=start_y + dy)
|
|
261
|
+
tk.Label(self._frame, text='Lower bounds [mm]', font='Verdana 9').place(x=start_x, y=start_y + 2 * dy)
|
|
262
|
+
tk.Label(self._frame, text='Spacing [mm]', font='Verdana 7 bold').place(x=start_x + 1.97 * dx,
|
|
263
|
+
y=start_y - 0.6 * dy)
|
|
264
|
+
tk.Label(self._frame, text='Plate thk. [mm]', font='Verdana 7 bold').place(x=start_x + 2.97 * dx,
|
|
265
|
+
y=start_y - 0.6 * dy)
|
|
266
|
+
tk.Label(self._frame, text='Web height [mm]', font='Verdana 7 bold').place(x=start_x + 3.97 * dx,
|
|
267
|
+
y=start_y - 0.6 * dy)
|
|
268
|
+
tk.Label(self._frame, text='Web thk. [mm]', font='Verdana 7 bold').place(x=start_x + 4.97 * dx,
|
|
269
|
+
y=start_y - 0.6 * dy)
|
|
270
|
+
tk.Label(self._frame, text='Flange width [mm]', font='Verdana 7 bold').place(x=start_x + 5.97 * dx,
|
|
271
|
+
y=start_y - 0.6 * dy)
|
|
272
|
+
tk.Label(self._frame, text='Flange thk. [mm]', font='Verdana 7 bold').place(x=start_x + 6.97 * dx,
|
|
273
|
+
y=start_y - 0.6 * dy)
|
|
274
|
+
tk.Label(self._frame, text='Estimated running time for algorithm not calculated.',
|
|
275
|
+
font='Verdana 9 bold').place(x=start_x, y=start_y + 2.8 * dy)
|
|
276
|
+
tk.Label(self._frame, text='- Harmonize stiffener spacing for section.', font='Verdana 9 bold')\
|
|
277
|
+
.place(x=start_x + 5*dx, y=start_y + 2.8 * dy)
|
|
278
|
+
# self._runnig_time_label = tk.Label(self._frame, text='', font='Verdana 9 bold')
|
|
279
|
+
# self._runnig_time_label.place(x=start_x + 2.7 * dx, y=start_y + 2.8 * dy)
|
|
280
|
+
# tk.Label(self._frame, text='seconds ', font='Verdana 9 bold').place(x=start_x + 3.3 * dx, y=start_y + 2.8 * dy)
|
|
281
|
+
self._result_label = tk.Label(self._frame, text='', font='Verdana 9 bold')
|
|
282
|
+
self._result_label.place(x=start_x, y=start_y + 3.4 * dy)
|
|
283
|
+
|
|
284
|
+
self._ent_spacing_upper.place(x=start_x + dx * 2, y=start_y)
|
|
285
|
+
self._ent_delta_spacing.place(x=start_x + dx * 2, y=start_y + dy)
|
|
286
|
+
self._ent_spacing_lower.place(x=start_x + dx * 2, y=start_y + 2 * dy)
|
|
287
|
+
self._ent_pl_thk_upper.place(x=start_x + dx * 3, y=start_y)
|
|
288
|
+
self._ent_delta_pl_thk.place(x=start_x + dx * 3, y=start_y + dy)
|
|
289
|
+
self._ent_pl_thk_lower.place(x=start_x + dx * 3, y=start_y + 2 * dy)
|
|
290
|
+
self._ent_web_h_upper.place(x=start_x + dx * 4, y=start_y)
|
|
291
|
+
self._ent_delta_web_h.place(x=start_x + dx * 4, y=start_y + dy)
|
|
292
|
+
self._ent_web_h_lower.place(x=start_x + dx * 4, y=start_y + 2 * dy)
|
|
293
|
+
self._ent_web_thk_upper.place(x=start_x + dx * 5, y=start_y)
|
|
294
|
+
self._ent_delta_web_thk.place(x=start_x + dx * 5, y=start_y + dy)
|
|
295
|
+
self._ent_web_thk_lower.place(x=start_x + dx * 5, y=start_y + 2 * dy)
|
|
296
|
+
self._ent_fl_w_upper.place(x=start_x + dx * 6, y=start_y)
|
|
297
|
+
self._ent_delta_fl_w.place(x=start_x + dx * 6, y=start_y + dy)
|
|
298
|
+
self._ent_fl_w_lower.place(x=start_x + dx * 6, y=start_y + 2 * dy)
|
|
299
|
+
self._ent_fl_thk_upper.place(x=start_x + dx * 7, y=start_y)
|
|
300
|
+
self._ent_delta_fl_thk.place(x=start_x + dx * 7, y=start_y + dy)
|
|
301
|
+
self._ent_fl_thk_lower.place(x=start_x + dx * 7, y=start_y + 2 * dy)
|
|
302
|
+
|
|
303
|
+
# setting default values
|
|
304
|
+
init_dim = float(100) # mm
|
|
305
|
+
init_thk = float(5) # mm
|
|
306
|
+
self._new_delta_spacing.set(init_dim)
|
|
307
|
+
self._new_delta_pl_thk.set(init_thk)
|
|
308
|
+
self._new_delta_web_h.set(init_dim)
|
|
309
|
+
self._new_delta_web_thk.set(init_thk)
|
|
310
|
+
self._new_delta_fl_w.set(init_dim)
|
|
311
|
+
self._new_delta_fl_thk.set(init_thk)
|
|
312
|
+
self._new_spacing_upper.set(round(800, 5))
|
|
313
|
+
self._new_spacing_lower.set(round(600, 5))
|
|
314
|
+
self._new_pl_thk_upper.set(round(25, 5))
|
|
315
|
+
self._new_pl_thk_lower.set(round(10, 5))
|
|
316
|
+
self._new_web_h_upper.set(round(500, 5))
|
|
317
|
+
self._new_web_h_lower.set(round(300, 5))
|
|
318
|
+
self._new_web_thk_upper.set(round(25, 5))
|
|
319
|
+
self._new_web_thk_lower.set(round(10, 5))
|
|
320
|
+
self._new_fl_w_upper.set(round(250, 5))
|
|
321
|
+
self._new_fl_w_lower.set(round(50, 5))
|
|
322
|
+
self._new_fl_thk_upper.set(round(30, 5))
|
|
323
|
+
self._new_fl_thk_lower.set(round(10, 5))
|
|
324
|
+
self._new_algorithm.set('anysmart')
|
|
325
|
+
self._new_algorithm_random_trials.set(10000)
|
|
326
|
+
self._new_processes.set(max(cpu_count() - 1, 1))
|
|
327
|
+
self._new_opt_girder_thk.set(0.018)
|
|
328
|
+
self._new_opt_girder_stf_web_h.set(0.250)
|
|
329
|
+
self._new_opt_girder_stf_web_thk.set(0.015)
|
|
330
|
+
self._new_opt_girder_stf_flange_b.set(0)
|
|
331
|
+
self._new_opt_girder_stf_flange_thk.set(0)
|
|
332
|
+
self._new_opt_girder_scale_high.set(1.1)
|
|
333
|
+
self._new_opt_girder_scale_low.set(0.9)
|
|
334
|
+
self._new_opt_span_max.set(6)
|
|
335
|
+
self._new_opt_span_min.set(2)
|
|
336
|
+
|
|
337
|
+
self._new_swarm_size.set(100)
|
|
338
|
+
self._new_omega.set(0.5)
|
|
339
|
+
self._new_phip.set(0.5)
|
|
340
|
+
self._new_phig.set(0.5)
|
|
341
|
+
self._new_maxiter.set(100)
|
|
342
|
+
self._new_minstep.set(1e-8)
|
|
343
|
+
self._new_minfunc.set(1e-8)
|
|
344
|
+
|
|
345
|
+
# self._new_delta_spacing.trace('w', self.update_running_time)
|
|
346
|
+
# self._new_delta_pl_thk.trace('w', self.update_running_time)
|
|
347
|
+
# self._new_delta_web_h.trace('w', self.update_running_time)
|
|
348
|
+
# self._new_delta_web_thk.trace('w', self.update_running_time)
|
|
349
|
+
# self._new_delta_fl_w.trace('w', self.update_running_time)
|
|
350
|
+
# self._new_delta_fl_thk.trace('w', self.update_running_time)
|
|
351
|
+
# self._new_spacing_upper.trace('w', self.update_running_time)
|
|
352
|
+
# self._new_spacing_lower.trace('w', self.update_running_time)
|
|
353
|
+
# self._new_pl_thk_upper.trace('w', self.update_running_time)
|
|
354
|
+
# self._new_pl_thk_lower.trace('w', self.update_running_time)
|
|
355
|
+
# self._new_web_h_upper.trace('w', self.update_running_time)
|
|
356
|
+
# self._new_web_h_lower.trace('w', self.update_running_time)
|
|
357
|
+
# self._new_web_thk_upper.trace('w', self.update_running_time)
|
|
358
|
+
# self._new_web_thk_lower.trace('w', self.update_running_time)
|
|
359
|
+
# self._new_fl_w_upper.trace('w', self.update_running_time)
|
|
360
|
+
# self._new_fl_w_lower.trace('w', self.update_running_time)
|
|
361
|
+
# self._new_fl_thk_upper.trace('w', self.update_running_time)
|
|
362
|
+
# self._new_fl_thk_lower.trace('w', self.update_running_time)
|
|
363
|
+
# self._new_algorithm_random_trials.trace('w', self.update_running_time)
|
|
364
|
+
# self._new_algorithm.trace('w', self.update_running_time)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
self.running_time_per_item = 4e-05
|
|
368
|
+
#self._runnig_time_label.config(text=str(self.get_running_time()))
|
|
369
|
+
self._ent_algorithm.place(x=start_x + dx * 10, y=start_y + dy)
|
|
370
|
+
self.algorithm_random_label = tk.Label(self._frame, text='Number of trials')
|
|
371
|
+
tk.Button(self._frame, text='algorith information', command=self.algorithm_info, bg='white') \
|
|
372
|
+
.place(x=start_x + dx * 10, y=start_y + dy * 2)
|
|
373
|
+
|
|
374
|
+
self.run_button = tk.Button(self._frame, text='RUN OPTIMIZATION!', command=self.run_optimizaion, bg='red',
|
|
375
|
+
font='Verdana 10', fg='Yellow')
|
|
376
|
+
self.run_button.place(x=start_x + dx * 10, y=start_y)
|
|
377
|
+
self._opt_actual_running_time.place(x=start_x + dx * 8, y=start_y + dy * 1.5)
|
|
378
|
+
# self.close_and_save = tk.Button(self._frame, text='Return and replace with selected optimized structure',
|
|
379
|
+
# command=self.save_and_close, bg='green', font='Verdana 10 bold', fg='yellow')
|
|
380
|
+
# self.close_and_save.place(x=start_x + dx * 10, y=10)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
tk.Button(self._frame, text='Open predefined stiffeners example',
|
|
384
|
+
command=self.open_example_file, bg='white', font='Verdana 10')\
|
|
385
|
+
.place(x=start_x+dx*10,y=10)
|
|
386
|
+
|
|
387
|
+
# Selection of constraints
|
|
388
|
+
self._new_check_sec_mod = tk.BooleanVar()
|
|
389
|
+
self._new_check_min_pl_thk = tk.BooleanVar()
|
|
390
|
+
self._new_check_shear_area = tk.BooleanVar()
|
|
391
|
+
self._new_check_buckling = tk.BooleanVar()
|
|
392
|
+
self._new_check_fatigue = tk.BooleanVar()
|
|
393
|
+
self._new_check_slamming = tk.BooleanVar()
|
|
394
|
+
self._new_check_local_buckling = tk.BooleanVar()
|
|
395
|
+
self._new_harmonize_spacing = tk.BooleanVar()
|
|
396
|
+
self._new_check_buckling_ml_cl = tk.BooleanVar()
|
|
397
|
+
|
|
398
|
+
self._new_check_sec_mod.set(True)
|
|
399
|
+
self._new_check_min_pl_thk.set(True)
|
|
400
|
+
self._new_check_shear_area.set(True)
|
|
401
|
+
self._new_check_buckling.set(True)
|
|
402
|
+
self._new_check_fatigue.set(True)
|
|
403
|
+
self._new_check_slamming.set(True)
|
|
404
|
+
self._new_check_local_buckling.set(True)
|
|
405
|
+
self._new_option_fraction.set(None)
|
|
406
|
+
self._new_option_panel.set(None)
|
|
407
|
+
self._new_harmonize_spacing.set(False)
|
|
408
|
+
self._new_check_buckling_ml_cl.set(False)
|
|
409
|
+
|
|
410
|
+
self._new_check_buckling_ml_cl.trace('w', self.update_running_time)
|
|
411
|
+
|
|
412
|
+
start_y, start_x, dy = 570, 100, 25
|
|
413
|
+
tk.Label(self._frame,text='Check for minimum section modulus').place(x=start_x+dx*9.7,y=start_y+4*dy)
|
|
414
|
+
tk.Label(self._frame, text='Check for minimum plate thk.').place(x=start_x+dx*9.7,y=start_y+5*dy)
|
|
415
|
+
tk.Label(self._frame, text='Check for minimum shear area').place(x=start_x+dx*9.7,y=start_y+6*dy)
|
|
416
|
+
tk.Label(self._frame, text='Check for buckling (RP-C201)').place(x=start_x+dx*9.7,y=start_y+7*dy)
|
|
417
|
+
tk.Label(self._frame, text='Check for fatigue (RP-C203)').place(x=start_x + dx * 9.7, y=start_y + 8 * dy)
|
|
418
|
+
tk.Label(self._frame, text='Check for bow slamming').place(x=start_x + dx * 9.7, y=start_y + 9 * dy)
|
|
419
|
+
tk.Label(self._frame, text='Check for local stf. buckling').place(x=start_x + dx * 9.7, y=start_y + 10 * dy)
|
|
420
|
+
tk.Label(self._frame, text='Check for buckling, ML-CL').place(x=start_x + dx * 9.7, y=start_y + 11 * dy)
|
|
421
|
+
|
|
422
|
+
tk.Label(self._frame, text='Frame (girder data) for weight calculation:', font = 'Verdana 9 bold')\
|
|
423
|
+
.place(x=start_x + dx * 13,
|
|
424
|
+
y=start_y + 4 * dy)
|
|
425
|
+
tk.Label(self._frame, text='Girder thickness').place(x=start_x + dx * 13, y=start_y + 5 * dy)
|
|
426
|
+
tk.Label(self._frame, text='Stiffener height').place(x=start_x + dx * 13, y=start_y + 6 * dy)
|
|
427
|
+
tk.Label(self._frame, text='Stiffener thickness').place(x=start_x + dx * 13, y=start_y + 7 * dy)
|
|
428
|
+
tk.Label(self._frame, text='Stf. flange width').place(x=start_x + dx * 13, y=start_y + 8 * dy)
|
|
429
|
+
tk.Label(self._frame, text='Stf. flange thickenss').place(x=start_x + dx * 13, y=start_y + 9 * dy)
|
|
430
|
+
tk.Label(self._frame, text='For weight calculation of girder: Max span mult / Min span mult')\
|
|
431
|
+
.place(x=start_x + dx * 13,y=start_y + 10 * dy)
|
|
432
|
+
tk.Label(self._frame, text='Maximum span / Minimum span ->')\
|
|
433
|
+
.place(x=start_x + dx * 13,y=start_y + 12 * dy)
|
|
434
|
+
|
|
435
|
+
self._ent_opt_girder_thk.place(x=start_x + dx * 15, y=start_y + 5 * dy)
|
|
436
|
+
self._ent_opt_girder_stf_web_h.place(x=start_x + dx * 15, y=start_y + 6 * dy)
|
|
437
|
+
self._ent_opt_girder_stf_web_thk.place(x=start_x + dx * 15, y=start_y + 7 * dy)
|
|
438
|
+
self._ent_opt_girder_stf_fl_b.place(x=start_x + dx * 15, y=start_y + 8 * dy)
|
|
439
|
+
self._ent_opt_girder_stf_fl_thk.place(x=start_x + dx * 15, y=start_y + 9 * dy)
|
|
440
|
+
self._ent_opt_girder_scale_high.place(x=start_x + dx * 15, y=start_y + 11 * dy)
|
|
441
|
+
self._ent_opt_girder_scale_low.place(x=start_x + dx * 15.5, y=start_y + 11 * dy)
|
|
442
|
+
self._ent_opt_max_span.place(x=start_x + dx * 15, y=start_y + 12 * dy)
|
|
443
|
+
self._ent_opt_min_span.place(x=start_x + dx * 15.5, y=start_y + 12 * dy)
|
|
444
|
+
|
|
445
|
+
tk.Checkbutton(self._frame,variable=self._new_check_sec_mod).place(x=start_x+dx*12,y=start_y+4*dy)
|
|
446
|
+
tk.Checkbutton(self._frame, variable=self._new_check_min_pl_thk).place(x=start_x+dx*12,y=start_y+5*dy)
|
|
447
|
+
tk.Checkbutton(self._frame, variable=self._new_check_shear_area).place(x=start_x+dx*12,y=start_y+6*dy)
|
|
448
|
+
tk.Checkbutton(self._frame, variable=self._new_check_buckling).place(x=start_x+dx*12,y=start_y+7*dy)
|
|
449
|
+
tk.Checkbutton(self._frame, variable=self._new_check_fatigue).place(x=start_x + dx * 12, y=start_y + 8 * dy)
|
|
450
|
+
tk.Checkbutton(self._frame, variable=self._new_check_slamming).place(x=start_x + dx * 12, y=start_y + 9 * dy)
|
|
451
|
+
tk.Checkbutton(self._frame, variable=self._new_check_local_buckling).place(x=start_x + dx * 12,
|
|
452
|
+
y=start_y + 10 * dy)
|
|
453
|
+
tk.Checkbutton(self._frame, variable=self._new_check_buckling_ml_cl).place(x=start_x + dx * 12,
|
|
454
|
+
y=start_y + 11 * dy)
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
tk.Checkbutton(self._frame, variable=self._new_harmonize_spacing).place(x=start_x + 3.9*dx, y=180)
|
|
458
|
+
|
|
459
|
+
# Stress scaling
|
|
460
|
+
self._new_fup = tk.DoubleVar()
|
|
461
|
+
self._new_fup.set(0.5)
|
|
462
|
+
self._new_fdwn = tk.DoubleVar()
|
|
463
|
+
self._new_fdwn.set(1)
|
|
464
|
+
|
|
465
|
+
tk.Label(self._frame, text='Factor when scaling stresses up, fup')\
|
|
466
|
+
.place(x=start_x + dx * 9.7, y=start_y + 12 * dy)
|
|
467
|
+
ent_fup = tk.Entry(self._frame, textvariable=self._new_fup, width = 5)
|
|
468
|
+
ent_fup.place(x=start_x + dx * 12, y=start_y + 12 * dy)
|
|
469
|
+
tk.Label(self._frame, text='Factor when scaling stresses up, fdown')\
|
|
470
|
+
.place(x=start_x + dx * 9.7, y=start_y + 13 * dy)
|
|
471
|
+
ent_fdwn = tk.Entry(self._frame, textvariable=self._new_fdwn, width = 5)
|
|
472
|
+
ent_fdwn.place(x=start_x + dx * 12, y=start_y + 13 * dy)
|
|
473
|
+
|
|
474
|
+
self._toggle_btn = tk.Button(self._frame, text="Iterate predefiened stiffeners", relief="raised",
|
|
475
|
+
command=self.toggle, bg = 'salmon')
|
|
476
|
+
self._toggle_btn.place(x=start_x+dx*10.5, y=start_y - dy * 16.8)
|
|
477
|
+
self._toggle_object, self._filez = None, None
|
|
478
|
+
|
|
479
|
+
self._options_fractions = (None, )
|
|
480
|
+
self._options_panels = (None, )
|
|
481
|
+
tk.Label(self._frame, text='Select number of panels:').place(x=start_x+dx*12, y=start_y - dy * 20.5)
|
|
482
|
+
tk.Label(self._frame, text='Select panel to plot: ').place(x=start_x+dx*12, y=start_y - dy * 19.5)
|
|
483
|
+
self._ent_option_fractions = tk.OptionMenu(self._frame, self._new_option_fraction, *self._options_fractions,
|
|
484
|
+
command=self.get_plate_field_options)
|
|
485
|
+
self._ent_option_field = tk.OptionMenu(self._frame, self._new_option_panel, *self._options_panels,
|
|
486
|
+
command=self.get_plate_field_options)
|
|
487
|
+
self._option_fractions_place = [start_x+dx*13.5, start_y - dy * 20.5]
|
|
488
|
+
self._options_panels_place = [start_x+dx*13.5, start_y - dy * 19.5]
|
|
489
|
+
self._ent_option_fractions.place(x=self._option_fractions_place[0], y=self._option_fractions_place[1])
|
|
490
|
+
self._ent_option_field.place(x=self._options_panels_place[0], y=self._options_panels_place[1])
|
|
491
|
+
|
|
492
|
+
self.run_results = tk.Button(self._frame,text='show calculated', command=self.plot_results, bg='white',
|
|
493
|
+
font='Verdana 10',fg='black')
|
|
494
|
+
self.run_results.place(x=start_x+dx*13, y=start_y - dy * 18)
|
|
495
|
+
|
|
496
|
+
self.run_results_prev = tk.Button(self._frame,text='Show previous\n'
|
|
497
|
+
'results', command=self.show_previous_results, bg='white',
|
|
498
|
+
font='Verdana 10',fg='black')
|
|
499
|
+
self.run_results_prev.place(x=start_x+dx*15, y=start_y - dy * 20)
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
# ----------------------------------END OF OPTIMIZE SINGLE COPY-----------------------------------------------
|
|
503
|
+
self.progress_count = tk.IntVar()
|
|
504
|
+
self.progress_count.set(0)
|
|
505
|
+
self.progress_bar = Progressbar(self._frame, orient="horizontal",length=200, mode="determinate",
|
|
506
|
+
variable=self.progress_count)
|
|
507
|
+
#self.progress_bar.place(x=start_x+dx*10.5,y=start_y-dy*16.5)
|
|
508
|
+
|
|
509
|
+
self._active_lines = []
|
|
510
|
+
self.controls()
|
|
511
|
+
self.draw_select_canvas()
|
|
512
|
+
# if __name__ == '__main__':
|
|
513
|
+
# self.run_optimizaion(load_pre = True, save_results=True)
|
|
514
|
+
|
|
515
|
+
def selected_algorithm(self, event):
|
|
516
|
+
'''
|
|
517
|
+
Action when selecting an algorithm in the optionm menu.
|
|
518
|
+
:return:
|
|
519
|
+
'''
|
|
520
|
+
start_x, start_y, dx, dy = 20, 100, 100, 40
|
|
521
|
+
if self._new_algorithm.get() == 'random' or self._new_algorithm.get() == 'random_no_delta':
|
|
522
|
+
self._ent_random_trials.place_forget()
|
|
523
|
+
self.algorithm_random_label.place_forget()
|
|
524
|
+
self._lb_swarm_size.place_forget()
|
|
525
|
+
self._lb_omega.place_forget()
|
|
526
|
+
self._lb_phip.place_forget()
|
|
527
|
+
self._lb_phig.place_forget()
|
|
528
|
+
self._lb_maxiter.place_forget()
|
|
529
|
+
self._lb_minstep.place_forget()
|
|
530
|
+
self._lb_minfunc.place_forget()
|
|
531
|
+
self._ent_swarm_size.place_forget()
|
|
532
|
+
self._ent_omega.place_forget()
|
|
533
|
+
self._ent_phip.place_forget()
|
|
534
|
+
self._ent_phig.place_forget()
|
|
535
|
+
self._ent_maxiter.place_forget()
|
|
536
|
+
self._ent_minstep.place_forget()
|
|
537
|
+
self._ent_minfunc.place_forget()
|
|
538
|
+
self._ent_random_trials.place(x=start_x + dx * 11.3, y=start_y + 1.2 * dy)
|
|
539
|
+
self.algorithm_random_label.place(x=start_x + dx * 11.3, y=start_y + 0.5 * dy)
|
|
540
|
+
|
|
541
|
+
elif self._new_algorithm.get() == 'anysmart' or self._new_algorithm.get() == 'anydetail':
|
|
542
|
+
self._ent_random_trials.place_forget()
|
|
543
|
+
self.algorithm_random_label.place_forget()
|
|
544
|
+
self._lb_swarm_size.place_forget()
|
|
545
|
+
self._lb_omega.place_forget()
|
|
546
|
+
self._lb_phip.place_forget()
|
|
547
|
+
self._lb_phig.place_forget()
|
|
548
|
+
self._lb_maxiter.place_forget()
|
|
549
|
+
self._lb_minstep.place_forget()
|
|
550
|
+
self._lb_minfunc.place_forget()
|
|
551
|
+
self._ent_swarm_size.place_forget()
|
|
552
|
+
self._ent_omega.place_forget()
|
|
553
|
+
self._ent_phip.place_forget()
|
|
554
|
+
self._ent_phig.place_forget()
|
|
555
|
+
self._ent_maxiter.place_forget()
|
|
556
|
+
self._ent_minstep.place_forget()
|
|
557
|
+
self._ent_minfunc.place_forget()
|
|
558
|
+
|
|
559
|
+
elif self._new_algorithm.get() == 'pso':
|
|
560
|
+
y_place_label = 11.2
|
|
561
|
+
y_place = 12.2
|
|
562
|
+
self._ent_random_trials.place_forget()
|
|
563
|
+
start_x = 150
|
|
564
|
+
|
|
565
|
+
self._lb_swarm_size.place(x=start_x + dx * 11, y=start_y - 1 * dy)
|
|
566
|
+
self._lb_omega.place(x=start_x + dx * 11, y=start_y - 0 * dy)
|
|
567
|
+
self._lb_phip.place(x=start_x + dx * 11, y=start_y + 1 * dy)
|
|
568
|
+
self._lb_phig.place(x=start_x + dx * 11, y=start_y + 2 * dy)
|
|
569
|
+
|
|
570
|
+
self._lb_maxiter.place(x=start_x + dx * 14, y=start_y - 1 * dy)
|
|
571
|
+
self._lb_minstep.place(x=start_x + dx * 14, y=start_y + 0 * dy)
|
|
572
|
+
self._lb_minfunc.place(x=start_x + dx * 14, y=start_y + 1 * dy)
|
|
573
|
+
|
|
574
|
+
self._ent_swarm_size.place(x=start_x + dx * 12, y=start_y - 1 * dy)
|
|
575
|
+
self._ent_omega.place(x=start_x + dx * 12, y=start_y - 0 * dy)
|
|
576
|
+
self._ent_phip.place(x=start_x + dx * 12, y=start_y + 1 * dy)
|
|
577
|
+
self._ent_phig.place(x=start_x + dx * 12, y=start_y + 2 * dy)
|
|
578
|
+
|
|
579
|
+
self._ent_maxiter.place(x=start_x + dx * 15, y=start_y - 1 * dy)
|
|
580
|
+
self._ent_minstep.place(x=start_x + dx * 15, y=start_y + 0 * dy)
|
|
581
|
+
self._ent_minfunc.place(x=start_x + dx * 15, y=start_y + 1 * dy)
|
|
582
|
+
|
|
583
|
+
def show_previous_results(self):
|
|
584
|
+
# if type(self._geo_results) is not list():
|
|
585
|
+
# if self._geo_results is not None:
|
|
586
|
+
# return
|
|
587
|
+
# else:
|
|
588
|
+
# if self._geo_results[0] is not None:
|
|
589
|
+
# return
|
|
590
|
+
self.draw_select_canvas(opt_results=self._geo_results)
|
|
591
|
+
|
|
592
|
+
def run_optimizaion(self, load_pre = False, save_results = False, harmonize = False):
|
|
593
|
+
'''
|
|
594
|
+
Function when pressing the optimization botton inside this window.
|
|
595
|
+
:return:
|
|
596
|
+
'''
|
|
597
|
+
frames, distances = self.opt_create_frames(self.opt_get_fractions())
|
|
598
|
+
self.opt_create_main_structure(frames,
|
|
599
|
+
self._active_points[0], self._active_points[1],
|
|
600
|
+
self._active_points[2], self._active_points[3])
|
|
601
|
+
|
|
602
|
+
contraints = (self._new_check_sec_mod.get(), self._new_check_min_pl_thk.get(),
|
|
603
|
+
self._new_check_shear_area.get(), self._new_check_buckling.get(),
|
|
604
|
+
self._new_check_fatigue.get(), self._new_check_slamming.get(),
|
|
605
|
+
self._new_check_local_buckling.get(), False, self._new_check_buckling_ml_cl.get(), False)
|
|
606
|
+
|
|
607
|
+
self.pso_parameters = (self._new_swarm_size.get(), self._new_omega.get(), self._new_phip.get(),
|
|
608
|
+
self._new_phig.get(),self._new_maxiter.get(), self._new_minstep.get(),
|
|
609
|
+
self._new_minfunc.get())
|
|
610
|
+
|
|
611
|
+
opt_girder_prop = (self._new_opt_girder_thk.get(), self._new_opt_girder_stf_web_h.get(),
|
|
612
|
+
self._new_opt_girder_stf_web_thk.get(), self._new_opt_girder_stf_flange_b.get(),
|
|
613
|
+
self._new_opt_girder_stf_flange_thk.get(),self._new_opt_girder_scale_high.get(),
|
|
614
|
+
self._new_opt_girder_scale_low.get())
|
|
615
|
+
min_max_span = (self._new_opt_span_min.get(), self._new_opt_span_max.get())
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
init_objects, fatigue_objects, fat_press_ext_int, slamming_pressures, lateral_press, fatigue_objects, \
|
|
619
|
+
slamming_press = [list() for dummy in range(7)]
|
|
620
|
+
|
|
621
|
+
broke = False
|
|
622
|
+
pressure_side = 'both sides' # default value
|
|
623
|
+
for line,coord in self._opt_structure.items():
|
|
624
|
+
if self.opt_create_struc_obj(self._opt_structure[line]) is None:
|
|
625
|
+
broke = True
|
|
626
|
+
break
|
|
627
|
+
else:
|
|
628
|
+
init_objects.append(self.opt_create_struc_obj(self._opt_structure[line])[0])
|
|
629
|
+
fat_obj_single = self.opt_create_struc_obj(self._opt_structure[line])[2]
|
|
630
|
+
fatigue_objects.append(fat_obj_single)
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
if __name__ == '__main__':
|
|
634
|
+
import example_data as ex
|
|
635
|
+
lateral_press.append(0.2) # for testing
|
|
636
|
+
slamming_press.append(0)
|
|
637
|
+
fatigue_objects.append(ex.get_fatigue_object())
|
|
638
|
+
for pressure in ex.get_geo_opt_fat_press():
|
|
639
|
+
fat_press_ext_int.append(((pressure['p_ext']['loaded'], pressure['p_ext']['ballast'],
|
|
640
|
+
pressure['p_ext']['part']),
|
|
641
|
+
(pressure['p_int']['loaded'], pressure['p_int']['ballast'],
|
|
642
|
+
pressure['p_int']['part'])))
|
|
643
|
+
pressure_side = 'both sides'
|
|
644
|
+
|
|
645
|
+
else:
|
|
646
|
+
p1, p2 = self._opt_structure[line]
|
|
647
|
+
# Check if line is horizontal or vertical
|
|
648
|
+
if p2[0] == p1[0]: # Vertical
|
|
649
|
+
to_find = [p2[0], min(p2[1], p1[1]) + abs((p2[1]-p1[1])*0.5)]
|
|
650
|
+
elif p2[1] == p1[1]: # Horizontal
|
|
651
|
+
to_find = [min(p2[0], p1[0])+ (p2[0]-p1[0])*0.5, p2[1]]
|
|
652
|
+
else: # Other orientations
|
|
653
|
+
to_find = [min(p2[0],p1[0])+abs((p2[0]-p1[0])*0.5), min(p2[1]-p1[1])+abs((p2[1]-p1[1])*0.5)]
|
|
654
|
+
|
|
655
|
+
# Taking properites from the closest line.
|
|
656
|
+
closet_line = self.opt_find_closest_orig_line(to_find)
|
|
657
|
+
pressure_side = self._line_to_struc[closet_line].overpressure_side
|
|
658
|
+
#print('Closest line', closet_line, p1, p2, to_find)
|
|
659
|
+
gotten_lat_press = self.app.get_highest_pressure(closet_line)
|
|
660
|
+
lateral_press.append(gotten_lat_press['normal'] / 1e6)
|
|
661
|
+
slamming_press.append(gotten_lat_press['slamming'])
|
|
662
|
+
if fat_obj_single is not None:
|
|
663
|
+
fat_press_single = self.app.get_fatigue_pressures(closet_line, fat_obj_single.get_accelerations())
|
|
664
|
+
fat_press_tuple = ((fat_press_single['p_ext']['loaded'], fat_press_single['p_ext']['ballast'],
|
|
665
|
+
fat_press_single['p_ext']['part']),
|
|
666
|
+
(fat_press_single['p_int']['loaded'], fat_press_single['p_int']['ballast'],
|
|
667
|
+
fat_press_single['p_int']['part']))
|
|
668
|
+
fat_press_ext_int.append(fat_press_tuple)
|
|
669
|
+
else:
|
|
670
|
+
fat_press_ext_int.append(((0, 0, 0), (0, 0,0)))
|
|
671
|
+
|
|
672
|
+
# except AttributeError:
|
|
673
|
+
# print('AttributeError')
|
|
674
|
+
# fat_press_ext_int.append(None)
|
|
675
|
+
if broke:
|
|
676
|
+
messagebox.showinfo(title='Selection error.',
|
|
677
|
+
message='This field cannot be subdivided or there are no loads. Error.')
|
|
678
|
+
return None
|
|
679
|
+
|
|
680
|
+
if not load_pre:
|
|
681
|
+
min_var = self.get_lower_bounds()
|
|
682
|
+
max_var = self.get_upper_bounds()
|
|
683
|
+
deltas = self.get_deltas()
|
|
684
|
+
spacings = np.arange(min_var[0], max_var[0],
|
|
685
|
+
deltas[0])
|
|
686
|
+
resulting_geo = list()
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
if self._new_harmonize_spacing.get():
|
|
690
|
+
geo_results = dict()
|
|
691
|
+
for spacing in spacings:
|
|
692
|
+
this_min_var = copy.deepcopy(min_var)
|
|
693
|
+
this_min_var[0] = spacing
|
|
694
|
+
this_max_var = copy.deepcopy(max_var)
|
|
695
|
+
this_max_var[0] = spacing
|
|
696
|
+
|
|
697
|
+
geo_results = op.run_optmizataion(initial_structure_obj=init_objects,min_var=this_min_var,
|
|
698
|
+
max_var=this_max_var,lateral_pressure=lateral_press,
|
|
699
|
+
deltas=self.get_deltas(), algorithm='anysmart',side=pressure_side,
|
|
700
|
+
const_chk = contraints,pso_options = self.pso_parameters,
|
|
701
|
+
is_geometric=True,fatigue_obj= fatigue_objects,
|
|
702
|
+
fat_press_ext_int=fat_press_ext_int,
|
|
703
|
+
min_max_span=min_max_span, tot_len=self.opt_get_length(),
|
|
704
|
+
frame_height=self.opt_get_distance(), frame_distance = distances,
|
|
705
|
+
predefined_stiffener_iter=self._filez,
|
|
706
|
+
processes = self._new_processes.get(),
|
|
707
|
+
slamming_press=slamming_press, opt_girder_prop=opt_girder_prop,
|
|
708
|
+
fdwn = self._new_fdwn.get(), fup = self._new_fdwn.get(),
|
|
709
|
+
ml_algo=self._ML_buckling)
|
|
710
|
+
resulting_geo.append(geo_results)
|
|
711
|
+
|
|
712
|
+
#need to find the lowest
|
|
713
|
+
for fraction in resulting_geo[0].keys():
|
|
714
|
+
weight = float('inf')
|
|
715
|
+
best_idx = None
|
|
716
|
+
for idx, geo_res in enumerate(resulting_geo):
|
|
717
|
+
this_sub_fraction_weight = geo_res[fraction][0]
|
|
718
|
+
if this_sub_fraction_weight < weight:
|
|
719
|
+
|
|
720
|
+
best_idx = idx
|
|
721
|
+
weight = this_sub_fraction_weight
|
|
722
|
+
|
|
723
|
+
geo_results[fraction] = resulting_geo[best_idx][fraction]
|
|
724
|
+
|
|
725
|
+
else:
|
|
726
|
+
geo_results = op.run_optmizataion(initial_structure_obj=init_objects, min_var=self.get_lower_bounds(),
|
|
727
|
+
max_var=self.get_upper_bounds(), lateral_pressure=lateral_press,
|
|
728
|
+
deltas=self.get_deltas(), algorithm='anysmart', side=pressure_side,
|
|
729
|
+
const_chk=contraints, pso_options=self.pso_parameters,
|
|
730
|
+
is_geometric=True, fatigue_obj=fatigue_objects,
|
|
731
|
+
fat_press_ext_int=fat_press_ext_int,
|
|
732
|
+
min_max_span=min_max_span, tot_len=self.opt_get_length(),
|
|
733
|
+
frame_height=self.opt_get_distance(), frame_distance=distances,
|
|
734
|
+
predefined_stiffener_iter=self._filez,
|
|
735
|
+
processes=self._new_processes.get(),
|
|
736
|
+
slamming_press=slamming_press, opt_girder_prop=opt_girder_prop,
|
|
737
|
+
fdwn=self._new_fdwn.get(), fup=self._new_fdwn.get())
|
|
738
|
+
|
|
739
|
+
self._geo_results = geo_results
|
|
740
|
+
|
|
741
|
+
if len([val*2 for val in self._geo_results.keys()]) != 0:
|
|
742
|
+
self._ent_option_fractions.destroy()
|
|
743
|
+
self._ent_option_fractions = tk.OptionMenu(self._frame, self._new_option_fraction,
|
|
744
|
+
*tuple([val*2 for val in self._geo_results.keys()]),
|
|
745
|
+
command=self.get_plate_field_options)
|
|
746
|
+
self._ent_option_fractions.place(x=self._option_fractions_place[0], y=self._option_fractions_place[1])
|
|
747
|
+
|
|
748
|
+
#SAVING RESULTS
|
|
749
|
+
if save_results:
|
|
750
|
+
with open('geo_opt_2.pickle', 'wb') as file:
|
|
751
|
+
pickle.dump(geo_results, file)
|
|
752
|
+
else:
|
|
753
|
+
with open('geo_opt_2.pickle', 'rb') as file:
|
|
754
|
+
self._geo_results = pickle.load(file)
|
|
755
|
+
|
|
756
|
+
self._ent_option_fractions.destroy()
|
|
757
|
+
self._ent_option_fractions = tk.OptionMenu(self._frame, self._new_option_fraction,
|
|
758
|
+
*tuple([val*2 for val in self._geo_results.keys()]),
|
|
759
|
+
command=self.get_plate_field_options)
|
|
760
|
+
self._ent_option_fractions.place(x=self._option_fractions_place[0], y=self._option_fractions_place[1])
|
|
761
|
+
|
|
762
|
+
save_file, filename = None, None
|
|
763
|
+
if save_results:
|
|
764
|
+
save_file = filedialog.asksaveasfile(mode="w", defaultextension=".txt", title = 'Save results to file')
|
|
765
|
+
if save_file is None: # ask saveasfile return `None` if dialog closed with "cancel".
|
|
766
|
+
filename = None
|
|
767
|
+
else:
|
|
768
|
+
filename = save_file.name
|
|
769
|
+
|
|
770
|
+
save_file, xplot, yplot = self.draw_result_text(self._geo_results, save_to_file=filename)
|
|
771
|
+
self.draw_select_canvas(opt_results=self._geo_results, save_file = save_file)
|
|
772
|
+
|
|
773
|
+
plt.axes(facecolor='lightslategray')
|
|
774
|
+
plt.plot(xplot, yplot,color='yellow', linestyle='solid', marker='o',markerfacecolor='white', markersize=6)
|
|
775
|
+
plt.xlabel('Length of plate fields [m]')
|
|
776
|
+
plt.ylabel('Weight / max weight')
|
|
777
|
+
plt.title('Length of plate fields vs. total weight')
|
|
778
|
+
plt.grid()
|
|
779
|
+
plt.show()
|
|
780
|
+
|
|
781
|
+
def opt_get_fractions(self):
|
|
782
|
+
''' Finding initial number of fractions '''
|
|
783
|
+
init_fractions = 0
|
|
784
|
+
# finding number of fractions
|
|
785
|
+
for dummy_i in range(1, 100):
|
|
786
|
+
if 3.8 < self.opt_get_length() / dummy_i < 4.2:
|
|
787
|
+
init_fractions = dummy_i
|
|
788
|
+
break
|
|
789
|
+
to_return = []
|
|
790
|
+
for dummy_i in range(init_fractions):
|
|
791
|
+
to_return.append(1/init_fractions)
|
|
792
|
+
|
|
793
|
+
return to_return
|
|
794
|
+
|
|
795
|
+
def opt_create_struc_obj(self,opt_line):
|
|
796
|
+
''' Creating preliminary stucture object from selected optimized line.
|
|
797
|
+
The properties of the new line oto be optimized is taken from the closest original line.'''
|
|
798
|
+
|
|
799
|
+
pt1 = opt_line[0]
|
|
800
|
+
pt2 = opt_line[1]
|
|
801
|
+
|
|
802
|
+
vector = [pt2[0] - pt1[0], pt2[1] - pt1[1]]
|
|
803
|
+
point = [pt1[0]+vector[0]*0.5, pt1[1]+vector[1]*0.5]
|
|
804
|
+
if self.opt_find_closest_orig_line(point) == None:
|
|
805
|
+
return None
|
|
806
|
+
objects = [copy.deepcopy(x) if x != None else None for x in
|
|
807
|
+
self._line_to_struc[self.opt_find_closest_orig_line(point)]]
|
|
808
|
+
objects[0].Plate.set_span(dist(pt1,pt2))
|
|
809
|
+
objects[0].Stiffener.set_span(dist(pt1, pt2))
|
|
810
|
+
|
|
811
|
+
return objects
|
|
812
|
+
|
|
813
|
+
def opt_find_closest_orig_line(self,coord):
|
|
814
|
+
''' Find the closest original line to the optimized line.
|
|
815
|
+
Used to create initial structure objects. '''
|
|
816
|
+
|
|
817
|
+
for key,value in self._line_dict.items():
|
|
818
|
+
|
|
819
|
+
pt1 = list(self._point_dict['point'+str(value[0])])
|
|
820
|
+
pt2 = list(self._point_dict['point'+str(value[1])])
|
|
821
|
+
distance = dist(pt2,pt1)
|
|
822
|
+
vector = [pt2[0]-pt1[0],pt2[1]-pt1[1]]
|
|
823
|
+
current = list(self._point_dict['point'+str(value[0])])
|
|
824
|
+
for dummy_i in range(1000):
|
|
825
|
+
delta = distance/1000
|
|
826
|
+
current[0] += (vector[0]/distance) * delta
|
|
827
|
+
current[1] += (vector[1]/distance) * delta
|
|
828
|
+
if dist(coord,current) <= 0.1:
|
|
829
|
+
if self._line_to_struc[key][0].Plate.get_structure_type() not in ('GENERAL_INTERNAL_NONWT', 'FRAME'):
|
|
830
|
+
return key
|
|
831
|
+
else:
|
|
832
|
+
return None
|
|
833
|
+
|
|
834
|
+
def opt_get_distance(self):
|
|
835
|
+
''' Getting the largest disctance between the two lines to be optimized. '''
|
|
836
|
+
if len(self._active_points) == 4:
|
|
837
|
+
return dist(self._point_dict[self._active_points[0]],self._point_dict[self._active_points[2]])
|
|
838
|
+
else:
|
|
839
|
+
return None
|
|
840
|
+
|
|
841
|
+
def opt_get_length(self):
|
|
842
|
+
''' Getting the length of the lines to be optimized. '''
|
|
843
|
+
if len(self._active_points)==4:
|
|
844
|
+
return dist(self._point_dict[self._active_points[0]],self._point_dict[self._active_points[1]])
|
|
845
|
+
|
|
846
|
+
def opt_get_fraction_bounds(self, max_len = 6, min_len = 2):
|
|
847
|
+
''' Return the fraction bounds(basis upper/lower) to be considered. '''
|
|
848
|
+
return int(self.opt_get_length()/max_len), int(self.opt_get_length()/min_len)
|
|
849
|
+
|
|
850
|
+
def opt_create_frames(self,fractions):
|
|
851
|
+
''' Creating frames between the the two lines to be optimized. '''
|
|
852
|
+
count = 1
|
|
853
|
+
|
|
854
|
+
self._opt_frames['opt_frame_start'] = [[self._point_dict[self._active_points[0]][0],
|
|
855
|
+
self._point_dict[self._active_points[0]][1]],
|
|
856
|
+
[self._point_dict[self._active_points[2]][0],
|
|
857
|
+
self._point_dict[self._active_points[2]][1]]]
|
|
858
|
+
|
|
859
|
+
self._opt_frames['opt_frame_stop'] = [[self._point_dict[self._active_points[1]][0],
|
|
860
|
+
self._point_dict[self._active_points[1]][1]],
|
|
861
|
+
[self._point_dict[self._active_points[3]][0],
|
|
862
|
+
self._point_dict[self._active_points[3]][1]]]
|
|
863
|
+
|
|
864
|
+
start = 0
|
|
865
|
+
for fraction in fractions:
|
|
866
|
+
start += fraction
|
|
867
|
+
if start != 1:
|
|
868
|
+
self._opt_frames['opt_frame'+str(count)] = [[self._point_dict[self._active_points[0]][0] +
|
|
869
|
+
round(self.opt_get_length()*start,5),
|
|
870
|
+
self._point_dict[self._active_points[0]][1]],
|
|
871
|
+
[self._point_dict[self._active_points[2]][0] +
|
|
872
|
+
round(self.opt_get_length() * start,5),
|
|
873
|
+
self._point_dict[self._active_points[2]][1]]]
|
|
874
|
+
count+=1
|
|
875
|
+
distances = {'start_dist': dist(self._opt_frames['opt_frame_start'][0], self._opt_frames['opt_frame_start'][1]),
|
|
876
|
+
'stop_dist': dist(self._opt_frames['opt_frame_stop'][0], self._opt_frames['opt_frame_stop'][1])}
|
|
877
|
+
|
|
878
|
+
return self._opt_frames, distances
|
|
879
|
+
|
|
880
|
+
def opt_create_main_structure(self,frames,start1,stop1,start2,stop2):
|
|
881
|
+
''' This creates line definition for the new structure objects.
|
|
882
|
+
The scipt searches the line to find frames.'''
|
|
883
|
+
line1_coord = self._point_dict[start1],self._point_dict[stop1]
|
|
884
|
+
line2_coord = self._point_dict[start2],self._point_dict[stop2]
|
|
885
|
+
|
|
886
|
+
structure = {}
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
p1_low,p1_high = list(line1_coord[0]),list(line2_coord[0])
|
|
890
|
+
p2_low,p2_high = list(line1_coord[1]),list(line2_coord[1])
|
|
891
|
+
vector_low,vector_high = [p2_low[0]-p1_low[0],p2_low[1]-p1_low[1]],[p2_high[0]-p1_high[0],p2_high[1]-p1_high[1]]
|
|
892
|
+
|
|
893
|
+
# Starting search on the lower or inner line
|
|
894
|
+
count = 1
|
|
895
|
+
tmp_struc = [p1_low] # starting point defined.
|
|
896
|
+
found = None
|
|
897
|
+
for frame, coords in frames.items():
|
|
898
|
+
current = list(p1_low)
|
|
899
|
+
if frame!='opt_frame_start' and frame!='opt_frame_stop':
|
|
900
|
+
for jump in range(100):
|
|
901
|
+
current[0] += vector_low[0] / 100
|
|
902
|
+
current[1] += vector_low[1] / 100
|
|
903
|
+
if dist(current,coords[0]) < 0.1 and frame != found:
|
|
904
|
+
found = frame
|
|
905
|
+
tmp_struc.append(coords[0])
|
|
906
|
+
self._opt_structure['opt_struc'+str(count)] = tmp_struc # adding found line
|
|
907
|
+
tmp_struc = [coords[0]]
|
|
908
|
+
count += 1
|
|
909
|
+
tmp_struc.append(p2_low)
|
|
910
|
+
self._opt_structure['opt_struc'+str(count)] = tmp_struc # adding found line (end)
|
|
911
|
+
count += 1
|
|
912
|
+
|
|
913
|
+
# Starting search of upper or outer line.
|
|
914
|
+
tmp_struc = [p1_high] # starting point defined.
|
|
915
|
+
found = None
|
|
916
|
+
for frame, coords in frames.items():
|
|
917
|
+
current = list(p1_high)
|
|
918
|
+
if frame!='opt_frame_start' and frame!='opt_frame_stop':
|
|
919
|
+
for jump in range(100):
|
|
920
|
+
current[0] += vector_high[0] / 100
|
|
921
|
+
current[1] += vector_high[1] / 100
|
|
922
|
+
if dist(current,coords[1]) < 0.1 and frame != found:
|
|
923
|
+
found = frame
|
|
924
|
+
tmp_struc.append(coords[1])
|
|
925
|
+
|
|
926
|
+
self._opt_structure['opt_struc'+str(count)] = tmp_struc # adding found line
|
|
927
|
+
tmp_struc = [coords[1]]
|
|
928
|
+
count += 1
|
|
929
|
+
tmp_struc.append(p2_high)
|
|
930
|
+
self._opt_structure['opt_struc'+str(count)] = tmp_struc # adding found line (end)
|
|
931
|
+
|
|
932
|
+
return self._opt_structure
|
|
933
|
+
|
|
934
|
+
def get_running_time(self):
|
|
935
|
+
'''
|
|
936
|
+
Estimate the running time of the algorithm.
|
|
937
|
+
:return:
|
|
938
|
+
'''
|
|
939
|
+
if self._new_algorithm.get() in ['anysmart', 'anydetail']:
|
|
940
|
+
try:
|
|
941
|
+
number_of_combinations = \
|
|
942
|
+
max((self._new_spacing_upper.get() - self._new_spacing_lower.get()) / self._new_delta_spacing.get(),
|
|
943
|
+
1) * \
|
|
944
|
+
max((self._new_pl_thk_upper.get() - self._new_pl_thk_lower.get()) / self._new_delta_pl_thk.get(),
|
|
945
|
+
1) * \
|
|
946
|
+
max((self._new_web_h_upper.get() - self._new_web_h_lower.get()) / self._new_delta_web_h.get(), 1) * \
|
|
947
|
+
max((self._new_web_thk_upper.get() - self._new_web_thk_lower.get()) / self._new_delta_web_thk.get(),
|
|
948
|
+
1) * \
|
|
949
|
+
max((self._new_fl_w_upper.get() - self._new_fl_w_lower.get()) / self._new_delta_fl_w.get(), 1) * \
|
|
950
|
+
max((self._new_fl_thk_upper.get() - self._new_fl_thk_lower.get()) / self._new_delta_fl_thk.get(), 1)
|
|
951
|
+
return int(number_of_combinations * self.running_time_per_item) * len(self._active_lines)
|
|
952
|
+
except TclError:
|
|
953
|
+
return 0
|
|
954
|
+
else:
|
|
955
|
+
try:
|
|
956
|
+
return int(self._new_algorithm_random_trials.get() * self.running_time_per_item) * len(
|
|
957
|
+
self._active_lines)
|
|
958
|
+
except TclError:
|
|
959
|
+
return 0
|
|
960
|
+
|
|
961
|
+
def get_deltas(self):
|
|
962
|
+
'''
|
|
963
|
+
Return a numpy array of the deltas.
|
|
964
|
+
:return:
|
|
965
|
+
'''
|
|
966
|
+
return np.array([float(self._ent_delta_spacing.get()) / 1000, float(self._new_delta_pl_thk.get()) / 1000,
|
|
967
|
+
float(self._new_delta_web_h.get()) / 1000, float(self._new_delta_web_thk.get()) / 1000,
|
|
968
|
+
float(self._new_delta_fl_w.get()) / 1000, float(self._new_delta_fl_thk.get()) / 1000])
|
|
969
|
+
|
|
970
|
+
def update_running_time(self, *args):
|
|
971
|
+
'''
|
|
972
|
+
Estimate the running time of the algorithm.
|
|
973
|
+
:return:
|
|
974
|
+
'''
|
|
975
|
+
|
|
976
|
+
# try:
|
|
977
|
+
# self._runnig_time_label.config(text=str(self.get_running_time()))
|
|
978
|
+
# except ZeroDivisionError:
|
|
979
|
+
# pass # _tkinter.TclError: pass
|
|
980
|
+
|
|
981
|
+
if self._new_check_buckling_ml_cl.get():
|
|
982
|
+
self._new_check_buckling.set(False)
|
|
983
|
+
self._new_check_local_buckling.set(False)
|
|
984
|
+
|
|
985
|
+
def get_upper_bounds(self):
|
|
986
|
+
'''
|
|
987
|
+
Return an numpy array of upper bounds.
|
|
988
|
+
:return:
|
|
989
|
+
'''
|
|
990
|
+
return np.array([self._new_spacing_upper.get() / 1000, self._new_pl_thk_upper.get() / 1000,
|
|
991
|
+
self._new_web_h_upper.get() / 1000, self._new_web_thk_upper.get() / 1000,
|
|
992
|
+
self._new_fl_w_upper.get() / 1000, self._new_fl_thk_upper.get() / 1000,
|
|
993
|
+
6, 10])
|
|
994
|
+
|
|
995
|
+
def get_lower_bounds(self):
|
|
996
|
+
'''
|
|
997
|
+
Return an numpy array of lower bounds.
|
|
998
|
+
:return:
|
|
999
|
+
'''
|
|
1000
|
+
return np.array([self._new_spacing_lower.get() / 1000, self._new_pl_thk_lower.get() / 1000,
|
|
1001
|
+
self._new_web_h_lower.get() / 1000, self._new_web_thk_lower.get() / 1000,
|
|
1002
|
+
self._new_fl_w_lower.get() / 1000, self._new_fl_thk_lower.get() / 1000,
|
|
1003
|
+
1, 10])
|
|
1004
|
+
|
|
1005
|
+
def checkered(self, line_distance):
|
|
1006
|
+
'''
|
|
1007
|
+
Creates a grid in the properties canvas.
|
|
1008
|
+
:param line_distance:
|
|
1009
|
+
:return:
|
|
1010
|
+
'''
|
|
1011
|
+
# vertical lines at an interval of "line_distance" pixel
|
|
1012
|
+
for x in range(line_distance, self._prop_canvas_dim[0], line_distance):
|
|
1013
|
+
self._canvas_opt.create_line(x, 0, x, self._prop_canvas_dim[0], fill="grey", stipple='gray50')
|
|
1014
|
+
# horizontal lines at an interval of "line_distance" pixel
|
|
1015
|
+
for y in range(line_distance, self._prop_canvas_dim[1], line_distance):
|
|
1016
|
+
self._canvas_opt.create_line(0, y, self._prop_canvas_dim[0], y, fill="grey", stipple='gray50')
|
|
1017
|
+
|
|
1018
|
+
def draw_properties(self, init_obj=None, opt_obj=None, line=None):
|
|
1019
|
+
'''
|
|
1020
|
+
Drawing properties in the canvas.
|
|
1021
|
+
:return:
|
|
1022
|
+
'''
|
|
1023
|
+
ctr_x = self._prop_canvas_dim[0] / 2
|
|
1024
|
+
ctr_y = self._prop_canvas_dim[1] / 2 + 200
|
|
1025
|
+
opt_color, opt_stippe = 'red', 'gray12'
|
|
1026
|
+
m = self._draw_scale
|
|
1027
|
+
|
|
1028
|
+
if init_obj != None:
|
|
1029
|
+
self._canvas_opt.delete('all')
|
|
1030
|
+
self.checkered(10)
|
|
1031
|
+
init_color, init_stipple = 'blue', 'gray12'
|
|
1032
|
+
|
|
1033
|
+
self._canvas_opt.create_rectangle(0, 0, self._prop_canvas_dim[0] + 10, 80, fill='white')
|
|
1034
|
+
self._canvas_opt.create_line(10, 10, 30, 10, fill=init_color, width=5)
|
|
1035
|
+
self._canvas_opt.create_text(270, 10, text='Initial - Pl.: ' + str(init_obj.get_s() * 1000) + 'x' + str(
|
|
1036
|
+
init_obj.get_pl_thk() * 1000) +
|
|
1037
|
+
' Stf.: ' + str(init_obj.get_web_h() * 1000) + 'x' + str(
|
|
1038
|
+
init_obj.get_web_thk() * 1000) + '+' +
|
|
1039
|
+
str(init_obj.get_fl_w() * 1000) + 'x' + str(
|
|
1040
|
+
init_obj.get_fl_thk() * 1000),
|
|
1041
|
+
font='Verdana 8',
|
|
1042
|
+
fill=init_color)
|
|
1043
|
+
self._canvas_opt.create_text(120, 30, text='Weight (per Lg width): ' +
|
|
1044
|
+
str(int(op.calc_weight([init_obj.get_s(),
|
|
1045
|
+
init_obj.get_pl_thk(),
|
|
1046
|
+
init_obj.get_web_h(),
|
|
1047
|
+
init_obj.get_web_thk(),
|
|
1048
|
+
init_obj.get_fl_w(),
|
|
1049
|
+
init_obj.get_fl_thk(),
|
|
1050
|
+
init_obj.span,
|
|
1051
|
+
init_obj.girder_lg]))),
|
|
1052
|
+
font='Verdana 8', fill=init_color)
|
|
1053
|
+
|
|
1054
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.get_s() / 2, ctr_y, ctr_x + m * init_obj.get_s() / 2,
|
|
1055
|
+
ctr_y - m * init_obj.get_pl_thk(), fill=init_color, stipple=init_stipple)
|
|
1056
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.get_web_thk() / 2, ctr_y - m * init_obj.get_pl_thk(),
|
|
1057
|
+
ctr_x + m * init_obj.get_web_thk() / 2,
|
|
1058
|
+
ctr_y - m * (init_obj.get_web_h() + init_obj.get_pl_thk())
|
|
1059
|
+
, fill=init_color, stipple=init_stipple)
|
|
1060
|
+
if init_obj.get_stiffener_type() not in ['L', 'L-bulb']:
|
|
1061
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.get_fl_w() / 2,
|
|
1062
|
+
ctr_y - m * (init_obj.get_pl_thk() + init_obj.get_web_h()),
|
|
1063
|
+
ctr_x + m * init_obj.get_fl_w() / 2,
|
|
1064
|
+
ctr_y - m * (
|
|
1065
|
+
init_obj.get_pl_thk() + init_obj.get_web_h() + init_obj.get_fl_thk()),
|
|
1066
|
+
fill=init_color, stipple=init_stipple)
|
|
1067
|
+
else:
|
|
1068
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.get_web_thk() / 2,
|
|
1069
|
+
ctr_y - m * (init_obj.get_pl_thk() + init_obj.get_web_h()),
|
|
1070
|
+
ctr_x + m * init_obj.get_fl_w(),
|
|
1071
|
+
ctr_y - m * (
|
|
1072
|
+
init_obj.get_pl_thk() + init_obj.get_web_h() + init_obj.get_fl_thk()),
|
|
1073
|
+
fill=init_color, stipple=init_stipple)
|
|
1074
|
+
|
|
1075
|
+
if opt_obj != None:
|
|
1076
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.get_s() / 2, ctr_y,
|
|
1077
|
+
ctr_x + m * opt_obj.get_s() / 2,
|
|
1078
|
+
ctr_y - m * opt_obj.get_pl_thk(), fill=opt_color,
|
|
1079
|
+
stipple=opt_stippe)
|
|
1080
|
+
|
|
1081
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.get_web_thk() / 2, ctr_y -
|
|
1082
|
+
m * opt_obj.get_pl_thk(),
|
|
1083
|
+
ctr_x + m * opt_obj.get_web_thk() / 2,
|
|
1084
|
+
ctr_y - m * (
|
|
1085
|
+
opt_obj.get_web_h() + opt_obj.get_pl_thk())
|
|
1086
|
+
, fill=opt_color, stipple=opt_stippe)
|
|
1087
|
+
if init_obj.get_stiffener_type() not in ['L', 'L-bulb']:
|
|
1088
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.get_fl_w() / 2, ctr_y
|
|
1089
|
+
- m * (
|
|
1090
|
+
opt_obj.get_pl_thk() + opt_obj.get_web_h()),
|
|
1091
|
+
ctr_x + m * opt_obj.get_fl_w() / 2, ctr_y -
|
|
1092
|
+
m * (
|
|
1093
|
+
opt_obj.get_pl_thk() + opt_obj.get_web_h() +
|
|
1094
|
+
opt_obj.get_fl_thk()),
|
|
1095
|
+
fill=opt_color, stipple=opt_stippe)
|
|
1096
|
+
else:
|
|
1097
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.get_web_thk() / 2, ctr_y
|
|
1098
|
+
- m * (
|
|
1099
|
+
opt_obj.get_pl_thk() + opt_obj.get_web_h()),
|
|
1100
|
+
ctr_x + m * opt_obj.get_fl_w(), ctr_y -
|
|
1101
|
+
m * (
|
|
1102
|
+
opt_obj.get_pl_thk() + opt_obj.get_web_h() +
|
|
1103
|
+
opt_obj.get_fl_thk()),
|
|
1104
|
+
fill=opt_color, stipple=opt_stippe)
|
|
1105
|
+
|
|
1106
|
+
self._canvas_opt.create_line(10, 50, 30, 50, fill=opt_color, width=5)
|
|
1107
|
+
self._canvas_opt.create_text(270, 50,
|
|
1108
|
+
text='Optimized - Pl.: ' + str(round(opt_obj.get_s() * 1000,1)) + 'x' +
|
|
1109
|
+
str(round(opt_obj.get_pl_thk() * 1000,1)) + ' Stf.: '
|
|
1110
|
+
+ str(round(opt_obj.get_web_h() * 1000,1)) +
|
|
1111
|
+
'x' + str(round(opt_obj.get_web_thk() * 1000,1)) + '+' +
|
|
1112
|
+
str(round(opt_obj.get_fl_w() * 1000,1)) +
|
|
1113
|
+
'x' + str(round(opt_obj.get_fl_thk() * 1000,1)),
|
|
1114
|
+
font='Verdana 8', fill=opt_color)
|
|
1115
|
+
self._canvas_opt.create_text(120, 70, text='Weight (per Lg width): '
|
|
1116
|
+
+ str(int(op.calc_weight([opt_obj.get_s(),
|
|
1117
|
+
opt_obj.get_pl_thk(),
|
|
1118
|
+
opt_obj.get_web_h(),
|
|
1119
|
+
opt_obj.get_web_thk(),
|
|
1120
|
+
opt_obj.get_fl_w(),
|
|
1121
|
+
opt_obj.get_fl_thk(),
|
|
1122
|
+
opt_obj.span,
|
|
1123
|
+
opt_obj.girder_lg]))),
|
|
1124
|
+
font='Verdana 8', fill=opt_color)
|
|
1125
|
+
else:
|
|
1126
|
+
self._canvas_opt.create_text(150, 60, text='No optimized solution found.')
|
|
1127
|
+
|
|
1128
|
+
if line != None:
|
|
1129
|
+
if __name__ == '__main__':
|
|
1130
|
+
lateral_press = 0.2 # for testing
|
|
1131
|
+
else:
|
|
1132
|
+
lateral_press = self.app.get_highest_pressure(line)['normal'] /1e6
|
|
1133
|
+
self._canvas_opt.create_text(250, self._prop_canvas_dim[1] - 10,
|
|
1134
|
+
text='Lateral pressure: ' + str(lateral_press) + ' kPa',
|
|
1135
|
+
font='Verdana 10 bold', fill='red')
|
|
1136
|
+
|
|
1137
|
+
def draw_select_canvas(self, opt_results = None, save_file = None):
|
|
1138
|
+
'''
|
|
1139
|
+
Making the lines canvas.
|
|
1140
|
+
:return:
|
|
1141
|
+
'''
|
|
1142
|
+
self._canvas_select.delete('all')
|
|
1143
|
+
text_type = 'Verdana 8'
|
|
1144
|
+
|
|
1145
|
+
if opt_results is None:
|
|
1146
|
+
# stippled lines and text.
|
|
1147
|
+
|
|
1148
|
+
self._canvas_select.create_line(self._canvas_draw_origo[0], 0, self._canvas_draw_origo[0], self._select_canvas_dim[1],
|
|
1149
|
+
stipple='gray50')
|
|
1150
|
+
self._canvas_select.create_line(0, self._canvas_draw_origo[1], self._select_canvas_dim[0], self._canvas_draw_origo[1],
|
|
1151
|
+
stipple='gray50')
|
|
1152
|
+
self._canvas_select.create_text(self._canvas_draw_origo[0] - 30,
|
|
1153
|
+
self._canvas_draw_origo[1] + 20, text='(0,0)',
|
|
1154
|
+
font='Text 10')
|
|
1155
|
+
self._canvas_select.create_text([700, 50],
|
|
1156
|
+
text='How to:\n'
|
|
1157
|
+
'For a double bottom structure: \n'
|
|
1158
|
+
'Click start point 1 -> click en point 1 (for example bottom plate)\n'
|
|
1159
|
+
'Click start point 2 -> click en point 2 (for example inner bottom\n'
|
|
1160
|
+
'Run optimization! Wait for the results...... wait.... wait....\n',
|
|
1161
|
+
font='Verdana 8 bold',
|
|
1162
|
+
fill='red')
|
|
1163
|
+
# drawing the line dictionary.
|
|
1164
|
+
if len(self._line_dict) != 0:
|
|
1165
|
+
for line, value in self._line_dict.items():
|
|
1166
|
+
color = 'black'
|
|
1167
|
+
coord1 = self.get_point_canvas_coord('point' + str(value[0]))
|
|
1168
|
+
coord2 = self.get_point_canvas_coord('point' + str(value[1]))
|
|
1169
|
+
vector = [coord2[0] - coord1[0], coord2[1] - coord1[1]]
|
|
1170
|
+
# drawing a bold line if it is selected
|
|
1171
|
+
if self._line_to_struc[line][0].Plate.get_structure_type() not in ('GENERAL_INTERNAL_NONWT','FRAME'):
|
|
1172
|
+
|
|
1173
|
+
if line in self._active_lines:
|
|
1174
|
+
self._canvas_select.create_line(coord1, coord2, width=6, fill=color,stipple='gray50')
|
|
1175
|
+
self._canvas_select.create_text(coord1[0] + vector[0] / 2 + 5, coord1[1] + vector[1] / 2 + 10,
|
|
1176
|
+
text='Line ' + str(get_num(line)), font='Verdand 10 bold',
|
|
1177
|
+
fill='red')
|
|
1178
|
+
else:
|
|
1179
|
+
self._canvas_select.create_line(coord1, coord2, width=3, fill=color,stipple='gray25')
|
|
1180
|
+
self._canvas_select.create_text(coord1[0] - 20 + vector[0] / 2 + 5, coord1[1] + vector[1] / 2 +
|
|
1181
|
+
|
|
1182
|
+
10,text='line' + str(get_num(line)),font="Text 8", fill='black')
|
|
1183
|
+
|
|
1184
|
+
if len(self._opt_frames) != 0:
|
|
1185
|
+
for key,value in self._opt_frames.items():
|
|
1186
|
+
coord1 = self.get_canvas_coord(value[0])
|
|
1187
|
+
coord2 = self.get_canvas_coord(value[1])
|
|
1188
|
+
vector = [coord2[0] - coord1[0], coord2[1] - coord1[1]]
|
|
1189
|
+
self._canvas_select.create_line(coord1, coord2, width=3, fill='SkyBlue1')
|
|
1190
|
+
else:
|
|
1191
|
+
pass
|
|
1192
|
+
|
|
1193
|
+
if len(self._active_points)>1:
|
|
1194
|
+
color = 'blue'
|
|
1195
|
+
coord1 = self.get_point_canvas_coord(self._active_points[0])
|
|
1196
|
+
coord2 = self.get_point_canvas_coord(self._active_points[1])
|
|
1197
|
+
vector = [coord2[0] - coord1[0], coord2[1] - coord1[1]]
|
|
1198
|
+
# drawing a bold line if it is selected
|
|
1199
|
+
self._canvas_select.create_line(coord1, coord2, width=6, fill=color)
|
|
1200
|
+
if len(self._active_points) > 3:
|
|
1201
|
+
coord1 = self.get_point_canvas_coord(self._active_points[2])
|
|
1202
|
+
coord2 = self.get_point_canvas_coord(self._active_points[3])
|
|
1203
|
+
vector = [coord2[0] - coord1[0], coord2[1] - coord1[1]]
|
|
1204
|
+
self._canvas_select.create_line(coord1, coord2, width=6, fill=color)
|
|
1205
|
+
|
|
1206
|
+
# self._canvas_select.create_polygon(points, outline='#f11',
|
|
1207
|
+
# fill='#1f1', width=2)
|
|
1208
|
+
|
|
1209
|
+
# drawing the point dictionary
|
|
1210
|
+
|
|
1211
|
+
for key,value in self._point_dict.items():
|
|
1212
|
+
pt_size = 6
|
|
1213
|
+
if key in self._active_points:
|
|
1214
|
+
self._canvas_select.create_oval(self.get_point_canvas_coord(key)[0] - pt_size + 2,
|
|
1215
|
+
self.get_point_canvas_coord(key)[1] - pt_size + 2,
|
|
1216
|
+
self.get_point_canvas_coord(key)[0] + pt_size + 2,
|
|
1217
|
+
self.get_point_canvas_coord(key)[1] + pt_size + 2, fill='blue')
|
|
1218
|
+
if self._active_points.index(key) == 0:
|
|
1219
|
+
self._canvas_select.create_text(self.get_point_canvas_coord(key)[0] - 5,
|
|
1220
|
+
self.get_point_canvas_coord(key)[1] - 14, text='START 1',
|
|
1221
|
+
font=text_type, fill = 'blue')
|
|
1222
|
+
elif self._active_points.index(key) == 1:
|
|
1223
|
+
self._canvas_select.create_text(self.get_point_canvas_coord(key)[0] - 5,
|
|
1224
|
+
self.get_point_canvas_coord(key)[1] - 14,
|
|
1225
|
+
text='STOP 1',font=text_type, fill='blue')
|
|
1226
|
+
elif self._active_points.index(key) == 2:
|
|
1227
|
+
self._canvas_select.create_text(self.get_point_canvas_coord(key)[0] - 5,
|
|
1228
|
+
self.get_point_canvas_coord(key)[1] - 14,
|
|
1229
|
+
text='START 2',font=text_type, fill='blue')
|
|
1230
|
+
elif self._active_points.index(key) == 3:
|
|
1231
|
+
self._canvas_select.create_text(self.get_point_canvas_coord(key)[0] - 5,
|
|
1232
|
+
self.get_point_canvas_coord(key)[1] - 14,
|
|
1233
|
+
text='STOP 2',font=text_type, fill='blue')
|
|
1234
|
+
else:
|
|
1235
|
+
pass
|
|
1236
|
+
else:
|
|
1237
|
+
self._canvas_select.create_oval(self.get_point_canvas_coord(key)[0] - pt_size,
|
|
1238
|
+
self.get_point_canvas_coord(key)[1] - pt_size,
|
|
1239
|
+
self.get_point_canvas_coord(key)[0] + pt_size,
|
|
1240
|
+
self.get_point_canvas_coord(key)[1] + pt_size, fill='red')
|
|
1241
|
+
|
|
1242
|
+
self._canvas_select.create_text(self.get_point_canvas_coord(key)[0] - 5,
|
|
1243
|
+
self.get_point_canvas_coord(key)[1] - 14, text='pt.'+str(get_num(key)),
|
|
1244
|
+
font='Verdana 8', fill='blue')
|
|
1245
|
+
else:
|
|
1246
|
+
self._canvas_select.create_text([20, 20], text='Results are presented here. '
|
|
1247
|
+
'All results may not fit the screen. '
|
|
1248
|
+
'All results are seen in your saved result file.',
|
|
1249
|
+
font='Verdana 12 bold',
|
|
1250
|
+
fill='red', anchor = 'w')
|
|
1251
|
+
|
|
1252
|
+
delta, start_x, y_loc = 20, 10, 40
|
|
1253
|
+
|
|
1254
|
+
for key, values in opt_results.items():
|
|
1255
|
+
# if y_loc > 700:
|
|
1256
|
+
# start_x = 400
|
|
1257
|
+
# y_loc = 40
|
|
1258
|
+
|
|
1259
|
+
y_loc = y_loc + delta
|
|
1260
|
+
check_ok = [val[2] is True for val in values[1]]
|
|
1261
|
+
|
|
1262
|
+
if save_file is not None:
|
|
1263
|
+
save_file.write('\n')
|
|
1264
|
+
save_file.write('--------------------------------------------------------------------------' + '\n')
|
|
1265
|
+
save_file.write('Plate fields: '+str(len(values[2]['objects']))+ ' Frames: '+
|
|
1266
|
+
str(len(values[2]['frames'])) + '\n')
|
|
1267
|
+
self._canvas_select.create_text([start_x + delta, y_loc],
|
|
1268
|
+
text=str(len(check_ok))+' panels with weight '+ str(round(values[0],1)),
|
|
1269
|
+
anchor='w', font=text_type)
|
|
1270
|
+
y_loc += delta
|
|
1271
|
+
item_count, endstring = 0, ''
|
|
1272
|
+
|
|
1273
|
+
for data_idx, data in enumerate(values[1]):
|
|
1274
|
+
for idx, stuc_info in enumerate(data):
|
|
1275
|
+
if type(stuc_info) == calc_structure.AllStructure:
|
|
1276
|
+
|
|
1277
|
+
if y_loc > 700:
|
|
1278
|
+
y_loc = 120
|
|
1279
|
+
start_x += 350
|
|
1280
|
+
if item_count == 0:
|
|
1281
|
+
endstring = ' START 1'+' OK!\n' if values[1][data_idx][3] else ' START 1'+' NOT OK!\n'
|
|
1282
|
+
elif item_count > 0 and item_count < len(values[1]) / 2-1 and len(values[1]) != 4:
|
|
1283
|
+
endstring = ' -------'+' OK!\n' if values[1][data_idx][3] else ' -------'+' NOT OK!\n'
|
|
1284
|
+
elif item_count == len(values[1])/2-1:
|
|
1285
|
+
endstring = ' -END 1-'+' OK!\n' if values[1][data_idx][3] else ' -END 1-'+' NOT OK!\n'
|
|
1286
|
+
elif item_count == len(values[1])/2:
|
|
1287
|
+
endstring = ' START 2'+' OK!\n' if values[1][data_idx][3] else ' START 2'+' NOT OK!\n'
|
|
1288
|
+
elif item_count > len(values[1])/2 and item_count < len(values[1])-1:
|
|
1289
|
+
endstring = ' -------'+' OK!\n' if values[1][data_idx][3] else ' -------'+' NOT OK!\n'
|
|
1290
|
+
elif item_count == len(values[1])-1:
|
|
1291
|
+
endstring = ' -END 2-'+' OK!\n' if values[1][data_idx][3] else ' -END 2-'+' NOT OK!\n'
|
|
1292
|
+
self._canvas_select.create_text([start_x + delta, y_loc],
|
|
1293
|
+
text=stuc_info.get_one_line_string_mixed()+endstring,
|
|
1294
|
+
anchor='w', font=text_type)
|
|
1295
|
+
y_loc += 15
|
|
1296
|
+
|
|
1297
|
+
if save_file is not None:
|
|
1298
|
+
save_file.write(stuc_info.get_one_line_string_mixed()+' ' +
|
|
1299
|
+
stuc_info.get_extended_string_mixed() +
|
|
1300
|
+
' | ' + stuc_info.Plate.get_report_stresses() +
|
|
1301
|
+
endstring)
|
|
1302
|
+
item_count += 1
|
|
1303
|
+
|
|
1304
|
+
if save_file is not None:
|
|
1305
|
+
save_file.write('Weight details for this solution:\n')
|
|
1306
|
+
save_file.write('Weight of main structure: ' + str([str(round(val, 1))
|
|
1307
|
+
for val in values[2]['objects']]) + '\n')
|
|
1308
|
+
save_file.write('Weight of frames: ' + str([str(round(val, 1))
|
|
1309
|
+
for val in values[2]['frames']]) + '\n')
|
|
1310
|
+
save_file.write('Scales used on frames: ' +
|
|
1311
|
+
str([str(round(val, 3)) for val in values[2]['scales']]) + '\n')
|
|
1312
|
+
save_file.write('----------------------------------------------------------------------------'+'\n')
|
|
1313
|
+
|
|
1314
|
+
if save_file is not None:
|
|
1315
|
+
save_file.write('\n ------------- END ---------------')
|
|
1316
|
+
save_file.close()
|
|
1317
|
+
|
|
1318
|
+
def draw_result_text(self, geo_opt_obj, save_to_file = None):
|
|
1319
|
+
''' Textual version of the results. '''
|
|
1320
|
+
|
|
1321
|
+
self._canvas_opt.delete('all')
|
|
1322
|
+
start_x = 20
|
|
1323
|
+
delta = 25
|
|
1324
|
+
start_y = 60
|
|
1325
|
+
y_loc = delta + start_y
|
|
1326
|
+
xplot = list()
|
|
1327
|
+
yplot = list()
|
|
1328
|
+
|
|
1329
|
+
self._canvas_opt.create_text([start_x, 40],
|
|
1330
|
+
text='Results seen next. Weight index is tot_weight / max_weight \n'
|
|
1331
|
+
'max_weight is the highest total weight of the checked variations.\n'
|
|
1332
|
+
'Weight index of 1 is the heaviest calculated variation.',
|
|
1333
|
+
font='Verdana 10', fill='Blue', anchor='w')
|
|
1334
|
+
|
|
1335
|
+
self._canvas_opt.create_text([start_x, y_loc],
|
|
1336
|
+
text='| Plate fields | Fields length | Weight index | All OK? |',
|
|
1337
|
+
font='Verdana 10 bold', fill='red', anchor = 'w')
|
|
1338
|
+
y_loc += delta / 2
|
|
1339
|
+
self._canvas_opt.create_text([start_x, y_loc],
|
|
1340
|
+
text='************************************************', anchor='w',
|
|
1341
|
+
font='Verdana 10 bold')
|
|
1342
|
+
text_type = 'Verdana 10 bold'
|
|
1343
|
+
weights = [self._geo_results[key][0] for key in self._geo_results.keys()]
|
|
1344
|
+
|
|
1345
|
+
max_weight = 0
|
|
1346
|
+
for weight in weights:
|
|
1347
|
+
if weight != float('inf'):
|
|
1348
|
+
max_weight = weight if weight > max_weight else max_weight
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
if save_to_file is not None:
|
|
1352
|
+
save_file = open(save_to_file, 'w')
|
|
1353
|
+
save_file.write('| Plate fields | Fields length | Weight index | All OK? |\n')
|
|
1354
|
+
save_file.write('*********************************************************\n')
|
|
1355
|
+
|
|
1356
|
+
for key, value in self._geo_results.items():
|
|
1357
|
+
y_loc = y_loc + delta
|
|
1358
|
+
|
|
1359
|
+
check_ok = [val[2] is True for val in value[1]]
|
|
1360
|
+
|
|
1361
|
+
self._canvas_opt.create_text([start_x + 20, y_loc ], text=str(len(check_ok)),
|
|
1362
|
+
anchor='w', font=text_type)
|
|
1363
|
+
|
|
1364
|
+
self._canvas_opt.create_text([start_x + 120, y_loc ], text=str('No results\n' if
|
|
1365
|
+
self._geo_results[key][1][0][0] is None else
|
|
1366
|
+
round(self._geo_results[key][1][0][0].
|
|
1367
|
+
Plate.span,4)),
|
|
1368
|
+
anchor='w', font=text_type)
|
|
1369
|
+
self._canvas_opt.create_text([start_x + 220, y_loc ],
|
|
1370
|
+
text=str(round(self._geo_results[key][0] / max_weight, 3))
|
|
1371
|
+
if max_weight != 0 else '',
|
|
1372
|
+
anchor='w', font=text_type)
|
|
1373
|
+
|
|
1374
|
+
self._canvas_opt.create_text([start_x + 330, y_loc ], text=str(all(check_ok)),
|
|
1375
|
+
anchor='w', font=text_type)
|
|
1376
|
+
|
|
1377
|
+
if save_to_file is not None:
|
|
1378
|
+
save_file.write(str(len(check_ok))+ ' ' + 'No results\n' if self._geo_results[key][1][0][0] is None
|
|
1379
|
+
else str(round(self._geo_results[key][1][0][0].Plate.span,
|
|
1380
|
+
4)) + ' ' +
|
|
1381
|
+
str(round(self._geo_results[key][0] / max_weight, 3))
|
|
1382
|
+
+ '\n' if max_weight != 0 else
|
|
1383
|
+
'' + ' ' + str(all(check_ok))+'\n')
|
|
1384
|
+
if self._geo_results[key][1][0][0] is not None:
|
|
1385
|
+
xplot.append(round(self._geo_results[key][1][0][0].Plate.span,4))
|
|
1386
|
+
yplot.append(round(self._geo_results[key][0] / max_weight, 4))
|
|
1387
|
+
|
|
1388
|
+
if save_to_file is not None:
|
|
1389
|
+
return save_file, xplot, yplot
|
|
1390
|
+
else:
|
|
1391
|
+
return None, xplot, yplot
|
|
1392
|
+
|
|
1393
|
+
def algorithm_info(self):
|
|
1394
|
+
''' When button is clicked, info is displayed.'''
|
|
1395
|
+
|
|
1396
|
+
messagebox.showinfo(title='Algorith information',
|
|
1397
|
+
message='The algorithms currently included is:\n'
|
|
1398
|
+
'ANYSMART: \n'
|
|
1399
|
+
' Calculates all alternatives using upper and lower bounds.\n'
|
|
1400
|
+
' The step used inside the bounds is defined in deltas.\n\n'
|
|
1401
|
+
'RANDOM: \n'
|
|
1402
|
+
' Uses the same bounds and deltas as in ANYSMART.\n'
|
|
1403
|
+
' Number of combinations calculated is defined in "trials",\n'
|
|
1404
|
+
' which selects withing the bounds and deltas defined.\n\n'
|
|
1405
|
+
'RANDOM_NO_BOUNDS:\n'
|
|
1406
|
+
' Same as RANDOM, but does not use the defined deltas.\n'
|
|
1407
|
+
' The deltas is set to 1 mm for all dimensions/thicknesses.\n\n'
|
|
1408
|
+
'ANYDETAIL:\n'
|
|
1409
|
+
' Same as for ANYSMART, but will take some more time and\n'
|
|
1410
|
+
' provide a chart of weight development during execution.\n\n'
|
|
1411
|
+
'PSO - Particle Swarm Search:\n'
|
|
1412
|
+
' The information can be found on \n'
|
|
1413
|
+
' http://pythonhosted.org/pyswarm/ \n'
|
|
1414
|
+
' For further information google it!\n'
|
|
1415
|
+
' Parameters:\n'
|
|
1416
|
+
' swarmsize : The number of particles in the swarm (Default: 100)\n'
|
|
1417
|
+
' omega : Particle velocity scaling factor (Default: 0.5)\n'
|
|
1418
|
+
' phip : Scaling factor to search away from the particle’s \n'
|
|
1419
|
+
' best known position (Default: 0.5)\n'
|
|
1420
|
+
' phig : Scaling factor to search away from the swarm’s best \n'
|
|
1421
|
+
' known position (Default: 0.5)\n'
|
|
1422
|
+
' maxiter : The maximum number of iterations for the swarm \n'
|
|
1423
|
+
' to search (Default: 100)\n'
|
|
1424
|
+
' minstep : The minimum stepsize of swarm’s best position \n'
|
|
1425
|
+
' before the search terminates (Default: 1e-8)\n'
|
|
1426
|
+
' minfunc : The minimum change of swarm’s best objective value\n'
|
|
1427
|
+
' before the search terminates (Default: 1e-8)\n\n'
|
|
1428
|
+
|
|
1429
|
+
'\n'
|
|
1430
|
+
'All algorithms calculates local scantling and buckling requirements')
|
|
1431
|
+
|
|
1432
|
+
def slider_used(self, event):
|
|
1433
|
+
'''
|
|
1434
|
+
Action when slider is activated.
|
|
1435
|
+
:return:
|
|
1436
|
+
'''
|
|
1437
|
+
self._canvas_scale = self.slider.get()
|
|
1438
|
+
self.draw_canvas()
|
|
1439
|
+
|
|
1440
|
+
def on_closing(self):
|
|
1441
|
+
'''
|
|
1442
|
+
Action when closing the window without saving.
|
|
1443
|
+
:return:
|
|
1444
|
+
'''
|
|
1445
|
+
if __name__ == '__main__':
|
|
1446
|
+
self._frame.destroy()
|
|
1447
|
+
return
|
|
1448
|
+
|
|
1449
|
+
mess = tk.messagebox.showwarning('Closed without saving', 'Closing will not save loads you have created',
|
|
1450
|
+
type='okcancel')
|
|
1451
|
+
if mess == 'ok':
|
|
1452
|
+
self._frame.grab_release()
|
|
1453
|
+
self._frame.destroy()
|
|
1454
|
+
self.app.on_aborted_load_window()
|
|
1455
|
+
|
|
1456
|
+
def get_point_canvas_coord(self, point_no):
|
|
1457
|
+
'''
|
|
1458
|
+
Returning the canvas coordinates of the point. This value will change with slider.
|
|
1459
|
+
:param point_no:
|
|
1460
|
+
:return:
|
|
1461
|
+
'''
|
|
1462
|
+
point_coord_x = self._canvas_draw_origo[0] + self._point_dict[point_no][0]* self._canvas_scale
|
|
1463
|
+
point_coord_y = self._canvas_draw_origo[1] - self._point_dict[point_no][1]* self._canvas_scale
|
|
1464
|
+
|
|
1465
|
+
return [point_coord_x, point_coord_y]
|
|
1466
|
+
|
|
1467
|
+
def get_canvas_coord(self, coord):
|
|
1468
|
+
'''
|
|
1469
|
+
Returning the canvas coordinates of the point. This value will change with slider.
|
|
1470
|
+
:param point_no:
|
|
1471
|
+
:return:
|
|
1472
|
+
'''
|
|
1473
|
+
point_coord_x = self._canvas_draw_origo[0] + coord[0] * self._canvas_scale
|
|
1474
|
+
point_coord_y = self._canvas_draw_origo[1] - coord[1] * self._canvas_scale
|
|
1475
|
+
|
|
1476
|
+
return [point_coord_x, point_coord_y]
|
|
1477
|
+
|
|
1478
|
+
def controls(self):
|
|
1479
|
+
'''
|
|
1480
|
+
Specifying the controls to be used.
|
|
1481
|
+
:return:
|
|
1482
|
+
'''
|
|
1483
|
+
self._canvas_select.bind('<Button-1>', self.button_1_click)
|
|
1484
|
+
self._canvas_select.bind('<Button-2>', self.button_2_click)
|
|
1485
|
+
self._canvas_select.bind('<Button-3>', self.button_3_click)
|
|
1486
|
+
|
|
1487
|
+
self._frame.bind('<Shift_L>', self.shift_pressed)
|
|
1488
|
+
self._frame.bind('<Shift_R>', self.shift_pressed)
|
|
1489
|
+
self._frame.bind('<Control_L>', self.ctrl_pressed)
|
|
1490
|
+
self._frame.bind('<Control_R>', self.ctrl_pressed)
|
|
1491
|
+
|
|
1492
|
+
self._frame.bind("<MouseWheel>", self.mouse_scroll)
|
|
1493
|
+
self._frame.bind("<B2-Motion>", self.button_2_click_and_drag)
|
|
1494
|
+
|
|
1495
|
+
def shift_pressed(self, event=None):
|
|
1496
|
+
'''
|
|
1497
|
+
Event is executed when shift key pressed.
|
|
1498
|
+
:return:
|
|
1499
|
+
'''
|
|
1500
|
+
self._add_to_lines = True
|
|
1501
|
+
|
|
1502
|
+
def ctrl_pressed(self, event=None):
|
|
1503
|
+
'''
|
|
1504
|
+
Event when control is pressed.
|
|
1505
|
+
:param event:
|
|
1506
|
+
:return:
|
|
1507
|
+
'''
|
|
1508
|
+
self._add_to_lines = False
|
|
1509
|
+
|
|
1510
|
+
def button_1_click(self, event):
|
|
1511
|
+
'''
|
|
1512
|
+
When clicking the right button, this method is called.
|
|
1513
|
+
method is referenced in
|
|
1514
|
+
'''
|
|
1515
|
+
self._previous_drag_mouse = [event.x, event.y]
|
|
1516
|
+
# if type(self._geo_results) is not list():
|
|
1517
|
+
# if self._geo_results is not None:
|
|
1518
|
+
# return
|
|
1519
|
+
# else:
|
|
1520
|
+
# if self._geo_results[0] is not None:
|
|
1521
|
+
# return
|
|
1522
|
+
click_x = self._canvas_select.winfo_pointerx() - self._canvas_select.winfo_rootx()
|
|
1523
|
+
click_y = self._canvas_select.winfo_pointery() - self._canvas_select.winfo_rooty()
|
|
1524
|
+
|
|
1525
|
+
self._point_is_active = False
|
|
1526
|
+
margin = 10
|
|
1527
|
+
self._active_point = ''
|
|
1528
|
+
for point, coords in self._point_dict.items():
|
|
1529
|
+
point_coord = self.get_point_canvas_coord(point)
|
|
1530
|
+
if point_coord[0]-margin < click_x < point_coord[0]+margin and\
|
|
1531
|
+
point_coord[1]-margin < click_y < point_coord[1]+margin:
|
|
1532
|
+
self._active_point = point
|
|
1533
|
+
self._point_is_active = True
|
|
1534
|
+
if len(self._active_points)<4:
|
|
1535
|
+
self._active_points.append(self._active_point)
|
|
1536
|
+
|
|
1537
|
+
if len(self._active_points)==4:
|
|
1538
|
+
self.opt_create_frames(self.opt_get_fractions())
|
|
1539
|
+
|
|
1540
|
+
self.draw_select_canvas()
|
|
1541
|
+
|
|
1542
|
+
def button_3_click(self, event):
|
|
1543
|
+
'''
|
|
1544
|
+
Event when right click.
|
|
1545
|
+
:param evnet:
|
|
1546
|
+
:return:
|
|
1547
|
+
'''
|
|
1548
|
+
self._previous_drag_mouse = [event.x, event.y]
|
|
1549
|
+
self._active_lines = []
|
|
1550
|
+
self._active_points = []
|
|
1551
|
+
self.draw_select_canvas()
|
|
1552
|
+
|
|
1553
|
+
def button_2_click(self, event):
|
|
1554
|
+
'''
|
|
1555
|
+
Event when right click.
|
|
1556
|
+
:param evnet:
|
|
1557
|
+
:return:
|
|
1558
|
+
'''
|
|
1559
|
+
self._previous_drag_mouse = [event.x, event.y]
|
|
1560
|
+
|
|
1561
|
+
if self._opt_resutls =={}:
|
|
1562
|
+
return
|
|
1563
|
+
click_x = self._canvas_select.winfo_pointerx() - self._canvas_select.winfo_rootx()
|
|
1564
|
+
click_y = self._canvas_select.winfo_pointery() - self._canvas_select.winfo_rooty()
|
|
1565
|
+
|
|
1566
|
+
if len(self._line_dict) > 0:
|
|
1567
|
+
for key, value in self._line_dict.items():
|
|
1568
|
+
|
|
1569
|
+
coord1x = self.get_point_canvas_coord('point' + str(value[0]))[0]
|
|
1570
|
+
coord2x = self.get_point_canvas_coord('point' + str(value[1]))[0]
|
|
1571
|
+
coord1y = self.get_point_canvas_coord('point' + str(value[0]))[1]
|
|
1572
|
+
coord2y = self.get_point_canvas_coord('point' + str(value[1]))[1]
|
|
1573
|
+
|
|
1574
|
+
vector = [coord2x - coord1x, coord2y - coord1y]
|
|
1575
|
+
click_x_range = [ix for ix in range(click_x - 10, click_x + 10)]
|
|
1576
|
+
click_y_range = [iy for iy in range(click_y - 10, click_y + 10)]
|
|
1577
|
+
distance = int(dist([coord1x, coord1y], [coord2x, coord2y]))
|
|
1578
|
+
|
|
1579
|
+
# checking along the line if the click is witnin +- 10 around the click
|
|
1580
|
+
for dist_mult in range(1, distance - 1):
|
|
1581
|
+
dist_mult = dist_mult / distance
|
|
1582
|
+
x_check = int(coord1x) + int(round(vector[0] * dist_mult, 0))
|
|
1583
|
+
y_check = int(coord1y) + int(round(vector[1] * dist_mult, 0))
|
|
1584
|
+
if x_check in click_x_range and y_check in click_y_range:
|
|
1585
|
+
self._canvas_select.delete('all')
|
|
1586
|
+
self._active_lines = []
|
|
1587
|
+
self._active_lines.append(key)
|
|
1588
|
+
if key in self._opt_resutls.keys() and self._opt_resutls[key] != None:
|
|
1589
|
+
self.draw_properties(init_obj=self._line_to_struc[key][0],
|
|
1590
|
+
opt_obj=self._opt_resutls[key][0],
|
|
1591
|
+
line=key)
|
|
1592
|
+
else:
|
|
1593
|
+
self.draw_properties(init_obj=self._line_to_struc[key][0], line=key)
|
|
1594
|
+
break
|
|
1595
|
+
self.draw_select_canvas()
|
|
1596
|
+
self.draw_select_canvas()
|
|
1597
|
+
self.update_running_time()
|
|
1598
|
+
|
|
1599
|
+
#############################
|
|
1600
|
+
self.opt_create_main_structure(self.opt_create_frames(self.opt_get_fractions())[0],self._active_points[0],
|
|
1601
|
+
self._active_points[1],self._active_points[2],self._active_points[3])
|
|
1602
|
+
|
|
1603
|
+
def save_and_close(self):
|
|
1604
|
+
'''
|
|
1605
|
+
Save and close
|
|
1606
|
+
:return:
|
|
1607
|
+
'''
|
|
1608
|
+
if __name__ == '__main__':
|
|
1609
|
+
self._frame.destroy()
|
|
1610
|
+
return
|
|
1611
|
+
try:
|
|
1612
|
+
to_return = {}
|
|
1613
|
+
for line in self._active_lines:
|
|
1614
|
+
to_return[line] = self._opt_resutls[line]
|
|
1615
|
+
self.app.on_close_opt_multiple_window(to_return)
|
|
1616
|
+
messagebox.showinfo(title='Return info', message='Returning: ' + str(self._active_lines))
|
|
1617
|
+
except IndexError:
|
|
1618
|
+
messagebox.showinfo(title='Nothing to return', message='No results to return.')
|
|
1619
|
+
return
|
|
1620
|
+
self._frame.destroy()
|
|
1621
|
+
|
|
1622
|
+
def toggle(self, found_files = None, obj = None, iterating = False, given_path: str = None):
|
|
1623
|
+
'''
|
|
1624
|
+
On off button.
|
|
1625
|
+
:param found_files:
|
|
1626
|
+
:param obj:
|
|
1627
|
+
:return:
|
|
1628
|
+
'''
|
|
1629
|
+
# if iterating:
|
|
1630
|
+
# if found_files is not None:
|
|
1631
|
+
# predefined_structure = hlp.helper_read_section_file(files=found_files, obj=obj)
|
|
1632
|
+
# else:
|
|
1633
|
+
predefined_structure = None
|
|
1634
|
+
if self._toggle_btn.config('relief')[-1] == 'sunken':
|
|
1635
|
+
self._toggle_btn.config(relief="raised")
|
|
1636
|
+
self._toggle_btn.config(bg = 'salmon')
|
|
1637
|
+
self._ent_spacing_upper.config(bg = 'white')
|
|
1638
|
+
self._ent_spacing_lower.config(bg = 'white')
|
|
1639
|
+
self._ent_delta_spacing.config(bg = 'white')
|
|
1640
|
+
self._filez = None
|
|
1641
|
+
else:
|
|
1642
|
+
self._toggle_btn.config(relief="sunken")
|
|
1643
|
+
self._toggle_btn.config(bg='lightgreen')
|
|
1644
|
+
self._ent_spacing_upper.config(bg = 'lightgreen')
|
|
1645
|
+
self._ent_spacing_lower.config(bg = 'lightgreen')
|
|
1646
|
+
self._ent_delta_spacing.config(bg = 'lightgreen')
|
|
1647
|
+
self._ent_pl_thk_upper.config(bg = 'lightgreen')
|
|
1648
|
+
self._ent_pl_thk_lower.config(bg = 'lightgreen')
|
|
1649
|
+
self._ent_delta_pl_thk.config(bg = 'lightgreen')
|
|
1650
|
+
if given_path is None:
|
|
1651
|
+
self._filez = list(askopenfilenames(parent=self._frame, title='Choose files to open',
|
|
1652
|
+
initialdir=self._root_dir))
|
|
1653
|
+
else:
|
|
1654
|
+
self._filez = [given_path]
|
|
1655
|
+
if self._filez == []:
|
|
1656
|
+
self._toggle_btn.config(relief="raised")
|
|
1657
|
+
self._toggle_btn.config(bg='salmon')
|
|
1658
|
+
self._ent_spacing_upper.config(bg='white')
|
|
1659
|
+
self._ent_spacing_lower.config(bg='white')
|
|
1660
|
+
self._ent_delta_spacing.config(bg='white')
|
|
1661
|
+
self._ent_pl_thk_upper.config(bg='white')
|
|
1662
|
+
self._ent_pl_thk_lower.config(bg='white')
|
|
1663
|
+
self._ent_delta_pl_thk.config(bg='white')
|
|
1664
|
+
|
|
1665
|
+
return found_files, predefined_structure
|
|
1666
|
+
|
|
1667
|
+
def open_example_file(self):
|
|
1668
|
+
import os
|
|
1669
|
+
if os.path.isfile('sections.csv'):
|
|
1670
|
+
os.startfile('sections.csv')
|
|
1671
|
+
else:
|
|
1672
|
+
os.startfile(self._root_dir + '/' + 'sections.csv')
|
|
1673
|
+
|
|
1674
|
+
def plot_results(self):
|
|
1675
|
+
'Plotting a selected panel'
|
|
1676
|
+
if self._geo_results is not None \
|
|
1677
|
+
and type(self._new_option_fraction.get()) == int and type(self._new_option_panel.get()) == int:
|
|
1678
|
+
op.plot_optimization_results(self._geo_results[int(self._new_option_fraction.get()/2)][1]
|
|
1679
|
+
[self._new_option_panel.get()])
|
|
1680
|
+
|
|
1681
|
+
def get_plate_field_options(self, event):
|
|
1682
|
+
|
|
1683
|
+
if self._geo_results is not None:
|
|
1684
|
+
self._ent_option_field.destroy()
|
|
1685
|
+
to_add = tuple([val for val in range(len(self._geo_results[int(self._new_option_fraction.get()/2)][1]))])
|
|
1686
|
+
self._ent_option_field = tk.OptionMenu(self._frame, self._new_option_panel, *to_add)
|
|
1687
|
+
self._ent_option_field.place(x=self._options_panels_place[0], y=self._options_panels_place[1])
|
|
1688
|
+
|
|
1689
|
+
def mouse_scroll(self,event):
|
|
1690
|
+
self._canvas_scale += event.delta/50
|
|
1691
|
+
self._canvas_scale = 0 if self._canvas_scale < 0 else self._canvas_scale
|
|
1692
|
+
|
|
1693
|
+
self.draw_select_canvas()
|
|
1694
|
+
|
|
1695
|
+
def button_2_click_and_drag(self,event):
|
|
1696
|
+
|
|
1697
|
+
self._canvas_draw_origo = (self._canvas_draw_origo[0]-(self._previous_drag_mouse[0]-event.x),
|
|
1698
|
+
self._canvas_draw_origo[1]-(self._previous_drag_mouse[1]-event.y))
|
|
1699
|
+
|
|
1700
|
+
self._previous_drag_mouse = (event.x,event.y)
|
|
1701
|
+
|
|
1702
|
+
self.draw_select_canvas()
|
|
1703
|
+
|
|
1704
|
+
if __name__ == '__main__':
|
|
1705
|
+
root = tk.Tk()
|
|
1706
|
+
my_app = CreateOptGeoWindow(master=root)
|
|
1707
|
+
|
|
1708
|
+
root.mainloop()
|