CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Linearization of implicit terms (http://www.cfd-online.com/Forums/main/108120-linearization-implicit-terms.html)

Simbelmynė October 15, 2012 09:50

Linearization of implicit terms
 
Hey,

If we discretize the (1d) heat equation implicitly. Is it possible to approximate some of the implicit terms using known values in time as follows

\frac{T^{n+1}_{i}-T^{n}_{i}}{\Delta} = \frac{\alpha}{(\Delta x)^{2}}\left( T_{i-1} - 2T_{i} + T_{i+1}\right)|^{n+1}

For the right hand side lets approximate all T^{n+1} as

T^{n+1}=2T^{n}-T^{n-1}

This yields an equation that has an explicit dependence. However, there does not seem to be any stability benefits of the approach over regular explicit discretization. Question is why :)

FMDenaro October 15, 2012 11:35

Quote:

Originally Posted by Simbelmynė (Post 386683)
Hey,

If we discretize the (1d) heat equation implicitly. Is it possible to approximate some of the implicit terms using known values in time as follows

\frac{T^{n+1}_{i}-T^{n}_{i}}{\Delta} = \frac{\alpha}{(\Delta x)^{2}}\left( T_{i-1} - 2T_{i} + T_{i+1}\right)|^{n+1}

For the right hand side lets approximate all T^{n+1} as

T^{n+1}=2T^{n}-T^{n-1}

This yields an equation that has an explicit dependence. However, there does not seem to be any stability benefits of the approach over regular explicit discretization. Question is why :)


what you have written corresponds to have a second derivative in time equated to zero at tn ...
I don't see why to do that, you have a simply linear algebraic system to solve with a Thomas algorithm...

Simbelmynė October 15, 2012 13:08

Quote:

Originally Posted by FMDenaro (Post 386716)
what you have written corresponds to have a second derivative in time equated to zero at tn ...
I don't see why to do that, you have a simply linear algebraic system to solve with a Thomas algorithm...

Hey, thank you for your reply. I am aware of how to solve the system implicitly, but I wish to solve it explicitly (not necessarily the 1d heat equation, but that is good enough for the example) and was thinking of ways to reduce the time-step constraint.

Let me put down the full equation:


\frac{T^{n+1}_{i}-T^{n}_{i}}{\Delta t} = \frac{\alpha}{(\Delta x)^{2}}\left( 2T^{n}_{i-1} - T^{n-1}_{i-1}- 2(2T^{n}_{i} - T^{n-1}_{i})+ T^{n}_{i+1} - T^{n-1}_{i+1} \right)

The above discretization works, but it is not any better than standard explicit discretization with regard to the time-step.

FMDenaro October 15, 2012 13:26

Quote:

Originally Posted by Simbelmynė (Post 386739)
Hey, thank you for your reply. I am aware of how to solve the system implicitly, but I wish to solve it explicitly (not necessarily the 1d heat equation, but that is good enough for the example) and was thinking of ways to reduce the time-step constraint.

Let me put down the full equation:


\frac{T^{n+1}_{i}-T^{n}_{i}}{\Delta t} = \frac{\alpha}{(\Delta x)^{2}}\left( 2T^{n}_{i-1} - T^{n-1}_{i-1}- 2(2T^{n}_{i} - T^{n-1}_{i})+ T^{n}_{i+1} - T^{n-1}_{i+1} \right)

The above discretization works, but it is not any better than standard explicit discretization with regard to the time-step.


if you force the second derivative in time to be zero, you are supposing simply a linear behavior of T between time step tn-1 and tn+1. That means the first derivative is approximated as a constant function (first order accurate). To get higher accuracy you have to use more accurate explicit schemes...

Simbelmynė October 15, 2012 13:50

Quote:

Originally Posted by FMDenaro (Post 386742)
if you force the second derivative in time to be zero, you are supposing simply a linear behavior of T between time step tn-1 and tn+1. That means the first derivative is approximated as a constant function (first order accurate). To get higher accuracy you have to use more accurate explicit schemes...

I don't think that I follow how I force the second derivative in time to be zero. What I did was approximate the original equation using a forward difference for the time derivative and assuming the space derivative is evaluated at time level (n+1). I then used a Taylor expansion to approximate T(n+1) and truncated after the second term (first derivative). I approximated the derivative using a backward difference. I am not interested in accuracy (yet) only stability.

When I look at the resulting difference equation it seems that for small time-steps it should correspond to standard explicit differencing, forward time centered space.

FMDenaro October 15, 2012 14:54

Quote:

