コード例 #1
0
ファイル: util.py プロジェクト: 3lectrologos/LimnoPlanner
 def __init__(self, x1, x2, fclass=None):
     super(Graph, self).__init__()
     self.xres = x1.shape[0]
     self.yres = x1.shape[1]
     self.fclass = fclass
     n = 2 * x1.size - 2 * self.yres
     self.add_nodes_from(range(1, n + 1))
     x1 = np.vstack((x1.reshape((-1, 1)), x1[-2:0:-1].reshape((-1, 1))))
     x2 = np.vstack((x2.reshape((-1, 1)), x2[-2:0:-1].reshape((-1, 1))))
     self.x = np.hstack((x1, x2))
     self.pos = dict(
         zip(range(1, n + 1), zip(x1.T.tolist()[0],
                                  x2.T.tolist()[0])))
     self.full = nx.DiGraph(self)
     for i in range(1, n + 1):
         for j in self.column(i):
             dx1 = np.absolute(self.pos[j][0] - self.pos[i][0])
             dx2 = np.absolute(self.pos[j][1] - self.pos[i][1])
             if dx2 <= dx1 / _GRAPH_ASPECT_RATIO:
                 self.full.add_edge(i, j)
     tmp = 1
     self.basic = set()
     step = self.yres / _GRAPH_YRES_BASIC
     while tmp < n + 1:
         self.basic = self.basic | set(self.column(tmp)[0::step])
         tmp = tmp + self.yres
     self.update_active()
コード例 #2
0
 def trefftz_plane_velocities(self,
                              pnts: MatrixVector,
                              betx: float = 1.0,
                              bety: float = 1.0,
                              betz: float = 1.0):
     # Trailing Vortex A
     agcs = self.relative_mach(pnts,
                               self.grda,
                               betx=betx,
                               bety=bety,
                               betz=betz)
     dirxa = -self.diro
     dirza = self.nrm
     dirya = dirza**dirxa
     alcs = MatrixVector(agcs * dirxa, agcs * dirya, agcs * dirza)
     alcs.x = zeros(alcs.shape, dtype=float)
     axx = MatrixVector(alcs.x, -alcs.z, alcs.y)
     am2 = square(alcs.y) + square(alcs.z)
     chkam2 = absolute(am2) < tol
     am2r = zeros(pnts.shape, dtype=float)
     reciprocal(am2, where=logical_not(chkam2), out=am2r)
     faca = -1.0
     veldl = elementwise_multiply(axx, am2r) * faca
     veldl.x[chkam2] = 0.0
     veldl.y[chkam2] = 0.0
     veldl.z[chkam2] = 0.0
     dirxi = Vector(dirxa.x, dirya.x, dirza.x)
     diryi = Vector(dirxa.y, dirya.y, dirza.y)
     dirzi = Vector(dirxa.z, dirya.z, dirza.z)
     velda = MatrixVector(veldl * dirxi, veldl * diryi,
                          veldl * dirzi) * faca
     # Trailing Vortex B
     bgcs = self.relative_mach(pnts,
                               self.grdb,
                               betx=betx,
                               bety=bety,
                               betz=betz)
     dirxb = self.diro
     dirzb = self.nrm
     diryb = dirzb**dirxb
     blcs = MatrixVector(bgcs * dirxb, bgcs * diryb, bgcs * dirzb)
     blcs.x = zeros(blcs.shape, dtype=float)
     bxx = MatrixVector(blcs.x, -blcs.z, blcs.y)
     bm2 = square(blcs.y) + square(blcs.z)
     chkbm2 = absolute(bm2) < tol
     bm2r = zeros(pnts.shape, dtype=float)
     reciprocal(bm2, where=logical_not(chkbm2), out=bm2r)
     facb = 1.0
     veldl = elementwise_multiply(bxx, bm2r) * facb
     veldl.x[chkbm2] = 0.0
     veldl.y[chkbm2] = 0.0
     veldl.z[chkbm2] = 0.0
     dirxi = Vector(dirxb.x, diryb.x, dirzb.x)
     diryi = Vector(dirxb.y, diryb.y, dirzb.y)
     dirzi = Vector(dirxb.z, diryb.z, dirzb.z)
     veldb = MatrixVector(veldl * dirxi, veldl * diryi,
                          veldl * dirzi) * facb
     # Add Together
     veld = velda + veldb
     return veld / twoPi
