-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathViscoelasticModel.py
242 lines (217 loc) · 8.65 KB
/
ViscoelasticModel.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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
from dolfinx.mesh import Mesh
from dolfinx.fem import Constant, Expression
from petsc4py.PETSc import ScalarType
import ufl
from ufl import (inner, tr, sym, Identity)
import numpy as np
from math import factorial
class ViscoelasticModel:
def __init__(self,mesh: Mesh, model_parameters: dict) -> None:
"""
Define the material model
"""
# weighting coefficient for temperature and structural energies, c.f. Nielsen et al. eq. 8
self.chi = 0.5
self.tableau_size = 6
self.dim = mesh.topology.dim
self.m_n_tableau = Constant(mesh,[
5.523e-2,
8.205e-2,
1.215e-1,
2.286e-1,
2.860e-1,
2.265e-1,
])
self.lambda_m_n_tableau = Constant(mesh,[
5.965e-4,
1.077e-2,
1.362e-1,
1.505e-1,
6.747e+0,
2.963e+1,
])
self.g_n_tableau = Constant(mesh,[
1.585,
2.354,
3.486,
6.558,
8.205,
6.498,
])
self.lambda_g_n_tableau = Constant(mesh,[
6.658e-5,
1.197e-3,
1.514e-2,
1.672e-1,
7.497e-1,
3.292e+0
])
self.k_n_tableau = Constant(mesh,[
7.588e-1,
7.650e-1,
9.806e-1,
7.301e+0,
1.347e+1,
1.090e+1,
])
self.lambda_k_n_tableau = Constant(mesh,[
5.009e-5,
9.945e-4,
2.022e-3,
1.925e-2,
1.199e-1,
2.033e+0,
# instead of Inf
])
# Identity tensor
self.I = Identity(mesh.topology.dim)
# Intial (fictive) temperture [K]
self.T_init = Constant(mesh, model_parameters["T_0"])
# Activation energy [J/mol]
self.H = Constant(mesh, model_parameters["H"])
# Universal gas constant [J/(mol K)]
self.Rg = Constant(mesh, model_parameters["Rg"])
# Base temperature [K]
self.Tb = Constant(mesh, model_parameters["Tb"])
# Solid thermal expansion coefficient [K^-1]
self.alpha_solid = Constant(mesh, model_parameters["alpha_solid"])
# Liquid thermal expansion coefficient [K^-1]
self.alpha_liquid = Constant(mesh, model_parameters["alpha_liquid"])
return
def _init_expressions(self,functions: dict, functions_next: dict,
functions_current: dict, functions_previous: dict,
functionSpaces: dict, dt: float) -> None:
"""
Initialize the FEniCS expressions that are needed
to compute the derived quantities defined in Nielsen et al.
for the viscoelastic tempering model.
They are individually called each time step by their respective
self.__update methods and stored as properties in advance, since they only have to be instantiated once.
"""
self.expressions = {}
# Eq. 25
self.expressions["phi"] = Expression(
ufl.exp(
self.H / self.Rg * (
1.0 / self.Tb
- self.chi / functions_current["T"]
- (1.0 - self.chi) / functions_previous["Tf"]
)),
functionSpaces["T"].element.interpolation_points()
)
# Eq. 24
self.expressions["Tf_partial"] = Expression(
ufl.as_vector([(
self.lambda_m_n_tableau[i] * functions_previous["Tf_partial"][i]
+ functions_current["T"] * dt * functions["phi"])
/ (self.lambda_m_n_tableau[i] + dt * functions["phi"])
for i in range(0,self.tableau_size)]
),
functionSpaces["Tf_partial"].element.interpolation_points()
)
# Eq. 26
self.expressions["Tf"] = Expression(
inner(self.m_n_tableau,functions_current["Tf_partial"]),
functionSpaces["T"].element.interpolation_points()
)
# Eq. 9
self.expressions["thermal_strain"] = Expression(
self.I * (self.alpha_solid * (functions_current["T"] - functions_previous["T"])
+ (self.alpha_liquid - self.alpha_solid)
* (functions_current["Tf"] - functions_previous["Tf"])),
functionSpaces["sigma"].element.interpolation_points()
)
# Eq. 28
self.expressions["total_strain"] = Expression(
- functions["thermal_strain"],
functionSpaces["sigma"].element.interpolation_points()
)
# Eq. 29
self.expressions["deviatoric_strain"] = Expression(
# TODO: Find out if 1/3 applies for all dims
functions["total_strain"] - 1/self.dim * self.I * tr(functions["total_strain"]),
functionSpaces["sigma"].element.interpolation_points()
)
# No eq. specified, extrapolation step
# T(i+1) = T(i) + dT = T(i) + (T(i) - T(i-1))
self.expressions["T_next"] = Expression(
functions_current["T"] + (functions_current["T"] - functions_previous["T"]),
functionSpaces["T"].element.interpolation_points()
)
# Eq. 5
self.expressions["phi"] = Expression(
ufl.exp(
self.H / self.Rg * (1/self.Tb - 1/functions_current["T"])
),
functionSpaces["T"].element.interpolation_points()
)
self.expressions["phi_next"] = Expression(
ufl.exp(
self.H / self.Rg * (1/self.Tb - 1/functions_next["T"])
),
functionSpaces["T"].element.interpolation_points()
)
# Eq. 19
self.expressions["xi"] = Expression(
dt/2 * (functions_next["phi"] - functions["phi"]),
functionSpaces["T"].element.interpolation_points()
)
# Eq. 15a + 20
self.expressions["ds_partial"] = Expression(
ufl.as_tensor([
2.0 * g_n * functions["deviatoric_strain"]/functions["xi"] *
lambda_g_n * (1.0 - self._taylor_exponential(functions,lambda_g_n))
for (lambda_g_n,g_n) in zip(self.lambda_g_n_tableau,self.g_n_tableau)]),
functionSpaces["sigma_partial"].element.interpolation_points()
)
# Eq. 15b + 20
self.expressions["dsigma_partial"] = Expression(
ufl.as_tensor([
k_n * (tr(functions["total_strain"])*self.I)/functions["xi"] *
lam_k_n * (1.0 - self._taylor_exponential(functions,lam_k_n))
for (lam_k_n,k_n) in zip(self.lambda_k_n_tableau,self.k_n_tableau)]),
functionSpaces["sigma_partial"].element.interpolation_points()
)
# Eq. 16a
_, i, j = ufl.indices(3)
self.expressions["s_tilde_partial_next"] = Expression(ufl.as_tensor([
functions_current["s_tilde_partial"][n,i,j] * self._taylor_exponential(
functions,self.lambda_g_n_tableau[n]) for n in range(0,self.tableau_size)
]),
functionSpaces["sigma_partial"].element.interpolation_points()
)
# Eq. 16b
self.expressions["sigma_tilde_partial_next"] = Expression(
ufl.as_tensor([
functions_current["sigma_tilde_partial"][n,i,j] * self._taylor_exponential(
functions,self.lambda_k_n_tableau[n]) for n in range(0,self.tableau_size)
]),
functionSpaces["sigma_partial"].element.interpolation_points()
)
# Eq. 17a
self.expressions["s_partial_next"] = Expression(
functions["ds_partial"] + functions_next["s_tilde_partial"],
functionSpaces["sigma_partial"].element.interpolation_points()
)
# Eq. 17b
self.expressions["sigma_partial_next"] = Expression(
functions["dsigma_partial"] + functions_next["sigma_tilde_partial"],
functionSpaces["sigma_partial"].element.interpolation_points()
)
# Eq. 18
self.expressions["sigma_next"] = Expression(
np.sum([functions_next["s_partial"][n,:,:] + functions_next["sigma_partial"][n,:,:] for
n in range(0,self.tableau_size)]),
functionSpaces["sigma"].element.interpolation_points()
)
return
def _taylor_exponential(self,functions: dict, lambda_value):
"""
A taylor series expression to replace an exponential
in order to avoid singularities,
c.f. Nielsen et al., Eq. 20.
"""
return (
np.sum([1.0/factorial(k)
* (- functions["xi"]/lambda_value)**k for k in range(0,3)])
)