I have worked with MATLAB for calculating below equation for any time ($n$) and place($i$). In this equation, flux limiter is used.


By writing the equation, the amount of flux limiter in the time zero ($n=0$) faced problem.

As you know, $r_i=\frac{C(i+1,n)-C(i,n)}{C(i,n)-C(i-1,n)}$, which the amount of $C$ in the time zero ($n=0$) for all places ($i$) is the same, then I reached undefined value ($0/0$) for $r$ in time zero($n=0$).

Is there any equation or any amount for calculating $r$ in the time of zero?


You can rewrite the limiter into a form that avoids division by zero, by checking the nominator and denominator with a couple of 'if' statements.

Alternatively, you can add a small number with the appropriate sign: $$r_i = \frac{C(i+1,n)-C(i,n) \pm \epsilon}{C(i,n)-C(i-1,n) \pm \epsilon}$$ where $\epsilon$ is a small positive constant, that should be added to a positive term and subtracted from a negative term, to prevent $r_i$ from changing sign.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.