-
Notifications
You must be signed in to change notification settings - Fork 9
/
one_elem_disp_chaboche.jl
177 lines (162 loc) · 6.76 KB
/
one_elem_disp_chaboche.jl
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/Materials.jl/blob/master/LICENSE
using JuliaFEM, FEMBase, LinearAlgebra
include("continuum.jl")
include("chaboche.jl")
X = Dict(
1 => [0.0, 0.0, 0.0],
2 => [1.0, 0.0, 0.0],
3 => [1.0, 1.0, 0.0],
4 => [0.0, 1.0, 0.0],
5 => [0.0, 0.0, 1.0],
6 => [1.0, 0.0, 1.0],
7 => [1.0, 1.0, 1.0],
8 => [0.0, 1.0, 1.0])
body_element = Element(Hex8, (1, 2, 3, 4, 5, 6, 7, 8))
body_elements = [body_element]
update!(body_elements, "geometry", X)
update!(body_elements, "youngs modulus", 200.0e3)
update!(body_elements, "poissons ratio", 0.3)
update!(body_elements, "K_n", 100.0)
update!(body_elements, "n_n", 10.0)
update!(body_elements, "C_1", 10000.0)
update!(body_elements, "D_1", 100.0)
update!(body_elements, "C_2", 50000.0)
update!(body_elements, "D_2", 1000.0)
update!(body_elements, "Q", 50.0)
update!(body_elements, "b", 0.1)
update!(body_elements, "yield stress", 100.0)
bc_element_1 = Element(Poi1, (1,))
bc_element_2 = Element(Poi1, (2,))
bc_element_3 = Element(Poi1, (3,))
bc_element_4 = Element(Poi1, (4,))
bc_element_5 = Element(Poi1, (5,))
bc_element_6 = Element(Poi1, (6,))
bc_element_7 = Element(Poi1, (7,))
bc_element_8 = Element(Poi1, (8,))
bc_elements = [bc_element_1, bc_element_2, bc_element_3, bc_element_4,
bc_element_5, bc_element_6, bc_element_7, bc_element_8]
update!(bc_elements, "geometry", X)
for element in (bc_element_1, bc_element_2, bc_element_3, bc_element_4)
update!(element, "displacement 3", 0.0)
end
for element in (bc_element_5, bc_element_6, bc_element_7, bc_element_8)
update!(element, "displacement 3", 0.0 => 0.0)
update!(element, "displacement 3", 1.0 => 5.0e-3)
update!(element, "displacement 3", 3.0 => -5.0e-3)
update!(element, "displacement 3", 5.0 => 5.0e-3)
update!(element, "displacement 3", 7.0 => -5.0e-3)
update!(element, "displacement 3", 9.0 => 5.0e-3)
update!(element, "displacement 3", 10.0 => 0.0)
end
update!(bc_element_1, "displacement 1", 0.0)
update!(bc_element_1, "displacement 2", 0.0)
update!(bc_element_2, "displacement 2", 0.0)
update!(bc_element_4, "displacement 1", 0.0)
update!(bc_element_5, "displacement 1", 0.0)
update!(bc_element_5, "displacement 2", 0.0)
update!(bc_element_6, "displacement 2", 0.0)
update!(bc_element_8, "displacement 1", 0.0)
#update!(bc_element_5, "displacement 1", 0.0)
#update!(bc_element_5, "displacement 2", 0.0)
#update!(bc_element_5, "displacement 3", 0.0 => 0.0)
#update!(bc_element_5, "displacement 3", 1.0 => 1.0e-3)
# Initialize material model to integration points
for ip in get_integration_points(body_element)
update!(ip, "yield stress", 0.0 => body_element("yield stress", ip, 0.0))
update!(ip, "plastic strain", 0.0 => zeros(6))
update!(ip, "stress", 0.0 => zeros(6))
update!(ip, "strain", 0.0 => zeros(6))
update!(ip, "backstress 1", 0.0 => zeros(6))
update!(ip, "backstress 2", 0.0 => zeros(6))
update!(ip, "cumulative equivalent plastic strain", 0.0 => 0.0)
ip.fields["material"] = field(Chaboche(body_element, ip, 0.0))
end
body = Problem(Continuum3D, "1 element problem", 3)
bc = Problem(Dirichlet, "fix displacement", 3, "displacement")
add_elements!(body, body_elements)
add_elements!(bc, bc_elements)
analysis = Analysis(Nonlinear, "solve problem")
# xdmf = Xdmf("results"; overwrite=true)
# add_results_writer!(analysis, xdmf)
add_problems!(analysis, body, bc)
# time_end = 1.0
time_end = 10.0
dtime = 0.05
for problem in get_problems(analysis)
initialize!(problem, analysis.properties.time)
end
while analysis.properties.time < time_end
analysis.properties.time += dtime
update!(body_element, "displacement", analysis.properties.time => Dict(j => zeros(3) for j in 1:8))
@info("time = $(analysis.properties.time)")
run!(analysis)
for ip in get_integration_points(body_element)
material = ip("material", analysis.properties.time)
material_matrix = zeros(6,6)
stress_vector = zeros(6)
calculate_stress!(material, body_element, ip,
analysis.properties.time, dtime, material_matrix, stress_vector)
update!(ip, "stress", analysis.properties.time => stress_vector)
# update!(ip, "stress", analysis.properties.time => copy(material.stress))
update!(ip, "plastic strain", analysis.properties.time => copy(material.plastic_strain))
update!(ip, "cumulative equivalent plastic strain", analysis.properties.time => copy(material.cumulative_equivalent_plastic_strain))
update!(ip, "backstress 1", analysis.properties.time => copy(material.backstress1))
update!(ip, "backstress 2", analysis.properties.time => copy(material.backstress2))
update!(ip, "yield stress", analysis.properties.time => copy(material.yield_stress))
end
# update material internal parameters
end
# close(xdmf)
using Plots
if true
ip1 = first(get_integration_points(body_element))
t = range(0, stop=time_end, length=Int(time_end/dtime)+1)
s11(t) = ip1("stress", t)[1]
s22(t) = ip1("stress", t)[2]
s33(t) = ip1("stress", t)[3]
s12(t) = ip1("stress", t)[4]
s23(t) = ip1("stress", t)[5]
s31(t) = ip1("stress", t)[6]
e11(t) = ip1("strain", t)[1]
e22(t) = ip1("strain", t)[2]
e33(t) = ip1("strain", t)[3]
s(t) = ip1("stress", t)
function vmis(t)
s11, s22, s33, s12, s23, s31 = ip1("stress", t)
return sqrt(1/2*((s11-s22)^2 + (s22-s33)^2 + (s33-s11)^2 + 6*(s12^2+s23^2+s31^2)))
end
path = joinpath("one_elem_disp_chaboche", "unitelement_results.rpt")
data = readdlm(path, Float64; skipstart=4)
t_ = data[:,1]
s11_ = data[:,2]
s12_ = data[:,3]
s13_ = data[:,4]
s22_ = data[:,5]
s23_ = data[:,6]
s33_ = data[:,7]
e11_ = data[:,8]
e12_ = data[:,9]
e13_ = data[:,10]
e22_ = data[:,11]
e23_ = data[:,12]
e33_ = data[:,13]
plot(e11.(t), s11.(t), label="\$\\sigma_{11}\$", legend=:topleft,
fg_legend=:transparent, bg_legend=:transparent)
plot!(e22.(t), s22.(t), label="\$\\sigma_{22}\$")
plot!(e33.(t), s33.(t), linecolor=:red, label="\$\\sigma_{33}\$")
plot!(e11_, s11_, ls=:dash, label="\$\\sigma_{11} \\quad \\mathrm{Commercial}\$")
plot!(e22_, s22_, ls=:dash, label="\$\\sigma_{22} \\quad \\mathrm{Commercial}\$")
plot!(e33_, s33_, linecolor=:black, lw=1, ls=:dash,
label="\$\\sigma_{33} \\quad \\mathrm{Commercial}\$")
title!("Chaboche plasticity model\nOne element model with uniaxial stress")
# xlabel!("\$\\varepsilon\$")
# ylabel!("\$\\sigma\$")
# labels = ["s11" "s22" "s33" "s12" "s23" "s31"]
# plot(t, s11, title="stress at integration point 1", label="s11")
# plot!(t, s22, label="s22")
# plot!(t, s33, label="s33")
# plot!(t, s12, label="s12")
# plot!(t, s23, label="s23")
# plot!(t, s31, label="s31")
end