forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7.4.3.1.b.py
147 lines (147 loc) · 5.84 KB
/
7.4.3.1.b.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
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
from sympy import *
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
from scipy.interpolate import InterpolatedUnivariateSpline
sp.init_printing(use_latex = "mathjax")
s11,s22,s33,nu,E,h,Svm,t = symbols("\u03c3_{11} \u03c3_{22} \u03c3_{33} nu E h \u03c3_{vM} t")
s = Matrix([[s11,0,0],[0,s22,0],[0,0,s33]])
hydr = (s11 + s22 + s33)/3;
Sdev = simplify(s-hydr*eye(3))
print(Sdev)
epmax = 25/100-550/200000
hslope = 150/epmax
print(epmax)
print(hslope)
rule = {E:200000, nu:0.3, h:hslope}
print("Relationship between stress components in the elastic regime")
a = solve((s22/E-nu*s33/E-nu*s11/E,s33/E-nu*s11/E-nu*s22/E),s22,s33)
for key in a:
a[key] = a[key].subs(rule)
print(a)
Sigmavm = sqrt(1/2*((s11-s22)**2+(s11-s33)**2+(s22-s33)**2))
Sigmavmsub = simplify(Sigmavm.subs(a))
print("s11, s22 and s33 at the elastic limit")
b = solve((Sigmavmsub-400),sqrt(s11**2), dict = true)
print(b[0])
print("Since s_11>0:")
b = {s11:700}
print(b)
s11initial = s11.subs(b)
s22initial = (s22.subs(a)).subs(b)
s33initial = (s33.subs(a)).subs(b)
print(s11initial,s22initial,s33initial)
print("Elastic strains right before plastifying")
ee11 = simplify((s11/E-nu*s22/E-nu*s33/E).subs(a)).subs(rule)
ee22 = simplify((-nu*s11/E+s22/E-nu*s33/E).subs(a)).subs(rule)
ee33 = simplify((-nu*s11/E-nu*s22/E+s33/E).subs(a)).subs(rule)
print(ee11,ee22,ee33)
print("Manipulation of rates")
s11t,s22t,s33t = Function('\u03c3_{11}')(t),Function('\u03c3_{22}')(t),Function('\u03c3_{33}')(t)
Sdev = Sdev.subs({s11:s11t,s22:s22t,s33:s33t})
Sigmavm = Sigmavm.subs({s11:s11t,s22:s22t,s33:s33t})
print(Sdev,Sigmavm)
ee22p = s22t.diff(t)/E-nu*s11t.diff(t)/E-nu*s33t.diff(t)/E
ee33p = s33t.diff(t)/E-nu*s11t.diff(t)/E-nu*s33t.diff(t)/E
cepp = 3/2*Sdev[0,0]*s11t.diff(t)/h/Svm+3/2*Sdev[1,1]*s22t.diff(t)/h/Svm+3/2*Sdev[2,2]*s33t.diff(t)/h/Svm
cep22p = simplify(cepp*3/2*Sdev[1,1]/Svm)
cep33p = simplify(cepp*3/2*Sdev[2,2]/Svm)
print(cepp,cep22p,cep33p)
print("Solving for s22'[t] and s33'[t] in terms of s11'[t] using the zero total strain conditions")
a = solve((ee22p+cep22p,ee33p+cep33p),s22t.diff(t),s33t.diff(t))
print(a)
print("Solving the ordinary differential equations for s11'[t],s22'[t] and s33'[t]")
eq1 = ((s22t.diff(t).subs(a)).subs(rule)).subs(Svm,Sigmavm)
eq2 = ((s33t.diff(t).subs(a)).subs(rule)).subs(Svm,Sigmavm)
equ1 = eq1.subs({s11t:s11,s22t:s22,s33t:s22,s11t.diff(t):1})
print(eq1,eq2)
equ2 = eq2.subs({s11t:s11,s22t:s33,s33t:s33,s11t.diff(t):1})
def rhs1(y,t):
f = sp.lambdify([s11,s22],equ1)
f = f(y[0],y[1])
return [1,f]
def rhs2(y,t):
f = sp.lambdify([s11,s33],equ2)
f = f(y[0],y[1])
return [1,f]
s11initial = float(s11initial)
t1 = np.linspace(s11initial,1050,20)
yzero1 = [s11initial,s22initial]
yzero2 = [s11initial,s33initial]
ff1 = odeint(rhs1,yzero1,t1)
ff2 = odeint(rhs2,yzero2,t1)
print("Solving the ordinary differential equations for ep'[t] and ep_ij'[t]")
cepp = (cepp.subs(rule)).subs(Svm,Sigmavm)
print(cepp)
eq1 = simplify(cepp)
eq2 = simplify(cepp*3/2*Sdev[0,0]/Sigmavm)
eq3 = simplify(cepp*3/2*Sdev[1,1]/Sigmavm)
eq4 = simplify(cepp*3/2*Sdev[2,2]/Sigmavm)
print(eq1,eq2,eq3,eq4)
rule2 = {s11t:s11,s22t:s22,s33t:s33,s11t.diff(t):1}
def integralsolve(eq, ff1,ff2):
eptp = simplify((((eq.subs(a)).subs(Svm,Sigmavm)).subs(rule)).subs(rule2))
f = sp.lambdify([s11,s22,s33],eptp)
sol = f(ff1[:,0],ff1[:,1],ff2[:,1])
f2 = InterpolatedUnivariateSpline(ff1[:,0],sol,k=1)
return [f2.integral(s11initial,ff1[i,0]) for i in range(20)]
epfunction = integralsolve(eq1,ff1,ff2)
ep11function = integralsolve(eq2,ff1,ff2)
ep22function = integralsolve(eq3,ff1,ff2)
ep33function = integralsolve(eq4,ff1,ff2)
#eeFunctions
ee11function = sp.lambdify([s11,s22,s33],(s11/E-s22/E*nu-s33/E*nu).subs(rule))
sol_ee11 = ee11function(ff1[:,0],ff1[:,1],ff2[:,1])
ee22function = sp.lambdify([s11,s22,s33],(-nu*s11/E+s22/E-s33/E*nu).subs(rule))
sol_ee22 = ee22function(ff1[:,0],ff1[:,1],ff2[:,1])
ee33function = sp.lambdify([s11,s22,s33],(-nu*s11/E-nu*s22/E+s33/E).subs(rule))
sol_ee33 = ee33function(ff1[:,0],ff1[:,1],ff2[:,1])
lambda1 = lambdify(t,(t*nu/(1-nu)).subs(rule))
lambda2 = lambdify(t,(t/E-nu*t/(1-nu)/E*nu-nu*t/(1-nu)/E*nu).subs(rule))
xL = np.linspace(0,s11initial,2)
fig,ax = plt.subplots(6,2, figsize = (20,30))
plt.setp(ax[0,0], xlabel = "s11",ylabel="s22")
ax[0,0].plot(ff1[:,0],ff1[:,1],'b-')
ax[0,0].plot(xL,lambda1(xL),'b-')
plt.setp(ax[0,1], xlabel = "s11",ylabel="s33")
ax[0,1].plot(ff2[:,0],ff2[:,1],'b-')
ax[0,1].plot(xL,lambda1(xL),'b-')
plt.setp(ax[1,0], xlabel = "s11",ylabel="ep")
ax[1,0].plot(ff1[:,0],epfunction,'b-')
ax[1,0].plot(xL,[0,0], 'b-')
plt.setp(ax[1,1], xlabel = "s11",ylabel="ep11")
ax[1,1].plot(ff1[:,0],ep11function,'b-')
ax[1,1].plot(xL,[0,0], 'b-')
plt.setp(ax[2,0], xlabel = "s11",ylabel="ep22")
ax[2,0].plot(ff1[:,0],ep22function,'b-')
ax[2,0].plot(xL,[0,0], 'b-')
plt.setp(ax[2,1], xlabel = "s11",ylabel="ep33")
ax[2,1].plot(ff1[:,0],ep33function,'b-')
ax[2,1].plot(xL,[0,0], 'b-')
plt.setp(ax[3,0], xlabel = "s11",ylabel="ee11")
ax[3,0].plot(ff1[:,0],sol_ee11,'b-')
ax[3,0].plot(xL,lambda2(xL),'b-')
plt.setp(ax[3,1], xlabel = "s11",ylabel="ee22")
ax[3,1].plot(ff1[:,0],sol_ee22,'b-')
ax[3,1].plot(xL,[0,0],'b-')
plt.setp(ax[4,0], xlabel = "s11",ylabel="ee33")
ax[4,0].plot(ff1[:,0],sol_ee33,'b-')
ax[4,0].plot(xL,[0,0],'b-')
plt.setp(ax[4,1], xlabel = "s11",ylabel="e11")
ax[4,1].plot(ff1[:,0],sol_ee11+ep11function,'b-')
ax[4,1].plot(xL,lambda2(xL),'b-')
plt.setp(ax[5,0], xlabel = "s11",ylabel="e22")
ax[5,0].plot(ff1[:,0],sol_ee22+ep22function,'b-')
ax[5,0].plot(xL,[0,0],'b-')
ax[5,0].set_ylim([-1,1])
plt.setp(ax[5,1], xlabel = "s11",ylabel="e33")
ax[5,1].plot(ff1[:,0],sol_ee33+ep33function,'b-')
ax[5,1].plot(xL,[0,0],'b-')
ax[5,1].set_ylim([-1,1])
for i in range(6):
for j in range(2):
ax[i,j].grid(True,which='both')
ax[i,j].axvline(x=0,color='k',alpha=0.5)
ax[i,j].axhline(y=0,color = 'k',alpha=0.5)
plt.show()