コード例 #3
0
ファイル: util.py プロジェクト: 3lectrologos/LimnoPlanner
 def __init__(self, x1, x2, fclass=None):
     super(Graph, self).__init__()
     self.xres = x1.shape[0]
     self.yres = x1.shape[1]
     self.fclass = fclass
     n = 2*x1.size - 2*self.yres
     self.add_nodes_from(range(1, n+1))
     x1 = np.vstack((x1.reshape((-1, 1)), x1[-2:0:-1].reshape((-1, 1))))
     x2 = np.vstack((x2.reshape((-1, 1)), x2[-2:0:-1].reshape((-1, 1))))
     self.x = np.hstack((x1, x2))
     self.pos = dict(zip(range(1, n+1),
                         zip(x1.T.tolist()[0], x2.T.tolist()[0])))
     self.full = nx.DiGraph(self)
     for i in range(1, n+1):
         for j in self.column(i):
             dx1 = np.absolute(self.pos[j][0] - self.pos[i][0])
             dx2 = np.absolute(self.pos[j][1] - self.pos[i][1])
             if dx2 <= dx1 / _GRAPH_ASPECT_RATIO:
                 self.full.add_edge(i, j)
     tmp = 1
     self.basic = set()
     step = self.yres/_GRAPH_YRES_BASIC
     while tmp < n+1:
         self.basic = self.basic | set(self.column(tmp)[0::step])
         tmp = tmp + self.yres
     self.update_active()
コード例 #4
0
 def doublet_velocity_potentials(self,
                                 pnts: MatrixVector,
                                 extraout: bool = False,
                                 sgnz: matrix = None,
                                 factor: bool = True,
                                 betx: float = 1.0):
     rls = self.points_to_local(pnts, betx=betx)
     absx = absolute(rls.x)
     rls.x[absx < tol] = 0.0
     absy = absolute(rls.y)
     rls.y[absy < tol] = 0.0
     absz = absolute(rls.z)
     rls.z[absz < tol] = 0.0
     if sgnz is None:
         sgnz = ones(rls.shape, float)
         sgnz[rls.z <= 0.0] = -1.0
     ovs = rls - self.grdol
     phido, oms = phi_doublet_matrix(ovs, rls, sgnz)
     phidt = phi_trailing_doublet_matrix(rls, sgnz, self.faco)
     phid = phido * self.faco + phidt
     if factor:
         phid = phid / fourPi
     if extraout:
         output = phid, rls, ovs, oms
     else:
         output = phid
     return output
コード例 #5
0
 def doublet_velocity_potentials(self,
                                 pnts: MatrixVector,
                                 extraout: bool = False,
                                 sgnz: matrix = None,
                                 factor: bool = True,
                                 betx: float = 1.0):
     rls = self.points_to_local(pnts, betx=betx)
     absx = absolute(rls.x)
     rls.x[absx < tol] = 0.0
     absy = absolute(rls.y)
     rls.y[absy < tol] = 0.0
     absz = absolute(rls.z)
     rls.z[absz < tol] = 0.0
     if sgnz is None:
         sgnz = ones(rls.shape, float)
         sgnz[rls.z <= 0.0] = -1.0
     avs = rls - self.grdal
     phida, ams = phi_doublet_matrix(avs, rls, sgnz)
     bvs = rls - self.grdbl
     phidb, bms = phi_doublet_matrix(bvs, rls, sgnz)
     phids = phida - phidb
     if factor:
         phids = phids / fourPi
     if extraout:
         return phids, rls, avs, ams, bvs, bms
     else:
         return phids
