Source code for bladedesigner.camberlines.n2dcamberline

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# ***************************************************************************
# *   Copyright (C) 2011-2012 by Andreas K├╝hrmann [kuean@users.sf.net]      *
# *                                                                         *
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU General Public License as published by  *
# *   the Free Software Foundation; either version 3 of the License, or     *
# *   (at your option) any later version.                                   *
# *                                                                         *
# *   This program is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
# *   GNU General Public License for more details.                          *
# *                                                                         *
# *   You should have received a copy of the GNU General Public License     *
# *   along with this program; if not, write to the                         *
# *   Free Software Foundation, Inc.,                                       *
# *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
# ***************************************************************************


import numpy as np

import bladedesigner.baseclasses as bcls
import bladedesigner.foundation as fdn


__all__ = ['N2DCamberLine']


[docs]class N2DCamberLine(bcls.AnalyticalCamberLine): r""" The NACA 2-digit camber line is characterized by two attributes :math:`m` and :math:`p` where :math:`m` is the maximum camber and :math:`p` is the chordwise location of maximum camber. This camber line is formed by two parabolic segments that match in value and slope at :math:`p`. The camber line equation is: .. math:: y = \Bigg\{ \begin{array}{ll} m p^{-2} x (2 p - x) & \mbox{if } x \leq p \\ m (1 - p)^{-2} (1 - 2 p + x (2 p - x)) & \mbox{if } x > p \end{array} .. tip:: Jacobs, Eastman N.; Ward, Kenneth E. and Pinkerton, Robert M.: *The Characteristics of 78 Related Airfoil Sections From Tests in the Variable-Density Wind Tunnel.* NACA Rep. 460, 1933 Ladson, Charles L.; Brooks, Cuyler W.; Hill, Acquilla S. and Sproles Darrell W.: *Computer Program To Obtain Ordinates for NACA Airfoils* NACA TM 4741, 1996. """ def __init__(self): super(N2DCamberLine, self).__init__() # properties (initialized by user) self.__max_camber = fdn.Uninit('max_camber') self.__max_camber_position = fdn.Uninit('max_camber_position') # add user properties to initialization summary self._properties.extend(['max_camber', 'max_camber_position']) @property def max_camber(self): """ Type: ``int or float`` """ return self.__max_camber @max_camber.setter @fdn.restrict(new_max_camber=(int, float))
[docs] def max_camber(self, new_max_camber): if self.__max_camber != new_max_camber: self.__max_camber = new_max_camber self.update()
@property def max_camber_position(self): """ Type: ``float`` - values between (exclusive) 0 and 1 only """ return self.__max_camber_position @max_camber_position.setter @fdn.restrict(new_max_camber_position=fdn.OpenInterval(0, 1))
[docs] def max_camber_position(self, new_max_camber_position): if self.__max_camber_position != new_max_camber_position: self.__max_camber_position = new_max_camber_position self.update()
@fdn.memoize
[docs] def get_derivations(self): """ get_derivations() Returns: ``ndarray`` Calculates camber line derivations and returns them in an array. .. note:: The return value will be cached. Recalling this method returns the cached value, if the attribues are unchanged. """ self._check_initialization() self._cached = True p = self.max_camber_position m = self.max_camber x = self.distribution(self.sample_rate) index = np.where(x <= p)[0] if index.size: dydx_1 = 2 * m / np.power(p, 2) * (p - x[index]) index = np.where(x > p)[0] if index.size: dydx_2 = m / (1 - p) ** 2 * 2 * (p - x[index]) return np.append(dydx_1, dydx_2)
@fdn.memoize
[docs] def as_array(self): """ as_array() Returns: ``ndarray`` Calculates camber line coordinates and returns them in an array. .. note:: The return value will be cached. Recalling this method returns the cached value, if the attribues are unchanged. """ self._check_initialization() self._cached = True p = self.max_camber_position m = self.max_camber x = self.distribution(self.sample_rate) index = np.where(x <= p)[0] if index.size: z = x[index] y1 = m / p ** 2 * (z * (2 * p - z)) index = np.where(x > p)[0] if index.size: z = x[index] y2 = m / (1 - p) ** 2 * (1 - 2 * p + z * (2 * p - z)) y = np.append(y1, y2) return np.reshape(np.append(x, y), (-1, 2), "F")