Example #1
0
def burgers1Dexact(xvect, tvect, x0, qL, qR, iMAX):
    for ti in tvect:
        #        yield flx.nlers2(qL, qR, (xvect-x0)/ti)
        xi = (xvect - x0) / ti
        solution = []
        for i in range(iMAX):
            solution.append(flx.nlers(qL, qR, xi[i]))
        yield solution
Example #2
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-")