コード例 #6
0
def vel_trailing_doublet_matrix(ov, om, faco):
    ov: MatrixVector = faco * ov
    oxx = MatrixVector(zeros(ov.shape), -ov.z, ov.y)
    oxxm = oxx.return_magnitude()
    chko = absolute(oxxm) < tol
    den = multiply(om, om - ov.x)
    chkd = absolute(den) < tol
    denr = zeros(ov.shape, dtype=float)
    reciprocal(den, where=logical_not(chkd), out=denr)
    velol = elementwise_multiply(oxx, denr)
    velol.x[chko] = 0.0
    velol.y[chko] = 0.0
    velol.z[chko] = 0.0
    return velol
コード例 #7
0
ファイル: dirichletpoly.py プロジェクト: Xero64/pyapm
def phi_source_matrix(am, bm, dab, rl, phid):
    numrab = am+bm+dab
    denrab = am+bm-dab
    Pab = divide(numrab, denrab)
    chkd = absolute(denrab) < tol
    Pab[chkd] = 1.0
    Qab = log(Pab)
    tmps = multiply(rl.y, Qab)
    phis = -multiply(rl.z, phid) - tmps
    return phis, Qab
コード例 #8
0
def phi_trailing_doublet_matrix(rls: MatrixVector, sgnz: matrix):
    ths = zeros(rls.shape, dtype=float)
    chky = absolute(rls.y) < tol
    ths[rls.y > 0.0] = piby2
    ths[rls.y < 0.0] = -piby2
    ths[chky] = -piby2
    gs = zeros(rls.shape, dtype=float)
    divide(rls.z, rls.y, where=logical_not(chky), out=gs)
    Js = arctan(gs)
    Js[rls.y == 0.0] = -piby2
    phids = Js - multiply(sgnz, ths)
    return phids
コード例 #9
0
 def trefftz_plane_velocities(self, pnts: MatrixVector):
     rls = self.points_to_local(pnts)
     rls.x = zeros(rls.shape, dtype=float)
     # ro = Vector(0.0, self.grdo.y, self.grdo.z)
     # o = rls-ro
     oxx = MatrixVector(rls.x, -rls.z, rls.y)
     om2 = square(rls.y) + square(rls.z)
     chkom2 = (absolute(om2) < tol)
     veldl = elementwise_divide(oxx, om2) * self.faco
     veldl.x[chkom2] = 0.0
     veldl.y[chkom2] = 0.0
     veldl.z[chkom2] = 0.0
     veld = self.vectors_to_global(veldl) * self.faco
     return veld / twoPi
コード例 #10
0
ファイル: panelsection.py プロジェクト: Xero64/pyapm
 def get_profile(self, offset: bool=True):
     num = self.cnum*2+1
     profile = zero_matrix_vector((1, num), dtype=float)
     for i in range(self.cnum+1):
         n = num-i-1
         j = n-num
         profile[0, i] = Vector(self.airfoil.xl[j], 0.0, self.airfoil.yl[j])
         profile[0, n] = Vector(self.airfoil.xu[j], 0.0, self.airfoil.yu[j])
     profile.z[absolute(profile.z) < tol] = 0.0
     profile.z = profile.z*self.thkcor
     if offset:
         offvec = Vector(self.xoc, 0.0, self.zoc)
         profile = profile-offvec
     return profile
コード例 #11
0
ファイル: dirichletpoly.py プロジェクト: Xero64/pyapm
def vel_doublet_matrix(av, am, bv, bm):
    adb = elementwise_dot_product(av, bv)
    abm = multiply(am, bm)
    dm = multiply(abm, abm+adb)
    axb = elementwise_cross_product(av, bv)
    axbm = axb.return_magnitude()
    chki = (axbm == 0.0)
    chki = logical_and(axbm >= -tol, axbm <= tol)
    chkd = absolute(dm) < tol
    fac = zeros(axbm.shape, dtype=float)
    divide(am+bm, dm, where=logical_not(chkd), out=fac)
    velvl = elementwise_multiply(axb, fac)
    velvl.x[chki] = 0.0
    velvl.y[chki] = 0.0
    velvl.z[chki] = 0.0
    return velvl
