Hi everyone,
I’m trying to input acceleration along z axis in a simple linear elasticity problem.
The shape of the result look good, but the displacements are out of range.
I’m shearching for a solution but I’m out of ideas. If you have any solution.
This is my complet code.
from netgen.occ import *
from ngsolve import *
from ngsolve.webgui import Draw
# Variable
E = 210000
nu = 0.3
rho = 7810e-9
acc = 100000 # Acceleration
# Dirichlet Boundaries
Face_Dirichletx = 'Face4'
Face_Dirichlety = 'Face4'
Face_Dirichletz = 'Face4'
# Degree of Element
EleDeg = 2
# Mesh the geometrie and get the boundaries --------------------------------------------------
box = Box((0,-10,-10), (200,10,10))
box.faces.Max(X).name="Face4"
box.faces.Min(X).name="Face2"
geo = OCCGeometry(box)
mesh = Mesh(geo.GenerateMesh(maxh=6)).Curve(3)
boundaries = list(mesh.GetBoundaries())
# Calculation of Acceleration -----------------------------------------------
FonctionVolume = CoefficientFunction(1)
volume = Integrate(FonctionVolume, mesh)
NbNod = mesh.nv
NbMai = mesh.ne
NodeAcc = (rho * volume * acc) / (NbNod)
print("NbNode", NbNod)
print("Volume", volume)
print("mass", rho * volume)
print("NodeAcc", NodeAcc)
ACC = CF((0,0,NodeAcc))
# FE Space ---------------------------------------------------------------------------------
fes = VectorH1(mesh, order=EleDeg, dirichletx=Face_Dirichletx, dirichlety=Face_Dirichlety, dirichletz=Face_Dirichletz)
u, v = fes.TnT()
gfu = GridFunction(fes)
# Stress function ---------------------------------------------------------------------------------
def Stress(strain):
print("Calculation of Stress")
mu = E / 2 / (1 + nu)
lam = E * nu / ((1 + nu) * (1 - 2 * nu))
return 2 * mu * strain + lam * Trace(strain) * Id(3)
# Assemble of a ----------------------------------------------------------------------------
with TaskManager():
a = BilinearForm(fes)
a += SymbolicEnergy(InnerProduct(Stress(Sym(Grad(u))), Sym(Grad(u))))
pre = Preconditioner(a, "bddc")
a.AssembleLinearization(gfu.vec)
# Assemble of f with acceleration ---------------------------------------------------------
# f = LinearForm(ACC * v * dx).Assemble()
f = LinearForm(fes)
f += SymbolicLFI(ACC*v)
f.Assemble()
# Run the Solver --------------------------------------------------------------------------
from ngsolve.krylovspace import CGSolver
inv = CGSolver(a.mat, pre, printrates='\r', tol=1e-6, maxiter=500)
gfu.vec.data = inv * f.vec
Draw(gfu)
Thanks in advance.
Thomas