Advertisement
Guest User

Julia_influenceMatrix

a guest
Jul 31st, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.29 KB | None | 0 0
  1. function influence_coeff(surf::TwoDSurf,curfield::TwoDFlowField,coll_loc,n,dt)
  2.     # With the surface and flowfield, determine the influence matrix "a"
  3.     a = zeros(surf.ndiv,surf.ndiv)
  4.     a[end,:] .= 1. # for wake portion
  5.     vc = surf.bv[1].vc
  6.  
  7.     if size(curfield.tev,1) == 0 # calculate TEV placement location
  8.         xloc = surf.bv[end].x + 0.5*surf.kinem.u*dt*cos(surf.kinem.alpha)
  9.         zloc = surf.bv[end].z + 0.5*surf.kinem.u*dt*sin(surf.kinem.alpha)
  10.     else
  11.         xloc = surf.bv[end].x + (1. /3.)*(curfield.tev[end].x - surf.bv[end].x)
  12.         zloc = surf.bv[end].z + (1. /3.)*(curfield.tev[end].z - surf.bv[end].z)
  13.     end
  14.  
  15.     for i = 1:surf.ndiv-1, j = 1:surf.ndiv
  16.         # i is test location, j is vortex source
  17.         t_x = coll_loc[i,1]
  18.         t_z = coll_loc[i,2]
  19.  
  20.         if j < surf.ndiv # Bound vortices (a_ij)
  21.             src = surf.bv[j]
  22.             xdist = src.x .- t_x
  23.             zdist = src.z .- t_z
  24.         else # Wake vorticy (a_iw)
  25.             xdist = xloc .- t_x
  26.             zdist = zloc .- t_z
  27.         end
  28.  
  29.         distsq = xdist.*xdist + zdist.*zdist
  30.         u = -zdist./(2*pi*sqrt.(vc*vc*vc*vc .+ distsq.*distsq))
  31.         w = xdist./(2*pi*sqrt.(vc*vc*vc*vc .+ distsq.*distsq))
  32.  
  33.         a[i,j] = u*n[i,1] + w*n[i,2]
  34.     end
  35.     return a
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement