Pure Diffusion - Energy Balance
I try to model pure diffusion case, considered with solving of the one-dimensional convection-diffusion equation (considering no flow, v=0 so no convection but only diffusion!). The Matlab code is given below. Accordingly, the initial condition is with 'the top water mass of the tank is at 90 °C while the bottom water mass of the tank is at 40 °C' fifty-fifty. You can see the temperature profile changing through time, below (you can see that stratification expands with time):
https://i.postimg.cc/x1Z3fmNz/2018-1...-_Figure_1.png The problem is that when I calculate the energy content/enthalpy through the tank height at each time step; I found that the overall tank enthalpy increases through time by only the diffusion effect. The energy content shall stay at the same level through time since there is only diffusion (no heat loss or gain considered). The calculation procedure is as the sum of all node enthalpies (each node enthalpy calculated by node mass x specific enthalpy of the node temperature) at each time step. Would you please tell me why this energy content (enthalpy) increase occurs with time? Can the reason be the finite difference method (Shall I accept such error, the enthalpy increase, due to numerical matters?)? https://i.postimg.cc/28rDGb6h/2018-1...-_Figure_1.png Code:
function [T,H] = CDR_FTCS_Diffusion(t_final,n) |
I do not consider the matlab code now but start the question showing all the equations of your model that you want to solve. Describe the PDE and the discretization.
|
Quote:
https://i.postimg.cc/HnDCJRcd/2018-1...nt1_-_Word.png |
Why do you discretize this way the spatial derivative?
It is simply (uniform mesh) (T(i-1)-2*T(i)+T(i+1))/h^2 |
Quote:
I carried out the same simulation with Crank-Nicolson scheme (this time no mixing characterization so alpha is constant). Still, I have this increase even with Crank-Nicolson. I need to indicate that the increase ratio at pure diffusion case (both by Crank-Nicolson and FTCS) is at around 0.6% (after some reasonably large time). Is this increase reasonable when using finite difference methods? |
Quote:
well, the PDE you wrote is not congruent to what you are doing.... If alpha is variable, you wrote a wrong PDE since you should write d/dx(alpha(x,t)*dT/dx) A general convection-diffusion equation would write in divergence form as dT/dt + d/dx (u*T - alpha(x,t)*dT/dx)=0 If you discretize on a compact stencil your formula is over 2h not over 4h |
Quote:
https://i.postimg.cc/MGcnKGGf/2018-1...nt1_-_Word.png and the relative error (still there is this increase, killing me :( ): https://i.postimg.cc/3x1qJKqh/2018-1...-_Figure_1.png Code:
function [T,H] = CDR_FTCS_Simple_Diffusion(t_final,n) |
It seems that you change the density with temperature.
Neither your PDE nor your energy integration is taking that into account. |
How do you compute the curve? Be careful, your equation describes a pure diffusion problem but, depending on the BCs., you could be prescribing an entering heat flux!
What are exactly your BCs.? |
Quote:
|
Quote:
Code:
T(n+1,j)=T(n,j); % Neumann boundary condition with backward Euler |
Quote:
Compute the integral of the temperature over the domain |
Quote:
(ii) and (iii) Can you please give more details about these points? I didn't get the idea. |
Quote:
Let us start first by a theoretical result: the equation can be integrated over the total volume and can be rewritten as d/dt Int[V] T dx = alpha [ dT/dx|BC_right -dT/dx|BC_left] = 0 Therefore the solution must ensure Int[V] T dx= constant, being such constant equal to that at the initial condition. If you adopt a FV method, the equation above can be used to define the flux function alpha*dT/dx on each section. The "telescopic" property ensures that, numerically, the temperature is conserved, depending only on the values of the flux at the boundaries. Therefore, the numerical check requires only to compute the difference between Int[V] T dx at any time and the value computed at t=0. Ideally such difference is zero, check if numerically is of the order of the adopted (single/double) precision. |
Quote:
|
All times are GMT -4. The time now is 07:26. |