Exemple #1
0
	def initializeWingCosine(self):
       
		theta_i = np.linspace(0.5*np.pi, np.pi, self.nj+1)
		y_i = -self.span*np.cos(theta_i)
		dy = self.span/float(self.nj)

		for j in range(self.nj):
			y     = y_i[j]
			yNext = y_i[j+1]
			eta     = y / self.span
			etaNext = yNext / self.span

			twist = (1.0 - eta) * self.twistRoot + eta * self.twistTip
			twistNext = (1.0 - etaNext) * self.twistRoot + etaNext * self.twistTip

			chord = Vector3((1.0 - eta) * self.chordRoot + eta * self.chordTip, 0.0, 0.0).rotate(0.0,twist,0.0)
			chordNext = Vector3((1.0 - etaNext) * self.chordRoot + etaNext * self.chordTip, 0.0, 0.0).rotate(0.0,twistNext,0.0)

			pt = Vector3(tan(self.sweep) * y, y, 0.0)
			ptNext = Vector3(tan(self.sweep) * yNext, yNext, 0.0)

			ds = chord / float(self.ni)
			dsNext = chordNext / float(self.ni)

			for i in range(self.ni):
				p1 = pt
				p4 = ptNext

				pt = pt + ds
				ptNext += dsNext

				p2 = pt
				p3 = ptNext

				self.panels.append(panel(p1,p2,p3,p4))
Exemple #2
0
	def initializeWing(self):
		dy = self.span/float(self.nj)
		y = 0.0
		yNext = y + dy
		for j in range(self.nj):
			eta     = y / self.span
			etaNext = yNext / self.span

			twist = (1.0 - eta) * self.twistRoot + eta * self.twistTip			
			twistNext = (1.0 - etaNext) * self.twistRoot + etaNext * self.twistTip

			chord = Vector3((1.0 - eta) * self.chordRoot + eta * self.chordTip, 0.0, 0.0).rotate(0.0,twist,0.0)
			chordNext = Vector3((1.0 - etaNext) * self.chordRoot + etaNext * self.chordTip, 0.0, 0.0).rotate(0.0,twistNext, 0.0)
            
			pt = Vector3(tan(self.sweep) * y, y, 0.0)
			ptNext = Vector3(tan(self.sweep) * yNext, yNext, 0.0)

			ds = chord / float(self.ni)
			dsNext = chordNext / float(self.ni)

			for i in range(self.ni):
				p1 = pt
				p4 = ptNext

				pt = pt + ds
				ptNext += dsNext

				p2 = pt
				p3 = ptNext

				self.panels.append(panel(p1,p2,p3,p4))

			y += dy
			yNext += dy
Exemple #3
0
	def computeForcesAndMoment(self):
		self.CL.append(0.0)
		self.CM.append(0.0)
		self.CD.append(0.0)

		inducedDownwashX = np.dot(self.inducedDownwash[0],self.gamma)
		inducedDownwashY = np.dot(self.inducedDownwash[1],self.gamma)
		inducedDownwashZ = np.dot(self.inducedDownwash[2],self.gamma)

		for index,panel in enumerate(self.panels):
			force = self.Ufree.crossProduct(panel.dl()) * self.rho * self.gammaij[index]

			distToRefrence = self.referencePoint - panel.forceActingPoint()
			moment = force.crossProduct(distToRefrence)

			downWash = Vector3(inducedDownwashX[index], inducedDownwashY[index], inducedDownwashZ[index])

			self.CL[-1] += force.dot(self.liftAxis)
			self.CM[-1] += moment[1]
			self.CD[-1] -= self.rho * downWash.dot(self.liftAxis) * self.gammaij[index] * panel.dy()

		self.CL[-1] /= ( 0.5 * self.rho * self.Ufree.Magnitude()**2 * self.Sref)
		self.CD[-1] /= ( 0.5 * self.rho * self.Ufree.Magnitude()**2 * self.Sref)
		self.CM[-1] /= ( 0.5 * self.rho * self.Ufree.Magnitude()**2 * self.Sref * self.cavg)

		if len(self.alphaRange) > 1:
			self.CL_alpha = (self.CL[-1]-self.CL[0])/radians(self.alphaRange[-1]-self.alphaRange[0])
