Internal heat flux in 1D heat conduction equation

I am trying to solve the following equation–
eqn: T’’= 0

BCs: T(0)=0
T’(1)=-1
T’(.5+)-T’(.5-)=-10 W/m^2 (internal point heat input)
I failed to apply the heat input condition in fenics. Here is my code–

from fenics import *
mesh = IntervalMesh(20,0,1)
import matplotlib.pyplot as plt
plot(mesh)
plt.show()
V = FunctionSpace(mesh, 'P', 1)
u_1 = Expression('0', degree=0)
tol = 1E-6
class Boundary0(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary and near(x[0], 0, tol)


boundary_markers = MeshFunction('size_t',mesh,mesh.topology().dim()-1)
boundary0=Boundary0()
boundary0.mark(boundary_markers, 0)

class Point_source(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[0], .5, tol)
point_source=Point_source()
point_source_markers = MeshFunction('size_t',mesh,mesh.topology().dim())
point_source.mark(point_source_markers, 3)

class Boundary1(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary and near(x[0], 1, tol)
boundary1 = Boundary1()
boundary1.mark(boundary_markers, 1)
bc1 = DirichletBC(V, u_1, boundary0)
ds = Measure('ds', domain=mesh, subdomain_data=boundary_markers)
dx = Measure('dx', domain=mesh, subdomain_data=point_source_markers)
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0)
a = dot(grad(u), grad(v))*dx
L = -(-1)*v*ds(1)-(-10)*v*dx(3)
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0)
a = dot(grad(u), grad(v))*dx
L = -(-1)*v*ds(1)-(-10)*v*dx(3)
u = Function(V)
solve(a == L, u, bc1)

If I’m parsing the question correctly, it sounds like you want to apply a point source of heat (although this would set the jump in T' at the source’s location, not the value of T'). I can see two ways to do this. First, you could use a PointSource object, which would have the advantage of allowing you to place the point source in the middle of an element (although this is generally a bad idea if it can be easily-avoided, because finite element shape functions are not good at approximating jumps in derivatives within elements). Alternatively, if you always have an element boundary at the location of the point source, you could do something similar to your current code, but using the dS measure instead of dx for the concentrated heat source. The dS measure integrates over interior boundaries between elements (and can be restricted to subsets with markers).

1 Like

Thanx a lot. I have done it by the PointSource object