Example #1
0
def main():
  from bempy2d import geomwing, geomwing, srfmatbc, bcondvel, solvephi, circlefld, \
                      calcphifld, fldmatbc, fldmatbcv, calcvelfld, fieldgrid
  from numpy import array, zeros, savetxt, eye, linspace
  from pylab import plot, show, grid
  nelem = 50
  chord = 1.5
  thickness = 0.3
  u = array([-1.,0.])
  xysrf = zeros((nelem+1,2))
  xnode = geomwing(nelem,chord,thickness)
  xysrf[:nelem,:] = xnode[:,:2]
  xysrf[nelem,:] = xnode[0,:2]
  #print xysrf
  plot(xysrf[:,0],xysrf[:,1])
  
  xnode = geomwing(nelem,chord,thickness)
  xysrf[:nelem,:] = xnode[:,:2]
  xysrf[nelem,:] = xnode[0,:2]
  #print xysrf
  plot(xysrf[:,0],xysrf[:,1])
  #B, C = srfmatbc(xnode)
  #print C
  #print B
  #chisrf = bcondvel(xnode, u)
  #phisrf = solvephi(B,C,chisrf,nelem)
  #print phisrf
  
  grid()
  show()
Example #2
0
def main():
    from bempy2d import geomwing, geomwing, srfmatbc, bcondvel, solvephi, circlefld, \
                        calcphifld, fldmatbc, fldmatbcv, calcvelfld, fieldgrid
    from numpy import array, zeros, savetxt, eye, linspace
    from pylab import plot, show, grid
    nelem = 50
    chord = 1.5
    thickness = 0.3
    u = array([-1., 0.])
    xysrf = zeros((nelem + 1, 2))
    xnode = geomwing(nelem, chord, thickness)
    xysrf[:nelem, :] = xnode[:, :2]
    xysrf[nelem, :] = xnode[0, :2]
    #print xysrf
    plot(xysrf[:, 0], xysrf[:, 1])

    xnode = geomwing(nelem, chord, thickness)
    xysrf[:nelem, :] = xnode[:, :2]
    xysrf[nelem, :] = xnode[0, :2]
    #print xysrf
    plot(xysrf[:, 0], xysrf[:, 1])
    #B, C = srfmatbc(xnode)
    #print C
    #print B
    #chisrf = bcondvel(xnode, u)
    #phisrf = solvephi(B,C,chisrf,nelem)
    #print phisrf

    grid()
    show()
Example #3
0
def plotcp(nelem, chord, thick, u):
    # Geometry
    xnode = geomwing(nelem, chord, thick)
    TEat1 = 1
    dt = 1.0
    # Boundary conditions
    chisrf = bcondvel(xnode, u)
    # Integral equation solution
    B, C = srfmatbc(xnode)
    phisrf = solvephi(B, C, chisrf)
    cpoint = collocation(xnode)
    # Pressure figure
    spl = subplot(111)
    spl.set_aspect("equal", "box")
    plotgeom(xnode)
    # Pressure calculation and plotting
    U = u.reshape((1, 2))
    cp = calccp(xnode, TEat1, dt, U, phisrf, chisrf)
    cl = calchalfcl(xnode, TEat1, dt, U, phisrf, chisrf)
    print cl
    plot(cpoint[: nelem / 2 + 1, 0], cp[: nelem / 2 + 1, 0])
    title(r"Stationary pressure coefficient, $c_L = %9.3f$" % cl[0])
    ylabel(r"$c_p$", size=18)
    xlabel(r"$x/c$", size=18)
    xticks(arange(-0.2, 1.3, 0.2))
    yticks(arange(-0.8, 1.3, 0.2))
