Why Does Increasing Final Run Time Cause Divergence in Finite Differencing?

  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Error Finite
Click For Summary
Increasing the final run time (tf) in a finite difference scheme can lead to numerical divergence due to stability issues tied to the time step (Δt) and spatial discretization (Δz). The discussion highlights the importance of adhering to the CFL stability criterion, which dictates that Δt must be appropriately scaled relative to Δz to maintain stability. Participants suggest performing a von Neumann stability analysis to derive conditions for stability, particularly for nonlinear equations. The conversation also touches on the challenges of linearizing nonlinear PDEs for stability analysis and the implications of initial conditions on numerical results. Ultimately, the relationship between tf and numerical stability is emphasized, particularly in how increasing time iterations can allow for larger tf values without divergence.
  • #31
Chestermiller said:
Follow up to posts #18 and 19: Are you sure that the volume is the integral of h2 (and not h)?
Chet
Yes, I am sure that the volume can be represented as ##F \int_{-L}^L h^2 dz## where ##F## is a known constant. How were you thinking to proceed?
 
Physics news on Phys.org
  • #32
joshmccraney said:
Yes, I am sure that the volume can be represented as ##F \int_{-L}^L h^2 dz## where ##F## is a known constant. How were you thinking to proceed?
I have something definitely in mind. Let me get you started. What do you get if you take the derivative of V with respect to time, applying the Leibnitz rule on the right hand side of the equation?

Chet
 
  • #33
Chestermiller said:
What do you get if you take the derivative of V with respect to time, applying the Leibnitz rule on the right hand side of the equation?
Chet

I assume ##V## is volume? Then we have $$\frac{\partial V}{\partial t} = \frac{\partial}{\partial t} \int_{-L}^L h^2 dz = \int_{-L}^L 2h h_t \, dz + 2h^2(L,t) \frac{dL}{dt}$$
since ##h## is even with respect to ##z##. Do you agree?
 
  • #34
joshmccraney said:
I assume ##V## is volume? Then we have $$\frac{\partial V}{\partial t} = \frac{\partial}{\partial t} \int_{-L}^L h^2 dz = \int_{-L}^L 2h h_t \, dz + 2h^2(L,t) \frac{dL}{dt}$$
since ##h## is even with respect to ##z##. Do you agree?
Yes. Now h(L,t) = 0, so
$$\frac{dV}{dt}= \frac{\partial}{\partial t} \left(\int_{-L}^L h^2 dz\right) = \int_{-L}^L\left(\frac{\partial h^2}{\partial t}\right) dz $$
But, if we combine this with the differential equation, we obtain:
$$\frac{dV}{dt}= \int_{-L}^L\left(\frac{\partial h^2}{\partial t}\right) dz=\frac{4}{3}\left(\frac{\partial h^3}{\partial z}\right)_{z=L}=0 $$
Do you agree?

Chet
 
  • #35
Chestermiller said:
Do you agree?

I do, since ##h## is even we evaluate from ##[0,L]## and multiply by ##2##. Then we are left with the expression you wrote since ##h_z(0,t)=0##. The last equality holds since volume is conserved. This is getting fun; what's the next plan? Obviously this qualifies your taylor expansion and post 24.
 
  • #36
joshmccraney said:
I do, since ##h## is even we evaluate from ##[0,L]## and multiply by ##2##. Then we are left with the expression you wrote since ##h_z(0,t)=0##. The last equality holds since volume is conserved. This is getting fun; what's the next plan? Obviously this qualifies your taylor expansion and post 24.
Yes, we are going to use Taylor series expansion. But, first I would like to go back to the transformed version of the problem:
$$\frac{\partial h^2}{\partial t}=Z\left(\frac{\partial h^2}{\partial Z}\right)\frac{1}{L}\frac{dL}{dt}+\frac{2}{3L^2}\frac{\partial ^2h^3}{\partial Z^2}\tag{1}$$
We note from the final equation of post #34 that volume will be conserved if, in the vicinity of Z=1, h is directly proportional to (Z-1). This also satisfies the boundary condition that h = 0 at Z = 1. So it makes sense to expand h in a Taylor series about Z = 1 as follows:
$$h=c_1(Z-1)+c_2(Z-1)^2+...\tag{2}$$
where
$$c_1(t)=\left(\frac{\partial h}{\partial Z}\right)_{Z=1}\tag{3}$$
$$c_2(t)=\frac{1}{2}\left(\frac{\partial^2 h}{\partial Z^2}\right)_{Z=1}\tag{4}$$
Retaining only the first two terms in Eqn. 2, what is h2 and h3 (also retaining only the first two terms in these expressions)?

