ANYstructure 5.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. anystruct/ANYstructure_documentation.pdf +0 -0
  2. anystruct/SN_curve_parameters.py +35 -0
  3. anystruct/__init__.py +0 -0
  4. anystruct/__main__.py +24 -0
  5. anystruct/api.py +772 -0
  6. anystruct/buckling_calc_external.py +120 -0
  7. anystruct/bulb_anglebar_tbar_flatbar.csv +677 -0
  8. anystruct/calc_loads.py +526 -0
  9. anystruct/calc_structure.py +4838 -0
  10. anystruct/compartment_window.py +176 -0
  11. anystruct/example_data.py +532 -0
  12. anystruct/example_data_puls.py +46 -0
  13. anystruct/excel_inteface.py +244 -0
  14. anystruct/fatigue_window.py +352 -0
  15. anystruct/grid_window.py +307 -0
  16. anystruct/gui.py +24 -0
  17. anystruct/helper.py +623 -0
  18. anystruct/images/ANYstructure_logo.jpg +0 -0
  19. anystruct/images/Buckling_Strength_of_Shells.png +0 -0
  20. anystruct/images/Panel_geometry_definitions.png +0 -0
  21. anystruct/images/current_comps_NONE.png +0 -0
  22. anystruct/images/fls_button.gif +0 -0
  23. anystruct/images/img_T_L_FB.gif +0 -0
  24. anystruct/images/img_axial_stresses.gif +0 -0
  25. anystruct/images/img_ext_pressure_button.gif +0 -0
  26. anystruct/images/img_ext_pressure_button_def.gif +0 -0
  27. anystruct/images/img_fixation_parameters.gif +0 -0
  28. anystruct/images/img_generate_report.gif +0 -0
  29. anystruct/images/img_int_pressure_button.gif +0 -0
  30. anystruct/images/img_int_pressure_button_search.gif +0 -0
  31. anystruct/images/img_multi_opt.gif +0 -0
  32. anystruct/images/img_optimize.gif +0 -0
  33. anystruct/images/img_plate_and_stiffener.gif +0 -0
  34. anystruct/images/img_stf_button.gif +0 -0
  35. anystruct/images/img_stiffener.gif +0 -0
  36. anystruct/images/img_stress_button.gif +0 -0
  37. anystruct/images/img_title.gif +0 -0
  38. anystruct/images/img_transverse_stress.gif +0 -0
  39. anystruct/load_factor_window.py +166 -0
  40. anystruct/load_window.py +721 -0
  41. anystruct/main_application.py +7918 -0
  42. anystruct/make_grid_numpy.py +506 -0
  43. anystruct/make_queue.py +52 -0
  44. anystruct/make_stack.py +52 -0
  45. anystruct/ml_files/CL_CSR-Tank_req_cl_predictor.pickle +0 -0
  46. anystruct/ml_files/CL_CSR-Tank_req_cl_scaler.pickle +0 -0
  47. anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor.pickle +0 -0
  48. anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_scaler.pickle +0 -0
  49. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  50. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  51. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  52. anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  53. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  54. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  55. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  56. anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  57. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  58. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  59. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  60. anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  61. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  62. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  63. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  64. anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  65. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  66. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  67. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  68. anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  69. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  70. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  71. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  72. anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  73. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
  74. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
  75. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
  76. anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
  77. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
  78. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
  79. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
  80. anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
  81. anystruct/opt_problem.py +31 -0
  82. anystruct/optimize.py +1680 -0
  83. anystruct/optimize_cylinder.py +898 -0
  84. anystruct/optimize_geometry.py +1708 -0
  85. anystruct/optimize_multiple_window.py +1507 -0
  86. anystruct/optimize_window.py +1117 -0
  87. anystruct/pl_stf_window.py +572 -0
  88. anystruct/report_generator.py +912 -0
  89. anystruct/sections.csv +202 -0
  90. anystruct/sesam_interface.py +115 -0
  91. anystruct/ship_section_example.txt +1 -0
  92. anystruct/stresses_window.py +269 -0
  93. anystruct/testCalc.py +118 -0
  94. anystructure-5.2.0.dist-info/METADATA +86 -0
  95. anystructure-5.2.0.dist-info/RECORD +99 -0
  96. anystructure-5.2.0.dist-info/WHEEL +5 -0
  97. anystructure-5.2.0.dist-info/entry_points.txt +2 -0
  98. anystructure-5.2.0.dist-info/licenses/LICENSE +21 -0
  99. anystructure-5.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,307 @@
