Beispiel #1
0
def perturb_rot(rpath, wpath, dth):

    # dht - amount to rotate blade

    cdim, sdim, x, y, z = read_blade.read_coords(rpath)

    # split the blade
    xu,yu,zu,xl,yl,zl = read_blade.split_blade(cdim,sdim,x,y,z)

    xle = xu[0,0]; yle = yu[0,0]
    xte = xu[-1,0]; yte = yu[-1,0]
    th = arctan2(y-yle,x-xle)
    r = sqrt((x-xle)**2 + (y-yle)**2)
    xp = xle + r*cos(th+dth)
    yp = yle + r*sin(th+dth)
    zp = copy(z)

    pylab.plot(x[:,0],y[:,0])
    pylab.plot(xp[:,0],yp[:,0])
    pylab.axis('Equal')
    pylab.show()
     
    # write out the blade surface
    f = open(wpath,'w')
    f.write('CDIM:       %d\n' % cdim)
    f.write('SDIM:       %d\n' % sdim)
    for i in arange(cdim):
        for j in arange(sdim):
            f.write('%20.8E' * 3 % (xp[i,j],yp[i,j],zp[i,j]))
            f.write('\n')
    
    f.close()

    # write out to tecplot format
    write_tecplot.write_blade_surf(xp,yp,zp,'tec_blade.dat')
Beispiel #2
0
def perturb_chev(rpath, wpath, M):

    # M - amplitudes of the Chevyshev modes

    cdim, sdim, x, y, z = read_blade.read_coords(rpath)

    # split the blade
    xu,yu,zu,xl,yl,zl = read_blade.split_blade(cdim,sdim,x,y,z)

    # compute the s coordinates
    tck, su = splprep([xu[:,0],yu[:,0]],s=0)
    tck, sl = splprep([xl[:,0],yl[:,0]],s=0)

    # form the modes
    nmodes = len(M)
    cheb = zeros((nmodes,x.shape[0],x.shape[1]))
    for i in arange(nmodes):
        n = i + 1
        if mod(n,2) == 0:
            gu =  (1-2*su-cos((n+1)*arccos(1-2*su)))/(n+1.)
            gl = -(1-2*sl-cos((n+1)*arccos(1-2*sl)))/(n+1.)
            cheb[i,:,:] = tile(hstack((gu,gl[::-1][1:])),(sdim,1)).T
        else:
            gu =  (1-cos((n+1)*arccos(1-2*su)))/(n+1.)
            gl = -(1-cos((n+1)*arccos(1-2*sl)))/(n+1.)
            cheb[i,:,:] = tile(hstack((gu,gl[::-1][1:])),(sdim,1)).T

    np = read_blade.calcNormals(x,y,z)

    for i in arange(nmodes):
        xp = x + np[:,:,0]*cheb[i,:,:]*M[i]
        yp = y + np[:,:,1]*cheb[i,:,:]*M[i]
        zp = z + np[:,:,2]*cheb[i,:,:]*M[i]

    pylab.plot(x[:,0],y[:,0])
    pylab.plot(xp[:,0],yp[:,0])
    pylab.axis('Equal')
    pylab.show()
     
    # write out the blade surface
    f = open(wpath,'w')
    f.write('CDIM:       %d\n' % cdim)
    f.write('SDIM:       %d\n' % sdim)
    for i in arange(cdim):
        for j in arange(sdim):
            f.write('%20.8E' * 3 % (xp[i,j],yp[i,j],zp[i,j]))
            f.write('\n')
    
    f.close()

    # write out to tecplot format
    write_tecplot.write_blade_surf(xp,yp,zp,'tec_blade.dat')