Chet
 
  • #37
Chestermiller said:
So it makes sense to expand h in a Taylor series about Z = 1 as follows:
$$h=c_1(Z-1)+c_2(Z-1)^2+...\tag{2}$$
where
$$c_1(t)=\left(\frac{\partial h}{\partial Z}\right)_{Z=1}\tag{3}$$
$$c_2(t)=\frac{1}{2}\left(\frac{\partial^2 h}{\partial Z^2}\right)_{Z=1}\tag{4}$$
Retaining only the first two terms in Eqn. 2, what is h2 and h3 (also retaining only the first two terms in these expressions)?
Chet

I assume you are looking for all terms before ##\mathcal{O}(Z-1)^3##? If so I arrive at $$h^2 = c_1(t)(Z-1)^2 + \mathcal{O}(Z-1)^3 \\h^3 = 0 + \mathcal{O}(Z-1)^3$$
How does this look?
 
  • #38
joshmccraney said:
I assume you are looking for all terms before ##\mathcal{O}(Z-1)^3##? If so I arrive at $$h^2 = c_1(t)(Z-1)^2 + \mathcal{O}(Z-1)^3 \\h^3 = 0 + \mathcal{O}(Z-1)^3$$
How does this look?
I was thinking more like:

h^2=c_1^2(Z-1)^2+2c_1c_2(Z-1)^3
$$h^3=c_1^3(Z-1)^3+3c_1^2c_2(Z-1)^4$$

Next, please substitute these into the differential equation, and then write out the equations that are the coefficients of (Z-1) and (Z-1)2.

Chet
 
  • #39
Ahh, now I se why you wanted the first two terms. We have $$2 c_1 c_1'(Z-1)^2 + 2(Z-1)^3(c_2c'_1+c_1 c_2') = Z\left[ 2 c_1^2(Z-1) + 6c_1 c_2 (Z-1)^2 \right]\frac{1}{L}\frac{dL}{dt} + \frac{2}{3L^2}\left[ 6c_1^3(Z-1)+36c_1^2c_2(Z-1)^2 \right] \implies\\
\mathcal{O}(Z-1): 0 = 3 L Z \frac{dL}{dt} + 2c_1\\
\mathcal{O}(Z-1)^2: c_1' L^2 = 3Zc_2 L\frac{dL}{dt} + 12c_1c_2 $$
Are you getting the same? I should say I have simplified and also canceled some ##c_1## terms since we are looking at a limit and can cancel.
 
Last edited by a moderator:
  • #40
Yes. This expansion is accurate in the vicinity of Z = 1. If we now collect the coefficients of (Z-1), we get:
$$\frac{2Z c_1^2}{L}\frac{dL}{dt} + \frac{4c_1^3}{3L^2}=0$$
Rearranging this and evaluating it at Z = 1 (otherwise we could have written Z = 1+(Z-1)), we get
$$L\frac{dL}{dt}=-\frac{2}{3}c_1$$
So, if we know ##c_1(t)##, we can integrate this to get L(t). Care to offer a finite difference approximation for ## c_1## in terms of h(1-ΔZ)?

Chet
 
  • #41
Chestermiller said:
Care to offer a finite difference approximation for ## c_1## in terms of h(1-ΔZ)?
Chet
$$c_1(t) = \left( \frac{\partial h}{\partial Z} \right)_{Z=1} \approx \frac{h(t,1)-h(t,1-\Delta Z)}{\Delta Z}$$ yet ##h(t,Z=1)=0## thus we may write $$c_1(t) \approx \frac{h(t,1-\Delta Z)}{\Delta Z}$$
Is this what you were thinking?
 
  • #42
joshmccraney said:
$$c_1(t) = \left( \frac{\partial h}{\partial Z} \right)_{Z=1} \approx \frac{h(t,1)-h(t,1-\Delta Z)}{\Delta Z}$$ yet ##h(t,Z=1)=0## thus we may write $$c_1(t) \approx \frac{h(t,1-\Delta Z)}{\Delta Z}$$
Is this what you were thinking?
Yes, except for a missing minus sign. Now you can substitute this into the equation for dL/dt to obtain ?

Chet
 
  • #43
Chestermiller said:
Yes, except for a missing minus sign. Now you can substitute this into the equation for dL/dt to obtain ?
Chet

