Ejemplo n.º 1
0
def plot_fv1D(
    xL,
    xR,
    x0,
    iMAX,
    qL,
    qR,
    tSTART,
    tEND,
    courant,
    nummtd,
    order="first",
    solintmtd="simple",
    maxiter=10000,
    pause=0.005,
    ylimext=0.15,
):
    # equidistant distribution of iMAX points between xL and xR
    xvect, dx = np.linspace(xL, xR, iMAX, retstep=True)
    # equidistant distribution of points between each spatial step
    xvect_b, dx_b = np.linspace(xL + dx / 2.0, xR - dx / 2.0, iMAX, retstep=True)
    # Initial condition
    solution = flx.shock(xvect_b, x0, qL, qR)
    # plot the first solution for t = o
    plt.ion()
    fig = plt.figure()
    ax = fig.add_subplot(111)
    qL_limit, qR_limit = get_q_limit(qL, qR, ylimext)
    # import pdb; pdb.set_trace()
    # print xvect_b
    # print prettyp(solution[:10])
    line1, = ax.plot(xvect_b, solution, "o")
    # plt.ylim( ( qL_limit, qR_limit ) )
    for time, solution in ORDER[order](solution, dx, qL, qR, tSTART, tEND, courant, nummtd, solintmtd, maxiter=10000):
        plt.pause(pause)
        ax.clear()
        # print xvect_b
        # print prettyp(solution[:10])
        plt.title("Current time t = {:6.5f}".format(time))
        line1, = ax.plot(xvect_b, solution, "o")
        xi = (xvect - x0) / time
        line2, = ax.plot(xvect_b, [flx.nlers(qL, qR, xq) for xq in xi], "r-")
Ejemplo n.º 2
0
def plot_burgers1Dexact(xL, xR, iMAX, x0, qL, qR, tEND, tMAX, pause=0.005, ylimext=0.15, **kargs):
    # compute the domine in space and time
    xvect, dx = np.linspace(xL, xR, iMAX, retstep=True)
    tvect, dt = np.linspace(0, tEND, tMAX, retstep=True)
    print ("the space step dx is: {0}".format(dx))
    print ("the time step dt is: {0}".format(dt))
    plt.ion()
    fig = plt.figure()
    ax = fig.add_subplot(111)
    qL_limit, qR_limit = (qL * (1.0 - ylimext), qR * (1.0 + ylimext))
    # compute initial state t = 0
    line1, = ax.plot(xvect, flx.shock(xvect, x0, qL, qR), "r-")
    plt.ylim((qL_limit, qR_limit))
    plt.pause(pause)
    # start the cycle for each step
    for solution in burgers1Dexact(xvect, tvect[1:], x0, qL, qR, iMAX):
        ax.clear()
        line1, = ax.plot(xvect, solution, "r-")
        plt.ylim((qL_limit, qR_limit))
        plt.pause(pause)