Exemple #4
0
	def __init__(self, ni=5, nj=10, chordRoot=1.0, chordTip=1.0, twistRoot=0.0, twistTip=0.0, span=5.0, sweep=30.0, Sref = 1.0, referencePoint=[0.0,0.0,0.0], wingType=1, alphaRange = [0.0]):

		self.size = ni * nj

		self.A   = np.zeros((self.size,self.size))
		self.rhs = np.zeros(self.size)
		self.inducedDownwash = [np.zeros((self.size,self.size)), np.zeros((self.size,self.size)), np.zeros((self.size,self.size))]
		
		self.nw = 1
		self.panels     = []
		self.wakePanels = []
		self.ni = ni
		self.nj = nj

		self.gamma   = np.zeros(self.size)
		self.gammaij = np.zeros(self.size)

		self.liftAxis = Vector3(0.0,0.0,1.0)

		self.Sref      = Sref
		self.chordRoot = chordRoot
		self.chordTip  = chordTip
		self.cavg      = 0.5 * (chordRoot + chordTip)
		self.twistRoot = twistRoot
		self.twistTip  = twistTip
		self.span      = span
		self.AR        = self.span/(self.chordRoot)
		self.sweep     = sweep * pi / 180.0
		self.referencePoint = Vector3(referencePoint[0],
			                          referencePoint[1],
			                          referencePoint[2])
		self.wingType = wingType

		self.CL = []
		self.CD = []
		self.CDi = []
		self.e = []
		self.CM = []

		self.clocal = np.zeros(self.nj)
		self.spanLoad = []

		if not hasattr(alphaRange, '__iter__'): alphaRange = (alphaRange,)
		self.alphaRange = alphaRange
		self.Ufree = Vector3(1.0,0.0,0.0)
		self.rho = 1.0
Exemple #5
0
	def updateFreeStream(self,alpha):
		self.Ufree = Vector3(cos(alpha * pi / 180.0), 0.0, sin(alpha * pi / 180.0))
		self.liftAxis = Vector3(-sin(alpha * pi / 180.0), 0.0, cos(alpha * pi / 180.0))
Exemple #6
0
    def influence(self, collocationPoint, Sym=True, boundInfluence=True):
        SYM = 0
        u = Vector3(0.0, 0.0, 0.0)
        rcut = 1.0e-12

        if (Sym): SYM = 1
        for sym in range(0, SYM + 1):
            x = collocationPoint.x
            y = collocationPoint.y
            if (sym): y *= -1.0
            z = collocationPoint.z

            if (boundInfluence):
                edges = [0, 1, 2, 3]
            else:
                edges = [1, 3]

            for i in edges:
                if (i == 0):
                    x1 = self.p1.x
                    y1 = self.p1.y
                    z1 = self.p1.z
                    x2 = self.p4.x
                    y2 = self.p4.y
                    z2 = self.p4.z
                elif (i == 1):
                    x1 = self.p4.x
                    x2 = self.p3.x
                    y1 = self.p4.y
                    y2 = self.p3.y
                    z1 = self.p4.z
                    z2 = self.p3.z
                elif (i == 2):
                    x1 = self.p3.x
                    x2 = self.p2.x
                    y1 = self.p3.y
                    y2 = self.p2.y
                    z1 = self.p3.z
                    z2 = self.p2.z
                elif (i == 3):
                    x1 = self.p2.x
                    x2 = self.p1.x
                    y1 = self.p2.y
                    y2 = self.p1.y
                    z1 = self.p2.z
                    z2 = self.p1.z
                r1r2x = (y - y1) * (z - z2) - (z - z1) * (y - y2)
                r1r2y = -((x - x1) * (z - z2) - (z - z1) * (x - x2))
                r1r2z = (x - x1) * (y - y2) - (y - y1) * (x - x2)

                r1 = sqrt((x - x1)**2 + (y - y1)**2 + (z - z1)**2)
                r2 = sqrt((x - x2)**2 + (y - y2)**2 + (z - z2)**2)
                r0 = Vector3(x2 - x1, y2 - y1, z2 - z1)

                r1 = sqrt((x - x1)**2 + (y - y1)**2 + (z - z1)**2)
                r2 = sqrt((x - x2)**2 + (y - y2)**2 + (z - z2)**2)
                r0 = Vector3(x2 - x1, y2 - y1, z2 - z1)

                # //calculation of (r1 x r2)^2
                square = ((r1r2x)**2 + (r1r2y)**2 + (r1r2z)**2)

                if ((r1 < rcut) or (r2 < rcut) or (square < rcut)):
                    pass
                else:
                    r0r1 = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (
                        z2 - z1) * (z - z1)
                    r0r2 = (x2 - x1) * (x - x2) + (y2 - y1) * (y - y2) + (
                        z2 - z1) * (z - z2)
                    coef = 1.0 / (4.0 * pi * square) * (r0r1 / r1 - r0r2 / r2)

                    u.x += r1r2x * coef
                    if (sym):
                        u.y -= r1r2y * coef
                    else:
                        u.y += r1r2y * coef
                    u.z += r1r2z * coef
        return u