0
$\begingroup$

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

$$C(i,n+1)=C(i,n)-V\left[1+\frac{1}{2}\psi(r_i)-\frac{1}{2}\frac{1}{(r_i-1)}\psi(r_i-1)\right]\left(C(i,n)-C(i-1,n)\right)$$

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?

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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