Originally Posted by Simbelmynė (Post 386747)
I don't think that I follow how I force the second derivative in time to be zero. What I did was approximate the original equation using a forward difference for the time derivative and assuming the space derivative is evaluated at time level (n+1). I then used a Taylor expansion to approximate T(n+1) and truncated after the second term (first derivative). I approximated the derivative using a backward difference. I am not interested in accuracy (yet) only stability.

When I look at the resulting difference equation it seems that for small time-steps it should correspond to standard explicit differencing, forward time centered space.


I am not sure to understand what you are looking for...
Consider the differenzial equation:

dT/dt = alpha*d^2T/dx^2

that can be integrated in time as

Tn+1 - Tn = alpha* Int [tn, tn+1] d^2T/dx^2 dt

The LHS can be written by means of Taylor expansion as

Tn+1 - Tn = dt*|dT/dt|n + dt^2/2 * |d^2T/dt^2|n + ...

Then

Tn+1 - Tn = dt*alpha*|d^2T/dx^2|n + dt^2/2 * |d^2T/dt^2|n + ...

Now, you can use a Lax-Wendroff type procedure:
d^2T/dt^2 = d/dt (alpha*d^2T/dx^2)= alpha^2*d^4T/dx^4

This leads to a single-step second order accurate time-discretization that is explicit.

Your procedure (Tn+1=2*Tn-Tn-1) is equivalent to say that

(Tn+1 -2*Tn +Tn-1)/dt^2 = d^2T/dt^2 + O(dt^2) = 0

Therefore, you force that
d^2T/dt^2 = O(dt^2)

Simbelmynė October 15, 2012 15:39

Quote:

Originally Posted by FMDenaro (Post 386753)
I am not sure to understand what you are looking for...
Consider the differenzial equation:

dT/dt = alpha*d^2T/dx^2

that can be integrated in time as

Tn+1 - Tn = alpha* Int [tn, tn+1] d^2T/dx^2 dt

The LHS can be written by means of Taylor expansion as

Tn+1 - Tn = dt*|dT/dt|n + dt^2/2 * |d^2T/dt^2|n + ...

Then

Tn+1 - Tn = dt*alpha*|d^2T/dx^2|n + dt^2/2 * |d^2T/dt^2|n + ...

Now, you can use a Lax-Wendroff type procedure:
d^2T/dt^2 = d/dt (alpha*d^2T/dx^2)= alpha^2*d^4T/dx^4

This leads to a single-step second order accurate time-discretization that is explicit.

Your procedure (Tn+1=2*Tn-Tn-1) is equivalent to say that

(Tn+1 -2*Tn +Tn-1)/dt^2 = d^2T/dt^2 + O(dt^2) = 0

Therefore, you force that
d^2T/dt^2 = O(dt^2)

Thank you for the input. Perhaps what I try to do is not valid (but it still works ;)), here is some further explanation.

T^{n+1}_{i} = T^{n}_{i} + \left(\frac {\partial T}{\partial t}\right)^{n}_{i}\Delta t (1)

then approximate the \left(\frac {\partial T}{\partial t}\right)^{n}_{i} term as

\left(\frac {\partial T}{\partial t}\right)^{n}_{i} = \frac{T^{n}_{i} - T^{n-1}_{i}}{\Delta t} (2)

I don't know if this is a valid operation since we could just as well state from (1) that

\left(\frac {\partial T}{\partial t}\right)^{n}_{i} = \frac{T^{n+1}_{i} - T^{n}_{i}}{\Delta t} (3)

Anyways, (2) in (1) leads to

T^{n+1}=2T^{n}-T^{n-1}

I assume that the derivatives can be written using higher order approximations as you state.

Shenren_CN October 15, 2012 17:25

When you start writing those finite difference equations using \approx or using \equal but including the H.O.T. you'll find the subtle difference.

Quote:

Originally Posted by Simbelmynė (Post 386757)
Thank you for the input. Perhaps what I try to do is not valid (but it still works ;)), here is some further explanation.

T^{n+1}_{i} = T^{n}_{i} + \left(\frac {\partial T}{\partial t}\right)^{n}_{i}\Delta t (1)

then approximate the \left(\frac {\partial T}{\partial t}\right)^{n}_{i} term as

\left(\frac {\partial T}{\partial t}\right)^{n}_{i} = \frac{T^{n}_{i} - T^{n-1}_{i}}{\Delta t} (2)

I don't know if this is a valid operation since we could just as well state from (1) that

\left(\frac {\partial T}{\partial t}\right)^{n}_{i} = \frac{T^{n+1}_{i} - T^{n}_{i}}{\Delta t} (3)

