This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to correct boundary conditions and heat equation solution?

0 votes

hello, I'm new to programming and FEinC so this might seem trivial or silly but I'm hoping to get some help with regards to my boundary conditions and the solution to the heat equation only being confined to one particular area and not the whole structure. I've included the code below and attempted to annotate it

from dolfin import *
# Some constants
Ic = 340*10**-6 # critical current of device 
P = Ic*2.8 # Power dissapation
K = 0.01 #Thermal conductivity

# Define mesh 
mesh = Mesh()

# Create list of polygonal domain vertices
domain_vertices = [Point(-0.05, 0.0),
                   Point(-0.05, -2.0),
                   Point(-4.0, -2.0),
                   Point(-4.0, 2.0),
                   Point(-0.05, 2.0),
                   Point(-0.05, 0.1),
                   Point(0.05, 0.1),
                   Point(0.05, 2.0),
                   Point(4.0, 2.0),
                   Point(4.0, -2.0),
                   Point(0.05, -2.0),
                   Point(0.05, 0.0)]

PolygonalMeshGenerator.generate(mesh, domain_vertices, 0.025);

# Defining variables
V = FunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
a = inner(grad(u), grad(v))*dx
L = K*P*v*dx


# Defining boundry and scalar vectors for point source calculations 
bc = DirichletBC(V, Constant(4.2), DomainBoundary()) 
#4.2 is the temperature at the edges of the structure
A, b = assemble_system(a, L, bc)
u = Function(V)

# Applying the  Point source to the Function space in the middle of the constriction
delta = PointSource(V, Point(-0.05, 0.05), 100)
delta.apply(b)
solve(A, u.vector(), b)
plot(u, interactive=True)
# reset rhs
b.zero()
bc.apply(b) 

Any help is greatly appreciated and thank you in advance.

asked Oct 21, 2014 by abu_adan FEniCS Novice (120 points)

1 Answer

0 votes

I'm sorry but I don't get the question.
Can you clarify what is not working with your code? What error/misbehaviour you are getting and what you would expect to happen instead?

answered Oct 25, 2014 by Massimiliano Leoni FEniCS User (1,760 points)
...