Dear all, I want to solve heat transfer problem on a rectangular plate, where the boundary conditions are:
(i) Initial temperature of the model is 0 degree Celsius.
(ii) The right boundary is suddenly heats up to 400 degree Celsius.
(iii) all other boundaries are insulated.
I defined the boundary conditions as follows:
#Initial temperature
u_0 = Constant(0.0)
u0=interpolate(u_0, V)
#Right Boundary
def right_boundary( x, on_boundary):
return on_boundary and ((abs(x[0])-1)< DOLFIN_EPS)
bc1= DirichletBC(V, Constant(400.0),right_boundary)
# Insulated Boundary
class InsulatedBoundary(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and (near(x[0], 0) or near(x[1], 1) or (near(x[1],0)))
bc2 = DirichletBC(V, Constant(0.0), InsulatedBoundary())
bc=[bc1, bc2]
However, i am not getting my desired result. i guess, my defined insulated boundary is not correct. Please anyone help me to figure out my mistake.
When you say the boundary is insulated, I guess that shouldn’t mean that the boundary value should be 0? Doesn’t insulation yield something closer to a Neumann condition, i.e. \frac{\partial u}{\partial n} = 0?
You can check your boundary conditions with the following code:
from dolfin import *
mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, "Lagrange", 1)
# Initial temperature
u_0 = Constant(0.0)
u0 = interpolate(u_0, V)
# Right Boundary
def right_boundary(x, on_boundary):
return on_boundary and ((abs(x[0])-1) < DOLFIN_EPS)
bc1 = DirichletBC(V, Constant(400.0), right_boundary)
# Insulated Boundary
class InsulatedBoundary(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and (near(x[0], 0) or near(x[1], 1) or (near(x[1], 0)))
bc2 = DirichletBC(V, Constant(0.0), InsulatedBoundary())
bc = [bc1, bc2]
u = Function(V)
u.vector()[:] = -400 # This will be the value of all interior nodes.
[b.apply(u.vector()) for b in bc]
with XDMFFile("test.xdmf") as xdmf:
xdmf.write(u)