1
+ import math
2
+ from matplotlib.backends import backend_tkagg
3
+ from matplotlib import pyplot as plt
4
+ import numpy as np
5
+ from collections import deque
6
+ import copy
7
+ import matplotlib.animation as animation
8
+
9
+
10
+ try:
11
+ import anystruct.example_data as test
12
+ except ModuleNotFoundError:
13
+ import ANYstructure.anystruct.example_data as test
14
+
15
+
16
+ def dist(p, q):
17
+ return math.sqrt((p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2)
18
+
19
+ class CreateGridWindow():
20
+
21
+ def __init__(self, grid, canvas_dim, to_draw, canvas_origo, find_lines: bool = False):
22
+ self._grid = grid
23
+ self._parent_dimensions = canvas_dim
24
+ self._to_draw = to_draw
25
+ self._parent_origo = canvas_origo
26
+ self._points_child = {}
27
+ self._child_dimensions = (canvas_dim[0]-canvas_origo[0]+1, canvas_origo[1]+1)
28
+ self._bfs_search_data = None
29
+
30
+ for line,point in to_draw.items():
31
+ point1 = (int(point[0][0]),int(point[0][1]))
32
+ point2 = (int(point[1][0]),int(point[1][1]))
33
+ self._points_child[line] = [point1,point2]
34
+
35
+ for line, points in self._points_child.items():
36
+ for point in self._grid.get_points_along_line(points[0],points[1]):
37
+ if not find_lines:
38
+ self._grid.set_barrier(point[0],point[1])
39
+ else:
40
+ self._grid.set_barrier(point[0], point[1], line_number = hlp.get_num(line))
41
+
42
+
43
+ def __str__(self):
44
+ return 'class CreateGridWindow(): __str__ - Not implemented'
45
+
46
+ @property
47
+ def grid(self):
48
+ return self._grid
49
+
50
+ @grid.setter
51
+ def grid(self, val):
52
+ self._grid = val
53
+
54
+ @property
55
+ def bfs_search_data(self):
56
+ return self._bfs_search_data
57
+
58
+ @bfs_search_data.setter
59
+ def bfs_search_data(self, val):
60
+ self._bfs_search_data = val
61
+
62
+ def draw_grid(self, save = False, tank_count = None):
63
+ '''
64
+ Drawing grid
65
+ EMPTY = yellow
66
+ FULL = red
67
+ :return:
68
+ '''
69
+
70
+
71
+ def discrete_matshow(data):
72
+ if self._bfs_search_data is not None:
73
+ comp_cell_count = self._bfs_search_data
74
+ area_mult = self._parent_dimensions[0]/(10*self._parent_dimensions[0]) * \
75
+ self._parent_dimensions[1]/(10*self._parent_dimensions[1])
76
+ plt_txt = list()
77
+ tank_iter = [] if tank_count == None else range(tank_count)
78
+ for num in tank_iter:
79
+ if self._bfs_search_data is not None:
80
+ tank_area = comp_cell_count[num + 2] * area_mult
81
+ plt_txt.append('Comp' + str(num + 2) + ' Approx. area: ' + str(round(tank_area,1)))
82
+ else:
83
+ plt_txt.append('Comp' + str(num + 2))
84
+
85
+ fig = plt.figure(figsize=[12, 8])
86
+ ax = fig.add_subplot(111)
87
+ ax.tick_params(labelsize=8)
88
+ fig.subplots_adjust(left=0.05, right=0.90, top=0.95, bottom=0.05)
89
+ # get discrete colormap
90
+ #cmap = plt.get_cmap('Accent_r', np.int32(np.max(data)) - np.int32(np.min(data)) + 1)
91
+
92
+ cmap = plt.get_cmap('jet', np.int32(np.max(data)) - np.int32(np.min(data)) + 1)
93
+ # set limits .5 outside true range
94
+ cax = ax.matshow(data, cmap=cmap, vmin=np.min(data) - .5, vmax=np.max(data) + .5)
95
+ # tell the colorbar to tick at integers
96
+ colb = fig.colorbar(cax, ticks=np.arange(np.min(data), np.max(data) + 1), shrink=0.8)
97
+ if tank_count is not None:
98
+ colb.set_ticks([-1, 0, 1] + [num + 2 for num in range(tank_count)])
99
+ colb.set_ticklabels(['BHD/Deck', 'Not searched', 'External'] + plt_txt)
100
+
101
+ # generate data
102
+ discrete_matshow(self._grid.get_matrix())
103
+ plt.suptitle('Compartments returned from search operation displayed below', fontsize=20, color='red')
104
+ plt.xscale('linear')
105
+ plt.axis('off')
106
+ plt.annotate('*area calculation inaccuracies due to thickness of barriers (BHD/Deck)', (0, 0), (0, -20),
107
+ xycoords='axes fraction', textcoords='offset points', va='top', fontsize = 10)
108
+ if save:
109
+ plt.savefig('current_comps.png')
110
+ else:
111
+ plt.show()
112
+
113
+ def animate_grid(self, grids_to_animate: list = None, tank_count = None):
114
+ ''' If animation is selected, the grid is shown here. '''
115
+
116
+ all_grids = grids_to_animate
117
+
118
+ def generate_data():
119
+ if len(all_grids) == 0:
120
+ ani.event_source.stop()
121
+ current_grid = all_grids.pop(0)
122
+ return current_grid
123
+
124
+ def update(data):
125
+ if len(all_grids) == 0:
126
+ ani.event_source.stop()
127
+ cax.set_data(data)
128
+ return cax
129
+
130
+ def data_gen():
131
+ if len(all_grids) == 0:
132
+ ani.event_source.stop()
133
+ while True:
134
+ yield generate_data()
135
+ plt.ion()
136
+ #tank_count = np.max(all_grids[-1])
137
+ fig = plt.figure(figsize=[12, 8])
138
+ ax = fig.add_subplot(111)
139
+ ax.tick_params(labelsize=8)
140
+ fig.subplots_adjust(left=0.05, right=0.90, top=0.95, bottom=0.05)
141
+ # get discrete colormap
142
+ cmap = plt.get_cmap('Accent_r', np.int32(np.max(all_grids[-1])) - np.int32(np.min(all_grids[-1])) + 1)
143
+ # set limits .5 outside true range
144
+ cax = ax.matshow(all_grids[-1], cmap=cmap, vmin=np.min(all_grids[-1]) - .5, vmax=np.max(all_grids[-1]) + .5)
145
+ # tell the colorbar to tick at integers
146
+ colb = fig.colorbar(cax, ticks=np.arange(np.min(all_grids[-1]), np.max(all_grids[-1]) + 1), shrink=0.8)
147
+
148
+ if self._bfs_search_data is not None:
149
+ comp_cell_count = self._bfs_search_data
150
+ area_mult = self._parent_dimensions[0] / (10 * self._parent_dimensions[0]) * \
151
+ self._parent_dimensions[1] / (10 * self._parent_dimensions[1])
152
+ plt_txt = list()
153
+ for num in range(tank_count):
154
+ if self._bfs_search_data is not None:
155
+ tank_area = comp_cell_count[num + 2] * area_mult
156
+ plt_txt.append('Comp' + str(num + 2) + ' Approx. area: ' + str(round(tank_area, 1)))
157
+ else:
158
+ plt_txt.append('Comp' + str(num + 2))
159
+
160
+ if tank_count is not None:
161
+ colb.set_ticks([-1, 0, 1] + [num + 2 for num in range(int(tank_count))])
162
+ colb.set_ticklabels(['BHD/Deck', 'Not searched', 'External'] + plt_txt)
163
+ ani = animation.FuncAnimation(fig, update, data_gen, interval=50)
164
+ fm = plt.get_current_fig_manager()
165
+ #fm.window.activateWindow()
166
+ #fm.window.raise_()
167
+ plt.suptitle('Compartments returned from search operation displayed below', fontsize=20, color='red')
168
+ plt.xscale('linear')
169
+ plt.axis('off')
170
+ plt.annotate('*area calculation inaccuracies due to thickness of barriers (BHD/Deck)', (0, 0), (0, -20),
171
+ xycoords='axes fraction', textcoords='offset points', va='top', fontsize = 10)
172
+ plt.show()
173
+
174
+ def search_bfs(self, animate = False):
175
+ '''
176
+ Bredth first search method.
177
+
178
+ Searcing every 20th pixel for empty places in the grid. When a empty cell is found, the search starts.
179
+ The search ends when no more empty cells are found in the boudnary regions (circular expansion of search).
180
+
181
+ USE GRID CONVENSION HERE. NOT POINTS.
182
+
183
+ grid(row,col) is same as grid(y,x)
184
+
185
+ points uses
186
+
187
+ point(x , y) is same as grid(col,row)
188
+ :return:
189
+ '''
190
+ compartment_count = 1
191
+ compartments = {}
192
+ all_grids = []
193
+ anim_count = 0
194
+
195
+ if animate:
196
+ all_grids.append(self._grid.get_matrix())
197
+
198
+ barriers_where = np.where(self._grid.cells.reshape((1,np.prod(self._grid.cells.shape))) == -1)
199
+ barrier_comp_count = dict()
200
+
201
+ for startrow in range(0, self._child_dimensions[1], 20):
202
+ for startcol in range(0, self._child_dimensions[0], 20):
203
+ if self._grid.is_empty(startrow,startcol):
204
+ el_max = ''
205
+ el_min = ''
206
+ cells = 0
207
+ boundary = deque()
208
+ boundary.append((startrow,startcol))
209
+ corners = []
210
+ barrier_comp_count[compartment_count] = 0
211
+
212
+ while len(boundary) != 0:
213
+ current_cell = boundary.pop()
214
+ #find the min/max elevation, counting cells in tank
215
+ if el_max == '':
216
+ el_max = current_cell[0]
217
+ el_min = current_cell[0]
218
+ else:
219
+ if current_cell[0] < el_max:
220
+ el_max = current_cell[0]
221
+ if current_cell[0] > el_min:
222
+ el_min = current_cell[0]
223
+ cells += 1
224
+ anim_count += 1
225
+
226
+ four_neighbors = self._grid.four_neighbors(current_cell[0], current_cell[1])
227
+ neighbors = self._grid.eight_neighbors(current_cell[0], current_cell[1])
228
+
229
+ #doing serach operations and looking for corners
230
+ no_of_barriers = 0
231
+ for neighbor in four_neighbors:
232
+ if self._grid.get_value(neighbor[0], neighbor[1]) == -1:
233
+ no_of_barriers += 1
234
+ barrier_comp_count[compartment_count] += 1
235
+ else:
236
+ pass
237
+
238
+ if self._grid.is_empty(neighbor[0], neighbor[1]):
239
+ self._grid.set_value(neighbor[0], neighbor[1],compartment_count)
240
+ boundary.append(neighbor)
241
+ if animate:
242
+ if compartment_count > 1:
243
+ anim_interval = 2000
244
+ else:
245
+ anim_interval = 20000
246
+
247
+ if anim_count/anim_interval - anim_count//anim_interval == 0.0:
248
+ all_grids.append(copy.deepcopy(self._grid.get_matrix()))
249
+ #finding corners on diagonal cells
250
+ for neighbor in [item for item in neighbors if item not in four_neighbors]:
251
+ if self._grid.get_value(neighbor[0], neighbor[1]) == -1:
252
+ no_of_barriers += 1
253
+ else:
254
+ pass
255
+
256
+ if no_of_barriers > 4:
257
+ corners.append((neighbor[0], neighbor[1]))
258
+
259
+ # returning values to the program
260
+ compartments[compartment_count] = cells, corners
261
+ compartment_count += 1
262
+ if animate:
263
+ all_grids.append(self._grid.get_matrix())
264
+
265
+ cells_modified, area_modified = dict(), dict()
266
+ comp_sum = np.sum([data for data in barrier_comp_count.values()])
267
+ for comp_no, data in compartments.items():
268
+ barrier_ratio_of_total = barrier_comp_count[comp_no] / comp_sum
269
+ if np.isnan(barriers_where[0].shape[0] * barrier_ratio_of_total):
270
+ continue
271
+ cells_modified[comp_no] = data[0] + int(barriers_where[0].shape[0] * barrier_ratio_of_total)
272
+
273
+ to_return = {'compartments': compartments, 'grids':all_grids, 'modified_cell_count': cells_modified}
274
+ self.bfs_search_data = to_return['modified_cell_count']
275
+ self._grid.bfs_search_data = to_return['modified_cell_count']
276
+ return to_return
277
+
278
+ def find_lines_inside_area(self, row1, col1, row2, col2):
279
+ '''
280
+ Define a search area.
281
+ Return the lines in this area.
282
+ This method makes sense if "find_lines" is set to True.
283
+ '''
284
+ return np.unique(self._grid.get_array()[row1:row2, col1:col2])
285
+
286
+ if __name__ == '__main__':
287
+ import time
288
+ t1 = time.time()
289
+ canvas_dim = [1000,720]
290
+ canvas_origo = (50,670)
291
+ my_grid = CreateGridWindow(test.get_grid_no_inp(), canvas_dim, test.get_to_draw(), canvas_origo)
292
+
293
+ search_return = my_grid.search_bfs(animate = True)
294
+ my_grid.draw_grid(tank_count=4)
295
+ print(np.unique(my_grid.grid))
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
anystruct/gui.py ADDED
@@ -0,0 +1,24 @@
1
+ import sys, multiprocessing, ctypes, os
2
+ import tkinter as tk
3
+ from anystruct.main_application import Application
4
+
5
+ def main(args=None):
6
+ """The main routine."""
7
+
8
+ if args is None:
9
+ args = sys.argv[1:]
10
+
11
+ multiprocessing.freeze_support()
12
+ errorCode = ctypes.windll.shcore.SetProcessDpiAwareness(2)
13
+ root = tk.Tk()
14
+ width = root.winfo_screenwidth()
15
+ height = root.winfo_screenheight()
16
+ root.geometry(f'{width}x{height}')
17
+ my_app = Application(root)
18
+ root.mainloop()
19
+
20
+ # Do argument parsing here (eg. with argparse) and anything else
21
+ # you want your project to do.
22
+
23
+ if __name__ == "__main__":
24
+ main()