def draw_value_along_curve(t, f, sigma, limits, fname, title, save):

    fig = plt.figure()
    plt.plot(t / np.max(t), f, color='black')
    plt.fill_between(t / np.max(t),
                     f - sigma,
                     f + sigma,
                     color='red',
                     alpha=0.5,
                     linewidth=0)
    #plt.title(title)

    plt.axes().set_ylim(limits)

    plt.ylabel(r'$C_l^{||}$')
    plt.xlabel(r'$t$')

    myplt.set_font_sizes(plt.gca())
    myplt.make_grid(plt.gca())

    if save:
        myplt.save_figure(fig, 3.5, fname)
        #fig.savefig(fname, bbox_inches='tight')
        plt.close(fig)
    else:
        plt.show()
Ejemplo n.º 2
0
def dump_plots(positions, alldata, ref):

    plt.plot(ref[:, 0],
             ref[:, 1],
             "o",
             color="C0",
             label="C. Liu et al., Lab on a Chip (2015)",
             zorder=2,
             markeredgewidth=0.75,
             markeredgecolor='black',
             ms=3)

    for data, err, label, fmt, color in alldata:
        plt.errorbar(positions,
                     data,
                     yerr=err,
                     fmt=fmt,
                     color=color,
                     label=label,
                     markeredgewidth=0.75,
                     markeredgecolor='black',
                     ms=3,
                     zorder=3)

    ax = plt.gca()

    plt.xlabel(r'$y/R$')
    plt.ylabel(r'$C_{l}$')
    #plt.legend()

    myplt.set_font_sizes(ax)
    myplt.make_grid(ax)
def draw_cross_section(alldata,
                       gpY,
                       gpZ,
                       sep,
                       equilibria,
                       points,
                       title,
                       fname,
                       save,
                       rotation=True):

    fig = plt.figure()

    #plt.title(title)
    plt.xlabel('$y / (H/2)$')
    plt.ylabel('$z / (H/2)$')
    myplt.set_font_sizes(plt.gca())

    plt.axes().set_xlim([-0.02, 0.72])
    plt.axes().set_ylim([-0.02, 0.72])

    plt.axes().set_aspect('equal', 'box', anchor='SW')

    norm, cmap = draw_quiver(alldata)

    x = np.linspace(0, 0.7, 40)
    y = np.linspace(0, 0.7, 40)
    X, Y = np.meshgrid(x, y)
    grid = np.array([X.flatten(), Y.flatten()]).T
    #draw_gp(grid, gpY, gpZ, norm, cmap)

    plt.plot(sep[:, 0], sep[:, 1], color='grey', linewidth=2)

    if rotation:
        plt.scatter(sep[:, 0][0],
                    sep[:, 1][0],
                    color='C3',
                    linewidth=1.5,
                    s=25.0,
                    zorder=5)
        plt.scatter(sep[:, 0][-1],
                    sep[:, 1][-1],
                    facecolors='none',
                    edgecolors='C3',
                    linewidth=1.5,
                    s=25.0,
                    zorder=5)


#    plt.scatter( points[0,:], points[1,:], color='C3', s=5.0, zorder=5)

    if save:
        myplt.save_figure(fig, 4.5, fname)
        #fig.savefig(fname, bbox_inches='tight')
        plt.close(fig)
    else:
        plt.show()

    return fig
Ejemplo n.º 4
0
def prepare_plot(ax):

    myplt.make_grid(ax, True)
    myplt.set_font_sizes(ax)
    ax.set_xscale("log", nonposx='clip')
    ax.set_yscale("log", nonposy='clip')

    ax.set_xlabel("Operational intensity")
    ax.set_ylabel("GFLOPs / s")
Ejemplo n.º 5
0
def dump_plots(positions, alldata, r1, r2):
    
    plt.plot(r1[:,0], r1[:,1], "o", color="C0", zorder=2, markeredgewidth=0.75, markeredgecolor='black', ms=3, label="Nakagawa et al., J. Fluid Mech (2015)")
    plt.plot(r2[:,0], r2[:,1], "s", color="C1", zorder=2, markeredgewidth=0.75, markeredgecolor='black', ms=3, label="Di Carlo et al., Phys Rev Lett (2009)")
        
    for data, err, label, fmt in alldata:
        plt.errorbar(positions, data, yerr=err, color="C2", zorder=3, markeredgewidth=0.75, markeredgecolor='black', ms=3, fmt=fmt, label=label)

    plt.xlabel(r'$y/R$')
    plt.ylabel(r'$C_l$')
    plt.grid()
    #plt.legend(fontsize=14)

    myplt.set_font_sizes(plt.gca())