Example #4
0
def plotcp(nelem, chord, thick, u):
    #Geometry
    xnode = geomwing(nelem, chord, thick)
    TEat1 = 1
    dt = 1.
    #Boundary conditions
    chisrf = bcondvel(xnode, u)
    #Integral equation solution
    B, C = srfmatbc(xnode)
    phisrf = solvephi(B, C, chisrf)
    cpoint = collocation(xnode)
    #Pressure figure
    spl = subplot(111)
    spl.set_aspect('equal', 'box')
    plotgeom(xnode)
    #Pressure calculation and plotting
    U = u.reshape((1, 2))
    cp = calccp(xnode, TEat1, dt, U, phisrf, chisrf)
    cl = calchalfcl(xnode, TEat1, dt, U, phisrf, chisrf)
    print cl
    plot(cpoint[:nelem / 2 + 1, 0], cp[:nelem / 2 + 1, 0])
    title(r'Stationary pressure coefficient, $c_L = %9.3f$' % cl[0])
    ylabel(r'$c_p$', size=18)
    xlabel(r'$x/c$', size=18)
    xticks(arange(-0.2, 1.3, 0.2))
    yticks(arange(-0.8, 1.3, 0.2))
Example #5
0
def main():
    nelem = 151
    chord = 1.
    thick = 0.2
    xnode = geomwing(nelem, chord, thick)
    TEat1 = 1
    cpoint = collocation(xnode)
    ntstep = 41
    Ttot = 1
    oar = [10, 20, 30, 40]
    T = linspace(0., Ttot, ntstep)
    uarr = sinspeedprof(ntstep, Ttot)
    umax = norm(uarr[-1, :])
    hv2 = 0.5 * umax**2
    dt = Ttot / (ntstep - 1.)
    pres, lift = solvebem(xnode, uarr, TEat1, dt)
    pres /= hv2
    lift /= hv2
    #PLOT SPEED
    figure(1)
    plotvel(uarr, Ttot, oar)
    #PLOT GEOMETRY and PRESSURE
    figure(2)
    spl = subplot(111)
    spl.set_aspect('equal', 'box')
    for t in oar:
        plot(cpoint[:nelem / 2 + 1, 0],
             pres[:nelem / 2 + 1, t],
             label=r'$t=%9.2f$' % T[t])
    legend(loc=0)
    plotgeom(xnode)
    title(r'Pressure')
    grid()
    ylabel(r'$\frac{p-p_\infty}{\rho}$', size=22)
    xlabel(r'$x/c$', size=18)
    xticks(arange(-0.2, 1.3, 0.2))
    yticks(arange(-0.8, 1.3, 0.2))
    #Pressure
    figure(3)
    print lift
    plotcl(lift, Ttot)
    show()
Example #6
0
def main():
    nelem = 151
    chord = 1.
    thick = 0.2
    xnode = geomwing(nelem, chord, thick); TEat1 = 1
    cpoint = collocation(xnode)
    ntstep = 41
    Ttot = 1
    oar = [10,20,30,40]
    T = linspace(0.,Ttot,ntstep)
    uarr = sinspeedprof(ntstep,Ttot)
    umax = norm(uarr[-1,:])
    hv2 = 0.5*umax**2
    dt = Ttot/(ntstep-1.)
    pres ,lift = solvebem(xnode, uarr, TEat1, dt)
    pres /= hv2
    lift /= hv2
    #PLOT SPEED
    figure(1)
    plotvel(uarr, Ttot, oar)
    #PLOT GEOMETRY and PRESSURE
    figure(2)
    spl = subplot(111)
    spl.set_aspect('equal','box')
    for t in oar:
        plot(cpoint[:nelem/2+1,0],pres[:nelem/2+1,t],label=r'$t=%9.2f$' % T[t])
    legend(loc=0)
    plotgeom(xnode)
    title(r'Pressure')
    grid()
    ylabel(r'$\frac{p-p_\infty}{\rho}$', size=22)
    xlabel(r'$x/c$', size=18)
    xticks(arange(-0.2,1.3,0.2))
    yticks(arange(-0.8,1.3,0.2))
    #Pressure
    figure(3)
    print lift
    plotcl(lift, Ttot)
    show()
