Source code for bladedesigner.camberlines.d2pcamberline

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


[docs]class D2PCamberLine(bcls.AnalyticalCamberLine): """ some documentation """ def __init__(self): super(D2PCamberLine, 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()
def __get_coefficients(self): self._check_initialization('angle_of_inflow') a = np.tan(self.angle_of_inflow - np.pi / 2.) return a, -a @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 x = self.distribution(self._sample_rate) a_1, a_2 = self.__get_coefficients() return x * (x * 2 * a_2) + a_1
@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 x = self.distribution(self.sample_rate) a_1, a_2 = self.__get_coefficients() y = x * (x * a_2 + a_1) return np.reshape(np.append(x, y), (-1, 2), "F")