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()
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
Exemple #3
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)
Exemple #4
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()
Exemple #5
0
            
        err_Cls.append(0)
        
    return Cls, err_Cls

alldata = []
#alldata.append( get_forces("/home/alexeedm/extern/daint/project/alexeedm/focusing_square/case_5_0.08__80_20_1.5__") + ("Present", "o") )
alldata.append( get_forces("/home/alexeedm/extern/daint/project/alexeedm/focusing_square/case_5_0.0788__160_20_3.0__", 2.3) + ("Present", "D") ) # 2244!
#alldata.append( get_forces_cubism("/home/alexeedm/extern/daint/scratch/cubism-square-lift-2d/case_4_0_") + ("Present", "o") )
#alldata.append( get_forces_cubism("/home/alexeedm/extern/daint/scratch/cubism-square-lift-2d/case_4_0_") + ("Present", "o") )
#alldata.append( get_forces_cubism("/home/alexeedm/extern/daint/project/alexeedm/cubism-square-lift-2d/case_yetwider_8_0_") + ("Present", "o") )
#alldata.append( get_forces("/home/alexeedm/extern/daint/project/alexeedm/focusing_square/case_5_0.02144__80_10_1.5__", 1.1704) + ("Present", "o") )

print(alldata)
#print Cls
#print err_Cls

myplt.set_pgf_backend()
fig = plt.figure()
positions = np.linspace(0.0, 0.72, 19)
#positions = np.arange(0.0, 0.8, 0.1)

dump_plots(positions, alldata, nakagawa, dicarlo)
myplt.save_figure(fig, 3, 'duct_lift_coefficients.pdf')
plt.close()





Exemple #6
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')













        err = 0.5 * (np.abs(data[:, 4] - data[:, 3]) +
                     np.abs(data[:, 5] - data[:, 3]))

        #plt.errorbar(data[:,0], data[:,3], yerr=err, fmt=fmt, color=c, ms=3, linewidth=1, label=r'$Ca = ' + str(Ca) + r', \lambda = ' + str(lbd) + r'$')
        plt.plot(data[:, 0],
                 -data[:, 3],
                 fmt,
                 color=c,
                 ms=4,
                 linewidth=1,
                 label=r'$ \begin{aligned}Ca &= ' + str(Ca) +
                 r',\\ \lambda &= ' + str(lbd) + r'\end{aligned}')

#        print(data)
#        print("")

plt.legend(ncol=3, handletextpad=0.01)

ax = plt.gca()
ax.set_ylabel(r'$W = \int_{\bm S} C^{||}_l \, ds$')
ax.set_xlabel(r'$Re$')
myplt.set_font_sizes(ax)
myplt.set_figure_size(fig, 4.5)

y = plt.ylim()
plt.ylim(-0.018, y[1])

#plt.show()
myplt.save_figure(fig, 4.5, 'tube_soft_lift_work.pdf')
draw_value_along_curve(t, f, fsigma, '-')

# modified
moddata = pickle.load(
    open(folder + 'modrotation' + str(int(Re)) + '.pckl', 'rb'))
#print(moddata)

coo = moddata[:, 0:2]

idx = np.argsort(np.arctan2(coo[:, 1], coo[:, 0]))
coo = coo[idx, :]
fym, eym, fzm, ezm = [moddata[idx, i] for i in [4, 5, 6, 7]]

gpym = gaussian_fit(coo, fym, eym)
gpzm = gaussian_fit(coo, fzm, ezm)

fmod, mods = val_along_curve(gpym, gpzm, coo)

lengths = np.empty(coo.shape[0])
lengths[0] = 0.0
for i in range(1, coo.shape[0]):
    lengths[i] = lengths[i - 1] + np.sqrt(
        np.dot(coo[i - 1] - coo[i], coo[i - 1] - coo[i]))

print(lengths)

draw_value_along_curve(lengths, fmod, mods, ':')

myplt.save_figure(fig, 3.5, 'square/mod_rotation_Re_100.pdf')
Exemple #9
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)
Exemple #10
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)
Exemple #11
0
cpuref = roofline(68, 998)
gpuref = roofline(732, 8524)

myplt.set_pgf_backend()
fig = plt.figure()

draw_one(gpu[0], gpu[1], '-', 'C2', 1.5, 'Nvidia Tesla P100 16GB')
draw_one(cpu[0], cpu[1], '-', 'royalblue', 1.5, 'Intel Xeon E5-2690 v3')

draw_one(gpuref[0], gpuref[1], ':', 'C2', 0.75, '')
draw_one(cpuref[0], cpuref[1], ':', 'royalblue', 0.75, '')

