Exemple #1
0
def main(dir,
         casename="fct+iga",
         lamb_x0=2.,
         lamb_y0=1.,
         time_l=[1, 3, 7],
         dt=0.01,
         nxy=400,
         xy_lim=10,
         eps=1.e-7):
    plt.figure(1, figsize=(9, 8))
    #plotting comparison between analytic solution and model results
    for it, time in enumerate(time_l):
        print "plotting for " + casename + ", t = " + str(time)
        #model variables TODO: time
        h_m, px_m, py_m = reading_modeloutput(dir +
                                              "spreading_drop_2delipsa_" +
                                              casename +
                                              ".out/timestep0000000" +
                                              str(int(time / dt)) + '.h5')
        # calculate velocity (momentum/height) only in the droplet region.
        vy_m = np.where(h_m > eps, py_m / h_m, 0)
        vx_m = np.where(h_m > eps, px_m / h_m, 0)

        # calculating the analatycial solution for t=time
        x_range = y_range = np.linspace(-xy_lim, xy_lim, nxy)
        lamb_ar = an_eq.d2_el_lamb_lamb_t_evol(time, lamb_x0, lamb_y0)
        h_an = an_eq.d2_el_height_plane(lamb_ar[0], lamb_ar[2], x_range,
                                        y_range)
        v_an = an_eq.d2_el_velocity_tot_plane(lamb_ar[0], lamb_ar[1],
                                              lamb_ar[2], lamb_ar[3], x_range,
                                              y_range)

        # calculating depth for t=0
        h_an0 = an_eq.d2_el_height_plane(2, 1, x_range, x_range)
        # two vertical cross-scections
        hx_an, hy_an = h_an[nxy / 2, :], h_an[:, nxy / 2]
        hx_an0, hy_an0 = h_an0[nxy / 2, :], h_an0[:, nxy / 2]
        vx_an = np.where(hx_an > eps, x_range / lamb_ar[0] * lamb_ar[1], 0)
        vy_an = np.where(hy_an > eps, y_range / lamb_ar[2] * lamb_ar[3], 0)

        #plotting xz vertical cross-sections
        ax = plt.subplot(len(time_l), 2, 2 * it + 1)
        lab_op = ["u"]
        if it == len(time_l) - 1:
            lab_op = lab_op + ["x"]
        analytic_model_fig(ax, np.linspace(-xy_lim, xy_lim, nxy),
                           np.zeros(nxy), h_m[:, nxy / 2], vx_m[:, nxy / 2],
                           hx_an0, hx_an, vx_an, lab_op, " t= " + str(time))

        #plotting yz vertical cross-sections
        ax = plt.subplot(len(time_l), 2, 2 * it + 2)
        lab_op = ["v"]
        if it == len(time_l) - 1:
            lab_op = lab_op + ["y"]
        analytic_model_fig(ax, np.linspace(-xy_lim, xy_lim, nxy),
                           np.zeros(nxy), h_m[nxy / 2, :], vy_m[nxy / 2, :],
                           hy_an0, hy_an, vy_an, lab_op, " t= " + str(time))

    plt.savefig("fig6.pdf")
    plt.show()
