Skip to content

Commit ed12ddc

Browse files
authored
Merge pull request #41 from audunarn/bugfix
Bugfix
2 parents 3623c75 + 3d93e67 commit ed12ddc

File tree

4 files changed

+152
-54
lines changed

4 files changed

+152
-54
lines changed

ANYstructure/calc_structure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, main_dict, *args, **kwargs):
3434

3535
self.sigma_y = self.sigma_y2 + (self.sigma_y1-self.sigma_y2)\
3636
*(min(0.25*self.span,0.5*self.spacing)/self.span)
37+
3738
try:
3839
self.girder_lg=main_dict['girder_lg'][0]
3940
except KeyError:

ANYstructure/helper.py

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'''
44

55
import math, copy, csv
6-
print_it = False
6+
print_it = True
77

88
def print_helper(properties, prop_text, units):
99
'''
@@ -53,38 +53,52 @@ def one_load_combination(line_name_obj, coord, defined_loads, load_condition,
5353
elif load_condition == 'slamming':
5454
return helper_slamming(defined_loads)
5555
else:
56-
return None
56+
return [None, ' ']
5757

5858
def helper_dnva_dnvb(line_name_obj, coord, defined_loads, load_condition,
5959
defined_tanks, comb_name, acc, load_factors_all, print_to_file = False):
6060

6161
# calculate the defined loads
62-
calc_load = []
62+
calc_load, load_print = [], ['',]
6363
line_name = line_name_obj[0]
6464
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
6868
static_pressure,dynamic_pressure = 0,0
6969

7070
if len(defined_loads) != 0:
7171
for load in defined_loads :
7272
if load != None:
73-
if line_name_obj[0] == 'line29':
74-
print('LOAD NAME: ',comb_name, line_name, load.get_name())
73+
7574
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')
7681
# USE GET() (static,dyn, on/off)
7782
if load_condition == load.get_load_condition():
7883
static_pressure = (load_factors[2].get())*(load_factors[0].get())\
7984
*load.get_calculated_pressure(coord, acc[0],structure_type)
8085
dynamic_pressure = (load_factors[2].get())*(load_factors[1].get())\
8186
*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')
88102
calc_load.append(static_pressure+dynamic_pressure)
89103

90104
# calculate the tank loads
@@ -108,15 +122,15 @@ def helper_dnva_dnvb(line_name_obj, coord, defined_loads, load_condition,
108122
+tank_name_obj[1].get_overpressure()*overpress_lf[1]
109123

110124
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')
120134
# choosing the tank with the highest pressures
121135

122136
if len(defined_loads) == 0:
@@ -131,25 +145,35 @@ def helper_dnva_dnvb(line_name_obj, coord, defined_loads, load_condition,
131145
calc_load.append(-highest_tank_pressure if highest_tank_pressure else 0)
132146
else:
133147
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('\nRESULT: ' + 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+
'\nRESULT: ' + str(round(calc_load[0],1))+'\n')
155+
else:
156+
pass
136157

137-
return int(abs(sum(calc_load)))
158+
load_print.append('------------------------------------------------------------------\n')
159+
return [int(abs(sum(calc_load))), load_print]
138160

139161
def helper_slamming(defined_loads):
140162

141163
# calculate the defined loads
142-
164+
calc_load, load_print = [], ['',]
143165
if len(defined_loads) != 0:
144166
for load in defined_loads:
145167
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, ' ']
147171

148172

149173
def helper_tank_test(line_name_obj, coord, defined_loads, load_condition,
150174
defined_tanks, comb_name, acc, load_factors_all):
151175
# calculate the defined loads
152-
calc_load = []
176+
calc_load, load_print = [], ['',]
153177
static_pressure, dynamic_pressure = 0, 0
154178
line_name = line_name_obj[0]
155179
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,
165189
dynamic_pressure = (load_factors[2].get()) * (load_factors[1].get()) \
166190
* load.get_calculated_pressure(coord, acc[1], structure_type)
167191
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+
168199

169200
# calculate the tank loads
170201
temp_tank={}
@@ -175,7 +206,9 @@ def helper_tank_test(line_name_obj, coord, defined_loads, load_condition,
175206

176207
for tank_name_obj in defined_tanks:
177208
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')
179212
# USE GET() (static,dyn, on/off)
180213
overpress_lf = [1.3, 0] if load_factors[0].get() == 1.2 else [1, 0]
181214
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,
186219
+tank_name_obj[1].get_overpressure()*overpress_lf[1]
187220

188221
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')
189229
# choosing the tank with the highest pressures
190230
if len(defined_tanks) != 0:
191231
highest_tank_pressure = max([temp_tank[tank[0]] for tank in defined_tanks])
192232
calc_load.append(-highest_tank_pressure[0] if len(highest_tank_pressure) > 0 else 0)
193233
else:
194234
pass
195-
return int(abs(sum(calc_load)))
235+
return [int(abs(sum(calc_load))), load_print]
196236

197237
def helper_manual(line_name, comb_name,load_factors_all):
198-
238+
calc_load, load_print = [], ['',]
199239
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]
202245

203246
def helper_read_section_file(files, obj = None, to_json = False, to_csv = False):
204247
''' Read a xml file. '''

0 commit comments

Comments
 (0)