3
3
'''
4
4
5
5
import math , copy , csv
6
- print_it = False
6
+ print_it = True
7
7
8
8
def print_helper (properties , prop_text , units ):
9
9
'''
@@ -53,38 +53,52 @@ def one_load_combination(line_name_obj, coord, defined_loads, load_condition,
53
53
elif load_condition == 'slamming' :
54
54
return helper_slamming (defined_loads )
55
55
else :
56
- return None
56
+ return [ None , ' ' ]
57
57
58
58
def helper_dnva_dnvb (line_name_obj , coord , defined_loads , load_condition ,
59
59
defined_tanks , comb_name , acc , load_factors_all , print_to_file = False ):
60
60
61
61
# calculate the defined loads
62
- calc_load = []
62
+ calc_load , load_print = [], [ '' , ]
63
63
line_name = line_name_obj [0 ]
64
64
structure_type = line_name_obj [1 ].get_structure_type ()
65
- if line_name_obj [ 0 ] == 'line29' and print_it :
66
- print ( '---STRUCTURE TYPE---' , structure_type )
67
- print ( '-----HELPER START FOR' , comb_name , load_condition , line_name , '-----' )
65
+ if print_it :
66
+ #load_print.append('Load calculation for '+line_name_obj[0] + ' ' + comb_name+ ' ' + load_condition )
67
+ pass
68
68
static_pressure ,dynamic_pressure = 0 ,0
69
69
70
70
if len (defined_loads ) != 0 :
71
71
for load in defined_loads :
72
72
if load != None :
73
- if line_name_obj [0 ] == 'line29' :
74
- print ('LOAD NAME: ' ,comb_name , line_name , load .get_name ())
73
+
75
74
load_factors = load_factors_all [(comb_name , line_name , load .get_name ())]
75
+ if print_it :
76
+ if load_factors [0 ].get () != 0 :
77
+ load_print .append ('LOAD NAME: ' + ' ' + comb_name + ' ' + line_name + ' ' + load .get_name ()+ '\n ' )
78
+ if load_factors [1 ].get () != 0 :
79
+ if load_factors [0 ].get () != 0 :
80
+ load_print .append ('LOAD NAME: ' + ' ' + comb_name + ' ' + line_name + ' ' + load .get_name ()+ '\n ' )
76
81
# USE GET() (static,dyn, on/off)
77
82
if load_condition == load .get_load_condition ():
78
83
static_pressure = (load_factors [2 ].get ())* (load_factors [0 ].get ())\
79
84
* load .get_calculated_pressure (coord , acc [0 ],structure_type )
80
85
dynamic_pressure = (load_factors [2 ].get ())* (load_factors [1 ].get ())\
81
86
* load .get_calculated_pressure (coord , acc [1 ],structure_type )
82
- if line_name_obj [0 ] == 'line29' and print_it :
83
- print ('load (NON-TANK) calculation for load condition:' , load_condition , ' - Load is: ' , load .get_name (), ' - Type is: ' )
84
- print ('static with acc:' , acc [0 ], ' is: ' ,str (load_factors [2 ].get ()),'*' ,str (load_factors [0 ].get ()),'*' ,
85
- str (load .get_calculated_pressure (coord , acc [0 ],structure_type )), ' = ' , static_pressure )
86
- print ('dynamic with acc:' , acc [1 ],' is: ' ,str (load_factors [2 ].get ()),'*' ,str (load_factors [1 ].get ()),'*' ,
87
- str (load .get_calculated_pressure (coord , acc [1 ],structure_type )), ' = ' , dynamic_pressure )
87
+ if print_it :
88
+ # load_print.append('load (NON-TANK) calculation for load condition:' + load_condition + ' - Load is: '+ \
89
+ # load.get_name() + ' - Type is: \n')
90
+ if load_factors [0 ].get () != 0 :
91
+ load_print .append (' static with acceleration: ' + str (acc [0 ])+ ' is: \n ' +
92
+ str (load_factors [2 ].get ())+ '*' + \
93
+ str (load_factors [0 ].get ())+ '*' + \
94
+ str (round (load .get_calculated_pressure (coord , acc [0 ],structure_type ),1 ))+ ' = ' + \
95
+ str (round (static_pressure ,1 ))+ '\n ' )
96
+ if load_factors [1 ].get () != 0 :
97
+ load_print .append (' dynamic with acceleration: ' + str (acc [1 ])+ ' is: \n ' +
98
+ str (load_factors [2 ].get ())+ '*' + \
99
+ str (load_factors [1 ].get ())+ '*' + \
100
+ str (round (load .get_calculated_pressure (coord , acc [1 ],structure_type ),1 ))+ ' = ' + \
101
+ str (round (dynamic_pressure ,1 ))+ '\n ' )
88
102
calc_load .append (static_pressure + dynamic_pressure )
89
103
90
104
# calculate the tank loads
@@ -108,15 +122,15 @@ def helper_dnva_dnvb(line_name_obj, coord, defined_loads, load_condition,
108
122
+ tank_name_obj [1 ].get_overpressure ()* overpress_lf [1 ]
109
123
110
124
temp_tank [tank_name_obj [0 ]] = static_pressure + dynamic_pressure # .append((static_pressure + dynamic_pressure))
111
- if line_name_obj [ 0 ] == 'line29' and print_it :
112
- print ('load (TANK) calculation for load condition:' , load_condition , ' - Tank is: ' , tank_name_obj [0 ])
113
- print ('load factors : ' , load_factors [0 ].get (), load_factors [1 ].get (), load_factors [2 ].get ())
114
- print ( ' static: ', str (load_factors [2 ].get ()), '*' , str (load_factors [0 ].get ()) , '*' ,
115
- str (tank_name_obj [1 ].get_calculated_pressure (coord ,acc [0 ])), ' + ' ,
116
- str (tank_name_obj [1 ].get_overpressure ()), '*' , str (overpress_lf [0 ]), ' = ' , static_pressure )
117
- print ( ' dynamic: ', str (load_factors [2 ].get ()), '*' , str (load_factors [1 ].get ()), '*'
118
- , str (tank_name_obj [1 ].get_calculated_pressure (coord , acc [1 ])), ' + ' ,
119
- str (tank_name_obj [1 ].get_overpressure ()), '*' , str (overpress_lf [1 ]), ' = ' , dynamic_pressure )
125
+ if print_it :
126
+ #load_print.append ('load (TANK) calculation for load condition:'+ load_condition+ ' - Tank is: '+ tank_name_obj[0]+'\n' )
127
+ #load_print.append ('load factors : '+ str( load_factors[0].get())+str( load_factors[1].get())+str( load_factors[2].get())+'\n' )
128
+ load_print . append ( ' \n ' + tank_name_obj [ 0 ] + ' - static: '+ str (load_factors [2 ].get ())+ '*' + str (load_factors [0 ].get ()) + '*' + \
129
+ str (tank_name_obj [1 ].get_calculated_pressure (coord ,acc [0 ]))+ ' + ' + \
130
+ str (tank_name_obj [1 ].get_overpressure ())+ '*' + str (overpress_lf [0 ])+ ' = ' + str ( static_pressure ) + ' \n ' )
131
+ load_print . append ( tank_name_obj [ 0 ] + ' - dynamic: '+ str (load_factors [2 ].get ())+ '*' + str (load_factors [1 ].get ())+ '*' + \
132
+ str (tank_name_obj [1 ].get_calculated_pressure (coord , acc [1 ]))+ ' + ' + \
133
+ str (tank_name_obj [1 ].get_overpressure ())+ '*' + str (overpress_lf [1 ])+ ' = ' + str ( dynamic_pressure ) + ' \n ' )
120
134
# choosing the tank with the highest pressures
121
135
122
136
if len (defined_loads ) == 0 :
@@ -131,25 +145,35 @@ def helper_dnva_dnvb(line_name_obj, coord, defined_loads, load_condition,
131
145
calc_load .append (- highest_tank_pressure if highest_tank_pressure else 0 )
132
146
else :
133
147
pass
134
- if line_name_obj [0 ] == 'line29' and print_it :
135
- print ('-----HELPER END, RESULT IS: ' , calc_load ,'-----' )
148
+ if print_it :
149
+ if len (calc_load ) == 2 :
150
+ load_print .append ('\n RESULT: ' + str (round (calc_load [0 ], 1 )) + ' + ' +
151
+ str (round (calc_load [1 ])) + ' = ' + str (round (sum (calc_load ),1 )) + '\n ' )
152
+ elif len (calc_load ) == 1 :
153
+ load_print .append (
154
+ '\n RESULT: ' + str (round (calc_load [0 ],1 ))+ '\n ' )
155
+ else :
156
+ pass
136
157
137
- return int (abs (sum (calc_load )))
158
+ load_print .append ('------------------------------------------------------------------\n ' )
159
+ return [int (abs (sum (calc_load ))), load_print ]
138
160
139
161
def helper_slamming (defined_loads ):
140
162
141
163
# calculate the defined loads
142
-
164
+ calc_load , load_print = [], [ '' ,]
143
165
if len (defined_loads ) != 0 :
144
166
for load in defined_loads :
145
167
if load != None and load .get_load_condition () == 'slamming' :
146
- return load .get_calculated_pressure (0 , 0 , 'slamming' )
168
+ load_print .append ('Slamming pressure: \n ' + str (load .get_calculated_pressure (0 , 0 , 'slamming' ))+ ' Pa \n ' )
169
+ return [load .get_calculated_pressure (0 , 0 , 'slamming' ), load_print ]
170
+ return [None , ' ' ]
147
171
148
172
149
173
def helper_tank_test (line_name_obj , coord , defined_loads , load_condition ,
150
174
defined_tanks , comb_name , acc , load_factors_all ):
151
175
# calculate the defined loads
152
- calc_load = []
176
+ calc_load , load_print = [], [ '' , ]
153
177
static_pressure , dynamic_pressure = 0 , 0
154
178
line_name = line_name_obj [0 ]
155
179
structure_type = line_name_obj [1 ].get_structure_type ()
@@ -165,6 +189,13 @@ def helper_tank_test(line_name_obj, coord, defined_loads, load_condition,
165
189
dynamic_pressure = (load_factors [2 ].get ()) * (load_factors [1 ].get ()) \
166
190
* load .get_calculated_pressure (coord , acc [1 ], structure_type )
167
191
calc_load .append (static_pressure + dynamic_pressure )
192
+ if print_it :
193
+ load_print .append (
194
+ 'Tank test for: ' + load_condition [0 ] + '\n ' + str (load_factors [2 ].get ())+ ' * ' +
195
+ str (load_factors [0 ].get ()) + ' * ' +
196
+ str (round (load .get_calculated_pressure (coord , acc [0 ], structure_type ),1 )) + ' + ' +
197
+ str (round (dynamic_pressure )) + ' = ' + str (round (dynamic_pressure + static_pressure ))+ '\n ' )
198
+
168
199
169
200
# calculate the tank loads
170
201
temp_tank = {}
@@ -175,7 +206,9 @@ def helper_tank_test(line_name_obj, coord, defined_loads, load_condition,
175
206
176
207
for tank_name_obj in defined_tanks :
177
208
load_factors = load_factors_all [(comb_name , line_name , tank_name_obj [0 ])]
178
- # print('tank test LF: ', load_factors[0],load_factors[1],load_factors[2])
209
+ # if print_it:
210
+ # load_print.append('Tank test LF: '+ str(load_factors[0].get())+' '+str(load_factors[1].get())+' '+
211
+ # str(load_factors[2].get())+'\n')
179
212
# USE GET() (static,dyn, on/off)
180
213
overpress_lf = [1.3 , 0 ] if load_factors [0 ].get () == 1.2 else [1 , 0 ]
181
214
static_pressure = (load_factors [2 ].get ()) * (load_factors [0 ].get ())\
@@ -186,19 +219,29 @@ def helper_tank_test(line_name_obj, coord, defined_loads, load_condition,
186
219
+ tank_name_obj [1 ].get_overpressure ()* overpress_lf [1 ]
187
220
188
221
temp_tank [tank_name_obj [0 ]].append ((static_pressure + dynamic_pressure ))
222
+ if print_it :
223
+ load_print .append (
224
+ 'Tank test for: ' + tank_name_obj [0 ] + '\n ' + str (load_factors [2 ].get ()) + ' * ' +
225
+ str (load_factors [0 ].get ()) + ' * ' +
226
+ str (round (tank_name_obj [1 ].get_calculated_pressure (coord , acc [0 ]), 1 )) + ' + ' +
227
+ str (tank_name_obj [1 ].get_overpressure ()) + ' * ' + str (overpress_lf [0 ]) +
228
+ ' = ' + str (round (dynamic_pressure + static_pressure )) + '\n ' )
189
229
# choosing the tank with the highest pressures
190
230
if len (defined_tanks ) != 0 :
191
231
highest_tank_pressure = max ([temp_tank [tank [0 ]] for tank in defined_tanks ])
192
232
calc_load .append (- highest_tank_pressure [0 ] if len (highest_tank_pressure ) > 0 else 0 )
193
233
else :
194
234
pass
195
- return int (abs (sum (calc_load )))
235
+ return [ int (abs (sum (calc_load ))), load_print ]
196
236
197
237
def helper_manual (line_name , comb_name ,load_factors_all ):
198
-
238
+ calc_load , load_print = [], [ '' ,]
199
239
load_factors = load_factors_all [(comb_name , line_name [0 ], 'manual' )]
200
-
201
- return load_factors [0 ].get () * load_factors [1 ].get () * load_factors [2 ].get ()
240
+ man_press = load_factors [0 ].get () * load_factors [1 ].get () * load_factors [2 ].get ()
241
+ if print_it :
242
+ load_print .append ('Manual pressure:\n ' + str (load_factors [0 ].get ())+ ' * ' + str (load_factors [1 ].get ())+ ' * ' +
243
+ str (load_factors [2 ].get ()) + ' = ' + str (man_press ) + '\n ' )
244
+ return [man_press , load_print ]
202
245
203
246
def helper_read_section_file (files , obj = None , to_json = False , to_csv = False ):
204
247
''' Read a xml file. '''
0 commit comments