def main(dir, casename="fct+iga", lamb_x0=2., lamb_y0=1., time_l=[1,3,7], 
         dt=0.01, nxy=400, xy_lim=10, eps=1.e-7):
    plt.figure(1, figsize = (9,8))
    #plotting comparison between analytic solution and model results 
    for it, time in enumerate(time_l):
        print "plotting for " + casename + ", t = " + str(time)
        #model variables TODO: time
        h_m, px_m, py_m = reading_modeloutput(dir+"spreading_drop_2delipsa_" + casename + ".out/timestep0000000" + str(int(time/dt)) + '.h5')
        # calculate velocity (momentum/height) only in the droplet region.
        vy_m = np.where(h_m>eps, py_m / h_m, 0)
        vx_m = np.where(h_m>eps, px_m / h_m, 0)
        
        # calculating the analatycial solution for t=time
        x_range = y_range = np.linspace(-xy_lim, xy_lim, nxy)
        lamb_ar = an_eq.d2_el_lamb_lamb_t_evol(time, lamb_x0, lamb_y0)
        h_an = an_eq.d2_el_height_plane(lamb_ar[0], lamb_ar[2], x_range, y_range)
        v_an = an_eq.d2_el_velocity_tot_plane(lamb_ar[0], lamb_ar[1], lamb_ar[2],
                                              lamb_ar[3], x_range, y_range)
      
        # calculating depth for t=0
        h_an0 = an_eq.d2_el_height_plane(2, 1, x_range, x_range)        
        # two vertical cross-scections 
        hx_an, hy_an = h_an[nxy/2,:], h_an[:,nxy/2]
        hx_an0, hy_an0 = h_an0[nxy/2,:], h_an0[:,nxy/2]
        vx_an = np.where(hx_an>eps, x_range/lamb_ar[0] * lamb_ar[1],0)
        vy_an = np.where(hy_an>eps, y_range/lamb_ar[2] * lamb_ar[3], 0)

        #plotting xz vertical cross-sections
        ax = plt.subplot(len(time_l),2,2*it+1)
        lab_op = ["u"]
        if it == len(time_l)-1:
            lab_op = lab_op + ["x"]
        analytic_model_fig(ax,
                           np.linspace(-xy_lim, xy_lim, nxy),np.zeros(nxy),
                           h_m[:,nxy/2], vx_m[:, nxy/2], hx_an0, hx_an, vx_an, 
                           lab_op, " t= "+str(time))

        #plotting yz vertical cross-sections
        ax = plt.subplot(len(time_l),2,2*it+2)  
        lab_op = ["v"]
        if it == len(time_l)-1:
            lab_op = lab_op + ["y"]
        analytic_model_fig(ax,
                           np.linspace(-xy_lim, xy_lim, nxy), np.zeros(nxy),
                           h_m[nxy/2,:], vy_m[nxy/2,:], hy_an0, hy_an, vy_an, 
                           lab_op, " t= "+str(time))   

    plt.savefig("fig6.pdf")
    plt.show()
def main(dir,
         lamb_x0=2.,
         lamb_y0=1.,
         time=7,
         dt=0.01,
         dx=0.05,
         xy_lim=10,
         casename="fct+iga",
         eps=1.e-7):
    x_range = y_range = np.arange(-xy_lim, xy_lim, dx)
    time_str = str(int(time / dt))
    h_m, px_m, py_m = reading_modeloutput(dir + "spreading_drop_2delipsa_" +
                                          casename + ".out/timestep0000000" +
                                          time_str + '.h5')
    #calculating the analytical solution
    lamb_ar = an_eq.d2_el_lamb_lamb_t_evol(time, lamb_x0, lamb_y0)
    h_an = an_eq.d2_el_height_plane(lamb_ar[0], lamb_ar[2], x_range, y_range)
    #the error is normalized by initial height of the drop
    h0_max = 1. / (lamb_x0 * lamb_y0)
    h_diff = abs(h_m - h_an) / h0_max
    print "max of abs(h_m-h_an), h_an.max, h_m.max", abs(
        h_diff).max(), h_an.max(), h_m.max()
    levels_diff = np.linspace(1.e-10, 2.e-3, 4)
    plt.figure(1, figsize=(3., 3.))
    ax = plt.subplot(1, 1, 1, aspect='equal')
    contour_plot(ax, h_diff, x_range, y_range, levels_var=levels_diff)
    plt.savefig("fig7.pdf")
    plt.show()
def errors(dir, dt, dx, time_l, xy_lim, casename, eps, lamb_x0=2., lamb_y0=1.):
    x_range = y_range = np.arange(-xy_lim, xy_lim, dx)
    for it, time in enumerate(time_l):
        print "\n", "TIME t = " + str(time), "dx, dt", dx, dt
        time_str = str(int(time/dt))
        # reading the mode output
        # TODO: simplify the files names
        if time/dt >= 1000:
            h_m, px_m, py_m = reading_modeloutput(dir + casename + ".out/timestep000000" + time_str + '.h5')
        elif time/dt < 100:
            h_m, px_m, py_m = reading_modeloutput(dir + casename + ".out/timestep00000000" + time_str + '.h5')
        else:
            h_m, px_m, py_m = reading_modeloutput(dir + casename + ".out/timestep0000000" + time_str + '.h5')

        # calculating the analytical solution 
        lamb_ar = an_eq.d2_el_lamb_lamb_t_evol(time, lamb_x0=lamb_x0, lamb_y0=lamb_y0)
        h_an = an_eq.d2_el_height_plane(lamb_ar[0], lamb_ar[2], x_range, y_range)
                        
        # calculating the errors of the drop depth, eq. 25 and 26 from the paper
        h_diff = h_m - h_an
        points_nr = h_m.shape[0]*h_m.shape[1]
        print "number of points in the domain, max(h_an), max(h_num)", points_nr, h_an.max(), h_m.max()
        h0_max = 1. / lamb_x0 / lamb_y0
        delh_inf = abs(h_diff).max() / h0_max 
        delh_2 = 1./time * ((h_diff**2).sum() / points_nr )**0.5 

        print "L_inf = max|h_m-h_an|/h_0", delh_inf 
        print "L_2 = sqrt(sum(h_m-h_an)^2 / N) / time", delh_2, "\n"