Ejemplo n.º 6
0
def dump_plots(alldata, Re, kappa):
    fig, axes = plt.subplots(nrows=3, ncols=4, sharex=True, sharey=True, figsize=(60, 40))
    #plt.suptitle(r'$Re = ' + str(Re) + r'$, $\kappa = ' + str(kappa) + r'$')
    
    axes = axes.flatten()
    
    i=0
    for x, data, err, gp, Y, lbd in alldata:            
        label = r'$Ca =' + str(Y) + '$, $\lambda = ' + str(lbd) + r'$'
        
        gpx = np.linspace(0.0, np.max(x), 100)
        axes[i].errorbar(x, data, yerr=3.0*err, fmt='D', 
            label=label, color='C2', markeredgewidth=0.75, markeredgecolor='black', ms=3, zorder=5)
        
#        print x
#        print data
#        print err
#        print ""
        
        y_fit, sigma = gp.predict(np.atleast_2d(gpx).T, return_std=True)
        axes[i].plot(gpx, y_fit, color='black', zorder=4)
        axes[i].fill_between(gpx, y_fit - 2*sigma, y_fit + 2*sigma, color='red', alpha=0.5, linewidth=0, zorder=3)
        
        axes[i].grid()
        axes[i].legend(loc=3, fontsize=7)
        
        if i % 4 == 0:
            axes[i].set_ylabel(r'$C_{l}$')
            
        if i >= 8:
            axes[i].set_xlabel(r'$y/R$')
            
        myplt.set_font_sizes(axes[i])
        
        i=i+1
        
    
#    plt.xlabel('y/R', fontsize=16)
#    plt.ylabel('Cl', fontsize=16)


    plt.tight_layout()
    plt.subplots_adjust(hspace=0.01, wspace=0.01)

    #plt.show()
    myplt.save_figure(fig, 7, 'soft_circle/tube_lift_soft__Re_' + str(Re) + '_kappa_' + str(kappa) + '.pdf')
    plt.close(fig)
def draw_value_along_curve(t, f, sigma, ls):
    plt.plot(t / np.max(t), f, ls, color='black')
    plt.fill_between(t / np.max(t),
                     f - sigma,
                     f + sigma,
                     color='red',
                     alpha=0.5,
                     linewidth=0)
    #plt.title(title)

    #plt.axes().set_ylim(limits)

    plt.ylabel(r'$C_l^{||}$')
    plt.xlabel(r'$t$')

    myplt.set_font_sizes(plt.gca())
    myplt.make_grid(plt.gca())
Ejemplo n.º 8
0
def angle(y, z, fy, fz, wy, wz, save=False, fname='', title=''):

    fig = plt.figure()

    N = 20
    yi = np.linspace(0, 0.8, N)
    zi = np.linspace(0, 0.8, N)
    Y, Z = np.meshgrid(yi, zi)

    ang = np.abs((fy * wy + fz * wz) / (fy * fy + fz * fz)**0.5 /
                 (wy * wy + wz * wz)**0.5)

    # Z is a matrix of x-y values
    angi = scinterp.griddata((y, z),
                             ang, (yi[None, :], zi[:, None]),
                             method='cubic')

    #plt.title(title)
    plt.pcolormesh(Y,
                   Z,
                   angi.reshape(Y.shape),
                   shading='gouraud',
                   cmap=plt.cm.plasma,
                   vmax=0.12,
                   vmin=0.0)
    cbar = plt.colorbar()
    cbar.ax.get_yaxis().labelpad = 20
    cbar.ax.set_ylabel(r'$\cos(\bm{F}^{\text{diff}}_l, \bm{\omega})$',
                       size=9,
                       rotation=270)
    cbar.ax.tick_params(labelsize=8)

    plt.xlim(0, 0.65)
    plt.ylim(0, 0.65)

    plt.xlabel('$y / (H/2)$')
    plt.ylabel('$z / (H/2)$')

    myplt.set_font_sizes(plt.gca())

    if save:
        myplt.save_figure(fig, 3, fname, dpi=600)
        #plt.close(fig)
    else:
        plt.show()
Ejemplo n.º 9
0
    if kappa == 0.15:
        fmt = 'o'
    if kappa == 0.22:
        fmt = 's'
    if kappa == 0.3:
        fmt = 'D'
    #plt.plot(data[0,:], data[2,:], 'o', label=r'$Re = ' + str(Re) + r', \kappa = ' + str(kappa) + r'$')
    plt.errorbar(data[0,:], transform(data[0,:], data[1,:], Re, kappa, res.x), yerr=transform(data[0,:], data[2,:], Re, kappa, res.x),
                 fmt=fmt, color=c, ms=3, linewidth=1, label=r'$Re = ' + str(Re) + r', \kappa = ' + str(kappa) + r'$')
    
plt.legend()

ax = plt.gca()
ax.set_ylabel(r'$ \dfrac{C_{l}}{y} \times Re^{1/3} \left( 1 + \dfrac{7.894}{Re \left( 1 - \kappa - y \right)} \right)$')
ax.set_xlabel(r'$y$')
myplt.set_font_sizes(ax)
myplt.save_figure(fig, 4.1, 'tube_lift_collapse.pdf')













