For a project I am assigned to solve the heat equation in a 2D environment in Python. To do this, I am using the Crank-Nicolson ADI scheme and so far things have been going smooth. I would also like to add that this is the first time that I have done numerical computing like this and I don't have a lot of experience with PDE's and finite difference methods.

However, problems start when I try to add a second material with a different thermal diffusivity. At the boundaries of the 2 materials, the temperature keeps rising and rising exponentially, but only at the boundaries (as if they are a heat source). Any other place in the domain functions fine and does not show this behaviour at all. Why does this happen and how can I stop it? Do I need to impose new boundary conditions on these boundaries, or can I just 'force' my way through this by calculating the temperature on the boundary and treating the two materials as independent domains?

  • 2
    $\begingroup$ What is your finite difference equation for matching the heat fluxes at the boundary? $\endgroup$ Apr 12, 2018 at 13:43
  • $\begingroup$ Currently the whole domain has fixed temperature boundary conditions at the edges of the (square) domain. I haven't implemented boundary conditions between the two materials because I thought the program could just calculate the temperature values, only with a different thermal diffusivity. I know there is such a thing as thermal resistance, but I wanted to add that later. I just cant understand why the boundaries between the materials get so 'hot'. $\endgroup$ Apr 12, 2018 at 13:59
  • 1
    $\begingroup$ Like I said, what is the heat flux matching boundary condition between the two materials? $\endgroup$ Apr 12, 2018 at 14:38
  • 3
    $\begingroup$ I'm voting to close this question as off-topic because it is about debugging code and not about a physics concept. $\endgroup$ Dec 18, 2019 at 19:03

1 Answer 1


The reason it got 'hot' is the interface between the two parts is not properly set. you cannot set a fixed temperature boundary condition on both parts. This "temperature" is calculated but not given. If you set a "guessed" temperature, the local temperature gradient will be unphysical. On one part, it will be a heat source or sink.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.