コード例 #12
0
ファイル: dirichletpoly.py プロジェクト: Xero64/pyapm
def phi_doublet_matrix(vecs: MatrixVector, sgnz: matrix):
    mags = vecs.return_magnitude()
    chkm = mags < tol
    chky = absolute(vecs.y) < tol
    vecs.y[chky] = 0.0
    ms = zeros(mags.shape, dtype=float)
    divide(vecs.x, vecs.y, where=logical_not(chky), out=ms)
    ths = arctan(ms)
    ths[chky] = piby2
    ts = zeros(mags.shape, dtype=float)
    divide(vecs.z, mags, where=logical_not(chkm), out=ts)
    gs = multiply(ms, ts)
    Js = arctan(gs)
    Js[chky] = piby2
    phids = Js - multiply(sgnz, ths)
    return phids, mags
コード例 #13
0
 def within_and_absz_ttol(self, pnts: MatrixVector, ttol: float = 0.1):
     shp = pnts.shape
     pnts = pnts.reshape((-1, 1))
     rgcs = pnts - self.pnto
     wint = full(pnts.shape, False)
     absz = full(pnts.shape, float('inf'))
     for i in range(self.num):
         dirx = self.dirxab[0, i]
         diry = self.diryab[0, i]
         dirz = self.dirzab[0, i]
         xy1 = ones((pnts.shape[0], 3), dtype=float)
         xy1[:, 1] = rgcs * dirx
         xy1[:, 2] = rgcs * diry
         t123 = xy1 * self.baryinv[i].transpose()
         mint = t123.min(axis=1)
         chk = mint > -ttol
         wint[chk] = True
         abszi = absolute(rgcs * dirz)
         abszi[logical_not(chk)] = float('inf')
         absz = minimum(absz, abszi)
     wint = wint.reshape(shp)
     absz = absz.reshape(shp)
     return wint, absz
コード例 #14
0
        pnts[i, j] = Vector(x, y, zorg)

start = perf_counter()
phid, phis, veld, vels = dpnl.influence_coefficients(pnts)
finished = perf_counter()
elapsed = finished - start
print(f'Dirichlet Panel time elapsed is {elapsed:.6f} seconds.')

start = perf_counter()
phidp, phisp, veldp, velsp = poly.influence_coefficients(pnts)
finished = perf_counter()
elapsed = finished - start
print(f'Poly time elapsed is {elapsed:.6f} seconds.')

if zorg == 0.0:
    phid[absolute(phid) < 1e-12] = 0.0
    phid[absolute(phid - 0.5) < 1e-12] = 0.5
    phid[absolute(phid + 0.5) < 1e-12] = -0.5
    vels.z[absolute(vels.z) < 1e-12] = 0.0
    vels.z[absolute(vels.z - 0.5) < 1e-12] = 0.5
    vels.z[absolute(vels.z + 0.5) < 1e-12] = -0.5
    phidp[absolute(phidp) < 1e-12] = 0.0
    phidp[absolute(phidp - 0.5) < 1e-12] = 0.5
    phidp[absolute(phidp + 0.5) < 1e-12] = -0.5
    velsp.z[absolute(velsp.z) < 1e-12] = 0.0
    velsp.z[absolute(velsp.z - 0.5) < 1e-12] = 0.5
    velsp.z[absolute(velsp.z + 0.5) < 1e-12] = -0.5

#%%
# Doublet Velocity Potential
figp = figure(figsize=(12, 10))
コード例 #15
0
pnts = zero_matrix_vector((numy, numx))
for i in range(numy):
    for j in range(numx):
        x = xorg-xamp+xint*j
        y = yorg-yamp+yint*i
        pnts[i, j] = Vector(x, y, zorg)

start = perf_counter()
phiv, velv = hsv.doublet_influence_coefficients(pnts)
phip, velp = poly.doublet_influence_coefficients(pnts)
finished = perf_counter()
elapsed = finished-start
print(f'Time elapsed is {elapsed:.2f} seconds.')

if zorg == 0.0:
    phiv[absolute(phiv) < 1e-12] = 0.0
    phiv[absolute(phiv-0.5) < 1e-12] = 0.5
    phiv[absolute(phiv+0.5) < 1e-12] = -0.5
    phip[absolute(phip) < 1e-12] = 0.0
    phip[absolute(phip-0.5) < 1e-12] = 0.5
    phip[absolute(phip+0.5) < 1e-12] = -0.5