We have $$ \int_{L_0}^L L' \, dL' \approx \frac{2}{3} \int_0^t \frac{h(t',1-\Delta Z)}{\Delta Z} \, dt' \implies \\
L = \sqrt{L_0^2 + \frac{4}{3} \int_0^t \frac{h(t',1-\Delta Z)}{\Delta Z} \, dt'}$$ where prime notation denotes dummy variables and ##L_0## is the initial length. I dropped the minus sign after the root since we can work with positive ##Z## domain. How to solve the integral though?
 
Last edited by a moderator:
  • #44
$$L^2(t+Δt)=L^2(t)+\frac{4}{3}\frac{h(t,1-ΔZ)}{\Delta Z}Δt$$
In the main differential equation, you need L2, and you need ##\frac{1}{L}\frac{dL}{dt}##. But,
$$\frac{1}{L}\frac{dL}{dt}=\frac{L}{L^2}\frac{dL}{dt}=\frac{1}{2L^2}\frac{dL^2}{dt}$$
This is approximated numerically by:
$$\frac{1}{2L^2}\frac{dL^2}{dt}≈\frac{\frac{2}{3}\frac{h(t,1-ΔZ)}{\Delta Z}}{L^2(t)+\frac{2}{3}\frac{h(t,1-ΔZ)}{\Delta Z}Δt}$$
Note that this is evaluated half way between t and t + Δt (for better numerical accuracy). In the main differential equation, you also evaluate the L2 at t+Δt/2:
$$L^2(t+Δt/2)=L^2(t)+\frac{2}{3}\frac{h(t,1-ΔZ)}{\Delta Z}Δt$$
So, at each time step, you first evaluate the new values of the two expressions involving L in the main differential equation and then use these same values at each grid point to evaluate the new h^2's.

Chet
 
Last edited:
  • #45
Chestermiller said:
$$L^2(t+Δt)=L^2(t)+\frac{4}{3}h(t,1-ΔZ)Δt$$
I'm trying to follow your work, and it looks like you're doing this: $$ \int_{L(t)}^{L(t+\Delta t)} L dL' = \frac{2}{3}\int_{t}^{t+\Delta t}\frac{h(t',1-\Delta Z)}{\Delta Z} dt' $$ Evidently $$\int_{t}^{t+\Delta t}\frac{h(t',1-\Delta Z)}{\Delta Z} dt' = h(t',1-\Delta Z) \Delta t$$ Could you explain this? I don't see how the ##\Delta Z## is gone.

Chestermiller said:
This is approximated numerically by:
$$\frac{1}{2L^2}\frac{dL^2}{dt}≈\frac{\frac{2}{3}h(t,1-ΔZ)Δt}{L^2(t)+\frac{2}{3}h(t,1-ΔZ)Δt}$$

I'm also having trouble here, if you can help? I understand that ##L^2## in the denominator is ## L^2(t)+\frac{2}{3}h(t,1-ΔZ)Δt## from above (although shouldn't it be ## L^2(t)+\frac{4}{3}h(t,1-ΔZ)Δt##?) If so, this means $$\frac{1}{2}\frac{d L^2}{dt} = \frac{2}{3} h(t,1-\Delta Z)\Delta t$$. Could you also explain this please?

Thanks so much! You're great!
 
  • #46
joshmccraney said:
I'm trying to follow your work, and it looks like you're doing this: $$ \int_{L(t)}^{L(t+\Delta t)} L dL' = \frac{2}{3}\int_{t}^{t+\Delta t}\frac{h(t',1-\Delta Z)}{\Delta Z} dt' $$ Evidently $$\int_{t}^{t+\Delta t}\frac{h(t',1-\Delta Z)}{\Delta Z} dt' = h(t',1-\Delta Z) \Delta t$$ Could you explain this? I don't see how the ##\Delta Z## is gone.
Oops. I left out the delta z. I'm going back and correcting all the equations. Thanks for spotting this.
I'm also having trouble here, if you can help? I understand that ##L^2## in the denominator is ## L^2(t)+\frac{2}{3}h(t,1-ΔZ)Δt## from above (although shouldn't it be ## L^2(t)+\frac{4}{3}h(t,1-ΔZ)Δt##?)
No. It's being evaluated at the time half-way across the interval to provide better accuracy in the time integration of the main differential equation.
If so, this means $$\frac{1}{2}\frac{d L^2}{dt} = \frac{2}{3} h(t,1-\Delta Z)\Delta t$$. Could you also explain this please?

