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,912 @@
1
+ #Making reports for the project
2
+
3
+ import time
4
+ from reportlab.lib.enums import TA_LEFT
5
+ from reportlab.platypus import Spacer
6
+ from reportlab.lib.styles import ParagraphStyle
7
+ from PIL import Image
8
+ from reportlab.lib.pagesizes import letter, A4, landscape
9
+ from reportlab.lib.styles import getSampleStyleSheet
10
+ from reportlab.lib.units import mm, inch
11
+ from reportlab.pdfgen import canvas
12
+ from reportlab.platypus import Image, Paragraph, Table
13
+ from time import strftime, gmtime
14
+ import os
15
+ from matplotlib import pyplot as plt
16
+ import matplotlib
17
+ cmap_sections = plt.get_cmap('jet')
18
+ from reportlab.platypus import SimpleDocTemplate, TableStyle
19
+ from reportlab.lib import colors
20
+ from matplotlib import colors as matplotlib_colors
21
+ import tkinter as tk
22
+
23
+ try:
24
+ import anystruct.example_data as test
25
+ import anystruct.helper as hlp
26
+ except ModuleNotFoundError:
27
+ import ANYstructure.anystruct.example_data as test
28
+ import ANYstructure.anystruct.helper as hlp
29
+
30
+
31
+
32
+ def create_report(input_data):
33
+ '''
34
+ This class uses the module REPORTLAB to generate a report.
35
+ :param line_obj_dict:
36
+ :type a dictionary
37
+ :return:
38
+ '''
39
+
40
+ Story = []
41
+
42
+ file_name = "Report_current_results.pdf"
43
+ doc = SimpleDocTemplate(file_name, pagesize=letter,
44
+ rightMargin=72, leftMargin=72,
45
+ topMargin=72, bottomMargin=18)
46
+
47
+ # logo = "canvas_screenshot.gif"
48
+ formatted_time = time.ctime()
49
+ # im = Image(logo, 5 * inch, 4 * inch)
50
+ # Story.append(im)
51
+ styles = getSampleStyleSheet()
52
+ styles.add(ParagraphStyle(name='Justify',alignment=TA_LEFT))
53
+ ptext = '<font size=12>%s</font>' % formatted_time
54
+ Story.append(Paragraph(ptext, styles["Normal"]))
55
+ Story.append(Spacer(1, 12))
56
+
57
+ # Create return address
58
+ ptext = '<font size=12>%s</font>' % 'The results for the structure is shown here'
59
+ Story.append(Paragraph(ptext, styles["Justify"]))
60
+ Story.append(Spacer(1, 3))
61
+ ptext = '----------------------------------------------------------------------------------------------------------'
62
+ Story.append(Paragraph(ptext, styles["Justify"]))
63
+ Story.append(Spacer(5, 3))
64
+
65
+ for line in input_data['lines'].keys():
66
+ struc_obj = input_data['calc_structure'][line]
67
+ fat_obj = input_data['calc_fatigue'][line]
68
+ pressure = input_data['pressures'][line]
69
+
70
+ ptext = '<font size=12>' + 'Results for: '+str(line) + '</font>'
71
+ Story.append(Paragraph(ptext, styles["Justify"]))
72
+
73
+ ptext = '<font size=10>'+'Plate thickness: '+ str(struc_obj.Plate.get_pl_thk()*1000)+ ' [mm], Stiffener spacing: '+\
74
+ str(struc_obj.get_s()*1000)+' [mm]'+'</font>'
75
+ Story.append(Paragraph(ptext, styles["Justify"]))
76
+
77
+ ptext = '<font size=10>'+'Stiffener: '+ str(struc_obj.Stiffener.get_web_h()*1000)+ 'x' + str(struc_obj.Stiffener.get_web_thk()*1000) \
78
+ + ' + ' + str(struc_obj.Stiffener.get_fl_w()*1000)+ 'x' + str(struc_obj.Stiffener.get_fl_thk()*1000) +'</font>'
79
+ Story.append(Paragraph(ptext, styles["Justify"]))
80
+
81
+ ptext = '<font size=10>'+struc_obj.get_report_stresses()+'</font>'
82
+ Story.append(Paragraph(ptext, styles["Justify"]))
83
+
84
+ ptext = '<font size=10>'+struc_obj.get_results_for_report()+'</font>'
85
+ Story.append(Paragraph(ptext, styles["Justify"]))
86
+
87
+ Story.append(Spacer(2, 3))
88
+ ptext = '<font size=12>END OF RESULTS</font>'
89
+ Story.append(Paragraph(ptext, styles["Justify"]))
90
+ my_canvas = canvas.Canvas(file_name)
91
+ my_canvas.line(0,0,200,200)
92
+ doc.build(Story, canvasmaker=my_canvas)
93
+
94
+ class LetterMaker(object):
95
+ """"""
96
+
97
+ def __init__(self, pdf_file, org, seconds, data):
98
+
99
+ self.c = canvas.Canvas(pdf_file, pagesize=A4)
100
+ self.styles = getSampleStyleSheet()
101
+ self.width, self.height = A4
102
+ self.organization = org
103
+ self.seconds = seconds
104
+ self.data = data
105
+ self.draw_lines()
106
+
107
+ def createDocument(self):
108
+ """"""
109
+ voffset = 100
110
+ user = os.getlogin()
111
+ time_now = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
112
+
113
+ # create return address
114
+ address = """<font size="12"><strong> ANYstructure report generator<br/></strong></font>""" + '<br/>' + \
115
+ """<font size="12"> User: </font>""" + '<font size="12">' + user + '</font>' + '<br/>' + '<br/>' + \
116
+ """<font size="12"> Time : </font>""" + '<font size="12">' + time_now + '</font>' + '<br/>'+ \
117
+ '<br/>'+'<font size="12">' + self.data._project_information.get('1.0', tk.END) + '</font>'
118
+ p = Paragraph(address, self.styles["Normal"])
119
+ # add a logo and size it
120
+ img_file_name = 'ANYstructure_logo.jpg'
121
+ if os.path.isfile('images/' + img_file_name):
122
+ file_path = 'images/' + img_file_name
123
+ else:
124
+ file_path = os.path.dirname(os.path.abspath(__file__)) + '/images/' + img_file_name
125
+ logo = Image(file_path)
126
+ logo.drawHeight = 1 * inch
127
+ logo.drawWidth = 2.5 * inch
128
+ data = [[p, logo]]
129
+ table = Table(data, colWidths=4 * inch)
130
+ table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP")])
131
+ table.wrapOn(self.c, self.width, self.height)
132
+ table.drawOn(self.c, *self.coord(18, 50, mm))
133
+
134
+ self.draw_lines()
135
+
136
+ ptext = '<font size="12" color = "blue"><strong>' + "Compartments: " + '</strong></font>'
137
+ self.createParagraph(ptext, 10, voffset + 85)
138
+ delta = 0
139
+ h_start = 130
140
+ if self.data._tank_dict != {}:
141
+ for name, obj in self.data._tank_dict.items():
142
+
143
+ ptext = '<font size="7" color = "black">' + 'Name: '+ name + ', content: ' \
144
+ + obj.get_content() + '</font>'
145
+ self.createParagraph(ptext, h_start, voffset + 100 + delta)
146
+
147
+ delta += 3
148
+ ptext = '<font size="7" color = "black">' + 'Min. elevation: ' + str(obj.get_lowest_elevation()) + \
149
+ ', Max. elevation: ' + str(obj.get_highest_elevation()) + '</font>'
150
+ self.createParagraph(ptext, h_start, voffset + 100 + delta)
151
+
152
+ delta += 3
153
+ ptext = '<font size="7" color = "black">' + 'Applied overpressure: ' + str(obj.get_overpressure()) + \
154
+ '</font>'
155
+ self.createParagraph(ptext, h_start, voffset + 100 + delta)
156
+
157
+ delta += 3
158
+ ptext = '<font size="7" color = "black">'+'(a_stat, a_dyn_loa, a_dyn_bal): ' + \
159
+ str(obj.get_accelerations()) + '</font>'
160
+ self.createParagraph(ptext, h_start, voffset + 100 + delta)
161
+ delta += 4
162
+ try:
163
+ self.c.drawImage('current_comps.png', 10,50, width=350, height=250)
164
+ except OSError:
165
+ self.c.drawImage('current_comps_NONE.png', 10, 50, width=350, height=250)
166
+
167
+ # insert body of letter
168
+
169
+ self.c.showPage()
170
+ ptext = '<font size="12" color = "blue"><strong>' + "Results for defined structure: " + '</strong></font>'
171
+ self.createParagraph(ptext, 10, 0)
172
+
173
+ delta = 140 if self.data._new_buckling_method.get() == 'DNV-RP-C201 - prescriptive' else 180
174
+ vpos = 950
175
+
176
+ for line in sorted(self.data._line_dict.keys()):
177
+ vpos -= delta
178
+
179
+ if line in self.data._line_to_struc.keys():
180
+ if self.data._line_to_struc[line][5] is None:
181
+ struc_obj = self.data._line_to_struc[line][0]
182
+ fo = self.data._line_to_struc[line][2]
183
+ pressure = self.data.get_highest_pressure(line)['normal']/1000
184
+ textobject = self.c.beginText()
185
+ textobject.setTextOrigin(30,vpos)
186
+ textobject.setFont("Helvetica-Oblique", 10)
187
+ textobject.textLine('*********** '+line+' ***********')
188
+ textobject.textLine('Plate thickness: '+ str(struc_obj.Plate.get_pl_thk()*1000)+ ' [mm] '
189
+ 'Stiffener spacing: '+
190
+ str(struc_obj.Plate.get_s()*1000)+' [mm]'+ ' Span: '+
191
+ str(round(struc_obj.Plate.span,4))
192
+ + ' [m]')
193
+ if struc_obj.Stiffener is not None:
194
+ textobject.textLine('Stiffener: '+ str(struc_obj.Stiffener.get_web_h()*1000)+ 'x' +
195
+ str(struc_obj.Stiffener.get_web_thk()*1000)
196
+ + ' + ' + str(struc_obj.Stiffener.get_fl_w()*1000)+ 'x' +
197
+ str(struc_obj.Stiffener.get_fl_thk()*1000))
198
+
199
+ textobject.textLine('Fixation paramters: kps: = '+str(struc_obj.Plate.get_kps())+ ' kpp = '
200
+ + str(struc_obj.Plate.get_kpp())+
201
+ ', Bending moment factors km1/km2/km3 (support/field/support)' + ' = '+
202
+ str(int(struc_obj.Plate.get_km1()))+'/'+
203
+ str(int(struc_obj.Plate.get_km2()))+'/'+
204
+ str(int(struc_obj.Plate.get_km3())))
205
+ textobject.textLine('Defined stresses [MPa]: sigma_x1 = '+str(struc_obj.Plate.sigma_x1)+
206
+ ' sigma_x2 = ' + str(struc_obj.Plate.sigma_x2) +
207
+ ' sigma_y1 = '+ str(struc_obj.Plate.sigma_y1) +
208
+ ' sigma_y2 = '+ str(struc_obj.Plate.sigma_y2) +
209
+ ' tau_xy = ' + str(struc_obj.Plate.tau_xy))
210
+ textobject.textLine('ULS max pressure for line: '+ str(round(pressure,2)*1000)
211
+ + ' []'+' Pressure applied at: '+struc_obj.overpressure_side)
212
+
213
+ if fo is not None:
214
+ textobject.textLine('Fatigue pressure [Pa]: '+' p_int:'+' loaded/ballast/part = '
215
+ + str(round(self.data.get_color_and_calc_state()['pressure_fls'][line]['p_int']['loaded'],0))
216
+ +'/'+str(round(self.data.get_color_and_calc_state()['pressure_fls'][line]['p_int']['ballast'],0))
217
+ +'/'+str(round(self.data.get_color_and_calc_state()['pressure_fls'][line]['p_int']['part'],0))
218
+ + ' p_ext:'+' loaded/ballast/part = '+
219
+ str(round(self.data.get_color_and_calc_state()['pressure_fls'][line]['p_ext']['loaded'],0))
220
+ +'/'+str(round(self.data.get_color_and_calc_state()['pressure_fls'][line]['p_ext']['ballast'],0))
221
+ +'/'+str(round(self.data.get_color_and_calc_state()['pressure_fls'][line]['p_ext']['part'],0)))
222
+ else:
223
+ textobject.textLine(' Fatigue pressure: No pressures defined')
224
+
225
+ textobject.setFillColor('red') if self.data.get_color_and_calc_state()['colors'][line]['section'] == 'red' \
226
+ else textobject.setFillColor('black')
227
+
228
+ textobject.textLine('Section modulus: '+str(int(min(self.data.get_color_and_calc_state()['section_modulus'][line]['sec_mod'])
229
+ *1000**3))+ ' [mm3]'+' Min. section modulus: '+
230
+ str(int(self.data.get_color_and_calc_state()['section_modulus'][line]['min_sec_mod']*1000**3))+' [mm3]'+
231
+ ' -> ' + 'OK' if int(min(self.data.get_color_and_calc_state()['section_modulus'][line]['sec_mod'])*1000**3) >=
232
+ int(self.data.get_color_and_calc_state()['section_modulus'][line]['min_sec_mod']*1000**3)
233
+ else 'Section modulus: '+str(int(min(self.data.get_color_and_calc_state()['section_modulus'][line]['sec_mod'])
234
+ *1000**3))+ ' [mm3]'+ ' Min. section modulus: '+
235
+ str(int(self.data.get_color_and_calc_state()['section_modulus'][line]['min_sec_mod']*1000**3))+' [mm3]'+
236
+ ' -> ' + 'NOT OK')
237
+ textobject.setFillColor('black')
238
+ textobject.setFillColor('red') if self.data.get_color_and_calc_state()['colors'][line]['thickness'] == 'red' \
239
+ else textobject.setFillColor('black')
240
+ textobject.textLine('Min plate thickness: '+
241
+ str(round(self.data.get_color_and_calc_state()['thickness'][line]['min_thk'],2)) + ' [mm] '
242
+ ' -> ' +
243
+ 'OK' if struc_obj.Plate.get_pl_thk()*1000 >=
244
+ self.data.get_color_and_calc_state()['thickness'][line]['min_thk'] else
245
+ 'Min plate thickness: '+ str(round(
246
+ self.data.get_color_and_calc_state()['thickness'][line]['min_thk'],2)) + ' [mm] '
247
+ ' -> '+'NOT OK')
248
+ textobject.setFillColor('black')
249
+ textobject.setFillColor('red') if self.data.get_color_and_calc_state()['colors'][line]['shear'] == 'red' \
250
+ else textobject.setFillColor('black')
251
+ textobject.textLine('Shear area: '+str(int(self.data.get_color_and_calc_state()['shear_area'][line]['shear_area']*1000**2))+' [mm2] '+
252
+ ' Min shear area: '+str(int(self.data.get_color_and_calc_state()['shear_area'][line]['min_shear_area']*1000**2))
253
+ + ' [mm2] ' +
254
+ ' -> ' + 'OK' if self.data.get_color_and_calc_state()['shear_area'][line]['shear_area'] >=
255
+ self.data.get_color_and_calc_state()['shear_area'][line]['min_shear_area']
256
+ else 'Shear area: '+str(int(self.data.get_color_and_calc_state()['shear_area'][line]['shear_area']*1000**2))+
257
+ ' [mm2] ' +
258
+ ' Min shear area: '+str(int(self.data.get_color_and_calc_state()['shear_area'][line]['min_shear_area']*1000**2))
259
+ + ' [mm2] ' + ' -> ' + 'NOT OK')
260
+ textobject.setFillColor('black')
261
+ if self.data._new_buckling_method.get() == 'DNV-RP-C201 - prescriptive':
262
+ textobject.setFillColor('red') if self.data.get_color_and_calc_state()['colors'][line]['buckling'] == 'red' \
263
+ else textobject.setFillColor('black')
264
+ buc_util = list()
265
+ for key, val in self.data.get_color_and_calc_state()['buckling'][line].items():
266
+ for uf in val.values():
267
+ if type(uf) == list:
268
+ buc_util.append(uf[0])
269
+ buc_util.append(uf[1])
270
+ else:
271
+ buc_util.append(uf)
272
+
273
+ textobject.textLine('Highest buckling utilization DNV-RP-C203: '+
274
+ str(round(max(buc_util),2))+
275
+ ' -> '+'OK' if max(buc_util) < 1 else
276
+ 'Highest buckling utilization DNV-RP-C203: '+
277
+ str(round(max(buc_util),2))+' -> '+'NOT OK')
278
+ elif self.data._new_buckling_method.get() == 'DNV PULS':
279
+ if self.data._PULS_results is not None:
280
+ puls_method = self.data._line_to_struc[line][0].Plate.get_puls_method()
281
+ textobject.textLine('PULS results using '+str(puls_method) + 'utilization with acceptance '+
282
+ str(self.data._PULS_results.puls_acceptance))
283
+ if line in self.data._PULS_results.get_run_results().keys():
284
+ puls_buckling = self.data._PULS_results.get_run_results()[line]['Buckling strength']['Actual usage Factor'][0]
285
+ puls_ultimate = self.data._PULS_results.get_run_results()[line]['Ultimate capacity']['Actual usage Factor'][0]
286
+ if puls_buckling is not None:
287
+ if puls_method == 'buckling' and puls_buckling/self.data._PULS_results.puls_acceptance > 1:
288
+ textobject.setFillColor('red')
289
+ textobject.textLine('PULS buckling utilization = ' + str(puls_buckling))
290
+ textobject.setFillColor('black')
291
+ if puls_ultimate is not None:
292
+ if puls_method == 'ultimate' and puls_ultimate/self.data._PULS_results.puls_acceptance > 1:
293
+ textobject.setFillColor('red')
294
+ textobject.textLine('PULS ultimate utilization = ' + str(puls_ultimate))
295
+ textobject.setFillColor('black')
296
+
297
+ else:
298
+ puls_method = self.data._line_to_struc[line][0].Plate.get_puls_method()
299
+ textobject.textLine('ML-CL results using '+str(puls_method) + 'utilization with acceptance 0.87')
300
+ if line in self.data._PULS_results.get_run_results().keys():
301
+ ml_buckling = self.data.get_color_and_calc_state()['ML buckling class'][line]['buckling']
302
+ ml_ultimate = self.data.get_color_and_calc_state()['ML buckling class'][line]['ultimate']
303
+ color_ml_buc = self.data.get_color_and_calc_state()['ML buckling colors'][line]['buckling']
304
+ color_ml_ult = self.data.get_color_and_calc_state()['ML buckling colors'][line]['ultimate']
305
+ color_csr = self.data.get_color_and_calc_state()['ML buckling colors'][line]['CSR requirement']
306
+
307
+ if puls_method == 'buckling':
308
+ textobject.setFillColor('red' if color_ml_buc == 'red' else 'black')
309
+ textobject.textLine('Buckling ML-CL results: ' + self.data._ML_classes[ml_buckling])
310
+ textobject.setFillColor('black')
311
+ if puls_method == 'ultimate':
312
+ textobject.setFillColor('red' if color_ml_ult == 'red' else 'black')
313
+ textobject.textLine('Ultimate ML-CL result: ' + self.data._ML_classes[ml_ultimate])
314
+ textobject.setFillColor('red' if color_csr == 'red' else 'black')
315
+ textobject.textLine('CSR tank requirement (stiffener): ' + 'OK' if color_csr == 'green'
316
+ else 'red')
317
+ textobject.setFillColor('black')
318
+
319
+ textobject.setFillColor('black')
320
+ textobject.setFillColor('red') if self.data.get_color_and_calc_state()['colors'][line]['fatigue'] == 'red' \
321
+ else textobject.setFillColor('black')
322
+ if self.data.get_color_and_calc_state()['fatigue'][line]['damage'] is not None:
323
+ textobject.textLine('Fatigue (plate/stiffeners) utilization: '+
324
+ str(round(self.data.get_color_and_calc_state()['fatigue'][line]['damage'],2))+ ' * DFF('+
325
+ str(self.data.get_color_and_calc_state()['fatigue'][line]['dff']) + ') = ' +
326
+ str(round(self.data.get_color_and_calc_state()['fatigue'][line]['damage']*
327
+ self.data.get_color_and_calc_state()['fatigue'][line]['dff'],2)) + ' (SN-curve = '+
328
+ self.data.get_color_and_calc_state()['fatigue'][line]['curve']+')')
329
+
330
+ else:
331
+ textobject.textLine('No fatigue results')
332
+
333
+ # textobject.textLine('Utilization percentage (highest calculated): '+
334
+ # str(int(max(self.data.get_color_and_calc_state()['utilization'][line].values())*100))+ '%')
335
+
336
+ textobject.setFillColor('black')
337
+ self.c.drawText(textobject)
338
+ vpos -= 10
339
+ else:
340
+ cyl_obj = self.data._line_to_struc[line][5]
341
+ textobject = self.c.beginText()
342
+ textobject.setTextOrigin(30, vpos)
343
+ textobject.setFont("Helvetica-Oblique", 10)
344
+ textobject.textLine('*********** ' + line + ' ***********')
345
+ textobject.textLine('Cylinder radius: ' + str(round(cyl_obj.ShellObj.radius*1000,2)) +
346
+ ' mm , thickness: ' +str(round(cyl_obj.ShellObj.thk*1000,2)) + ' mm')
347
+ textobject.textLine('Longitudinal stiffener: ' + cyl_obj.LongStfObj.get_beam_string())
348
+ textobject.textLine('Ring stiffener: ' + cyl_obj.LongStfObj.get_beam_string())
349
+ textobject.textLine('Heavy ring girder: ' + cyl_obj.LongStfObj.get_beam_string())
350
+ textobject.textLine(
351
+ 'Dist. between rings/length, l: ' + str(round(cyl_obj.ShellObj.dist_between_rings, 1)))
352
+ textobject.textLine(
353
+ 'Lenght of shell, L: ' + str(round(cyl_obj.ShellObj.length_of_shell, 1)) + ' '
354
+ +'Total cyl. lenght, Lc: ' + str(round(cyl_obj.ShellObj.tot_cyl_length, 1)))
355
+
356
+ results = cyl_obj.get_utilization_factors()
357
+ textobject.textLine('Design axial stress/force: ' + str(cyl_obj.sasd / 1e6) + ' MPa')
358
+ textobject.textLine('Design bending stress/moment: ' + str(cyl_obj.smsd / 1e6) + ' MPa')
359
+ textobject.textLine('Design tosional stress/moment: ' + str(cyl_obj.tTsd / 1e6) + ' MPa')
360
+ textobject.textLine('Design shear stress/force: ' + str(cyl_obj.tQsd / 1e6) + ' MPa')
361
+ textobject.textLine('Design lateral pressure ' + str(cyl_obj.psd / 1e6) + ' MPa' )
362
+ textobject.textLine('Additional hoop stress ' + str(cyl_obj.shsd / 1e6) + ' MPa')
363
+ vpos -= 40
364
+ for key, value in results.items():
365
+ if key in ['Weight', 'Need to check column buckling']:
366
+ continue
367
+ if key not in ['Stiffener check', 'Stiffener check detailed']:
368
+ text_key = key
369
+ if key == 'Column stability check':
370
+ if results['Need to check column buckling'] == False:
371
+ continue
372
+ uf_text = 'N/A' if value is None else 'OK' if value else 'Not ok'
373
+ else:
374
+ uf_text = 'N/A' if value is None else str(round(value, 2))
375
+ if value is None:
376
+ uf_col = 'grey'
377
+ else:
378
+ uf_col = 'red' if any([value > 1, value == False]) else 'green'
379
+ textobject.setFillColor(uf_col)
380
+ textobject.textLine(text_key + ' : UF = ' + uf_text)
381
+ textobject.setFillColor('black')
382
+ elif key == 'Stiffener check':
383
+ if value is not None:
384
+ textobject.textLine('Stiffener requirement checks:')
385
+ stf_type_all = ''
386
+ for stf_type, chk_bool in value.items():
387
+ chk_text = 'OK' if chk_bool == True else 'Not OK' if chk_bool == False else 'N/A'
388
+ stf_type_all += stf_type + ' : ' + chk_text + ' '
389
+ textobject.textLine(stf_type_all)
390
+ vpos -= 10
391
+
392
+ self.c.drawText(textobject)
393
+ vpos += 10
394
+ else:
395
+ textobject.setFont("Helvetica-Oblique", 10)
396
+ textobject.textLine('*********** '+line+' ***********')
397
+ textobject.textLine('(no structural properties defined)')
398
+ if vpos <= 290:
399
+ self.c.showPage()
400
+ vpos = 950
401
+
402
+ # ----------------------------------------------------------------------
403
+ self.c.showPage()
404
+ self.draw_lines(draw_type='section')
405
+ self.c.showPage()
406
+ self.draw_lines(draw_type='plate')
407
+ self.c.showPage()
408
+ self.draw_lines(draw_type='pressure')
409
+ self.c.showPage()
410
+ self.draw_lines(draw_type='utilization')
411
+ self.c.showPage()
412
+ self.draw_lines(draw_type='sigma x')
413
+ self.c.showPage()
414
+ self.draw_lines(draw_type='sigma y1')
415
+ self.c.showPage()
416
+ self.draw_lines(draw_type='sigma y2')
417
+ self.c.showPage()
418
+ self.draw_lines(draw_type='tau xy')
419
+ self.c.showPage()
420
+ self.draw_lines(draw_type='structure type')
421
+ self.c.showPage()
422
+
423
+ idx, new = 0, False
424
+ for load_name in self.data._load_dict.keys():
425
+ self.draw_lines(draw_type=None, load_idx_name = [idx % 3, load_name])
426
+ if idx % 3 == 2:
427
+ self.c.showPage()
428
+ idx += 1
429
+
430
+
431
+ def draw_lines(self, draw_type = 'UF', load_idx_name = None):
432
+ '''
433
+ Draw the defined lines.
434
+ :return:
435
+ '''
436
+
437
+ points = self.data._point_dict
438
+ lines = self.data._line_dict
439
+ if self.data._new_buckling_method.get() == 'DNV-RP-C201 - prescriptive':
440
+ colors = self.data.get_color_and_calc_state()['colors']
441
+ elif self.data._new_buckling_method.get() == 'DNV PULS':
442
+ colors = self.data.get_color_and_calc_state()['PULS colors']
443
+ else:
444
+ colors = self.data.get_color_and_calc_state()['ML buckling colors']
445
+
446
+ highest_y = max([coord[1] for coord in points.values()])
447
+ highest_x = max([coord[0] for coord in points.values()])
448
+
449
+ if any([highest_x == 0, highest_y == 0]):
450
+ scale = 10
451
+ elif load_idx_name is not None:
452
+ scale = 5
453
+ else:
454
+ scale = min(500/highest_y, 500/highest_x, 10)
455
+ if draw_type == 'UF':
456
+ origo = (50,350)
457
+ elif load_idx_name is not None:
458
+ origo = (50, 600 - 200*load_idx_name[0])
459
+ else:
460
+ origo = (50, 450)
461
+ self.c.setLineWidth(2)
462
+ self.c.setStrokeColor('red')
463
+ idx, drawed_data = 0, list()
464
+ all_line_data = self.data.get_color_and_calc_state()
465
+ for line, pt in lines.items():
466
+ if line not in list(self.data._line_to_struc.keys()):
467
+ continue
468
+ if draw_type == 'UF':
469
+ if self.data._new_buckling_method.get() == 'DNV-RP-C201 - prescriptive':
470
+ try:
471
+ self.c.setStrokeColor('red' if 'red' in colors[line].values() else 'green')
472
+ except KeyError:
473
+ self.c.setStrokeColor('black')
474
+ elif self.data._new_buckling_method.get() == 'DNV PULS':
475
+ try:
476
+ method = self.data._line_to_struc[line][0].Plate.get_puls_method()
477
+ if self.data._PULS_results is not None:
478
+ util = self.data._PULS_results.get_utilization(line, method, self.data._new_puls_uf.get())
479
+ if util is not None:
480
+ self.c.setStrokeColor('red' if util > 1 else 'green')
481
+ except KeyError:
482
+ self.c.setStrokeColor('black')
483
+ else:
484
+
485
+ method = self.data._line_to_struc[line][0].Plate.get_puls_method()
486
+ self.c.setStrokeColor(colors[line][method])
487
+
488
+ elif draw_type == 'section' and self.data._line_to_struc[line][0].Stiffener is not None:
489
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['section'])
490
+ if self.data._line_to_struc[line][0].Stiffener.get_beam_string() not in drawed_data:
491
+ textobject = self.c.beginText()
492
+ if 400 - 20 * idx > 20:
493
+ textobject.setTextOrigin(50, 400 - 20 * idx)
494
+ else:
495
+ textobject.setTextOrigin(300, 400 - 20 * idx)
496
+ textobject.setFillColor(all_line_data['color code']['lines'][line]['section'])
497
+ textobject.setFont("Helvetica-Oblique", 10)
498
+ textobject.textLine(self.data._line_to_struc[line][0].Stiffener.get_beam_string())
499
+ self.c.drawText(textobject)
500
+ drawed_data.append(self.data._line_to_struc[line][0].Stiffener.get_beam_string())
501
+ idx += 1
502
+ elif draw_type == 'plate':
503
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['plate'])
504
+ elif draw_type == 'pressure':
505
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['pressure color'])
506
+ elif draw_type == 'utilization':
507
+ if self.data._new_buckling_method.get() == 'DNV-RP-C201 - prescriptive':
508
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['rp uf color'])
509
+ elif self.data._new_buckling_method.get() == 'DNV PULS':
510
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['PULS uf color'])
511
+ else:
512
+ puls_method = self.data._line_to_struc[line][0].Plate.get_puls_method()
513
+ self.c.setStrokeColor(matplotlib_colors.rgb2hex(all_line_data['ML buckling colors'][line][puls_method]))
514
+
515
+ elif draw_type == 'sigma x':
516
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['sigma x'])
517
+ elif draw_type == 'sigma y1':
518
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['sigma y1'])
519
+ elif draw_type == 'sigma y2':
520
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['sigma y2'])
521
+ elif draw_type == 'tau xy':
522
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['tau xy'])
523
+ elif draw_type == 'structure type':
524
+ self.c.setStrokeColor(all_line_data['color code']['lines'][line]['structure type'])
525
+ elif load_idx_name is not None:
526
+ points = self.data._point_dict
527
+ highest_y = max([coord[1] for coord in points.values()])
528
+ highest_x = max([coord[0] for coord in points.values()])
529
+
530
+ if any([highest_x == 0, highest_y == 0]):
531
+ scale = 10
532
+ else:
533
+ scale = min(180 / highest_y, 300 / highest_x, 10)
534
+ if line in self.data._load_dict[load_idx_name[1]][1]:
535
+ self.c.setStrokeColor('orange')
536
+ else:
537
+ self.c.setStrokeColor('black')
538
+
539
+ x1, y1 = points['point'+str(pt[0])][0] * scale + origo[0], \
540
+ points['point'+str(pt[0])][1] * scale + origo[1]
541
+ x2, y2 = points['point'+str(pt[1])][0] * scale + origo[0], \
542
+ points['point'+str(pt[1])][1] * scale + origo[1]
543
+ self.c.line(x1,y1,x2,y2)
544
+ if load_idx_name is None:
545
+ textobject = self.c.beginText()
546
+ textobject.setTextOrigin(x1+(x2-x1)*0.5-5, y1 + (y2-y1)*0.5+2 )
547
+ textobject.setFont("Helvetica-Oblique", 9)
548
+ textobject.textLine(str(hlp.get_num(line)))
549
+ self.c.drawText(textobject)
550
+
551
+ if draw_type == 'UF':
552
+ pass
553
+ elif draw_type == 'section':
554
+ textobject = self.c.beginText()
555
+ textobject.setTextOrigin(50,800)
556
+ textobject.setFont("Helvetica-Oblique", 15)
557
+ textobject.setFillColor('black')
558
+ textobject.textLine('Model beam section properties')
559
+ self.c.drawText(textobject)
560
+ elif draw_type == 'plate':
561
+ textobject = self.c.beginText()
562
+ textobject.setTextOrigin(50, 800)
563
+ textobject.setFillColor('black')
564
+ textobject.setFont("Helvetica-Oblique", 15)
565
+ textobject.textLine('Model plate thicknesses')
566
+ self.c.drawText(textobject)
567
+ all_thicknesses =self.data.get_color_and_calc_state()['color code']['all thicknesses']
568
+ for idx, thk in enumerate(all_thicknesses):
569
+ textobject = self.c.beginText()
570
+ if 400 - 20 * idx > 20:
571
+ textobject.setTextOrigin(50, 400 - 20 * idx)
572
+ else:
573
+ textobject.setTextOrigin(300, 400 - 20 * idx)
574
+
575
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(all_thicknesses.index(thk)/
576
+ len(all_thicknesses))))
577
+ textobject.setFont("Helvetica-Oblique", 10)
578
+ textobject.textLine(str(thk*1000) + ' mm')
579
+ self.c.drawText(textobject)
580
+ elif draw_type == 'pressure':
581
+ textobject = self.c.beginText()
582
+ textobject.setTextOrigin(50, 800)
583
+ textobject.setFillColor('black')
584
+ textobject.setFont("Helvetica-Oblique", 15)
585
+ textobject.textLine('Highest pressures for lines in model')
586
+ self.c.drawText(textobject)
587
+ idx = 0
588
+
589
+ pressure_map =self.data.get_color_and_calc_state()['color code']['pressure map']
590
+ for press in pressure_map:
591
+ textobject = self.c.beginText()
592
+ if 400 - 20 * idx > 20:
593
+ textobject.setTextOrigin(50, 400 - 20 * idx)
594
+ else:
595
+ textobject.setTextOrigin(300, 400 - 20 * idx)
596
+
597
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(list(pressure_map).index(press)/
598
+ len(list(pressure_map)))))
599
+ textobject.setFont("Helvetica-Oblique", 10)
600
+ textobject.textLine(str(press))
601
+ self.c.drawText(textobject)
602
+ drawed_data.append(press)
603
+ idx += 1
604
+ elif draw_type == 'utilization':
605
+ textobject = self.c.beginText()
606
+ textobject.setTextOrigin(50, 800)
607
+ textobject.setFillColor('black')
608
+ textobject.setFont("Helvetica-Oblique", 12)
609
+ if self.data._new_buckling_method.get() == 'DNV-RP-C201 - prescriptive':
610
+ this_text = 'DNV-RP-C201 Buckling Strength of Plated Structures'
611
+ elif self.data._new_buckling_method.get() == 'DNV PULS':
612
+ this_text = 'Utilization factors (max of all checks) - PULS (Panel Ultimate Limit State)'
613
+ else:
614
+ this_text = 'ML-CL utilization factors not avaliable. ML-CLassifier only shows ok or not ok.'
615
+
616
+ textobject.textLine(this_text)
617
+ self.c.drawText(textobject)
618
+
619
+ if self.data._new_buckling_method.get() == 'DNV-RP-C201 - prescriptive':
620
+ all_utils = all_line_data['color code']['utilization map']
621
+ elif self.data._new_buckling_method.get() == 'DNV PULS':
622
+ all_utils = all_line_data['color code']['PULS utilization map']
623
+ else:
624
+ all_utils = list()
625
+
626
+ for idx, uf in enumerate(all_utils):
627
+ textobject = self.c.beginText()
628
+ if 400 - 20 * idx > 20:
629
+ textobject.setTextOrigin(50, 400 - 20 * idx)
630
+ else:
631
+ textobject.setTextOrigin(300, 400 - 20 * idx)
632
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(uf)))
633
+ textobject.setFont("Helvetica-Oblique", 10)
634
+ textobject.textLine(str('UF = ' +str(round(uf,1))))
635
+ self.c.drawText(textobject)
636
+ elif draw_type == 'structure type':
637
+ textobject = self.c.beginText()
638
+ textobject.setTextOrigin(50,800)
639
+ textobject.setFont("Helvetica-Oblique", 15)
640
+ textobject.setFillColor('black')
641
+ textobject.textLine('Structure types')
642
+ self.c.drawText(textobject)
643
+ for idx, value in enumerate(list(all_line_data['color code']['structure types map'])):
644
+ textobject = self.c.beginText()
645
+ if 400 - 20 * idx > 20:
646
+ textobject.setTextOrigin(50, 400 - 20 * idx)
647
+ else:
648
+ textobject.setTextOrigin(300, 400 - 20 * idx)
649
+
650
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(
651
+ list(all_line_data['color code']['structure types map']).index(value)/
652
+ len(list(all_line_data['color code']['structure types map'])))))
653
+ textobject.setFont("Helvetica-Oblique", 10)
654
+ textobject.textLine(str(value))
655
+ self.c.drawText(textobject)
656
+ drawed_data.append(value)
657
+ elif draw_type == 'sigma x':
658
+ textobject = self.c.beginText()
659
+ textobject.setTextOrigin(50,800)
660
+ textobject.setFont("Helvetica-Oblique", 15)
661
+ textobject.setFillColor('black')
662
+ textobject.textLine('Global stresses - sigma x')
663
+ self.c.drawText(textobject)
664
+ for idx, value in enumerate(list(all_line_data['color code']['sigma x map'])):
665
+ textobject = self.c.beginText()
666
+ if 400 - 20 * idx > 20:
667
+ textobject.setTextOrigin(50, 400 - 20 * idx)
668
+ else:
669
+ textobject.setTextOrigin(300, 400 - 20 * idx)
670
+
671
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(
672
+ list(all_line_data['color code']['sigma x map']).index(value)/
673
+ len(list(all_line_data['color code']['sigma x map'])))))
674
+ textobject.setFont("Helvetica-Oblique", 10)
675
+ textobject.textLine(str(value))
676
+ self.c.drawText(textobject)
677
+ drawed_data.append(value)
678
+ elif draw_type == 'sigma y1':
679
+ textobject = self.c.beginText()
680
+ textobject.setTextOrigin(50,800)
681
+ textobject.setFont("Helvetica-Oblique", 15)
682
+ textobject.setFillColor('black')
683
+ textobject.textLine('Global stresses - sigma y1')
684
+ self.c.drawText(textobject)
685
+ for idx, value in enumerate(list(all_line_data['color code']['sigma y1 map'])):
686
+ textobject = self.c.beginText()
687
+ if 400 - 20 * idx > 20:
688
+ textobject.setTextOrigin(50, 400 - 20 * idx)
689
+ else:
690
+ textobject.setTextOrigin(300, 400 - 20 * idx)
691
+
692
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(
693
+ list(all_line_data['color code']['sigma y1 map']).index(value)/
694
+ len(list(all_line_data['color code']['sigma y1 map'])))))
695
+ textobject.setFont("Helvetica-Oblique", 10)
696
+ textobject.textLine(str(value))
697
+ self.c.drawText(textobject)
698
+ drawed_data.append(value)
699
+ elif draw_type == 'sigma y2':
700
+ textobject = self.c.beginText()
701
+ textobject.setTextOrigin(50,800)
702
+ textobject.setFont("Helvetica-Oblique", 15)
703
+ textobject.setFillColor('black')
704
+ textobject.textLine('Global stresses - sigma y2')
705
+ self.c.drawText(textobject)
706
+ for idx, value in enumerate(list(all_line_data['color code']['sigma y2 map'])):
707
+ textobject = self.c.beginText()
708
+ if 400 - 20 * idx > 20:
709
+ textobject.setTextOrigin(50, 400 - 20 * idx)
710
+ else:
711
+ textobject.setTextOrigin(300, 400 - 20 * idx)
712
+
713
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(
714
+ list(all_line_data['color code']['sigma y2 map']).index(value)/
715
+ len(list(all_line_data['color code']['sigma y2 map'])))))
716
+ textobject.setFont("Helvetica-Oblique", 10)
717
+ textobject.textLine(str(value))
718
+ self.c.drawText(textobject)
719
+ drawed_data.append(value)
720
+ elif draw_type == 'tau xy':
721
+ textobject = self.c.beginText()
722
+ textobject.setTextOrigin(50,800)
723
+ textobject.setFont("Helvetica-Oblique", 15)
724
+ textobject.setFillColor('black')
725
+ textobject.textLine('Global stresses - tau xy')
726
+ self.c.drawText(textobject)
727
+ for idx, value in enumerate(list(all_line_data['color code']['tau xy map'])):
728
+ textobject = self.c.beginText()
729
+ if 400 - 20 * idx > 20:
730
+ textobject.setTextOrigin(50, 400 - 20 * idx)
731
+ else:
732
+ textobject.setTextOrigin(300, 400 - 20 * idx)
733
+
734
+ textobject.setFillColor(matplotlib.colors.rgb2hex(cmap_sections(
735
+ list(all_line_data['color code']['tau xy map']).index(value)/
736
+ len(list(all_line_data['color code']['tau xy map'])))))
737
+ textobject.setFont("Helvetica-Oblique", 10)
738
+ textobject.textLine(str(value))
739
+ self.c.drawText(textobject)
740
+ drawed_data.append(value)
741
+ elif load_idx_name is not None:
742
+ for lidx, loadtext in enumerate(reversed(self.data._load_dict[load_idx_name[1]][0].get_report_string())):
743
+ textobject = self.c.beginText()
744
+ textobject.setTextOrigin(370 , origo[1]+50+ 11*lidx)
745
+ textobject.setFont("Helvetica-Oblique", 11)
746
+ textobject.setFillColor('black')
747
+ textobject.textLine(loadtext)
748
+ self.c.drawText(textobject)
749
+
750
+ def coord(self, x, y, unit=1):
751
+ """
752
+ # http://stackoverflow.com/questions/4726011/wrap-text-in-a-table-reportlab
753
+ Helper class to help position flowables in Canvas objects
754
+ """
755
+ x, y = x * unit, self.height - y * unit
756
+ return x, y
757
+
758
+ # ----------------------------------------------------------------------
759
+
760
+ def createParagraph(self, ptext, x, y, style=None):
761
+ """"""
762
+ if not style:
763
+ style = self.styles["Normal"]
764
+ p = Paragraph(ptext, style=style)
765
+ p.wrapOn(self.c, self.width, self.height)
766
+ p.drawOn(self.c, *self.coord(x, y, mm))
767
+
768
+ # ----------------------------------------------------------------------
769
+ def savePDF(self):
770
+ """"""
771
+ self.c.save()
772
+
773
+ # ----------------------------------------------------------------------
774
+
775
+ def createTable(self):
776
+ '''
777
+ Create a table of results for all lines.
778
+ '''
779
+
780
+ table_all = []
781
+ cylindersy, flat_plates, idx = False, False,-1
782
+ for line in sorted(self.data._line_dict.keys()):
783
+ idx += 1
784
+ if self.data._line_to_struc[line][5] is None and cylinders is False:
785
+ flat_plates = True
786
+ if idx == 0:
787
+ headers = ['Line', 'pl thk', 's', 'web h', 'web thk', 'fl. w', 'fl. thk', 'sig x1', 'sig x2', 'sig y1',
788
+ 'sig y2', 'tau xy', 'max press.', 'sec. mod', 'min sec.', 'min plt',
789
+ 'shr area', 'min shr A', 'fat uf', 'buc uf']
790
+ table_all.append(headers)
791
+ if line not in list(self.data._line_to_struc.keys()):
792
+ continue
793
+ struc_obj = self.data._line_to_struc[line][0]
794
+ pressure = round(self.data.get_highest_pressure(line)['normal'] / 1000,0)
795
+
796
+ if self.data._PULS_results is not None:
797
+ puls_method = self.data._line_to_struc[line][0].Plate.get_puls_method()
798
+ if line in self.data._PULS_results.get_run_results().keys():
799
+ if puls_method == 'buckling':
800
+ buckling_uf = \
801
+ self.data._PULS_results.get_run_results()[line]['Buckling strength']['Actual usage Factor'][0]
802
+ else:
803
+ buckling_uf = \
804
+ self.data._PULS_results.get_run_results()[line]['Ultimate capacity']['Actual usage Factor'][0]
805
+ else:
806
+ try:
807
+ buckling_uf = str(round(max(self.data.get_color_and_calc_state()['buckling'][line]), 2))
808
+ except TypeError:
809
+ buckling_uf = None
810
+
811
+ if self.data.get_color_and_calc_state()['fatigue'][line]['damage'] is not None:
812
+ fat_uf = self.data.get_color_and_calc_state()['fatigue'][line]['damage']
813
+ fat_uf = round(fat_uf, 3)
814
+ else:
815
+ fat_uf = self.data.get_color_and_calc_state()['fatigue'][line]['damage']
816
+
817
+
818
+ data = [line,str(struc_obj.Plate.get_pl_thk() * 1000), str(struc_obj.Plate.get_s() * 1000),
819
+ str('' if struc_obj.Stiffener is None else struc_obj.Stiffener.get_web_h() * 1000),
820
+ str('' if struc_obj.Stiffener is None else struc_obj.Stiffener.get_web_thk() * 1000),
821
+ str('' if struc_obj.Stiffener is None else struc_obj.Stiffener.get_fl_w() * 1000),
822
+ str('' if struc_obj.Stiffener is None else struc_obj.Stiffener.get_fl_thk() * 1000),
823
+ str(round(struc_obj.Plate.sigma_x1, 0)), str(round(struc_obj.Plate.sigma_x2, 0)),
824
+ str(round(struc_obj.Plate.sigma_y1, 0)),
825
+ str(round(struc_obj.Plate.sigma_y2, 0)),
826
+ str(round(struc_obj.Plate.tau_xy, 0)), str(round(pressure, 2) * 1000),
827
+ str(int(min(self.data.get_color_and_calc_state()['section_modulus'][line]['sec_mod']) * 1000 ** 3)),
828
+ str(int(self.data.get_color_and_calc_state()['section_modulus'][line]['min_sec_mod'] * 1000 ** 3)),
829
+ str(round(self.data.get_color_and_calc_state()['thickness'][line]['min_thk'], 2)),
830
+ str(int(self.data.get_color_and_calc_state()['shear_area'][line]['shear_area'] * 1000 ** 2)),
831
+ str(int(self.data.get_color_and_calc_state()['shear_area'][line]['min_shear_area'] * 1000 ** 2)),
832
+ fat_uf, buckling_uf]
833
+
834
+ table_all.append(data)
835
+
836
+ elif not flat_plates:
837
+ cylinders = True
838
+ if idx == 0:
839
+ headers = ['Line', 'Radius', 'Thickness', 'Span', 'Tot. length',
840
+ 'Axial stress', 'Bend stress', 'Tors. stress', 'Shear stress', 'Lat. press.',
841
+ 'Hoop stress',
842
+ 'UF shell', 'UF long. stf.', 'UF ring. stf.', 'UF girder']
843
+ table_all.append(headers)
844
+ cyl_obj = self.data._line_to_struc[line][5]
845
+ radius = round(cyl_obj.ShellObj.radius * 1000, 2)
846
+ thickness = round(cyl_obj.ShellObj.thk * 1000, 2)
847
+ long_str = cyl_obj.LongStfObj.get_beam_string()
848
+ ring_stf = cyl_obj.LongStfObj.get_beam_string()
849
+ heavy_ring = cyl_obj.LongStfObj.get_beam_string()
850
+ span = round(cyl_obj.ShellObj.dist_between_rings, 1)
851
+ tot_length = round(cyl_obj.ShellObj.length_of_shell, 1)
852
+ tot_cyl = round(cyl_obj.ShellObj.tot_cyl_length, 1)
853
+ sigma_axial = cyl_obj.sasd / 1e6
854
+ sigma_bend = cyl_obj.smsd / 1e6
855
+ sigma_tors = cyl_obj.tTsd / 1e6
856
+ tau_xy = cyl_obj.tQsd / 1e6
857
+ lat_press = cyl_obj.psd / 1e6
858
+ sigma_hoop = cyl_obj.shsd / 1e6
859
+ results = cyl_obj.get_utilization_factors()
860
+ data = [line, radius, thickness, span, tot_length,
861
+ sigma_axial,
862
+ sigma_bend,
863
+ sigma_tors,
864
+ tau_xy,
865
+ lat_press,
866
+ sigma_hoop,
867
+ round(0 if results['Unstiffened shell'] is None else results['Unstiffened shell'],2),
868
+ round(0 if results['Longitudinal stiffened shell'] is None else results['Longitudinal stiffened shell'],2),
869
+ round(0 if results['Ring stiffened shell'] is None else results['Ring stiffened shell'],2),
870
+ round(0 if results['Heavy ring frame'] is None else results['Heavy ring frame'],2)
871
+ ]
872
+ table_all.append([str(data_item) for data_item in data])
873
+ if cylinders:
874
+ t = Table(table_all,colWidths=[0.7*inch])
875
+ t.setStyle(TableStyle([
876
+ ('GRID', (0, 0), (-1, -1), 0.5, colors.gray),
877
+ ('BACKGROUND', (0, 0), (-1, -1), colors.lightblue),
878
+ ('FONTSIZE', (0, 0), (-1, -1), 8),
879
+ ('FONTSIZE', (0, 4), (-1, 4), 8),
880
+ ('TEXTFONT', (0, 1), (-1, 1), 'Times-Bold'),
881
+ ('TEXTFONT', (0, 4), (-1, 4), 'Times-Bold'),
882
+ ]))
883
+ else:
884
+ t = Table(table_all,colWidths=[0.55*inch])
885
+ t.setStyle(TableStyle([
886
+ ('GRID', (0, 0), (-1, -1), 0.5, colors.gray),
887
+ ('BACKGROUND', (0, 0), (-1, -1), colors.lightblue),
888
+ ('FONTSIZE', (0, 0), (-1, -1), 8),
889
+ ('FONTSIZE', (0, 4), (-1, 4), 8),
890
+ ('TEXTFONT', (0, 1), (-1, 1), 'Times-Bold'),
891
+ ('TEXTFONT', (0, 4), (-1, 4), 'Times-Bold'),
892
+ ]))
893
+
894
+ return [t,]
895
+
896
+
897
+ if __name__ == '__main__':
898
+ import multiprocessing, ctypes, tkinter
899
+ import main_application as app
900
+ multiprocessing.freeze_support()
901
+ errorCode = ctypes.windll.shcore.SetProcessDpiAwareness(2)
902
+ root = tkinter.Tk()
903
+ my_app = app.Application(root)
904
+ ship_example = r'C:\Github\ANYstructure\ship_section_example.txt'
905
+ my_app.openfile(ship_example)
906
+ #
907
+ my_app.table_generate()
908
+ #my_app.report_generate(autosave=True)
909
+ # doc = LetterMaker("example.pdf", "The MVP", 10, to_report_gen)
910
+ # doc.createDocument()
911
+ # doc.savePDF()
912
+