Beispiel #3
0
def perturb_chev(rpath, wpath, M):

    # M - amplitudes of the Chevyshev modes

    cdim, sdim, x, y, z = read_blade.read_coords(rpath)

    # split the blade
    xu, yu, zu, xl, yl, zl = read_blade.split_blade(cdim, sdim, x, y, z)

    # compute the s coordinates
    tck, su = splprep([xu[:, 0], yu[:, 0]], s=0)
    tck, sl = splprep([xl[:, 0], yl[:, 0]], s=0)

    # form the modes
    nmodes = len(M)
    cheb = zeros((nmodes, x.shape[0], x.shape[1]))
    for i in arange(nmodes):
        n = i + 1
        if mod(n, 2) == 0:
            gu = (1 - 2 * su - cos((n + 1) * arccos(1 - 2 * su))) / (n + 1.)
            gl = -(1 - 2 * sl - cos((n + 1) * arccos(1 - 2 * sl))) / (n + 1.)
            cheb[i, :, :] = tile(hstack((gu, gl[::-1][1:])), (sdim, 1)).T
        else:
            gu = (1 - cos((n + 1) * arccos(1 - 2 * su))) / (n + 1.)
            gl = -(1 - cos((n + 1) * arccos(1 - 2 * sl))) / (n + 1.)
            cheb[i, :, :] = tile(hstack((gu, gl[::-1][1:])), (sdim, 1)).T

    np = read_blade.calcNormals(x, y, z)

    for i in arange(nmodes):
        xp = x + np[:, :, 0] * cheb[i, :, :] * M[i]
        yp = y + np[:, :, 1] * cheb[i, :, :] * M[i]
        zp = z + np[:, :, 2] * cheb[i, :, :] * M[i]

    pylab.plot(x[:, 0], y[:, 0])
    pylab.plot(xp[:, 0], yp[:, 0])
    pylab.axis('Equal')
    pylab.show()

    # write out the blade surface
    f = open(wpath, 'w')
    f.write('CDIM:       %d\n' % cdim)
    f.write('SDIM:       %d\n' % sdim)
    for i in arange(cdim):
        for j in arange(sdim):
            f.write('%20.8E' * 3 % (xp[i, j], yp[i, j], zp[i, j]))
            f.write('\n')

    f.close()

    # write out to tecplot format
    write_tecplot.write_blade_surf(xp, yp, zp, 'tec_blade.dat')
Beispiel #4
0
def perturb_rot(rpath, wpath, dth):

    # dht - amount to rotate blade

    cdim, sdim, x, y, z = read_blade.read_coords(rpath)

    # split the blade
    xu, yu, zu, xl, yl, zl = read_blade.split_blade(cdim, sdim, x, y, z)

    xle = xu[0, 0]
    yle = yu[0, 0]
    xte = xu[-1, 0]
    yte = yu[-1, 0]
    th = arctan2(y - yle, x - xle)
    r = sqrt((x - xle)**2 + (y - yle)**2)
    xp = xle + r * cos(th + dth)
    yp = yle + r * sin(th + dth)
    zp = copy(z)

    pylab.plot(x[:, 0], y[:, 0])
    pylab.plot(xp[:, 0], yp[:, 0])
    pylab.axis('Equal')
    pylab.show()

    # write out the blade surface
    f = open(wpath, 'w')
    f.write('CDIM:       %d\n' % cdim)
    f.write('SDIM:       %d\n' % sdim)
    for i in arange(cdim):
        for j in arange(sdim):
            f.write('%20.8E' * 3 % (xp[i, j], yp[i, j], zp[i, j]))
            f.write('\n')

    f.close()

    # write out to tecplot format
    write_tecplot.write_blade_surf(xp, yp, zp, 'tec_blade.dat')