Ooooops. Another mistake. Going back to correct that too. Please give me about 10 minutes to correct it, and then let me know if it's OK.

Chet
 
  • #47
I think I follow you. Let me reiterate it and you let me know if I've made a mistake. Begin with

$$\int_{L(t)}^{L(t+\Delta t)}L' dL' =\frac{2}{3} \int_t^{t+\Delta t}\frac{h(t',1-\Delta Z)}{\Delta Z} dt' \implies\\
L^2(t+\Delta t) = L^2(t) + \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z} \Delta t $$ Thus we have an expression for ##L^2(t+\Delta t)##. The integral was approximated using a left endpoint rule. Next we must find ##dL/dt##. Begin where we left off

$$ L^2(t+\Delta t) = L^2(t) + \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z} \Delta t \implies\\
\frac{L^2(t+\Delta t) - L^2(t)}{\Delta t} = \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z}$$ Notice the left side term is an approximation of ##dL/dt##. Plugging in the above into
$$\frac{1}{L}\frac{dL}{dt}=\frac{L}{L^2}\frac{dL}{dt}=\frac{1}{2L^2}\frac{dL^2}{dt}$$
Is approximated numerically by:
$$\left.\frac{1}{2L^2}\frac{dL^2}{dt}\right|_{t=t+\Delta t} = \frac{\frac{2}{3} \frac{h(t',1-\Delta Z)}{\Delta Z}}{L^2(t) + \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z} \Delta t }$$

I'm missing the ##t+\Delta t/2## concept, though.
 
  • #48
joshmccraney said:
I think I follow you. Let me reiterate it and you let me know if I've made a mistake. Begin with

$$\int_{L(t)}^{L(t+\Delta t)}L' dL' =\frac{2}{3} \int_t^{t+\Delta t}\frac{h(t',1-\Delta Z)}{\Delta Z} dt' \implies\\
L^2(t+\Delta t) = L^2(t) + \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z} \Delta t $$
I would replace the t primes in the finite difference equation with t. That goes for all the other finite difference equations below as well.
Thus we have an expression for ##L^2(t+\Delta t)##. The integral was approximated using a left endpoint rule. Next we must find ##dL/dt##. Begin where we left off

$$ L^2(t+\Delta t) = L^2(t) + \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z} \Delta t \implies\\
\frac{L^2(t+\Delta t) - L^2(t)}{\Delta t} = \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z}$$ Notice the left side term is an approximation of ##dL/dt##. Plugging in the above into
$$\frac{1}{L}\frac{dL}{dt}=\frac{L}{L^2}\frac{dL}{dt}=\frac{1}{2L^2}\frac{dL^2}{dt}$$
Is approximated numerically by:
$$\left.\frac{1}{2L^2}\frac{dL^2}{dt}\right|_{t=t+\Delta t} = \frac{\frac{2}{3} \frac{h(t',1-\Delta Z)}{\Delta Z}}{L^2(t) + \frac{4}{3} \frac{h(t',1-\Delta Z)}{\Delta Z} \Delta t }$$

I'm missing the ##t+\Delta t/2## concept, though.
For extra accuracy, I'm trying to evaluate the entire term at the average over the time interval between t and t + Δt, rather than at either end of the interval. It really doesn't matter much whether, in the denominator, you use L2(t), L2(t+Δt/2), or L2(t+Δt). L2(t+Δt/2) just gives a little more accuracy at no additional computational cost. If you want to use the value at t + Δt, I have no major problem with that. I just feel that, if the added accuracy is there for the taking, why not take it?

Chet
 
  • Like
Likes member 428835
  • #49
Chestermiller said:
I would replace the t primes in the finite difference equation with t. That goes for all the other finite difference equations below as well.
Ooops, yea, I didn't see this. My fault.

Chestermiller said:
For extra accuracy, I'm trying to evaluate the entire term at the average over the time interval between t and t + Δt, rather than at either end of the interval.
Chet

So it seems what changes is the 4 in the denominator turns into a 2, right? Does this stem from $$\frac{\partial h}{\partial t} \approx \frac{h(t+\Delta t/2)-h(t)}{\Delta t/2}$$

So then we are solving $$\left(\frac{\partial y}{\partial t}\right)_Z=Z\left(\frac{\partial y}{\partial Z}\right)_t\frac{1}{L}\frac{dL}{dt}+\frac{2}{3L^2}\frac{\partial ^2(y^{3/2})}{\partial Z^2}$$

where we just found an expression for the ##L## terms. Boundary conditions are ##y(t,Z=\pm 1)=0##, and ##y'(t,Z=0)=0##. Am I missing any BC's and how would we take a finite difference of the non-linear term? We can't just write it as ##(y_i^j)^{3/2}## can we? The chain rule should be considered, right? Or should we not make the ##y## transform and stay with ##h## using instead the ##Z=z/L(t)##?
 
  • #50
joshmccraney said:
Ooops, yea, I didn't see this. My fault.
So it seems what changes is the 4 in the denominator turns into a 2, right? Does this stem from $$\frac{\partial h}{\partial t} \approx \frac{h(t+\Delta t/2)-h(t)}{\Delta t/2}$$
No. We are still doing
$$\frac{\partial y}{\partial t} \approx \frac{y(t+\Delta t)-y(t)}{\Delta t}$$
But you get extra accuracy if you evaluate the right hand side of the equation at t + Δt/2.
So then we are solving $$\left(\frac{\partial y}{\partial t}\right)_Z=Z\left(\frac{\partial y}{\partial Z}\right)_t\frac{1}{L}\frac{dL}{dt}+\frac{2}{3L^2}\frac{\partial ^2(y^{3/2})}{\partial Z^2}$$

where we just found an expression for the ##L## terms. Boundary conditions are ##y(t,Z=\pm 1)=0##, and ##y'(t,Z=0)=0##. Am I missing any BC's
Yes. I'm hoping that you are only solving the equation over the domain from 0 to 1, and not from -1 to + 1. And I'm hoping that, at y = 0, you are solving the differential equation for y(0) using a reflective boundary condition, rather than just setting y(0) equal to y(Δz)
and how would we take a finite difference of the non-linear term? We can't just write it as ##(y_i^j)^{3/2}## can we?
Yes. This is what you should do.
The chain rule should be considered, right? Or should we not make the ##y## transform and stay with ##h## using instead the ##Z=z/L(t)##?
No and no.

Chet
 
  • #51
Chestermiller said:
I'm hoping that you are only solving the equation over the domain from 0 to 1, and not from -1 to + 1.
Absolutely!
Chestermiller said:
And I'm hoping that, at y = 0, you are solving the differential equation for y(0) using a reflective boundary condition, rather than just setting y(0) equal to y(Δz)
I'm a little unsure of what you are saying here. Can you specify please?
 
  • #52
joshmccraney said:
Absolutely!
I'm a little unsure of what you are saying here. Can you specify please?
$$\left(\frac{\partial y}{\partial t}\right)_Z=Z\left(\frac{\partial y}{\partial Z}\right)_t\frac{1}{L}\frac{dL}{dt}+\frac{2}{3L^2}\frac{\partial ^2(y^{3/2})}{\partial Z^2}$$
At z = 0, ##\frac{\partial y}{\partial Z}=0##, then ##y^{3/2}(-ΔZ)=y^{3/2}(+ΔZ)##. This means that:
$$y^{3/2}(-ΔZ)-2y^{3/2}(0)+y^{3/2}(+Δz)=2[y^{3/2}(+Δz)-y^{3/2}(0)]$$
So, at Z = 0,
$$\frac{y(0,t+Δt)-y(0,t)}{Δt}=\frac{4}{3L^2}\frac{[y^{3/2}(t,+Δz)-y^{3/2}(t,0)]}{(ΔZ)^2}$$

This is the finite difference equation that should be used at Z = 0.

Chet
 
  • #53
I'm with you! Thanks for clearing that up! Ok, so since our thoughts have been all over the place (mainly due to my questions) I've decided to type up a latex document. I'll post the pdf when I finish it for both your review and others who may want to see the answer but don't want to look through all the conversation. Thanks a ton for your help. I'll probably be writing on this thread before the pdf is finished, as I want to ensure the FD is correct.
 
  • #54
Please note also, that, as things stand now, you are still using Forward Euler to integrate with respect to time. If stability is an issue, you can control it by taking the time step small enough. But please note that, in terms of stability, Forward Euler is the worst scheme that one can use. So, if the time step is too large, the scheme will go unstable. Stability problems can typically be removed by going to so-called implicit schemes, such as Backward Euler, in which the right hand side of the equation is evaluated at t + Δt, rather than t. But this requires the solution of a set of coupled algebraic equations at each time step. Hopefully, for your problem, Forward Euler will be adequate. But, if not, I can help.

Chet
 
  • #55
Chet, I have a quick question about taking a finite difference over non-linear terms. Notice the following $$ \frac{\partial (h^2)}{\partial t} = 2h\frac{\partial h}{\partial t}$$ Applying a finite difference to each yields $$\frac{\partial (h^2)}{\partial t} = \frac{h^2(t+\Delta t) - h^2(t)}{\Delta t}$$ but also $$ 2h\frac{\partial h}{\partial t} = 2 h(t) \frac{h(t+\Delta t)-h(t)}{\Delta t} $$ Clearly the finite differences are not equal. Can you explain what is happening?
 
  • #56
Attached is the finite difference technique along with how we arrived. Please review it, especially the end, and let me know what you think. The conclusion doesn't look right. EDIT: the limits should be from the left, but you get the idea.
 

Attachments

  • #57
joshmccraney said:
Chet, I have a quick question about taking a finite difference over non-linear terms. Notice the following $$ \frac{\partial (h^2)}{\partial t} = 2h\frac{\partial h}{\partial t}$$ Applying a finite difference to each yields $$\frac{\partial (h^2)}{\partial t} = \frac{h^2(t+\Delta t) - h^2(t)}{\Delta t}$$ but also $$ 2h\frac{\partial h}{\partial t} = 2 h(t) \frac{h(t+\Delta t)-h(t)}{\Delta t} $$ Clearly the finite differences are not equal. Can you explain what is happening?
These are two slightly different first order finite difference approximations to the exact same quantity, and, as such, neither one of them is favored over the other. In each case, the discretization error decreases linearly with Δt when Δt becomes small. To see that, expand h(t+Δt) in a Taylor series about t, and substitute the resulting series into each of the two finite difference approximations.

Chet
 
  • Like
Likes member 428835
  • #58
joshmccraney said:
Attached is the finite difference technique along with how we arrived. Please review it, especially the end, and let me know what you think. The conclusion doesn't look right. EDIT: the limits should be from the left, but you get the idea.
Corrections:

Eqn. 16 should be the derivative of h3, not h.

In Eqn. 25, there should be a 2 in the numerator, not a 4. I would also prefer to see a 4 in the denominator, but I can't strongly argue against the 4.

Eqn. 26 is incorrect. The second derivative of h3 with respect to Z has been evaluated incorrectly.

I didn't check Eqns. 28 and 29.

Josh,

I've had a huge amount of practical experience with numerical analysis, particularly on problems like this one. And that practical experience involved many situations in which a lot of money was riding on the outcome of the correct numerical solution of the equations. Based on this experience, I am very strongly urging you to solve this problem numerically in terms of y rather than in terms of h, for the following reasons:

1. There are many fewer mathematical operations involved in solving it this way
2. There is much less of a chance of making a coding error
3. The finite difference equations that result in this approach automatically conserve volume, unlike the scheme involving h, in which volume is conserved only in the limit of vanishing ##\Delta Z##

If I were coding this problem, starting from the beginning of each time step (so that y is known at all grid points at time t), I would carry out the following sequence of steps:

1. Calculate y3/2 at all the grid points
2. Calculate √y at the grid point adjacent to the right boundary. This is h at that location.
3. Calculate L2(t+Δt) and (1/L)dL/dt
4. Evaluate the right hand side of the main differential equation at each grid point
5. Execute a time step at each grid point

Chet
 
  • #59
Chestermiller said:
These are two slightly different first order finite difference approximations to the exact same quantity, and, as such, neither one of them is favored over the other. In each case, the discretization error decreases linearly with Δt when Δt becomes small. To see that, expand h(t+Δt) in a Taylor series about t, and substitute the resulting series into each of the two finite difference approximations.
Chet

Ok, this is cool! I just did the expansion and it works. Awesome!
 
  • #60
Chestermiller said:
Josh,

I've had a huge amount of practical experience with numerical analysis, particularly on problems like this one. And that practical experience involved many situations in which a lot of money was riding on the outcome of the correct numerical solution of the equations. Based on this experience, I am very strongly urging you to solve this problem numerically in terms of y rather than in terms of h
Chet

I'll definitely do it this way now that I see (from your previous post) that the expansion is the same! This was not immediately obvious to me, hence why I never introduced the ##y## transform. Thanks so much fro your help, Chet! Stay tuned, as I'll fix the corrections, introduce the transform, and also post a flow chart for the code (although you've seem to have already done this).

You're awesome!
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K