Anyways, (2) in (1) leads to

T^{n+1}=2T^{n}-T^{n-1}

I assume that the derivatives can be written using higher order approximations as you state.


Simbelmynė October 16, 2012 03:17

Quote:

Originally Posted by Shenren_CN (Post 386768)
When you start writing those finite difference equations using \approx or using \equal but including the H.O.T. you'll find the subtle difference.

I am sorry I have no idea what you mean with \approx or \equal in this context. Is it possible for you to show what you mean?

Thank you.

FMDenaro October 16, 2012 03:24

Quote:

Originally Posted by Simbelmynė (Post 386803)
I am sorry I have no idea what you mean with \approx or \equal in this context. Is it possible for you to show what you mean?

Thank you.


I think he said that Eq.s (2) and (3) have to be written as approximation. If you use "equal to" then you have to explicitate the local truncation error, this way you will see what you are disregarding

Simbelmynė October 16, 2012 04:53

Quote:

Originally Posted by FMDenaro (Post 386805)
I think he said that Eq.s (2) and (3) have to be written as approximation. If you use "equal to" then you have to explicitate the local truncation error, this way you will see what you are disregarding

Ok, I might do this wrong because I don't see your point here, but here goes:


T^{n+1}_{i} = T^{n}_{i} + \left(\frac {\partial T}{\partial t}\right)^{n}_{i}\Delta t + HOT...O(\Delta t)^{2} (1)


T^{n-1}_{i} = T^{n}_{i} - \left(\frac {\partial T}{\partial t}\right)^{n}_{i}\Delta t + HOT...O(\Delta t)^{2} (2)

from (2) we get an expression

\left(\frac {\partial T}{\partial t}\right)^{n}_{i}\Delta t = T^{n}_{i} - T^{n-1}_{i} + HOT...O(\Delta t)^{2} (3)

(3) is inserted in (1)

T^{n+1}_{i} = T^{n}_{i} +T^{n}_{i} - T^{n-1}_{i} + HOT...O(\Delta t)^{2}

What am I supposed to see?

michujo October 16, 2012 09:46

Hi, when they say to write down the higher order terms they mean to actually write them down:

T^{n+1}=T^n+\frac{dT}{dt}\cdot \Delta t+\frac{d^2T}{dt^2}\cdot\frac{(\Delta t)^2}{2}+\frac{d^3T}{dt^3}\cdot\frac{(\Delta t)^3}{6} +\mathcal{O}(\Delta t)^4 (1)

and

T^{n-1}=T^n-\frac{dT}{dt}\cdot \Delta t+\frac{d^2T}{dt^2}\cdot\frac{(\Delta t)^2}{2}-\frac{d^3T}{dt^3}\cdot\frac{(\Delta t)^3}{6} +\mathcal{O}(\Delta t)^4 (2)

Combining (1) and (2) one gets:

T^{n+1}+T^{n-1}=2T^n+\frac{d^2T}{dt^2}\cdot\frac{(\Delta t)^2}{2}+\mathcal{O}(\Delta t)^4

Here you see that the expression you came up with results from setting the second derivative to zero.

I hope it helps.

Cheers,
Michujo.

Simbelmynė October 16, 2012 18:08

Quote:

Originally Posted by michujo (Post 386890)
Hi, when they say to write down the higher order terms they mean to actually write them down:

T^{n+1}=T^n+\frac{dT}{dt}\cdot \Delta t+\frac{d^2T}{dt^2}\cdot\frac{(\Delta t)^2}{2}+\frac{d^3T}{dt^3}\cdot\frac{(\Delta t)^3}{6} +\mathcal{O}(\Delta t)^4 (1)

and

T^{n-1}=T^n-\frac{dT}{dt}\cdot \Delta t+\frac{d^2T}{dt^2}\cdot\frac{(\Delta t)^2}{2}-\frac{d^3T}{dt^3}\cdot\frac{(\Delta t)^3}{6} +\mathcal{O}(\Delta t)^4 (2)

Combining (1) and (2) one gets:

T^{n+1}+T^{n-1}=2T^n+\frac{d^2T}{dt^2}\cdot\frac{(\Delta t)^2}{2}+\mathcal{O}(\Delta t)^4

Here you see that the expression you came up with results from setting the second derivative to zero.

I hope it helps.

Cheers,
Michujo.

Ok, thank you. To me it just says that I set the second derivative to zero if I wish to maintain fourth order accuracy.