prepare_plot(plt.gca())

plt.legend()
myplt.save_figure(fig, 3, 'new_roofline.pdf')
plt.close(fig)

xeon = roofline(402.503e-3 * 72, 2467.047e-3 * 103)
amd = roofline(306.105e-3 * 72, 1368.974e-3 * 103)
gpu = roofline(1846.646e-3 * 72, 25507.547e-3 * 90)

xeonref = roofline(51.2, 332.8)
amdref = roofline(51.2, 332.8)  # intentionally same
gpuref = roofline(250, 3935)

myplt.set_pgf_backend()
fig = plt.figure()

draw_one(gpu[0], gpu[1], '-', 'C2', 1.5, 'Nvidia Tesla K20X')
draw_one(xeon[0], xeon[1], '-', 'royalblue', 1.5, 'Intel Xeon E5-2670')
Exemple #12
0
        
        intersections = np.empty((0, 4))
        for x, d, err, gp, Y, lbd in processed:
            x0, elo, ehi = intersection(gp)
            
            intersections = np.vstack( (intersections, np.array([x0, 0.5*(elo+ehi), Y, lbd])) )    
        
        #%%
        for lbd, style in [(1.0, '--D'), (5.0, '--o'), (25.0, '--s')]:
            idxs = np.where(intersections[:,3] == lbd)
            plt.errorbar(intersections[idxs, 2], intersections[idxs, 0], yerr=intersections[idxs, 1], label=r'$\lambda=' + str(lbd) + r'$',
              fmt=style, markeredgewidth=0.75, markeredgecolor='black', ms=3, zorder=2, linewidth=1.0)
            
        #TODO: eqiulibrium vs size and vs Reynolds 
        
        plt.legend()
        
        plt.xscale('log')
        plt.xlabel(r'$Ca$')
        plt.ylabel(r'$C_0/R$')
        
        myplt.make_grid(plt.gca())
        
        
        plt.tight_layout()
        myplt.save_figure(fig, 3, 'soft_circle/tube_lift_soft__intersection_' + str(Re) + '_kappa_' + str(kappa) + '.pdf')
        plt.close(fig)

        a= alsdfkja

Exemple #13
0
#alldata.append( get_forces(folder + "case_newcode_ratio_5_0.05177__110_25_2.0__") + (r'Present', "D", 'C2') )

alldata.append(
    get_forces(folder + "case_0.14602_0_0.15__160_43.2253_3.0__") +
    (r'Present', "D", 'C2'))
#alldata.append( get_forces(folder + "case_0.14602_1_0.15__160_43.2253_3.0__") + (r'Inhibited rotation', "D", 'C3') )

#alldata.append( get_forces(folder + "case_newcode_ratio_5_0.14516__160_43.0935_3.0__") + (r'$\gamma = 43$', "-o") )
#alldata.append( get_forces(folder + "case_newcode_ratio_5_0.16335__160_45.7969_3.0__") + (r'$\gamma = 45$', "-o") )
#alldata.append( get_forces(folder + "case_newcode_ratio_5_0.22234__160_53.6651_3.0_") + (r'$\gamma = 54$', "-o") )
#alldata.append( get_forces(folder + "case_newcode_ratio_5_0.29040__160_61.4946_3.0__") + (r'$\gamma = 61$', "-o") )

#alldata.append( get_forces("/home/alexeedm/extern/daint/scratch/focusing_soft/case_noforce_0.1_0.2__80_20_1.5__") + (r'$\lambda = 0.2$', "-o") )
#alldata.append( get_forces("/home/alexeedm/extern/daint/scratch/focusing_soft/case_noforce_0.1_1.0__80_20_1.5__") + (r'$\lambda = 1.0$', "-o") )
#alldata.append( get_forces("/home/alexeedm/extern/daint/scratch/focusing_soft/case_noforce_0.1_5.0__80_20_1.5__") + (r'$\lambda = 5.0$', "-o") )
#alldata.append( get_forces("/home/alexeedm/extern/daint/scratch/focusing_soft/case_noforce_0.1_20.0__80_20_1.5__") + (r'$\lambda = 20.0$', "-o") )
#alldata.append( get_forces("/home/alexeedm/extern/daint/scratch/focusing_soft/case_noforce_0.1_40.0__80_20_1.5__") + (r'$\lambda = 40.0$', "-o") )

print(alldata)
#print Cls
#print err_Cls

myplt.set_pgf_backend()

fig = plt.figure()
positions = np.linspace(0.0, 0.7, 8)

dump_plots(positions, alldata, ref)
myplt.save_figure(fig, 3, 'tube_lift_coefficients.pdf')
plt.close()