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
anystruct/helper.py ADDED
@@ -0,0 +1,623 @@
1
+ '''
2
+ Helper funations to be used.
3
+ '''
4
+
5
+ import math, copy, csv, os
6
+ import numpy as np
7
+
8
+ print_it = True
9
+ root_dir = os.path.dirname(os.path.abspath(__file__))
10
+ def print_helper(properties, prop_text, units):
11
+ '''
12
+ Used to print out the properties
13
+ '''
14
+ dummy_i = 0
15
+ print(' \n ')
16
+ for prop_i in prop_text:
17
+ print(str(prop_i) + ' ' + str(properties[dummy_i]) + ' ' + str(units[dummy_i]) )
18
+ dummy_i += 1
19
+
20
+ def dist(p, q):
21
+ return math.sqrt((p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2)
22
+
23
+ def get_num(x):
24
+ try:
25
+ return int(''.join(ele for ele in x if ele.isdigit() or ele == '.'))
26
+ except ValueError:
27
+ return x
28
+
29
+ def list_2_string(list):
30
+ new_string = ''
31
+ for item in list[0:-1]:
32
+ new_string += str(item)
33
+ new_string += ' , '
34
+ new_string += str(list[-1])
35
+ return new_string
36
+
37
+ def one_load_combination(line_name_obj, coord, defined_loads, load_condition,
38
+ defined_tanks, comb_name, acc, load_factors_all):
39
+ '''
40
+ Creating load combination.
41
+ Inserted into self.line_to_struc index = 4
42
+ "dnva", "line12", "static_ballast_10m"
43
+ #load combination dictionary (comb,line,load) : [stat - DoubleVar(), dyn - DoubleVar], on/off - IntVar()]
44
+ :return:
45
+ '''
46
+
47
+ if load_condition not in ['tanktest','manual', 'slamming']:
48
+ return helper_dnva_dnvb(line_name_obj, coord, defined_loads, load_condition,
49
+ defined_tanks, comb_name, acc, load_factors_all)
50
+ elif load_condition == 'tanktest' and comb_name == 'tanktest':
51
+ return helper_tank_test(line_name_obj, coord, defined_loads, load_condition,
52
+ defined_tanks, comb_name, acc, load_factors_all)
53
+ elif load_condition == 'manual':
54
+ return helper_manual(line_name_obj, comb_name,load_factors_all)
55
+ elif load_condition == 'slamming':
56
+ return helper_slamming(defined_loads)
57
+ else:
58
+ return [None, ' ']
59
+
60
+ def helper_dnva_dnvb(line_name_obj, coord, defined_loads, load_condition,
61
+ defined_tanks, comb_name, acc, load_factors_all):
62
+
63
+ # calculate the defined loads
64
+ calc_load, load_print, prt_conditions = [], ['',], []
65
+ line_name = line_name_obj[0]
66
+ structure_type = line_name_obj[1].get_structure_type()
67
+ # if line_name_obj[0] == 'line12':
68
+ # print('Load calculation for '+line_name_obj[0] + ' ' + comb_name+ ' ' + load_condition)
69
+
70
+ # if print_line != None and line_name == print_line:
71
+ # print('Load calculation for '+line_name_obj[0] + ' ' + comb_name+ ' ' + load_condition)
72
+
73
+ if len(defined_loads) != 0:
74
+ for load in defined_loads :
75
+ if comb_name+load_condition not in prt_conditions:
76
+ load_print.append("Loads for condition: " + load_condition + ' - ' + comb_name +' ' + '\n')
77
+ prt_conditions.append(comb_name+load_condition)
78
+ if load != None:
79
+
80
+ load_factors = load_factors_all[(comb_name, line_name, load.get_name())]
81
+ # if print_it:
82
+ # if load_factors[0].get() != 0:
83
+ # load_print.append('LOAD NAME: '+' '+ comb_name+ ' '+ line_name+' '+ load.get_name()+'\n')
84
+ # if load_factors[1].get() != 0:
85
+ # if load_factors[0].get() != 0:
86
+ # load_print.append('LOAD NAME: '+' '+ comb_name+ ' '+ line_name+' '+ load.get_name()+'\n')
87
+ # USE GET() (static,dyn, on/off)
88
+
89
+ if load_condition == load.get_load_condition():
90
+ static_pressure = (load_factors[2].get())*(load_factors[0].get())\
91
+ *load.get_calculated_pressure(coord, acc[0],structure_type)
92
+ dynamic_pressure = (load_factors[2].get())*(load_factors[1].get())\
93
+ *load.get_calculated_pressure(coord, acc[1],structure_type)
94
+ if print_it:
95
+ # load_print.append('load (NON-TANK) calculation for load condition:' + load_condition + ' - Load is: '+ \
96
+ # load.get_name() + ' - Type is: \n')
97
+ if load_factors[0].get() != 0:
98
+ load_print.append(' static with acceleration: '+ str(acc[0])+ ' is: \n '+
99
+ str(load_factors[2].get())+'*'+\
100
+ str(load_factors[0].get())+'*'+\
101
+ str(round(load.get_calculated_pressure(coord, acc[0],structure_type),1))+ ' = '+ \
102
+ str(round(static_pressure,1))+'\n')
103
+ if load_factors[1].get() != 0:
104
+ load_print.append(' dynamic with acceleration: '+ str(acc[1])+' is: \n '+
105
+ str(load_factors[2].get())+'*'+\
106
+ str(load_factors[1].get())+'*'+\
107
+ str(round(load.get_calculated_pressure(coord, acc[1],structure_type),1))+ ' = '+ \
108
+ str(round(dynamic_pressure,1))+'\n')
109
+ # if line_name_obj[0] == 'line12':
110
+ # print('Pressures',static_pressure,'+',dynamic_pressure,'=',static_pressure+dynamic_pressure)
111
+ calc_load.append(static_pressure+dynamic_pressure)
112
+
113
+ # calculate the tank loads
114
+
115
+ if len(defined_tanks) != 0:
116
+ temp_tank = {}
117
+ if comb_name + load_condition not in prt_conditions:
118
+ load_print.append("Loads for condition: " + load_condition + ' - ' + comb_name + ' ' + '\n')
119
+ prt_conditions.append(comb_name + load_condition)
120
+ for tank_name_obj in defined_tanks:
121
+ temp_tank[tank_name_obj[0]] = 0
122
+
123
+ load_factors = load_factors_all[(comb_name, line_name, tank_name_obj[0])]
124
+ overpress_lf = [1.3,0]# if load_factors[0].get()==1.2 else [1,1.3]
125
+
126
+ if load_condition == tank_name_obj[1].get_condition():
127
+ # USE GET() (static,dyn, on/off)
128
+ static_pressure = load_factors[2].get()*(load_factors[0].get())\
129
+ *tank_name_obj[1].get_calculated_pressure(coord,acc[0])\
130
+ +tank_name_obj[1].get_overpressure()*overpress_lf[0]
131
+ dynamic_pressure = load_factors[2].get()*load_factors[1].get()\
132
+ *tank_name_obj[1].get_calculated_pressure(coord,acc[1])\
133
+ +tank_name_obj[1].get_overpressure()*overpress_lf[1]
134
+
135
+ temp_tank[tank_name_obj[0]] = static_pressure + dynamic_pressure# .append((static_pressure + dynamic_pressure))
136
+ if print_it and tank_name_obj[0]+load_condition not in prt_conditions:
137
+ prt_conditions.append(tank_name_obj[0]+load_condition)
138
+ #load_print.append('load (TANK) calculation for load condition:'+ load_condition+ ' - Tank is: '+ tank_name_obj[0]+'\n')
139
+ #load_print.append('load factors : '+ str(load_factors[0].get())+str(load_factors[1].get())+str(load_factors[2].get())+'\n')
140
+ load_print.append('\n' + tank_name_obj[0] + ' - static: '+ str(load_factors[2].get())+ '*'+ str(load_factors[0].get()) + '*'+\
141
+ str(tank_name_obj[1].get_calculated_pressure(coord,acc[0]))+' + '+\
142
+ str(tank_name_obj[1].get_overpressure())+ '*'+str(overpress_lf[0])+ ' = '+str(static_pressure)+'\n')
143
+ load_print.append(tank_name_obj[0] + ' - dynamic: '+str(load_factors[2].get())+ '*'+ str(load_factors[1].get())+ '*'+\
144
+ str(tank_name_obj[1].get_calculated_pressure(coord, acc[1]))+' + '+\
145
+ str(tank_name_obj[1].get_overpressure())+ '*'+str(overpress_lf[1])+' = '+ str(dynamic_pressure)+'\n')
146
+ # choosing the tank with the highest pressures
147
+
148
+ if len(defined_loads) == 0:
149
+ line_tank_pressure_calc = max([pressure for pressure in temp_tank.values()])
150
+
151
+ #print('line_tank_pressure_calc', line_tank_pressure_calc)
152
+ highest_dnv_tank_pressure = tank_name_obj[1].get_tank_dnv_minimum_pressure(load_factors[0].get(),
153
+ load_factors[1].get())
154
+ #print('highest_dnv_tank_pressure', highest_dnv_tank_pressure)
155
+ line_dnv_tank_pressure = tank_name_obj[1].get_line_pressure_from_max_pressure(highest_dnv_tank_pressure,
156
+ coord)
157
+ #print('line_dnv_tank_pressure', line_dnv_tank_pressure)
158
+ # if line_name_obj[0] == 'line29':
159
+ # print('Tank load to append is max( ',highest_tank_pressure_calc,highest_dnv_tank_pressure,')')
160
+ highest_tank_pressure = max(line_tank_pressure_calc,line_dnv_tank_pressure)
161
+ calc_load.append(-highest_tank_pressure if highest_tank_pressure else 0)
162
+ load_print.append('\nDNVGL-OS-C101 4.3.7 and 4.3.8 (Tank pressures) = '+ str(highest_tank_pressure)+'\n')
163
+ else:
164
+ pass
165
+ if print_it:
166
+ if len(calc_load) == 2:
167
+ load_print.append('\nRESULT: ' + str(round(calc_load[0], 1)) +' + '+
168
+ str(round(calc_load[1])) + ' = ' + str(round(sum(calc_load),1)) +'\n')
169
+ elif len(calc_load) == 1:
170
+ load_print.append(
171
+ '\nRESULT: ' + str(round(calc_load[0],1))+'\n')
172
+ else:
173
+ pass
174
+
175
+ load_print.append('------------------------------------------------------------------\n')
176
+ # if line_name_obj[0] == 'line12':
177
+ # print('end')
178
+ return [int(abs(sum(calc_load))), load_print]
179
+
180
+ def helper_slamming(defined_loads):
181
+
182
+ # calculate the defined loads
183
+ calc_load, load_print = [], ['',]
184
+ if len(defined_loads) != 0:
185
+ for load in defined_loads:
186
+ if load != None and load.get_load_condition() == 'slamming':
187
+ load_print.append('Slamming pressure: \n'+ str(load.get_calculated_pressure(0, 0, 'slamming'))+ ' Pa \n')
188
+ return [load.get_calculated_pressure(0, 0, 'slamming'), load_print]
189
+ return [None, ' ']
190
+
191
+
192
+ def helper_tank_test(line_name_obj, coord, defined_loads, load_condition,
193
+ defined_tanks, comb_name, acc, load_factors_all):
194
+ # calculate the defined loads
195
+ calc_load, load_print = [], ['',]
196
+ static_pressure, dynamic_pressure = 0, 0
197
+ line_name = line_name_obj[0]
198
+ structure_type = line_name_obj[1].get_structure_type()
199
+
200
+ if len(defined_loads) != 0:
201
+ for load in defined_loads:
202
+ if load != None:
203
+ load_factors = load_factors_all[(comb_name, line_name, load.get_name())]
204
+ # USE GET() (static,dyn, on/off)
205
+ if load_condition == load.get_load_condition():
206
+ static_pressure = (load_factors[2].get()) * (load_factors[0].get()) \
207
+ * load.get_calculated_pressure(coord, acc[0], structure_type)
208
+ dynamic_pressure = (load_factors[2].get()) * (load_factors[1].get()) \
209
+ * load.get_calculated_pressure(coord, acc[1], structure_type)
210
+ calc_load.append(static_pressure + dynamic_pressure)
211
+ if print_it:
212
+ load_print.append(
213
+ 'Tank test for: ' + load_condition[0] + '\n' + str(load_factors[2].get())+' * '+
214
+ str(load_factors[0].get()) +' * '+
215
+ str(round(load.get_calculated_pressure(coord, acc[0], structure_type),1)) + ' + ' +
216
+ str(round(dynamic_pressure)) + ' = ' + str(round(dynamic_pressure + static_pressure))+'\n')
217
+
218
+
219
+ # calculate the tank loads
220
+ temp_tank={}
221
+ if len(defined_tanks) != 0:
222
+
223
+ for tank_name_obj in defined_tanks:
224
+ temp_tank[tank_name_obj[0]] = []
225
+
226
+ for tank_name_obj in defined_tanks:
227
+ load_factors = load_factors_all[(comb_name, line_name, tank_name_obj[0])]
228
+ # if print_it:
229
+ # load_print.append('Tank test LF: '+ str(load_factors[0].get())+' '+str(load_factors[1].get())+' '+
230
+ # str(load_factors[2].get())+'\n')
231
+ # USE GET() (static,dyn, on/off)
232
+ overpress_lf = [1.3, 0] if load_factors[0].get() == 1.2 else [1, 0]
233
+ static_pressure = (load_factors[2].get()) * (load_factors[0].get())\
234
+ * tank_name_obj[1].get_calculated_pressure(coord, acc[0])\
235
+ +tank_name_obj[1].get_overpressure()*overpress_lf[0]
236
+ dynamic_pressure = (load_factors[2].get()) * (load_factors[1].get())\
237
+ * tank_name_obj[1].get_calculated_pressure(coord, acc[1])\
238
+ +tank_name_obj[1].get_overpressure()*overpress_lf[1]
239
+
240
+ temp_tank[tank_name_obj[0]].append((static_pressure + dynamic_pressure))
241
+ if print_it:
242
+ load_print.append(
243
+ 'Tank test for: ' + tank_name_obj[0] + '\n' + str(load_factors[2].get()) + ' * ' +
244
+ str(load_factors[0].get()) + ' * ' +
245
+ str(round(tank_name_obj[1].get_calculated_pressure(coord, acc[0]), 1)) + ' + ' +
246
+ str(tank_name_obj[1].get_overpressure()) +' * ' + str(overpress_lf[0]) +
247
+ ' = ' + str(round(dynamic_pressure + static_pressure)) + '\n')
248
+ # choosing the tank with the highest pressures
249
+ if len(defined_tanks) != 0:
250
+ highest_tank_pressure = max([temp_tank[tank[0]] for tank in defined_tanks])
251
+ calc_load.append(-highest_tank_pressure[0] if len(highest_tank_pressure) > 0 else 0)
252
+ else:
253
+ pass
254
+ return [int(abs(sum(calc_load))), load_print]
255
+
256
+ def helper_manual(line_name, comb_name,load_factors_all):
257
+ calc_load, load_print = [], ['',]
258
+ if (comb_name, line_name[0], 'manual') not in load_factors_all.keys():
259
+ return [0, 'Manual pressure: 0']
260
+ load_factors = load_factors_all[(comb_name, line_name[0], 'manual')]
261
+ man_press = load_factors[0].get() * load_factors[1].get() * load_factors[2].get()
262
+
263
+ if print_it:
264
+ load_print.append('Manual pressure:\n'+ str(load_factors[0].get())+' * '+ str(load_factors[1].get())+' * '+
265
+ str(load_factors[2].get()) + ' = '+ str(man_press) +'\n')
266
+ return [man_press, load_print]
267
+
268
+ def helper_read_section_file(files, obj = None, to_json = False, to_csv = None):
269
+ ''' Read a xml file. '''
270
+ import json
271
+ from xml.dom import minidom
272
+ to_return_final, to_return, return_csv = list(), dict(), list()
273
+ if type(files) != list:
274
+ files = [files,]
275
+ for file in files:
276
+ if file.endswith('xml'):
277
+ xmldoc = minidom.parse(file)
278
+ sectionlist = xmldoc.getElementsByTagName('section')
279
+ sec_types = ('unsymmetrical_i_section', 'l_section', 'bar_section')
280
+
281
+ for idx, sec_type in enumerate(sec_types):
282
+ sec_type_get = xmldoc.getElementsByTagName(sec_type)
283
+ if sec_types == []:
284
+ continue
285
+ for item, itemdata in zip(sectionlist, sec_type_get):
286
+ if sec_type == sec_types[0]:
287
+ stf_web_h, stf_web_thk = 'h', 'tw'
288
+ stf_flange_width, stf_flange_thk = 'bfbot', 'tfbot'
289
+ stiffener_type = 'T'
290
+ mult = 1/1000
291
+ elif sec_type == sec_types[1]:
292
+ stf_web_h, stf_web_thk = 'h', 'tw'
293
+ stf_flange_width, stf_flange_thk = 'b', 'tf'
294
+ stiffener_type = 'L'
295
+ mult = 1/1000
296
+ elif sec_type == sec_types[2]:
297
+ stf_web_h, stf_web_thk = 'h', 'b'
298
+ stf_flange_width, stf_flange_thk = None, None
299
+ stiffener_type = 'FB'
300
+ mult = 1 / 1000
301
+ section_name = item.getAttribute('name')
302
+ to_return[section_name] = {'stf_web_height': [float(itemdata.getAttribute(stf_web_h)) *mult, 'm'],
303
+ 'stf_web_thk': [float(itemdata.getAttribute(stf_web_thk)) *mult,'m'],
304
+ 'stf_flange_width': [0 if stf_flange_width is None else
305
+ float(itemdata.getAttribute(stf_flange_width)) *mult,'m'],
306
+ 'stf_flange_thk': [0 if stf_flange_thk is None else
307
+ float(itemdata.getAttribute(stf_flange_thk)) *mult, 'm'],
308
+ 'stf_type': [stiffener_type, '']}
309
+
310
+ return_csv.append([to_return[section_name][var][0] for var in ['stf_web_height', 'stf_web_thk',
311
+ 'stf_flange_width', 'stf_flange_thk',
312
+ 'stf_type']])
313
+ if to_json:
314
+ with open('sections.json', 'w') as file:
315
+ json.dump(to_return, file)
316
+ if to_csv:
317
+ with open('sections.csv', 'w', newline='') as file:
318
+ section_writer = csv.writer(file)
319
+ for line in return_csv:
320
+ section_writer.writerow(line)
321
+
322
+ elif file.endswith('json'):
323
+ with open(file, 'r') as json_file:
324
+ to_return = json.load(json_file)
325
+
326
+ elif file.endswith('csv'):
327
+ with open(file, 'r') as csv_file:
328
+ csv_reader = csv.reader(csv_file, delimiter=',')
329
+ for idx, section in enumerate(csv_reader):
330
+ if section[4] in ['L-bulb', 'bulb', 'hp']:
331
+ to_return[str(idx)] = {'stf_web_height': [float(section[0]) - float(section[3]), 'm'],
332
+ 'stf_web_thk': [float(section[1]),'m'],
333
+ 'stf_flange_width': [float(section[2]),'m'],
334
+ 'stf_flange_thk': [float(section[3]), 'm'],
335
+ 'stf_type': [section[4], '']}
336
+ else:
337
+ to_return[str(idx)] = {'stf_web_height': [float(section[0]), 'm'],
338
+ 'stf_web_thk': [float(section[1]),'m'],
339
+ 'stf_flange_width': [float(section[2]),'m'],
340
+ 'stf_flange_thk': [float(section[3]), 'm'],
341
+ 'stf_type': [section[4], '']}
342
+
343
+ if to_json:
344
+ with open('sections.json', 'w') as file:
345
+ json.dump(to_return, file)
346
+
347
+ if to_csv is not None:
348
+ with open(to_csv, 'w', newline = '') as file:
349
+ section_writer = csv.writer(file)
350
+ for line in return_csv:
351
+ section_writer.writerow(line)
352
+ if obj is not None: # This will return a modified object.
353
+ if type(obj) is not list:
354
+ obj = [obj, ]
355
+ append_list = [[],]
356
+ else:
357
+ append_list = [list() for dummy in obj]
358
+ else:
359
+ append_list = list()
360
+
361
+ for key, value in to_return.items():
362
+ if obj is not None: # This will return a modified object.
363
+ for idx, iter_obj in enumerate(obj):
364
+ new_obj = copy.deepcopy(iter_obj)
365
+ new_obj_prop = new_obj.get_structure_prop()
366
+ for prop_name, prop_val in value.items():
367
+ new_obj_prop[prop_name] = prop_val
368
+ new_obj.set_main_properties(new_obj_prop)
369
+ append_list[idx].append(new_obj)
370
+ else:
371
+ to_return_final.append(value)
372
+ if len(append_list) == 1:
373
+ to_return_final = append_list[0]
374
+ elif len(append_list) == 0:
375
+ pass
376
+ elif len(append_list) > 1:
377
+ to_return_final = append_list
378
+
379
+ return to_return_final
380
+
381
+ def open_example_file(root_path = None):
382
+ import os
383
+
384
+ if os.path.isfile('sections.csv'):
385
+ os.startfile('sections.csv')
386
+ else:
387
+ os.startfile(root_path + '/' + 'sections.csv')
388
+
389
+ def add_new_section(section_list, new_section):
390
+ ''' Checking if a section is already in the list. '''
391
+ existing_section = False
392
+
393
+ for section in section_list:
394
+
395
+ if section.__str__() == new_section.__str__():
396
+ existing_section = True
397
+
398
+ if existing_section == False:
399
+ # print('The new section', new_section)
400
+ # print('The section list', section_list)
401
+ section_list.append(new_section)
402
+
403
+ return section_list
404
+
405
+ def plot_weights(time_stamp = None, cog = None, structure = None, weight = None):
406
+ if __name__ == '__main__':
407
+ cog = [[22.15329254, 12.24742235],
408
+ [22.1937807, 12.1975691],
409
+ [22.24684556, 12.15423614],
410
+ [22.27489223, 12.09378247],
411
+ [22.29086617, 12.03458725],
412
+ [22.29559601, 11.97667798],
413
+ [22.58758899, 11.739118],
414
+ [22.34550004, 11.936077],
415
+ [22.39332625, 11.96360235],
416
+ [22.43016887, 11.99128875],
417
+ [22.29320631, 12.02004097],
418
+ [22.2458229, 11.99243978],
419
+ [22.20984338, 11.96499817]]
420
+ cog = np.array(cog)
421
+ structure = {'plates': [18.0, 25.0, 12.0, 20.0, 14.0, 30.0, 15.0],
422
+ 'beams': ['T_400_0x12_0__200_0x20_0', 'T_400_0x12_0__250_0x14_0', 'T_400_0x12_0__250_0x12_0',
423
+ 'T_400_0x12_0__200_0x18_0', 'T_400_0x12_0__150_0x20_0', 'T_500_0x12_0__150_0x20_0',
424
+ 'T_340_0x12_0__200_0x20_0', 'T_340_0x12_0__150_0x16_0', 'T_250_0x12_0__150_0x14_0',
425
+ 'T_450_0x12_0__150_0x20_0', 'T_375_0x12_0__150_0x18_0', 'T_500_0x12_0__150_0x25_0',
426
+ 'T_325_0x12_0__150_0x16_0', 'FB_250_0x18_0', 'FB_400_0x18_0',
427
+ 'T_350_0x12_0__150_0x20_0', 'T_320_0x12_0__150_0x20_0', 'T_300_0x12_0__150_0x20_0']}
428
+
429
+ time_stamp = [18920.477643045164, 18920.477684256162, 18920.477721255855, 18920.477761896746, 18920.477798285963,
430
+ 18920.477841150896, 18920.4778763735, 18920.477939357952, 18920.47800752034, 18920.47808087777,
431
+ 18920.478203353003, 18920.478237156338, 18920.47826686926]
432
+ weight = [0.97156037, 0.97553128, 0.979408, 0.97625964, 0.97319636, 0.97021818,
433
+ 1., 0.97518182, 0.97234545, 0.96950909, 0.97546545, 0.97830182,
434
+ 0.98113818]
435
+
436
+ import matplotlib.dates as mdate
437
+ from matplotlib import pyplot as plt
438
+ from matplotlib.gridspec import GridSpec
439
+
440
+ pl_and_bm = [['', ''] for dummy in range(max(len(list(structure.values())[0]), len(list(structure.values())[1])))]
441
+
442
+ for key, value in structure.items():
443
+ for idx, val in enumerate(value):
444
+ if key == 'plates':
445
+ pl_and_bm[idx][0] = str(val) + ' mm'
446
+ else:
447
+ pl_and_bm[idx][1] = val
448
+
449
+ fig = plt.figure(figsize=(14, 8))
450
+ gs = GridSpec(2, 3, figure=fig)
451
+
452
+ time_stamp = [mdate.date2num(val) for val in time_stamp]
453
+
454
+ ax3 = plt.subplot(gs[1, 0:2])
455
+ plt.plot(time_stamp, weight, 'tab:green')
456
+
457
+ ax1 = plt.subplot(gs[0, 0], sharex=ax3)
458
+ plt.plot(time_stamp, cog[:, 0])
459
+
460
+ ax2 = plt.subplot(gs[0, 1], sharex=ax3)
461
+ plt.plot(time_stamp, cog[:, 1], 'tab:orange')
462
+
463
+ ax4 = plt.subplot(gs[0:2, 2])
464
+ ax4.set_axis_off()
465
+ table1 = plt.table(cellText=pl_and_bm, colLabels = ['Plates in model', 'Beams in model'],loc='center')
466
+ table1.auto_set_column_width((0,1))
467
+ table1.scale(1,1.5)
468
+ # ax5 = plt.subplot(gs[0:2, 3])
469
+ # ax5.set_axis_off()
470
+ # table2 = plt.table(cellText=structure['beams'], colLabels = ['Beams in model'],loc='center')
471
+ # table2.scale(1,1.5)
472
+ # table2.auto_set_column_width(0)
473
+ # Choose your xtick format string
474
+ date_fmt = '%d-%m-%y %H:%M:%S'
475
+
476
+ # Use a DateFormatter to set the data to the correct format.
477
+ date_formatter = mdate.DateFormatter(date_fmt)
478
+ ax1.xaxis.set_major_formatter(date_formatter)
479
+ ax2.xaxis.set_major_formatter(date_formatter)
480
+ ax3.xaxis.set_major_formatter(date_formatter)
481
+ ax1.set_title('COG X')
482
+ ax2.set_title('COG Y')
483
+ ax3.set_title('Total weight / max(total weight)')
484
+
485
+ fig.suptitle('Developement of weight and COG')
486
+
487
+ # Sets the tick labels diagonal so they fit easier.
488
+ fig.autofmt_xdate()
489
+
490
+ plt.tight_layout()
491
+ plt.show()
492
+
493
+ def helper_cylinder_stress_to_force_to_stress(stresses = None, forces = None, geometry = None, shell_t = 0,
494
+ shell_radius = 0, shell_spacing = 0,
495
+ hw = 0, tw = 0, b = 0, tf = 0, CylinderAndCurvedPlate = None,
496
+ conical = False, psd = 0, cone_r1 = 0, cone_r2 = 0, cone_alpha = 0,
497
+ shell_lenght_l = 0):
498
+
499
+
500
+ A = 0 if geometry in [1, 2] else hw * tw + b * tf
501
+ eq_thk = shell_t if geometry in [1, 2] else shell_t + A/shell_spacing
502
+
503
+ Itot = CylinderAndCurvedPlate.get_Itot(hw=0 if geometry in [1, 2] else hw,
504
+ tw=0 if geometry in [1, 2] else tw,
505
+ b=0 if geometry in [1, 2] else b,
506
+ tf=0 if geometry in [1, 2] else tf,
507
+ r=shell_radius,
508
+ s=shell_spacing,
509
+ t=shell_t)
510
+
511
+ if forces is not None and stresses is None:
512
+ if not conical:
513
+ Nsd, Msd, Tsd, Qsd = forces
514
+ sasd = (Nsd / 2) / (math.pi * shell_radius * eq_thk) * 1000
515
+ smsd = (Msd/ Itot) * \
516
+ (shell_radius + shell_t / 2) * 1000000
517
+ tTsd = (Tsd* 10 ** 6) / (2 * math.pi * shell_t * math.pow(shell_radius, 2))
518
+ tQsd = Qsd / (math.pi * shell_radius * shell_t) * 1000
519
+ shsd = 0
520
+ return sasd, smsd, tTsd, tQsd, shsd
521
+ else:
522
+ Nsd, M1sd, M2sd, Tsd, Q1sd, Q2sd = forces
523
+ re = (cone_r1+cone_r2) / (2*math.cos(math.radians(cone_alpha)))
524
+ le = shell_lenght_l / math.cos(math.radians(cone_alpha))
525
+ te = shell_t *math.cos(math.radians(cone_alpha))
526
+ sasd = psd*re/2*te + Nsd/(2*math.pi*re*te) * 1000
527
+ smsd = ((M1sd*math.sin(math.radians(cone_alpha)) / (math.pi*math.pow(re,2)*te)) + \
528
+ (M2sd*math.cos(math.radians(cone_alpha)) / (math.pi*math.pow(re,2)*te))) * 1000000
529
+ shsd = psd*re/te
530
+ tTsd = Tsd/(2*math.pi*math.pow(re,2)*te)
531
+ tQsd = -(Q1sd*math.cos(math.radians(cone_alpha)) / (math.pi*re*te)) + \
532
+ (Q2sd*math.sin(math.radians(cone_alpha)) / (math.pi*re*te))
533
+ return sasd, smsd, tTsd, tQsd, shsd
534
+
535
+ else:
536
+ if not conical:
537
+ sasd, smsd, tTsd, tQsd, shsd = stresses
538
+ Nsd = (sasd * 2 * math.pi * shell_radius * eq_thk) / 1000
539
+ Msd = (smsd / (shell_radius * shell_t / 2)) * Itot / 1000000
540
+ Tsd = tTsd * 2 * math.pi * shell_t * math.pow(shell_radius, 2) / 1000000
541
+ Qsd = tQsd * math.pi * shell_radius * shell_t / 1000
542
+ else:
543
+ re = (cone_r1+cone_r2) / (2*math.cos(math.radians(cone_alpha)))
544
+ le = shell_lenght_l / math.cos(math.radians(cone_alpha))
545
+ te = shell_t *math.cos(math.radians(cone_alpha))
546
+ Itot = CylinderAndCurvedPlate.get_Itot(hw=0,
547
+ tw=0 ,
548
+ b=0 ,
549
+ tf=0,
550
+ r=re,
551
+ s=shell_spacing,
552
+ t=te)
553
+ sasd, smsd, tTsd, tQsd, shsd = stresses
554
+ Nsd = (sasd * 2 * math.pi * re * te) / 1000
555
+ Msd = (smsd / (re * te / 2)) * Itot / 1000000
556
+ Tsd = tTsd * 2 * math.pi * te * math.pow(re, 2) / 1000000
557
+ Qsd = tQsd * math.pi * re * te/ 1000
558
+
559
+ return Nsd, Msd, Tsd, Qsd, shsd
560
+
561
+
562
+ if __name__ == '__main__':
563
+ from tkinter import *
564
+
565
+
566
+
567
+ class AllTkinterWidgets:
568
+ def __init__(self, master):
569
+ frame = Frame(master, width=500, height=400, bd=1)
570
+ frame.pack()
571
+
572
+ iframe5 = Frame(frame, bd=2, relief=RAISED)
573
+ iframe5.pack(expand=1, fill=X, pady=10, padx=5)
574
+ c = Canvas(iframe5, bg='white', width=340, height=200)
575
+ c.pack()
576
+
577
+ height = 150
578
+ radius = 150
579
+ offset_oval = 30
580
+ start_x_cyl = 150
581
+ start_y_cyl = 20
582
+ coord1 = start_x_cyl, start_y_cyl, start_x_cyl + radius, offset_oval
583
+ coord2 = start_x_cyl, start_y_cyl + height, start_x_cyl + radius, offset_oval+ height
584
+
585
+ arc_1 = c.create_oval(coord1, width = 5, fill = 'grey90')
586
+ arc_2 = c.create_arc(coord2, extent = 180, start = 180,style=ARC, width = 3)
587
+
588
+ line1 = c.create_line(coord1[0], coord1[1]+offset_oval/4,
589
+ coord1[0], coord1[1]+height+offset_oval/4,
590
+ width = 3)
591
+ line2 = c.create_line(coord1[0]+radius, coord1[1]+offset_oval/4,
592
+ coord1[0]+radius, coord1[1]+height+offset_oval/4,
593
+ width = 3)
594
+ num_stf = 10
595
+ for line_num in range(1,num_stf,1):
596
+ angle = 180 - 180/(num_stf) *line_num
597
+ arc_x, arc_y = 1*math.cos(math.radians(angle)), 0.5*math.sin(math.radians(angle))
598
+ arc_x = (arc_x + 1)/2
599
+
600
+ line1 = c.create_line(coord1[0] + radius*arc_x,
601
+ coord1[1] +2*arc_y*offset_oval/3,
602
+ coord1[0] + radius*arc_x,
603
+ coord1[1] + height +2*arc_y*offset_oval/3,fill = 'blue')
604
+ num_ring_stiff = 5
605
+ for ring_stf in range(1,num_ring_stiff+1,1):
606
+ coord3 = coord1[0], coord1[1]+(height/(num_ring_stiff+1))*ring_stf, \
607
+ start_x_cyl +radius, coord1[3]+ (height/(num_ring_stiff+1))*ring_stf,
608
+ arc_2 = c.create_arc(coord3, extent=180, start=180, style=ARC, width=2,fill = 'orange', outline = 'orange')
609
+
610
+ num_ring_girder = 1
611
+ for ring_girder in range(1, num_ring_girder+1,1):
612
+ coord3 = coord1[0], coord1[1]+(height/(num_ring_girder+1))*ring_girder, \
613
+ start_x_cyl+ radius, coord1[3]+ (height/(num_ring_girder+1))*ring_girder,
614
+ arc_2 = c.create_arc(coord3, extent=180, start=180, style=ARC, width=4, fill = 'grey', outline = 'grey')
615
+
616
+ iframe5.pack(expand=1, fill=X, pady=10, padx=5)
617
+
618
+
619
+ root = Tk()
620
+ # root.option_add('*font', ('verdana', 10, 'bold'))
621
+ all = AllTkinterWidgets(root)
622
+ root.title('Tkinter Widgets')
623
+ root.mainloop()
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file