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)