# Finite Difference Question

1. Aug 25, 2015

### joshmccraney

Hi PF!

I was wondering if anyone could help me with a finite difference question? The problem I am doing is a 1-D space and time problem, so $z$ (space variable, from left to right) and $t$ (time) are my independent variables and my dependent variable is $h$, the height, governed by a PDE I don't think we need to get into. There is a moving boundary at both ends of $z$, however.

My question is, in writing a code I am doing a central finite difference scheme for all interior nodes and then for the node on the far left I am taking a forward difference and for the node are the far right I am taking a backward difference in order to evaluate these endpoints.

Is this a legitimate approach or is there something I am missing?

Thanks so much for your input!

Josh

2. Aug 26, 2015

### soarce

What is your boundary condition? You could extend your grid by adding an aditional fictitious point at each end and by imposing the boundary condition in terms of central finite differences you get the condition for the actual end points.

3. Aug 26, 2015

### joshmccraney

The boundary conditions are the right tip is zero and the left is 1. I believe I understand what you're proposing; not a bad idea.

Is there anything wrong with the technique I have used though? For some reason my code isn't working and I'm troubleshooting it. I can give this technique a try, though, but is there something wrong that you can see from what I've explained?

4. Aug 26, 2015

### soarce

The method you described should work, I have no experience with moving boundary conditions. To maintain the accuracy probably one uses a different stencil at the boundary. This modifies the symmetry of the matrix and in case of a dedicated matrix solver you can get into trouble. You can reduce the accurary at the boundary by using a first order stencil which preserve the symmetry of the matrix.

Can you write here the equation which you try to solve?

5. Aug 26, 2015

### soarce

The "zero boundary condition" means $f(z_b)=0$ or $f(z_b)\rightarrow 0$ at boundary $z_b$?

Last edited: Aug 26, 2015
6. Aug 26, 2015

### joshmccraney

The equation is $$h_t = h_{zz} \cdot h + 2 (h_z)^2$$. There is an integral constraint that dictates the position of the left tip, and a linear solution in time and space solves this PDE, which implies the right tip is linear; thus I linearly extrapolate to find it.