Example #7
0
def main():
    from bempy2d import circlegeom, srfmatbc, bcondvel, solvephi, \
                        circlefld, calcphifld, fldmatbc, fldmatbcv, \
                        calcvelfld, fieldgrid, calcdphidx, calcsrfvel, \
                        collocation, calcpres, geomwing, normals
    from numpy import array, zeros, savetxt, eye, linspace, sqrt, \
                      arctan2, cos, pi, sin
    from numpy.linalg import norm
    from pylab import plot, show, grid, figure, subplot, quiver, xlim
    #Geometry
    figure(1)
    nelem = 100
    R = 1.
    chord = 1.
    thick = 0.2
    ntstep = 10
    Ttot = 1.
    dt = Ttot/(ntstep-1.)
    #xnode = circlegeom(nelem,R); TEat1 = 0
    xnode = geomwing(nelem, chord, thick); TEat1 = 1
    plotgeom(xnode)
    #Boundary conditions
    u = array([-1.5,0.])
    chisrf = bcondvel(xnode, u)
    #Integral equation solution
    B, C = srfmatbc(xnode)
    phisrf = solvephi(B,C,chisrf)
    #Surface velocity calculation
    v = calcsrfvel(xnode,TEat1,phisrf, chisrf)
    #for i in xrange(nelem):
    #    v[i,0] += norm(u)
    cpoint = collocation(xnode)
    n = normals(xnode)
    #Pressure figure
    figure(2)
    spl = subplot(111)
    spl.set_aspect('equal','box')
    plotgeom(xnode)
    #Pressure calculation and plotting
    pres = calcpres(xnode,TEat1,dt,u,phisrf,chisrf)
    #plot(cpoint[:,0], cpoint[:,1], 'o')
    presplot = cpoint+pres*n
    #plot(presplot[:,0],presplot[:,1])
    plot(linspace(chord,0,nelem/2),pres[:nelem/2],'g')
    presn = abs(pres)*n
    col = zeros(nelem)
    for i in xrange(nelem):
        if pres[i] > 0.:
            col[i] = 1.
    quiver(cpoint[:,0], cpoint[:,1],presn[:,0],presn[:,1], col, units='dots', width=0.8)
    xlim(-1,chord+1)
    grid()
    #Analitical for circle
    #TH = linspace(pi/nelem,2*pi-pi/nelem,nelem)
    #presan = 0.5*norm(u)**2*(1-4*sin(TH)**2)
    #presplotan = cpoint+presan.reshape((nelem,1))*n
    #plot(presplotan[:,0],presplotan[:,1])
    figure(1)
    #Field definition
    xmin, xmax = -2.,  2.
    ymin, ymax = -1.5,  1.5
    nx, ny = 100, 100
    xfield = fieldgrid(xmin,xmax,nx,ymin,ymax,ny)
    #r = sqrt(xfield[:,0]**2+xfield[:,1]**2)
    #th = arctan2(xfield[:,1], -xfield[:,0])
    Bf, Cf = fldmatbc(xfield, xnode)
    phifld = calcphifld(phisrf,chisrf,Bf,Cf)
    #phifld += r*u[0]*cos(th)
    #for i in xrange(nx*ny):
    #    if r[i] < R:
    #        phifld[i] = 0.
    xcont = linspace(xmin,xmax,nx)
    ycont = linspace(ymin,ymax,ny)
    Z = phifld.reshape((ny,nx))
    plotphicont(xcont,ycont,Z)
    plotvelfld(cpoint, v)
    show()
