Example #1
0
def checkCFL(solution, dx, courant, time, tEND):
    """Return dt and boolean value
    Check CFL stability and final time matching

    >>> checkCFL([1,1,1,1,0,0,0,0], 0.5, 1, 1, 3,)
    0.5, False
    >>> checkCFL([1,1,1,1,0,0,0,0], 0.5, 1, 2.5, 3,)
    0.5, False
    >>> checkCFL([1,1,1,1,0,0,0,0], 0.5, 1, 2.6, 3,)
    0.5, False

    dt = c * dx / max( abs( eigenvalue(q) ) );
    if(time + dt > t1)
        dt = t1-time;
    end
    if(time >= t1)
        break
    end"""
    maxflux = np.max(np.abs(flx.eigenvalue(solution)))
    dt = courant * dx / maxflux
    # if dt == np.nan: return dt, False
    if time + dt > tEND:
        return tEND - time, False
    if time >= tEND:
        return -9999, False
    # strformat = 'time={t:6.5f}; dt={dt:6.5f}; dx={dx:6.5f}; c={c:3.2f}; maxflux={fl:6.5f};'
    # print(strformat.format(t=time, dt=dt, dx=dx, c=courant, fl=maxflux) )
    # return dt and stop
    return dt, True
Example #2
0
def g(q, xi):
    """
    function y = g(q,xi)
        y = eigenvalue(q)-xi;
    """
    return flx.eigenvalue(q)-xi