Beispiel #5
0
def perturb(rpath, wpath):

    cdim, sdim, x, y, z = read_blade.read_coords(rpath)
    
    # scale coordinates to be in cm
    scale = 1.0
    x *= scale
    y *= scale
    z *= scale
    
    xu, yu, zu, xl, yl, zl = read_blade.split_blade(cdim, sdim, x, y, z)
    xmc = 0.5*(xu+xl)
    ymc = 0.5*(yu+yl)
    zmc = 0.5*(zu+zl)
    
    dx = xu - xmc
    dy = yu - ymc
    dz = zu - zmc
    
    # camber random process
    sc,tc = read_blade.xyz2st(xmc,ymc,zmc)
    ns = xmc.shape[0]
    nt = xmc.shape[1]
    # mode cutoff
    Ks = ns
    Kt = nt
    fc = simulate.randProcess(sc, tc, ns, nt, Ks, Kt)
    
    tg, sg = meshgrid(tc,sc)
                         
    nc = read_blade.calcNormals(xmc,ymc,zmc)
    
    xmc = xmc + nc[:,:,0]*fc
    ymc = ymc + nc[:,:,1]*fc
    zmc = zmc + nc[:,:,2]*fc
     
    xu = xmc + dx
    yu = ymc + dy
    zu = zmc + dz
    
    xl = xmc - dx
    yl = ymc - dy
    zl = zmc - dz
    
    xp = vstack((xu[:-1,:],xl[::-1,:]))
    yp = vstack((yu[:-1,:],yl[::-1,:]))
    zp = vstack((zu[:-1,:],zl[::-1,:]))
 
    # normal random process
    sp,tp = read_blade.xyz2st(xp,yp,zp)
    ns = xp.shape[0]
    nt = xp.shape[1]
    Ks = ns
    Kt = nt
    fp = simulate.randProcessPeriodic(sp, tp, ns, nt, Ks, Kt)
    fp[0,:] = fp[-1,:]
    # fp = zeros(fp.shape)
    
    '''
    # interpolate back to original mesh
    ss = linspace(0,sp[-1]-sp[0],ns)
    tt = linspace(0,tp[-1]-tp[0],nt)
    ff = simulate.randProcessPeriodic(ss, tt, ns, nt, Ks, Kt)
    fp = simulate.interp(ss, tt, ff, sp, tp)
    
    tg, sg = meshgrid(tt,ss)
    pylab.contourf(sg,tg,ff,30)
    pylab.contourf(sg+sg[-1],tg,ff,30)
    pylab.colorbar()
    pylab.axes().set_aspect('equal', 'datalim')
    pylab.figure()
    '''
    tg, sg = meshgrid(tp,sp)
    pylab.contourf(sg,tg,fp,30)
    # pylab.contourf(sg+sg[-1],tg,fp,30)
    pylab.colorbar()
    pylab.xlim(0.0,sp[-1])
    pylab.axes().set_aspect('equal', 'datalim')
    pylab.xlabel('x')
    pylab.ylabel('y')
    pylab.show()
    
    np = read_blade.calcNormals(xp,yp,zp)
    
    xp = xp + np[:,:,0]*fp
    yp = yp + np[:,:,1]*fp
    zp = zp + np[:,:,2]*fp
    
    # scale coordinates back to original units
    x /= scale
    y /= scale
    z /= scale
    xp /= scale
    yp /= scale
    zp /= scale
    
    # write out the blade surface
    f = open(wpath,'w')
    f.write('CDIM:       %d\n' % cdim)
    f.write('SDIM:       %d\n' % sdim)
    for i in arange(cdim):
        for j in arange(sdim):
            f.write('%20.8E' * 3 % (xp[i,j],yp[i,j],zp[i,j]))
            f.write('\n')
    
    f.close()
    
    # write out the normal perturbation
    g = open('normal_field.dat','w')
    for i in arange(cdim):
        for j in arange(sdim):
            g.write('%20.8E' * 4 % (x[i,j],y[i,j],z[i,j],fp[i,j]))
            g.write('\n')
    
    g.close()
    
    '''
    fig = pylab.figure()
    ax = Axes3D(fig)
    surf = ax.plot_surface(sg, tg, fp, rstride=1, cstride=1, cmap = cm.jet)
    '''
    
    '''
    fig = pylab.figure()
    ax = Axes3D(fig)
    surf = ax.plot_surface(tg, sg, nf[1:-1,1:-1,2], rstride=1, cstride=1, cmap = cm.jet)
    # fig.colorbar(surf)
    '''
    
    '''
import read_blade
import simulate
from math import *
from numpy import *
import pylab
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

rpath = '/home/ericdow/code/random_blade/input/blade_surf.dat'
wpath = '/home/ericdow/code/random_blade/input/blade_surf_mod.dat'

cdim, sdim, x, y, z = read_blade.read_coords(rpath)
xu, yu, zu, xl, yl, zl = read_blade.split_blade(cdim, sdim, x, y, z)
xmc = 0.5*(xu+xl)
ymc = 0.5*(yu+yl)
zmc = 0.5*(zu+zl)

dx = xu - xmc
dy = yu - ymc
dz = zu - zmc

# camber random process
sc,tc = read_blade.xyz2st(xmc,ymc,zmc)
ns = xmc.shape[0]
nt = xmc.shape[1]
Ks = int(ns/5.)          # mode cutoff
Kt = int(nt/5.)
M = 1
N = 1
##########
# SINE