Example #8
0
def main():
    from bempy2d import circlegeom, srfmatbc, bcondvel, solvephi, \
                        circlefld, calcphifld, fldmatbc, fldmatbcv, \
                        calcvelfld, fieldgrid, calcdphidx, calcsrfvel, \
                        collocation, calcpres, geomwing, normals
    from numpy import array, zeros, savetxt, eye, linspace, sqrt, \
                      arctan2, cos, pi, sin
    from numpy.linalg import norm
    from pylab import plot, show, grid, figure, subplot, quiver, xlim
    #Geometry
    figure(1)
    nelem = 100
    R = 1.
    chord = 1.
    thick = 0.2
    ntstep = 10
    Ttot = 1.
    dt = Ttot / (ntstep - 1.)
    #xnode = circlegeom(nelem,R); TEat1 = 0
    xnode = geomwing(nelem, chord, thick)
    TEat1 = 1
    plotgeom(xnode)
    #Boundary conditions
    u = array([-1.5, 0.])
    chisrf = bcondvel(xnode, u)
    #Integral equation solution
    B, C = srfmatbc(xnode)
    phisrf = solvephi(B, C, chisrf)
    #Surface velocity calculation
    v = calcsrfvel(xnode, TEat1, phisrf, chisrf)
    #for i in xrange(nelem):
    #    v[i,0] += norm(u)
    cpoint = collocation(xnode)
    n = normals(xnode)
    #Pressure figure
    figure(2)
    spl = subplot(111)
    spl.set_aspect('equal', 'box')
    plotgeom(xnode)
    #Pressure calculation and plotting
    pres = calcpres(xnode, TEat1, dt, u, phisrf, chisrf)
    #plot(cpoint[:,0], cpoint[:,1], 'o')
    presplot = cpoint + pres * n
    #plot(presplot[:,0],presplot[:,1])
    plot(linspace(chord, 0, nelem / 2), pres[:nelem / 2], 'g')
    presn = abs(pres) * n
    col = zeros(nelem)
    for i in xrange(nelem):
        if pres[i] > 0.:
            col[i] = 1.
    quiver(cpoint[:, 0],
           cpoint[:, 1],
           presn[:, 0],
           presn[:, 1],
           col,
           units='dots',
           width=0.8)
    xlim(-1, chord + 1)
    grid()
    #Analitical for circle
    #TH = linspace(pi/nelem,2*pi-pi/nelem,nelem)
    #presan = 0.5*norm(u)**2*(1-4*sin(TH)**2)
    #presplotan = cpoint+presan.reshape((nelem,1))*n
    #plot(presplotan[:,0],presplotan[:,1])
    figure(1)
    #Field definition
    xmin, xmax = -2., 2.
    ymin, ymax = -1.5, 1.5
    nx, ny = 100, 100
    xfield = fieldgrid(xmin, xmax, nx, ymin, ymax, ny)
    #r = sqrt(xfield[:,0]**2+xfield[:,1]**2)
    #th = arctan2(xfield[:,1], -xfield[:,0])
    Bf, Cf = fldmatbc(xfield, xnode)
    phifld = calcphifld(phisrf, chisrf, Bf, Cf)
    #phifld += r*u[0]*cos(th)
    #for i in xrange(nx*ny):
    #    if r[i] < R:
    #        phifld[i] = 0.
    xcont = linspace(xmin, xmax, nx)
    ycont = linspace(ymin, ymax, ny)
    Z = phifld.reshape((ny, nx))
    plotphicont(xcont, ycont, Z)
    plotvelfld(cpoint, v)
    show()
