def FV_2D_Nwave(x1):

    sigma = x1[0][0]
    k_lensc = x1[0][1]
    h_bathy_pts = np.array([[x1[0][2]], [x1[0][3]], [x1[0][4]], [x1[0][5]],
                            [x1[0][6]], [x1[0][7]], [x1[0][8]]])
    # [x1[0][7]], [x1[0][8]] ]);
    amp_ratio = x1[0][9]
    # Amplitude ratio
    t1 = x1[0][10]
    # Time of crest peak
    t2 = x1[0][11]
    # Time of triugh peak

    dx = variables_file.dx
    Amp = variables_file.Amp
    CFL = variables_file.CFL
    g = variables_file.g
    eps = variables_file.eps
    lb = variables_file.lb
    ub = variables_file.ub
    N = variables_file.N
    h0 = variables_file.h0
    xc = variables_file.xc
    x_bathy = variables_file.x_bathy
    slope_upper = variables_file.slope_upper
    slope_lower = variables_file.slope_lower
    slope = variables_file.slope

    T = 5 * (t1 - t2) + 40

    #from the breakwater_interpolate file
    [gp_bathy,
     h_bathy_only] = bathy_GP(h_bathy_pts, k_lensc, sigma, xc, x_bathy,
                              slope_upper, slope_lower, slope)

    h = np.zeros(xc.shape)
    for i in range(xc.shape[0]):
        if (xc[i, 0] <= 0):
            h[i, 0] = h_bathy_only[i, 0]
        else:
            h[i, 0] = h0[i, 0]

    W = np.zeros((N, 2, 1))
    W[:, 0, :] = np.maximum(h, eps)

    t = 0
    iteration = 0

    fig = plt.figure()
    ax1 = fig.add_subplot(1, 1, 1)

    runup_all = np.zeros([1, 1])
    inund_all = np.zeros([1, 1])
    time_all = np.zeros([1, 1])

    while (t < T):

        dt = time_step(W, CFL, dx, eps, g)
        # Runge-kutta
        k1 = dt * rhs(W, t, N, dx, eps, h, g, xc, Amp, amp_ratio, t1, t2)
        k2 = dt * rhs(W + 0.5 * k1, t + 0.5 * dt, N, dx, eps, h, g, xc, Amp,
                      amp_ratio, t1, t2)
        k3 = dt * rhs(W + 0.5 * k2, t + 0.5 * dt, N, dx, eps, h, g, xc, Amp,
                      amp_ratio, t1, t2)
        k4 = dt * rhs(W + k3, t + dt, N, dx, eps, h, g, xc, Amp, amp_ratio, t1,
                      t2)
        W = W + (k1 + 2 * k2 + 2 * k3 + k4) / 6

        [runup, inund] = runup_inund_calc(W, xc, h)

        iteration = iteration + 1

        if (iteration == 1):
            runup_all[0, 0] = runup
            inund_all[0, 0] = inund
            time_all[0, 0] = t
        elif (iteration > 1):
            runup_all = np.append(runup_all, [[runup]], axis=0)
            inund_all = np.append(inund_all, [[inund]], axis=0)
            time_all = np.append(time_all, [[t]], axis=0)

        t = t + dt

        ax1.clear()
        ax1.plot(xc, W[:, 0, :] - h, 'b-')
        ax1.plot(xc, -h, 'r-')
        ax1.set_xlabel('x (m)', fontsize=13)
        ax1.set_ylabel('y (m)', fontsize=13)
        plt.pause(1e-17)
        time.sleep(0.000001)

    plt.show()

    index_peaks = find_peaks(runup_all[:, 0], height=0)
    runup_max = runup_all[index_peaks[0][0], 0]

    return -runup_max
def FV_2D(x1):

    sigma = x1[0][0]
    k_lensc = x1[0][1]
    xc_brk = x1[0][2]
    h_brk = np.array([[x1[0][3]], [x1[0][4]], [x1[0][5]], [x1[0][6]],
                      [x1[0][7]], [x1[0][8]], [x1[0][9]]])

    dx = variables_file.dx
    Amp = variables_file.Amp
    T_per = variables_file.T_per
    omega = variables_file.omega
    CFL = variables_file.CFL
    g = variables_file.g
    eps = variables_file.eps
    lb = variables_file.lb
    ub = variables_file.ub
    N = variables_file.N
    h0 = variables_file.h0
    T = variables_file.T
    xc = variables_file.xc
    brk_width = variables_file.brk_width
    x_brk = variables_file.x_brk

    #from the breakwater_interpolate file
    [gp_brk, h_brk_only] = brk_GP(h_brk, k_lensc, sigma, xc_brk, brk_width, xc,
                                  x_brk)

    h = np.zeros(xc.shape)
    for i in range(xc.shape[0]):
        if (h_brk_only[i, 0] != 0):
            h[i, 0] = h_brk_only[i, 0]
        else:
            h[i, 0] = h0[i, 0]

    W = np.zeros((N, 2, 1))
    W[:, 0, :] = np.maximum(h, eps)

    t = 0
    iteration = 0

    fig = plt.figure()
    ax1 = fig.add_subplot(1, 1, 1)

    runup_all = np.zeros([1, 1])
    inund_all = np.zeros([1, 1])
    time_all = np.zeros([1, 1])

    while (t < T):

        dt = time_step(W, CFL, dx, eps, g)
        # Runge-kutta
        k1 = dt * rhs(W, t, N, dx, eps, h, g, Amp, T_per, xc)
        k2 = dt * rhs(W + 0.5 * k1, t + 0.5 * dt, N, dx, eps, h, g, Amp, T_per,
                      xc)
        k3 = dt * rhs(W + 0.5 * k2, t + 0.5 * dt, N, dx, eps, h, g, Amp, T_per,
                      xc)
        k4 = dt * rhs(W + k3, t + dt, N, dx, eps, h, g, Amp, T_per, xc)
        W = W + (k1 + 2 * k2 + 2 * k3 + k4) / 6

        [runup, inund] = runup_inund_calc(W, xc, h)

        t = t + dt
        iteration = iteration + 1

        if (iteration == 1):
            runup_all[0, 0] = runup
            inund_all[0, 0] = inund
            time_all[0, 0] = t
        elif (iteration > 1):
            runup_all = np.append(runup_all, [[runup]], axis=0)
            inund_all = np.append(inund_all, [[inund]], axis=0)
            time_all = np.append(time_all, [[t]], axis=0)

        ax1.clear()
        ax1.plot(xc, W[:, 0, :] - h, 'b-')
        ax1.plot(xc, -h, 'r-')
        ax1.set_xlabel('x (m)', fontsize=13)
        ax1.set_ylabel('y (m)', fontsize=13)
        plt.pause(1e-17)
        time.sleep(0.000001)

    plt.show()

    runup_max = max(runup_all[:, 0])
    inund_max = max(inund_all[:, 0])

    return [runup_max, time_all, runup_all]