def main(dir, lamb_x0=2.0, lamb_y0=1.0, time=7, dt=0.01, dx=0.05, xy_lim=10, casename="fct+iga", eps=1.0e-7):
    x_range = y_range = np.arange(-xy_lim, xy_lim, dx)
    time_str = str(int(time / dt))
    h_m, px_m, py_m = reading_modeloutput(
        dir + "spreading_drop_2delipsa_" + casename + ".out/timestep0000000" + time_str + ".h5"
    )
    # calculating the analytical solution
    lamb_ar = an_eq.d2_el_lamb_lamb_t_evol(time, lamb_x0, lamb_y0)
    h_an = an_eq.d2_el_height_plane(lamb_ar[0], lamb_ar[2], x_range, y_range)
    # the error is normalized by initial height of the drop
    h0_max = 1.0 / (lamb_x0 * lamb_y0)
    h_diff = abs(h_m - h_an) / h0_max
    print "max of abs(h_m-h_an), h_an.max, h_m.max", abs(h_diff).max(), h_an.max(), h_m.max()
    levels_diff = np.linspace(1.0e-10, 2.0e-3, 4)
    plt.figure(1, figsize=(3.0, 3.0))
    ax = plt.subplot(1, 1, 1, aspect="equal")
    contour_plot(ax, h_diff, x_range, y_range, levels_var=levels_diff)
    plt.savefig("fig7.pdf")
    plt.show()
def errors(dir, dt, dx, time_l, xy_lim, casename, eps, lamb_x0=2., lamb_y0=1.):
    x_range = y_range = np.arange(-xy_lim, xy_lim, dx)
    for it, time in enumerate(time_l):
        print "\n", "TIME t = " + str(time), "dx, dt", dx, dt
        time_str = str(int(time / dt))
        # reading the mode output
        # TODO: simplify the files names
        if time / dt >= 1000:
            h_m, px_m, py_m = reading_modeloutput(dir + casename +
                                                  ".out/timestep000000" +
                                                  time_str + '.h5')
        elif time / dt < 100:
            h_m, px_m, py_m = reading_modeloutput(dir + casename +
                                                  ".out/timestep00000000" +
                                                  time_str + '.h5')
        else:
            h_m, px_m, py_m = reading_modeloutput(dir + casename +
                                                  ".out/timestep0000000" +
                                                  time_str + '.h5')

        # calculating the analytical solution
        lamb_ar = an_eq.d2_el_lamb_lamb_t_evol(time,
                                               lamb_x0=lamb_x0,
                                               lamb_y0=lamb_y0)
        h_an = an_eq.d2_el_height_plane(lamb_ar[0], lamb_ar[2], x_range,
                                        y_range)

        # calculating the errors of the drop depth, eq. 25 and 26 from the paper
        h_diff = h_m - h_an
        points_nr = h_m.shape[0] * h_m.shape[1]
        print "number of points in the domain, max(h_an), max(h_num)", points_nr, h_an.max(
        ), h_m.max()
        h0_max = 1. / lamb_x0 / lamb_y0
        delh_inf = abs(h_diff).max() / h0_max
        delh_2 = 1. / time * ((h_diff**2).sum() / points_nr)**0.5

        print "L_inf = max|h_m-h_an|/h_0", delh_inf
        print "L_2 = sqrt(sum(h_m-h_an)^2 / N) / time", delh_2, "\n"