Example #9
0
def main():
    from numpy import array, zeros, savetxt, eye, linspace, sqrt, \
                      arctan2, cos, pi, sin
    from numpy.linalg import norm
    from pylab import plot, show, grid, figure, subplot, quiver, xlim, \
                      ion, ioff, draw, savefig, ylim
    #Geometry
    figure(1)
    nelem = 151
    R = 1.
    chord = 1.
    thick = 0.2
    ntstep = 20
    Ttot = 1.
    dt = Ttot/(ntstep-1.)
    #xnode = circlegeom(nelem,R); TEat1 = 0
    xnode = geomwing(nelem, chord, thick); TEat1 = 1
    plotgeom(xnode)
    #Boundary conditions
    u = array([-1.,0.])
    uarr = norm(u)*sinspeedprof(ntstep,Ttot)
    chisrf = bcondvel(xnode, u)
    #Integral equation solution
    B, C = srfmatbc(xnode)
    phisrf = solvephi(B,C,chisrf)
    #Surface velocity calculation
    v = calcsrfvel(xnode,TEat1,phisrf, chisrf)
    #for i in xrange(nelem):
    #    v[i,0] += norm(u)
    cpoint = collocation(xnode)
    n = normals(xnode)
    #Pressure figure
    figure(2)
    #ion()
    spl = subplot(111)
    spl.set_aspect('equal','box')
    plotgeom(xnode)
    #Pressure calculation and plotting
    pres, lift = solvebem(xnode, uarr, TEat1, dt)
    for t in xrange(ntstep):
        hru2 = 0.5*norm(uarr[t,:])**2
        if hru2 > 0.001:
            pres[:,t] /= hru2
            lift[t] /= hru2
    #pres = calcpres(xnode,TEat1,dt,u,phisrf,chisrf)
    #plot(cpoint[:,0], cpoint[:,1], 'o')
    #presplot = cpoint+pres*n
    #plot(presplot[:,0],presplot[:,1])
    xlim(-1,chord+1)
    grid()
    ylim(-1,1)
    for t in xrange(ntstep):
        plot(linspace(chord,0,nelem/2+1),pres[:nelem/2+1,t],'g')
        #if t == 0:
        #    line, = plot(linspace(chord,0,nelem/2),pres[:nelem/2,t],'g')
        #else:
        #    line.set_ydata(pres[:nelem/2,t])
        ylim(-1,1)
        presn = abs(pres[:,t].reshape((nelem,1)))*n
        col = zeros(nelem)
        #print pres[:,t]
        for i in xrange(nelem):
            if pres[i,t] > 0.:
                col[i] = 1.
        quiver(cpoint[:,0], cpoint[:,1],presn[:,0],presn[:,1], col, units='dots', width=0.8)
        #if t == 0:
        #    qul = quiver(cpoint[:,0], cpoint[:,1],presn[:,0],presn[:,1], col, units='dots', width=0.8)
        #else:
        #    qul.set_UVC(presn[:,0],presn[:,1], col)
        #draw()
        #savefig('pres%d' % t)
    #ioff()
    #Analitical for circle
    #TH = linspace(pi/nelem,2*pi-pi/nelem,nelem)
    #presan = 0.5*norm(u)**2*(1-4*sin(TH)**2)
    #presplotan = cpoint+presan.reshape((nelem,1))*n
    #plot(presplotan[:,0],presplotan[:,1])
    #-----------LIFT------------
    figure(3)
    print lift
    plot(linspace(0,Ttot,ntstep),lift)
    figure(1)
    #Field definition
    xmin, xmax = -2.,  2.
    ymin, ymax = -1.5,  1.5
    nx, ny = 100, 100
    xfield = fieldgrid(xmin,xmax,nx,ymin,ymax,ny)
    #r = sqrt(xfield[:,0]**2+xfield[:,1]**2)
    #th = arctan2(xfield[:,1], -xfield[:,0])
    Bf, Cf = fldmatbc(xfield, xnode)
    phifld = calcphifld(phisrf,chisrf,Bf,Cf)
    #phifld += r*u[0]*cos(th)
    #for i in xrange(nx*ny):
    #    if r[i] < R:
    #        phifld[i] = 0.
    xcont = linspace(xmin,xmax,nx)
    ycont = linspace(ymin,ymax,ny)
    Z = phifld.reshape((ny,nx))
    plotphicont(xcont,ycont,Z)
    plotvelfld(cpoint, v)
    show()
