Dear colleagues,
I am using the heat equation based upon the FENICS heat_eq tutorial as per following code:
from __future__ import print_function
from fenics import *
import time
T = 1.0 # final time
num_steps = 1000 # number of time steps
dt = T / num_steps # time step size
# Import mesh and define function space
mesh = UnitCubeMesh(12,12,12);
V = FunctionSpace(mesh, 'P', 1)
# Define boundary condition
def left_boundary(x, on_boundary):
if (x[1]<DOLFIN_EPS):
return on_boundary
def right_boundary(x, on_boundary):
if (abs(x[1] - 10) < DOLFIN_EPS):
return on_boundary
def bottom_boundary(x, on_boundary):
if (x[1] < DOLFIN_EPS):
return on_boundary
bcs = []
#bc_left = DirichletBC(V, Constant(0), left_boundary)
#bcs.append(bc_left)
#bc_right = DirichletBC(V, Constant(1000), right_boundary)
#bcs.append(bc_right)
bc_bottom = DirichletBC(V, Constant(400), bottom_boundary)
bcs.append(bc_bottom)
#bc = [bc_left,bc_right]
# Define initial value
#u_0 = Expression('0*1',
# degree=2, a=5)
#u_n = interpolate(u_0, V)
u_n = interpolate(Constant(800), V)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0)
F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_n + dt*f)*v*dx
a, L = lhs(F), rhs(F)
# Create VTK file for saving solution
vtkfile = File('heat_equation/solution.pvd')
# Time-stepping
u = Function(V)
t = 0
for n in range(num_steps):
# Update current time
t += dt
# Compute solution
solve(a == L, u, bcs)
# Save to file and plot solution
#if (n%20 == 0):
#print('Printing the result at time step number =', n)
vtkfile << (u, t)
#plot(u)
# Update previous solution
u_n.assign(u)
print('Time step number =', n)
print('Time =', t)
The boundary condition is Dirichlet BC of fixed temperature at 400 at bottom. The initial solution declared is 800. When I start the analysis, in early time steps there I observe an unusual jump near BC where temperature crosses the value of 800 as shown in attached graph and contour plot.
I tried refining the mesh and it vanished but for smaller time steps, it appears again. Did anyone faced the same issue in FEM analysis? Any reasons of this behaviour and suggestions to resolve it? Thank you!