Ejemplo n.º 10
0
def plot_equilibrium(rot, suffix):
    # x is kappa, free rotation
    fig = plt.figure()
    for Re, style in [(50, '--D'), (100, '--o'), (200, '--s')]:
        idxs = np.where((intersections[:, 4] == rot)
                        & (intersections[:, 2] == Re))
        plt.errorbar(intersections[idxs, 3],
                     intersections[idxs, 0],
                     yerr=intersections[idxs, 1],
                     label=r'$Re = ' + str(Re) + r'$',
                     fmt=style,
                     markeredgewidth=0.75,
                     markeredgecolor='black',
                     ms=3,
                     zorder=2,
                     linewidth=1.0)

    plt.legend(labelspacing=0.2)

    #plt.xscale('log')
    plt.xlabel(r'$\kappa$')
    plt.ylabel(r'$Eq/y$')
    myplt.set_font_sizes(plt.gca())
    myplt.make_grid(plt.gca())
    if rot == 1:
        y = plt.ylim()
        plt.ylim(y[0], 0.46)

    plt.tight_layout()
    myplt.save_figure(fig, 3, 'tube_lift_rigid_' + suffix + '_kappa.pdf')
    plt.close(fig)

    # x is Re, no rotation
    fig = plt.figure()
    for kappa, style in [(0.3, '--D'), (0.22, '--o'), (0.15, '--s')]:
        idxs = np.where((intersections[:, 4] == rot)
                        & (intersections[:, 3] == kappa))
        plt.errorbar(intersections[idxs, 2],
                     intersections[idxs, 0],
                     yerr=intersections[idxs, 1],
                     label=r'$\kappa = ' + str(kappa) + r'$',
                     fmt=style,
                     markeredgewidth=0.75,
                     markeredgecolor='black',
                     ms=3,
                     zorder=2,
                     linewidth=1.0)

    plt.legend(labelspacing=0.2)

    #plt.xscale('log')
    plt.xlabel(r'$Re$')
    plt.ylabel(r'$Eq/R$')
    myplt.set_font_sizes(plt.gca())
    myplt.make_grid(plt.gca())

    if rot == 0:
        y = plt.ylim()
        plt.ylim(y[0], 0.75)

    plt.tight_layout()
    myplt.save_figure(fig, 3, 'tube_lift_rigid_' + suffix + '_re.pdf')
    plt.close(fig)
Ejemplo n.º 11
0
def dump_plots(alldata):
    fig, axes = plt.subplots(nrows=3,
                             ncols=3,
                             sharex=True,
                             sharey='row',
                             figsize=(50, 38))
    #plt.suptitle(r'$Re = ' + str(Re) + r'$, $\kappa = ' + str(kappa) + r'$')

    axes = axes.flatten()

    i = 0
    for x, data, err, gp, Re, kappa, rot, w, errw in alldata:
        label = (r'$Re = ' + str(Re) + r', \kappa = ' + str(kappa) +
                 r'$') if rot == 0.0 else ''
        fmt = 'D' if rot == 0.0 else 'o'

        gpx = np.linspace(0.0, np.max(x), 100)
        axes[i].errorbar(x,
                         data,
                         yerr=3.0 * err,
                         fmt=fmt,
                         label=label,
                         color='C2',
                         markeredgewidth=0.75,
                         markeredgecolor='black',
                         ms=3,
                         zorder=3)

        #        print x
        #        print data
        #        print err
        #        print ""

        y_fit, sigma = gp.predict(np.atleast_2d(gpx).T, return_std=True)
        axes[i].plot(gpx, y_fit, linewidth=0.75, color='black')
        axes[i].fill_between(gpx,
                             y_fit - sigma,
                             y_fit + sigma,
                             color='red',
                             alpha=0.5,
                             linewidth=0,
                             zorder=2)

        axes[i].grid()
        leg = axes[i].legend(loc=3,
                             fontsize=7,
                             handlelength=0,
                             handletextpad=0,
                             markerscale=0)
        for item in leg.legendHandles:
            item.set_visible(False)

        if i % 3 == 0:
            axes[i].set_ylabel(r'$C_{l}$')

        if i >= 6:
            axes[i].set_xlabel(r'$y/R$')

        myplt.set_font_sizes(axes[i])
        myplt.make_grid(axes[i])

        if rot == 1.0:
            i = i + 1

#    plt.xlabel('y/R', fontsize=16)
#    plt.ylabel('Cl', fontsize=16)

    plt.tight_layout()
    plt.subplots_adjust(hspace=0.01, wspace=0.01)

    #plt.show()
    myplt.save_figure(fig, 6.5, 'tube_lift_rigid.pdf')
    plt.close(fig)