However, being semi-smart I realize that after three people here trying to explain the phenomena I should have got it by now. I think that I will try tomorrow when the beer from the fantastic game between Germany and Sweden wears off (guess my nationality). Also, I do get some angry comments from the beautiful woman in the next room. Why does she not understand the fun of CFD? :)

Simbelmynė October 17, 2012 04:25

I think I get your points now. Thank you.

For instance if I would have put

T^{n+1} = T^{n}

that would correspond to setting the first derivative to zero.

So, is it possible to express T^{n+1} in terms of known values?

Edit:

One more thing;

It is not uncommon to extrapolate values around boundaries using mean value over the boundary (same as above essentially).

T_{i-1} = 2T_{i} - T_{i+1}

So this also forces the second (space) derivative to be zero at the boundary, correct?

michujo October 17, 2012 05:38

Hi, you could try a higher order discretization of your time derivative if you wish to increase time accuracy. Instead of discretizing the time derivative as:

\frac{\partial T}{\partial t}=\frac{T^{n+1}-T^n}{\Delta t}

you could try

\frac{\partial T}{\partial t}=\frac{3\cdot T^{n+1}-4\cdot T^n+T^{n-1}}{2\cdot \Delta t}

This expression is second order in time. The RHS of your equation is left untouched (fully implicit).

Cheers,
Michujo.

P.S: I took this scheme from Versteeg&Malalasekera, 2nd Edition, page 264.

FMDenaro October 17, 2012 06:09

Quote:

Originally Posted by Simbelmynė (Post 387025)
I think I get your points now. Thank you.

For instance if I would have put

T^{n+1} = T^{n}

that would correspond to setting the first derivative to zero.

So, is it possible to express T^{n+1} in terms of known values?

Edit:

One more thing;

It is not uncommon to extrapolate values around boundaries using mean value over the boundary (same as above essentially).

T_{i-1} = 2T_{i} - T_{i+1}

So this also forces the second (space) derivative to be zero at the boundary, correct?

yes, such a condition is typical of an outflow BC for developed flows

Simbelmynė October 17, 2012 06:44

Quote:

Originally Posted by FMDenaro (Post 387060)
yes, such a condition is typical of an outflow BC for developed flows

Really? Isn't a zero gradient condition used in such cases?

I would rather use the above condition if the variables are given on the boundary and the computational nodes do not coincide with the boundary.

Anyways, could you explain why forcing the second derivative to be zero is a bad thing in my case? Since I am not concerned with accuracy and I truncate the second derivative term, it could be "over 9000" as far as I am concerned ;)

Edit:

Perhaps you were referring to the zero gradient (1st order)

T^{n+1} = T^{n}

while my comment was about

T_{i-1} = 2T_{i} - T_{i+1}

michujo October 17, 2012 10:41

Hi, I did a stability analysis of your scheme (with the substitution of all the T^n+1 terms on the RHS by 2*T^n-T^n-1).

After a very long calculation I came up with the condition:

\frac{\alpha \cdot \Delta t}{(\Delta x)^2}<\frac{1}{6}

The scheme seems to be conditionally stable (as is the explicit scheme). However, the stability domain is reduced from \frac{\alpha \cdot \Delta t}{(\Delta x)^2}<\frac{1}{2} to \frac{\alpha \cdot \Delta t}{(\Delta x)^2}<\frac{1}{6}


You could check this behaviour in your code. I might have made some mistakes on the way, the calculation was a bit cumbersome.
In short: the trick you made does not help in the stability of the scheme, but rather it leads to a worse situation...

Did it help?

Cheers,
Michujo.

Simbelmynė October 17, 2012 13:08

Quote:

Originally Posted by michujo (Post 387104)
Hi, I did a stability analysis of your scheme (with the substitution of all the T^n+1 terms on the RHS by 2*T^n-T^n-1).

After a very long calculation I came up with the condition:

\frac{\alpha \cdot \Delta t}{(\Delta x)^2}<\frac{1}{6}

The scheme seems to be conditionally stable (as is the explicit scheme). However, the stability domain is reduced from \frac{\alpha \cdot \Delta t}{(\Delta x)^2}<\frac{1}{2} to \frac{\alpha \cdot \Delta t}{(\Delta x)^2}<\frac{1}{6}


You could check this behaviour in your code. I might have made some mistakes on the way, the calculation was a bit cumbersome.
In short: the trick you made does not help in the stability of the scheme, but rather it leads to a worse situation...

Did it help?

Cheers,
Michujo.


Thank you this is in accordance with my own simulations (as stated in my original post).

So as usual, there are no shortcuts :)


All times are GMT -4. The time now is 06:51.