I want to solve a problem in linear elasticity with an anisotropic material:
example ∇⋅S=0.Here, S denotes the stress, with Sij=Cijkl:εkl. ε is the linearized Green-Lagrange strain ε(u)=1/2(∇u+∇uT) u is the displacement and C is the tensor of elasticity.When i try to apply the formula in the case of my equation it shows me this error i would like to know how to resolve this. your help would be welcome.Because I’m stuck on this point.
# --------------------
# Parameters
# --------------------
c_11 = 1.19e11
c_12 = 0.84e11
c_13 = 0.83e11
c_33 = 1.17e11
c_44 = 0.21e11
eps_11 = 8.15e-9
eps_33 = 6.58e-9
e_15 = 12.09
e_13 = -6.03
e_33 = 15.49
alpha= 1.267e5
beta= 6.259e-10
theta = 0.5
rho_Piezo = Constant(7700.)
# different tensor of material
# Elasticity tensor c^E
C = as_tensor([[c_11,c_12,c_13,0.,0.,0.],[c_12,c_11,c_13,0.,0.,0.],[c_13,c_13,c_33,0.,0.,0.],[0.,0.,0.,c_44,0.,0],[0.,0.,0.,0.,c_44,0.],[0.,0.,0.,0.,0.,(c_11-c_12)/2]])
# coupling tensor e
E_piezo = as_tensor([[0. , 0. , 0., 0. , e_15, 0.],[0., 0., 0., e_15, 0., 0.],[e_13, e_13, e_33, 0., 0., 0.]])
# transpose form tensor
E_t_piezo =as_tensor([[0., 0., e_13],[0., 0., e_13],[0., 0., e_33],[0., e_15, 0.],[e_15, 0., 0.],[0., 0., 0.]])
# Permittivitatstensor epsilon^S
Eps_s = as_tensor([[eps_11, 0., 0.],[0., eps_11, 0.],[0., 0., eps_33]])
# Setup mesh
resolution = 30
geometry = Cylinder(Point(0, 0, 0), Point(0, 0, 0.001), 0.005, 0.005)
# Making Mesh (30 corresponds to the mesh density)
mesh = generate_mesh(geometry, resolution)
# --------------------
# Functions and classes
# --------------------
V = VectorElement("CG", mesh.ufl_cell(), 2, dim=3)
W = FiniteElement("CG", mesh.ufl_cell(), 1)
M = FunctionSpace(mesh, MixedElement([V,V, W]))
# Get the needed boundaries:
# 1. To apply a predefined stress on it We keep it simple: the top face sees the same stress vector.
# 2. For zero Displacement we choose the bottom face of the disc
class TopBoundary(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[2], 0.001)
class BottomBoundary(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[2], 0.)
# first define the function for the strain tensor in fenics notation
def epsilon(u):
# note that it would be shorter to use sym(grad(u)) but the way used now
# represents the formula
return 1./2.*(grad(u) + (grad(u).T))
def Sigma(u):
return dot(C, epsilon(u))
# define the potential
dt = 0.01
t = np.arange(0.00199578, 20.0, dt)
# Amplitude of the sine wave is sine of a variable like time
potential = np.sin(3*np.pi*(t-(20.0/2)))
phi = Expression("t", degree=0, t=potential[0])
# --------------------
# Boundary conditions
# --------------------
top_boundary = TopBoundary()
bottom_boundary = BottomBoundary()
# Create the boundary condition for displacement
boundary = []
boundary.append(DirichletBC(M.sub(2), 0., bottom_boundary))
boundary.append(DirichletBC(M.sub(2), phi, top_boundary))
for i in range(len(t)):
phi.t = t[i]
print(assemble(phi*dx(domain=mesh)))
# As the stress is defined over the outer surface we need to create a
# integral over that surface
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim()-1)
boundaries.set_all(0)
top_boundary.mark(boundaries, 1)
bottom_boundary.mark(boundaries, 2)
dx = Measure("dx", domain=mesh)
ds = Measure("ds", subdomain_data=boundaries)
mf = MeshFunction("size_t", mesh, mesh.topology().dim()-1)
mf.set_all(0)
top_boundary.mark(mf, 1)
bottom_boundary.mark(mf, 2)
# the initial values
zero1d=Expression('0.0', degree=1)
zero3d=Expression(('0.0','0.0','0.0'), degree=1)
u0=interpolate(zero3d,M.sub(0).collapse())
z0=interpolate(zero3d,M.sub(1).collapse())
phi0=interpolate(zero1d,M.sub(2).collapse())
# --------------------
# Function spaces
# --------------------
#Defining the "Trial" functions
u,z,phi=TrialFunctions(M)
#Defining the "Test" functions
v,y,w=TestFunctions(M)
a = rho_Piezo*inner(z, v)*dx
+ theta*dt*inner((Sigma(u)+dot(E_t_piezo, gad(phi) )),epsilon(v) )* dx
+ theta*dt*alpha*rho_Piezo*inner(z1, v) * dx
+ theta*dt*beta*inner(dot(C, epsilon(z)), epsilonB(v)) * dx
+ inner((dot(E_piezo, epsilon(u))-dot(Eps_s,grad(phi))), grad(w)) *dx
+ inner(u, y)*dx
- theta*dt*(inner(z, y))* dx
l = -rho_Piezo*inner(z0, v)*dx
+ theta*dt*inner((sigma(u0)+dot(E_t_piezo, gad(phi0))),epsilon(v)) * dx
+ theta*dt*alpha*rho_Piezo*inner(z0, v)*dx
+ theta*dt*Beta*inner(dot(C, epsilon(z0)),epsilon(v)) * dx
- inner(u0, z)*dx
- theta*dt*(inner(z0, y)) * dx
Dimension mismatch in dot product.
---------------------------------------------------------------------------
UFLException Traceback (most recent call last)
<ipython-input-64-0058a608ed80> in <module>
12
13 a = rho_Piezo*inner(z, v)*dx
---> 14 + theta*dt*inner((Sigma(u)+dot(E_t_piezo, gad(phi) )),epsilon(v) )* dx
15 + theta*dt*alpha*rho_Piezo*inner(z1, v) * dx
16 + theta*dt*beta*inner(dot(C, epsilon(z)), epsilonB(v)) * dx
<ipython-input-59-b7ff8cb334a9> in Sigma(u)
1 def Sigma(u):
----> 2 return dot(C, epsilon(u))
~/anaconda3/envs/fenicsfix2/lib/python3.8/site-packages/ufl/operators.py in dot(a, b)
185 if a.ufl_shape == () and b.ufl_shape == ():
186 return a * b
--> 187 return Dot(a, b)
188
189
~/anaconda3/envs/fenicsfix2/lib/python3.8/site-packages/ufl/tensoralgebra.py in __new__(cls, a, b)
206 "got arguments with ranks %d and %d." % (ar, br))
207 if not (scalar or ash[-1] == bsh[0]):
--> 208 error("Dimension mismatch in dot product.")
209
210 # Simplification
~/anaconda3/envs/fenicsfix2/lib/python3.8/site-packages/ufl/log.py in error(self, *message)
170 "Write error message and raise an exception."
171 self._log.error(*message)
--> 172 raise self._exception_type(self._format_raw(*message))
173
174 def begin(self, *message):
UFLException: Dimension mismatch in dot product.