#%%
# Doublet Panel Velocity Potential and Velocity in Z
figv = figure(figsize = (12, 10))
axv = figv.gca()
axv.set_aspect('equal')
axv.set_title('3D Doublet Panel Velocity Potential')
csv = axv.contourf(pnts.x, pnts.y, phiv, levels = 20)
cbv = figv.colorbar(csv)
コード例 #16
0
ファイル: invar_theano.py プロジェクト: DaiDengxin/invariant
    def project(self, img1):
        return self.projfcn(img1)

    def sim(self, img1, img2):
        self.simupdatefcn(img1, img2)

    def dissim(self, img1, img2):
        self.dissimupdatefcn(img1, img2)

    def dist(self, img1, img2):
        return self.pfcn(img1, img2)

img1 = np.random.random((96 * 96, 1)).astype(T.config.floatX)
img2 = np.random.random((96 * 96, 1)).astype(T.config.floatX)
img1 /= np.absolute(img1).sum()
img2 /= np.absolute(img2).sum()

nnet = NNet()

def iter():
    nnet.dissim(img1, img2)
    #nnet.dist(img1, img2)

def main():
    b = time()
    for i in xrange(100):
        iter()
    print time() - b

if __name__=='__main__':
コード例 #17
0
ファイル: invar_theano.py プロジェクト: tachim/invariant
    def project(self, img1):
        return self.projfcn(img1)

    def sim(self, img1, img2):
        self.simupdatefcn(img1, img2)

    def dissim(self, img1, img2):
        self.dissimupdatefcn(img1, img2)

    def dist(self, img1, img2):
        return self.pfcn(img1, img2)


img1 = np.random.random((96 * 96, 1)).astype(T.config.floatX)
img2 = np.random.random((96 * 96, 1)).astype(T.config.floatX)
img1 /= np.absolute(img1).sum()
img2 /= np.absolute(img2).sum()

nnet = NNet()


def iter():
    nnet.dissim(img1, img2)
    #nnet.dist(img1, img2)


def main():
    b = time()
    for i in xrange(100):
        iter()
    print time() - b
コード例 #18
0
ファイル: test_hsd.py プロジェクト: Xero64/pyapm
        pnts[i, j] = Vector(x, y, zorg)

start = perf_counter()
phiv, velv = hsv.doublet_influence_coefficients(pnts)
finished = perf_counter()
elapsed = finished-start
print(f'Horseshoe Time elapsed is {elapsed:.2f} seconds.')

start = perf_counter()
phid, veld = hsd.doublet_influence_coefficients(pnts)
finished = perf_counter()
elapsed = finished-start
print(f'Horseshoe Doublet Time elapsed is {elapsed:.2f} seconds.')

if zorg == 0.0:
    phiv[absolute(phiv) < 1e-12] = 0.0
    phiv[absolute(phiv-0.5) < 1e-12] = 0.5
    phiv[absolute(phiv+0.5) < 1e-12] = -0.5
    phid[absolute(phid) < 1e-12] = 0.0
    phid[absolute(phid-0.5) < 1e-12] = 0.5
    phid[absolute(phid+0.5) < 1e-12] = -0.5

