def testElemDivider(): pos = 5 + 2j elemList = [] v = f.VortexBlobKrasny(pos, -2.5, radius=0.01) elemList.append(f.Vortex(pos, -1.0, radius=0.01)) elemList.append(f.Vortex(pos, -1.0, radius=0.01)) elemList.append(f.Vortex(pos, -0.5, radius=0.01)) r = Rvm([]) elemList2 = r.elemDivider(v, 1.00) assert (elemList == elemList2)
def tempTest(): particleArray = [] strength = 1 noOfParticle = 500 ran = np.random.random for i in range(noOfParticle): pos = 2 * ran() - 1 + (2 * ran() - 1) * 1j particleArray.append(f.Vortex(pos, 1, 1, False)) ctime = time.clock() cell = Cell(0 + 0j, 1, 5) cell.addParticleArray(particleArray) cell.checkParticle() cell.getMPCoef(20) velArray = [] for particle in particleArray: velArray.append(cell.compute_vel(particle.position)) print(time.clock() - ctime) ctime = time.clock() velArray2 = f.velUpdate(particleArray) print(time.clock() - ctime) error = [0] * len(velArray) for i in range(len(velArray)): error[i] = abs(velArray[i] - velArray2[i]) plt.plot(error) plt.show()
def test_cell(): particleArray = [] cell = Cell(0 + 0j, 1, 1) particleArray.append(f.Vortex(complex(0.2, 0.2), 1, 1, False)) particleArray.append(f.Vortex(complex(0.6, 0.6), 1, 1, False)) particleArray.append(f.Vortex(complex(-0.3, -0.4), 1, 1, False)) particleArray.append(f.Vortex(complex(0.3, -0.4), 1, 1, False)) particleArray.append(f.Vortex(complex(-0.4, 0.5), 1, 1, False)) for particle in particleArray: cell.addParticle(particle) cell.checkParticle() cell.getMPCoef(15) tempVel = [] for particle in particleArray: tempVel.append(cell.compute_vel(particle.position)) for vel in tempVel: print(vel) assert (cell.childs[0].childs[0] == particleArray[4]) assert (cell.childs[1].childs[1].childs[0] == particleArray[1]) assert (cell.childs[2].childs[0] == particleArray[2]) assert (cell.childs[3].childs[0] == particleArray[3]) print("creating the quad tree test successful")
def createVortexBlob(self): positions = self.vortexBlobPoints vortexPanels = self.vortexPList vPositions = self.vortexPanelPoints velArray = self.getVel(vPositions, self.currentFlowArray) VortexBlobArray = [] for pos, element, vel in zip(positions, vortexPanels, velArray): distance = abs(element.position - pos) tangent = -element.position.imag + element.position.real * 1j tangent = tangent / abs(tangent) strength = component(vel * element.length, tangent) vortexBlob = f.Vortex(pos, strength, radius=distance) VortexBlobArray.append(vortexBlob) return VortexBlobArray
def testRandomWalk(): pos = 1.05 * (-0.7071067811865475 + 0.7071067811865475j) v = f.Vortex(pos, 2.5, radius=0.01) r = Rvm([]) r.randomWalk(v, 0.002, 0.1) assert (abs(v.position) >= 1.00)