Пример #1
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)
    '''
    
    '''
Пример #2
0
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
fc = 0.0010*sc[-1]*outer(sin(2*pi*M*sc/sc[-1]),sin(2*pi*N*tc/tc[-1]))
##########
'''
##########
# ANGLE
zmid = 0.5*(max(zmc[:,0]) + min(zmc[:,0]))
chord = sqrt((max(zmc[:,0])-min(zmc[:,0]))**2 + (max(zmc[:,0])-min(zmc[:,0]))**2)
Пример #3
0
    f = open('ob_modes/'+fname,'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('%e\n' % V_trans[imode,i,j])
    f.close()

# write out the transformed amplitudes
Cov_trans = dot(UT,dot(S_pca**2*eye(NZ),UT.T))
f = open('ob_modes/S.dat','w')
for i in arange(NZ):
    f.write('%e\n' % sqrt(Cov_trans[i,i]))
f.close()

s, t = read_blade.xyz2st(x,y,z)
s /= s[-1]

# tecplot file with ob modes
write_tecplot.write_blade_surf(x,y,z,V_trans,'ob_modes_r37.dat') 

# plot the transformed modes
# make sure they match up with the PCA modes
ls = len(s)+mod(len(s),2)
V_trans_tmp = zeros(V_trans.shape)
V_trans_tmp[:,:ls/2,:] = V_trans[:,ls/2-1:,:]
V_trans_tmp[:,ls/2-1:,:] = V_trans[:,:ls/2,:]
for i in range(4):
    pylab.figure()
    pylab.contourf(s,t,V_trans_tmp[i,:,:].T,50)
    pylab.title('Output-based mode '+str(i+1))
Пример #4
0
import pylab
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import time

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)

xp = vstack((xu[:-1,:],xl[::-1,:]))
yp = vstack((yu[:-1,:],yl[::-1,:]))
zp = vstack((zu[:-1,:],zl[::-1,:]))

sp,tp = read_blade.xyz2st(xp,yp,zp)
ns = xp.shape[0]
nt = xp.shape[1]
Ks = int(ns/5.)
Kt = int(nt/5.)

# 1D test
i1 = 10
i2 = 50

tp = linspace(0,tp[-1],nt)

N = 20000
f_sample = zeros((2,N))
for n in arange(N):
    tic = time.clock()