# Why heat PDE solution does not fully satisfy initial conditions?

• ujo142
In summary: But then i stopped and when i restarted the problem it started from the beginning.In summary, the problem is that the boundary condition for u(0,t) does not hold when t goes to 0+. Duhamel's principle can be used to solve the problem without showing the code.
ujo142
Homework Statement
Solving heat equation with internal heat cources
Relevant Equations
u_{t} = u_{xx} + q(x)/P,
Hi, I am solving heat equation with internal heat sources both numerically and analytically. My graphs are nearly identical but! analytical one have problem at the beginning and at the end for my domain. Many people have used the same technique to solve it analytically and they got good answers. Example solution from my professor had the same issue. I cannot ask him at this time, university is closed in this week. Does anyone have at least idea what is causing this problem and how to solve it? I came up with an idea that i have some kind of tradeoff between initial and boundary conditions.

Problem: u_{t} = u_{xx} + q(x)/P, q(x) = (-x^2+2x), P=const, x: [0,L], t: [0, 40000]

u(0,t) = u(L,t) = 0 u(x, 0) = T0 = 20U can see that analytical solution does not have 20*C close to edges with small time.

#### Attachments

• Screenshot 2022-05-01 at 15.45.00.png
53.8 KB · Views: 78
• Screenshot 2022-05-01 at 15.46.24.png
73.8 KB · Views: 74
MathematicalPhysicist said:
There's a solution through Duhamel's principle:
https://en.wikipedia.org/wiki/Duhamel's_principle

without showing us your code how can we tell?
Hi, thanks u for reply. I am not sure how showing my MATLAB code could help here. I checked several times if i correctly applied the formula. My problem is rather the formula that i derived analytically. When i put solution to equation it satisfies it. But when i just put t=0 to solution i don't get T0 as i should.

To be more precise i have solved this equation with those setps:

assume that i have solution in form u(x,t) = w(x,t) +v(x).
Then i put this into equation and got two equations:
a*w_{xx} = w_{t}
a*v_{xx} = -q/PNext i have solved first equation using separable method w(x,t)=X(x)T(t). Puting boundary conditions I got:
w(x,t) = sum_{n=1}^{inf} A_{n}sin(n*pi*x/L)*e^{-an^2pi^2t/L^4}For v(x) i got:
v(x) = P/(12a)[x^4 -2Lx^3+xL^3]So now i can put this together and got:
u(x,t) = v(x) + w(x,t) = P/(12a)[x^4 -2Lx^3+xL^3] + sum_{n=1}^{inf} A_{n}sin(n*pi*x/L)*e^{-an^2pi^2t/L^4}

Now its time to put initial conditions u(x, 0) = T0 = v(x) + w(x,0). So i have:
w(x,0) = T0 - v(x)

sum_{n=1}^{inf} A_{n}sin(n*pi*x/L)*e^{-an^2pi^2t/L^4} = T0 - P/(12a)[x^4 -2Lx^3+xL^3]

Now i have multiplied this by sinus(m*pi*x/L) and inegrated from 0 to L.
On the left side the integral is L/2*cronecker delta_{nm} and on the right there is large integral.

I calculated first 10 terms and implemented this in matlab. Is this approach correct?

ujo142 said:
Homework Statement:: Solving heat equation with internal heat cources
Relevant Equations:: u_{t} = u_{xx} + q(x)/P,

U can see that analytical solution does not have 20*C close to edges with small time.
why do you expect that when your boundary conditions are zero?

Chestermiller
wrobel said:
why do you expect that when your boundary conditions are zero?
For two reasons:
1. Numerical solution near edges is close to 20*C
2. Initial condition is 20*C for x belongs to (0,L)

Since the initial conditions do not satisfy the boundary ones the solution is not regular as ##t\to 0+##
I think you have only ##\|u(t,\cdot)-u(0,\cdot)\|_{L^2(0,L)}\to 0## as ##t\to 0+##

Last edited:
I'd guess it's that you just need to evaluate more terms. Try plotting the analytical solution u(x,0) vs. x for different number of terms in the series. I think you'll see as you increase the number of terms, the closer you get to satisfying the boundary condition.

Chestermiller and ujo142
vela said:
I'd guess it's that you just need to evaluate more terms. Try plotting the analytical solution u(x,0) vs. x for different number of terms in the series. I think you'll see as you increase the number of terms, the closer you get to satisfying the boundary condition.
Yeah, that was my problem. After 150 terms there were excellent results.

## 1. Why does the heat PDE solution not fully satisfy initial conditions?

The heat PDE solution may not fully satisfy initial conditions due to numerical errors or approximations made during the solving process. Additionally, the initial conditions may not be precisely defined or may not accurately reflect the behavior of the system.

## 2. Can the heat PDE solution be improved to better satisfy initial conditions?

Yes, the heat PDE solution can be improved by using more accurate numerical methods or by refining the initial conditions to better represent the behavior of the system. Additionally, increasing the number of grid points or time steps can also improve the accuracy of the solution.

## 3. Are there any limitations to the accuracy of the heat PDE solution?

Yes, there are limitations to the accuracy of the heat PDE solution. These limitations can arise from the choice of numerical method, the size of the time and space steps, and the complexity of the initial conditions. In some cases, the solution may also be limited by the computational resources available.

## 4. How can we determine if the heat PDE solution is accurate enough?

The accuracy of the heat PDE solution can be determined by comparing it to analytical solutions or by conducting convergence tests. Convergence tests involve solving the PDE with different grid sizes and time steps and examining how the solution changes. If the solution approaches a stable value as the grid size and time step decrease, then the solution is considered accurate.

## 5. Can the heat PDE solution be used for all initial conditions?

No, the heat PDE solution is designed to model specific types of initial conditions, such as those that involve heat transfer. It may not be applicable to other types of initial conditions, such as those involving chemical reactions or fluid flow. In these cases, a different PDE or numerical method may be more appropriate.

• Differential Equations
Replies
4
Views
1K
Replies
14
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
• Calculus and Beyond Homework Help
Replies
11
Views
797
• Differential Equations
Replies
7
Views
2K
Replies
52
Views
5K
• Calculus and Beyond Homework Help
Replies
5
Views
311
• Differential Equations
Replies
3
Views
2K
• Calculus
Replies
17
Views
2K
• Differential Equations
Replies
5
Views
2K