#%%
# Doublet Velocity Potential
figp = figure(figsize = (12, 10))
axp = figp.gca()
axp.set_aspect('equal')
axp.set_title('3D Doublet Panel Velocity Potential - Horseshoe')
cfp = axp.contourf(pnts.x, pnts.y, phiv, levels = 20)
cbp = figp.colorbar(cfp)
コード例 #19
0
 def doublet_influence_coefficients(self,
                                    pnts: MatrixVector,
                                    incvel: bool = True,
                                    betx: float = 1.0,
                                    bety: float = 1.0,
                                    betz: float = 1.0,
                                    checktol: bool = False):
     vecab = Vector(self.vecab.x / betx, self.vecab.y / bety,
                    self.vecab.z / betz)
     dirxab = vecab.to_unit()
     dirzab = Vector(self.nrm.x, self.nrm.y, self.nrm.z)
     diryab = dirzab**dirxab
     agcs = self.relative_mach(pnts,
                               self.grda,
                               betx=betx,
                               bety=bety,
                               betz=betz)
     bgcs = self.relative_mach(pnts,
                               self.grdb,
                               betx=betx,
                               bety=bety,
                               betz=betz)
     locz = agcs * self.nrm
     sgnz = ones(locz.shape, dtype=float)
     sgnz[locz <= 0.0] = -1.0
     phid = zeros(pnts.shape, dtype=float)
     if incvel:
         veld = zero_matrix_vector(pnts.shape, dtype=float)
     # Vector A in Local Coordinate System
     alcs = MatrixVector(agcs * dirxab, agcs * diryab, agcs * dirzab)
     if checktol:
         alcs.x[absolute(alcs.x) < tol] = 0.0
         alcs.y[absolute(alcs.y) < tol] = 0.0
         alcs.z[absolute(alcs.z) < tol] = 0.0
     # Vector A Doublet Velocity Potentials
     phida, amag = phi_doublet_matrix(alcs, sgnz)
     # Vector B in Local Coordinate System
     blcs = MatrixVector(bgcs * dirxab, bgcs * diryab, bgcs * dirzab)
     if checktol:
         blcs.x[absolute(blcs.x) < tol] = 0.0
         blcs.y[absolute(blcs.y) < tol] = 0.0
         blcs.z[absolute(blcs.z) < tol] = 0.0
     # Vector B Doublet Velocity Potentials
     phidb, bmag = phi_doublet_matrix(blcs, sgnz)
     # Edge Doublet Velocity Potentials
     phidi = phida - phidb
     # Add Edge Velocity Potentials
     phid += phidi
     if incvel:
         # Bound Edge Velocities in Local Coordinate System
         veldi = vel_doublet_matrix(alcs, amag, blcs, bmag)
         # Transform to Global Coordinate System and Add
         dirxi = Vector(dirxab.x, diryab.x, dirzab.x)
         diryi = Vector(dirxab.y, diryab.y, dirzab.y)
         dirzi = Vector(dirxab.z, diryab.z, dirzab.z)
         veld += MatrixVector(veldi * dirxi, veldi * diryi, veldi * dirzi)
     # Trailing Edge A Coordinate Transformation
     dirxa = self.diro
     dirza = self.nrm
     dirya = -dirza**dirxa
     alcs = MatrixVector(agcs * dirxa, agcs * dirya, agcs * dirza)
     # Trailing Edge A Velocity Potential
     phida, amag = phi_doublet_matrix(alcs, sgnz)
     phidt = phi_trailing_doublet_matrix(alcs, sgnz)
     phidi = phida + phidt
     # Add Trailing Edge A Velocity Potentials
     phid += phidi
     # Trailing Edge B Coordinate Transformation
     if incvel:
         # Trailing Edge A Velocities in Local Coordinate System
         veldi = vel_trailing_doublet_matrix(alcs, amag, 1.0)
         # Transform to Global Coordinate System and Add
         dirxi = Vector(dirxa.x, dirya.x, dirza.x)
         diryi = Vector(dirxa.y, dirya.y, dirza.y)
         dirzi = Vector(dirxa.z, dirya.z, dirza.z)
         veld += MatrixVector(veldi * dirxi, veldi * diryi, veldi * dirzi)
     # Trailing Edge B Coordinate Transformation
     dirxb = self.diro
     dirzb = self.nrm
     diryb = dirzb**dirxb
     blcs = MatrixVector(bgcs * dirxb, bgcs * diryb, bgcs * dirzb)
     # Trailing Edge B Velocity Potential
     phidb, bmag = phi_doublet_matrix(blcs, sgnz)
     phidt = phi_trailing_doublet_matrix(blcs, sgnz)
     phidi = phidb + phidt
     # Add Trailing Edge B Velocity Potentials
     phid += phidi
     if incvel:
         # Trailing Edge B Velocities in Local Coordinate System
         veldi = vel_trailing_doublet_matrix(blcs, bmag, 1.0)
         # Transform to Global Coordinate System and Add
         dirxi = Vector(dirxb.x, diryb.x, dirzb.x)
         diryi = Vector(dirxb.y, diryb.y, dirzb.y)
         dirzi = Vector(dirxb.z, diryb.z, dirzb.z)
         veld += MatrixVector(veldi * dirxi, veldi * diryi, veldi * dirzi)
     # Factors and Outputs
     phid = phid / fourPi
     if incvel:
         veld = veld / fourPi
         output = phid, veld
     else:
         output = phid
     return output
