Source code for bladedesigner.camberlines.acamberline

#!/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__ = ['ACamberLine']


[docs]class ACamberLine(bcls.AnalyticalCamberLine): """ some documentation """ def __init__(self): super(ACamberLine, self).__init__() # properties (initialized by user) self.__angle_of_inflow = fdn.Uninit('angle_of_inflow') # add user properties to initialization summary self._properties.append('angle_of_inflow') @property def angle_of_inflow(self): r""" Type: ``int or float`` - values between (exclusive) 0 and :math:`\pi` only """ return self.__angle_of_inflow @angle_of_inflow.setter @fdn.restrict(new_angle_of_inflow=fdn.OpenInterval(0, np.pi))
[docs] def angle_of_inflow(self, new_angle_of_inflow): if self.__angle_of_inflow != new_angle_of_inflow: self.__angle_of_inflow = new_angle_of_inflow self.update()
@fdn.memoize
[docs] def get_derivations(self): """ get_derivations() Returns: ``ndarray`` Calculates camber line derivations and returns them in an array. .. note:: **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 chi = self.angle_of_inflow sign = 1 if chi < np.pi / 2 else -1 r2 = (.5 / np.cos(chi)) ** 2 x = self.distribution(self.sample_rate) - .5 return sign * x / np.sqrt(r2 - x ** 2)
@fdn.memoize
[docs] def as_array(self): """ as_array() Returns: ``ndarray`` Calculates camber line coordinates and returns them in an array. .. note:: **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 chi = self.angle_of_inflow sign = -1 if chi < np.pi / 2 else 1 r2 = (.5 / np.cos(chi)) ** 2 x = self.distribution(self.sample_rate) y = sign * (np.sqrt(r2 - (x - .5) ** 2) - np.sqrt(r2 - .25)) return np.reshape(np.append(x, y), (-1, 2), "F")