Example #10
0
def main():
    from numpy import array, zeros, savetxt, eye, linspace, sqrt, \
                      arctan2, cos, pi, sin
    from numpy.linalg import norm
    from pylab import plot, show, grid, figure, subplot, quiver, xlim, \
                      ion, ioff, draw, savefig, ylim
    #Geometry
    figure(1)
    nelem = 151
    R = 1.
    chord = 1.
    thick = 0.2
    ntstep = 20
    Ttot = 1.
    dt = Ttot / (ntstep - 1.)
    #xnode = circlegeom(nelem,R); TEat1 = 0
    xnode = geomwing(nelem, chord, thick)
    TEat1 = 1
    plotgeom(xnode)
    #Boundary conditions
    u = array([-1., 0.])
    uarr = norm(u) * sinspeedprof(ntstep, Ttot)
    chisrf = bcondvel(xnode, u)
    #Integral equation solution
    B, C = srfmatbc(xnode)
    phisrf = solvephi(B, C, chisrf)
    #Surface velocity calculation
    v = calcsrfvel(xnode, TEat1, phisrf, chisrf)
    #for i in xrange(nelem):
    #    v[i,0] += norm(u)
    cpoint = collocation(xnode)
    n = normals(xnode)
    #Pressure figure
    figure(2)
    #ion()
    spl = subplot(111)
    spl.set_aspect('equal', 'box')
    plotgeom(xnode)
    #Pressure calculation and plotting
    pres, lift = solvebem(xnode, uarr, TEat1, dt)
    for t in xrange(ntstep):
        hru2 = 0.5 * norm(uarr[t, :])**2
        if hru2 > 0.001:
            pres[:, t] /= hru2
            lift[t] /= hru2
    #pres = calcpres(xnode,TEat1,dt,u,phisrf,chisrf)
    #plot(cpoint[:,0], cpoint[:,1], 'o')
    #presplot = cpoint+pres*n
    #plot(presplot[:,0],presplot[:,1])
    xlim(-1, chord + 1)
    grid()
    ylim(-1, 1)
    for t in xrange(ntstep):
        plot(linspace(chord, 0, nelem / 2 + 1), pres[:nelem / 2 + 1, t], 'g')
        #if t == 0:
        #    line, = plot(linspace(chord,0,nelem/2),pres[:nelem/2,t],'g')
        #else:
        #    line.set_ydata(pres[:nelem/2,t])
        ylim(-1, 1)
        presn = abs(pres[:, t].reshape((nelem, 1))) * n
        col = zeros(nelem)
        #print pres[:,t]
        for i in xrange(nelem):
            if pres[i, t] > 0.:
                col[i] = 1.
        quiver(cpoint[:, 0],
               cpoint[:, 1],
               presn[:, 0],
               presn[:, 1],
               col,
               units='dots',
               width=0.8)
        #if t == 0:
        #    qul = quiver(cpoint[:,0], cpoint[:,1],presn[:,0],presn[:,1], col, units='dots', width=0.8)
        #else:
        #    qul.set_UVC(presn[:,0],presn[:,1], col)
        #draw()
        #savefig('pres%d' % t)
    #ioff()
    #Analitical for circle
    #TH = linspace(pi/nelem,2*pi-pi/nelem,nelem)
    #presan = 0.5*norm(u)**2*(1-4*sin(TH)**2)
    #presplotan = cpoint+presan.reshape((nelem,1))*n
    #plot(presplotan[:,0],presplotan[:,1])
    #-----------LIFT------------
    figure(3)
    print lift
    plot(linspace(0, Ttot, ntstep), lift)
    figure(1)
    #Field definition
    xmin, xmax = -2., 2.
    ymin, ymax = -1.5, 1.5
    nx, ny = 100, 100
    xfield = fieldgrid(xmin, xmax, nx, ymin, ymax, ny)
    #r = sqrt(xfield[:,0]**2+xfield[:,1]**2)
    #th = arctan2(xfield[:,1], -xfield[:,0])
    Bf, Cf = fldmatbc(xfield, xnode)
    phifld = calcphifld(phisrf, chisrf, Bf, Cf)
    #phifld += r*u[0]*cos(th)
    #for i in xrange(nx*ny):
    #    if r[i] < R:
    #        phifld[i] = 0.
    xcont = linspace(xmin, xmax, nx)
    ycont = linspace(ymin, ymax, ny)
    Z = phifld.reshape((ny, nx))
    plotphicont(xcont, ycont, Z)
    plotvelfld(cpoint, v)
    show()