コード例 #20
0
ファイル: dirichletpoly.py プロジェクト: Xero64/pyapm
 def influence_coefficients(self, pnts: MatrixVector, incvel: bool=True,
                            betx: float=1.0, bety: float=1.0, betz: float=1.0,
                            checktol: bool=False):
     grdm = self.mach_grids(betx=betx, bety=bety, betz=betz)
     vecab = self.edge_vector(grdm)
     vecaxb = self.edge_cross(grdm)
     dirxab = vecab.to_unit()
     dirzab = vecaxb.to_unit()
     diryab = elementwise_cross_product(dirzab, dirxab)
     nrm = vecaxb.sum().to_unit()
     rgcs = self.relative_mach(pnts, self.pnto, betx=betx, bety=bety, betz=betz)
     locz = rgcs*nrm
     sgnz = ones(locz.shape, dtype=float)
     sgnz[locz <= 0.0] = -1.0
     vecgcs = []
     for i in range(self.num):
         vecgcs.append(self.relative_mach(pnts, self.grds[i], betx=betx, bety=bety, betz=betz))
     phid = zeros(pnts.shape, dtype=float)
     phis = zeros(pnts.shape, dtype=float)
     if incvel:
         veld = zero_matrix_vector(pnts.shape, dtype=float)
         vels = zero_matrix_vector(pnts.shape, dtype=float)
     for i in range(self.num):
         # Edge Length
         dab = vecab[0, i].return_magnitude()
         # Local Coordinate System
         dirx = dirxab[0, i]
         diry = diryab[0, i]
         dirz = dirzab[0, i]
         # Vector A in Local Coordinate System
         veca = vecgcs[i-1]
         alcs = MatrixVector(veca*dirx, veca*diry, veca*dirz)
         if checktol:
             alcs.x[absolute(alcs.x) < tol] = 0.0
             alcs.y[absolute(alcs.y) < tol] = 0.0
             alcs.z[absolute(alcs.z) < tol] = 0.0
         # Vector A Doublet Velocity Potentials
         phida, amag = phi_doublet_matrix(alcs, sgnz)
         # Vector B in Local Coordinate System
         vecb = vecgcs[i]
         blcs = MatrixVector(vecb*dirx, vecb*diry, vecb*dirz)
         if checktol:
             blcs.x[absolute(blcs.x) < tol] = 0.0
             blcs.y[absolute(blcs.y) < tol] = 0.0
             blcs.z[absolute(blcs.z) < tol] = 0.0
         # Vector B Doublet Velocity Potentials
         phidb, bmag = phi_doublet_matrix(blcs, sgnz)
         # Edge Doublet Velocity Potentials
         phidi = phida - phidb
         # Edge Source Velocity Potentials
         phisi, Qab = phi_source_matrix(amag, bmag, dab, alcs, phidi)
         # Add Edge Velocity Potentials
         phid += phidi
         phis += phisi
         # Calculate Edge Velocities
         if incvel:
             # Velocities in Local Coordinate System
             veldi = vel_doublet_matrix(alcs, amag, blcs, bmag)
             velsi = vel_source_matrix(Qab, alcs, phidi)
             # Transform to Global Coordinate System and Add
             dirxi = Vector(dirx.x, diry.x, dirz.x)
             diryi = Vector(dirx.y, diry.y, dirz.y)
             dirzi = Vector(dirx.z, diry.z, dirz.z)
             veld += MatrixVector(veldi*dirxi, veldi*diryi, veldi*dirzi)
             vels += MatrixVector(velsi*dirxi, velsi*diryi, velsi*dirzi)
     phid = phid/fourPi
     phis = phis/fourPi
     if incvel:
         veld = veld/fourPi
         vels = vels/fourPi
         output = phid, phis, veld, vels
     else:
         output = phid, phis
     return output