This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathhole-kt-study.py
120 lines (102 loc) · 3.55 KB
/
hole-kt-study.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
import math
import numpy as np
import sys
import pycalculix as pyc
import matplotlib.pyplot as plt
# set whether or not to show gui plots
show_gui = True
if '-nogui' in sys.argv:
show_gui = False
# set element shape
eshape = 'quad'
if '-tri' in sys.argv:
eshape = 'tri'
# Stress and geometry constants
stress_val = 1000
diam = 1.0
thickness = 0.01
# Make a list of geometry ratios, diam_hole/width_plate
ratios = np.arange(0,.5,.05)
ratios[0] = .001
# store results
(ktg_res, ktg_pet, err) = ([],[],[])
def kt_peterson(ratio):
# returns peterson kt for a given ratio, kt is Ktg
res = .284 + (2.0/(1-ratio)) - 0.600*(1-ratio) + 1.32*(1-ratio)**2
return res
# loop through ratios doing a stress run each time, storing the results
for ratio in ratios:
width = diam/ratio
# part geometry dimensions
print('D=%f, H=%f, D/H=%f' % (diam, width, diam/width))
top = width/2 # model width
right = top*2 # model length
rad = diam/2.0 #hole radius
bot = top - rad
left = right - rad
# vertical hole in plate model, make model
model_name = 'hole-kt-study'
model = pyc.FeaModel(model_name)
model.set_units('m') # this sets dist units to meters
# make part, coordinates are x, y = radial, axial
part = pyc.Part(model)
part.goto(0.0,rad)
part.draw_arc(rad, 0.0, 0.0, 0.0)
part.draw_line_rad(left)
part.draw_line_ax(top)
part.draw_line_rad(-right*.5)
part.draw_line_rad(-right*.5) #this point lets us chunks our area
part.draw_line_ax(-bot)
# part.plot_geometry('hole_kt_prechunk', display=disp)
part.chunk()
model.plot_geometry(model_name+'_chunked', display=False)
# set loads and constraints
model.set_load('press',part.top,-1*stress_val)
model.set_constr('fix',part.left,'y')
model.set_constr('fix',part.bottom,'x')
# set part material
mat = pyc.Material('steel')
mat.set_mech_props(7800, 210000, 0.3)
model.set_matl(mat, part)
# set the element type, line division, and mesh the database
ediv = 19
model.set_ediv('L0',ediv) # sets # of elements on the arc
model.set_eshape(eshape, 2)
model.set_etype('plstress', part, thickness)
model.mesh(1.0, 'gmsh') # mesh with 1.0 fineness, smaller is finer
model.plot_elements('%s_elem_%.3f' % (model_name, ratio),
display=False)
model.plot_pressures('%s_press' % (model_name), display=False)
# make model and solve it
prob = pyc.Problem(model, 'struct')
prob.solve()
# query results and store them
sx = prob.rfile.get_nmax('Sx')
kt_fea = sx/stress_val
ktg_res.append(kt_fea)
ktg_pet.append(kt_peterson(ratio))
error = 100*(kt_fea/kt_peterson(ratio) - 1)
err.append(error)
print('For ratio %3f, Kt_g = %3.2f' % (ratio, kt_fea))
# plot results
fig, ax = plt.subplots()
plt.plot(ratios, ktg_res, color='b', label='Ktg_FEA', marker='.')
plt.plot(ratios, ktg_pet, color='r', label='Ktg_Peterson', marker='.')
plt.grid()
plt.legend(loc='lower right')
plt.title('Tension Hole in Plate Stress Concentration Factor, Ktg')
plt.xlabel('D/h')
plt.ylabel('Ktg')
pyc.base_classes.plot_finish(plt, fname=model_name+'_kts',
display=show_gui)
# plot error
fig, ax = plt.subplots()
plt.plot(ratios, err, color='g', label='Error', marker='.')
plt.grid()
plt.legend(loc='lower right')
plt.title('Tension Hole in Plate Ktg Error, FEA vs Peterson')
plt.xlabel('D/h')
plt.ylabel('Error (%)')
pyc.base_classes.plot_finish(plt, fname=model_name+'_error',
display=show_gui)