Source code for bladedesigner.camberlines.d4pcamberline

#!/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.foundation as fdn

from d3pcamberline import D3PCamberLine


__all__ = ['D4PCamberLine']


[docs]class D4PCamberLine(D3PCamberLine): """ some documentation """ def __init__(self): super(D4PCamberLine, self).__init__() # properties (initialized by user) self.__max_camber_position = fdn.Uninit('max_camber_position') # add user properties to initialization summary self._properties.append('max_camber_position') @property def max_camber_position(self): return self.__max_camber_position @max_camber_position.setter @fdn.restrict(new_max_camber_position=fdn.OpenInterval(0, 1)) def max_camber_position(self, new_max_camber_position): """ Type: ``float`` - values between (exclusive) 0 and 1 only """ if self.__max_camber_position != new_max_camber_position: self.__max_camber_position = new_max_camber_position self.update() def __get_coefficients(self): args = ('angle_of_inflow', 'angle_of_outflow', 'max_camber_position') self._check_initialization(*args) slope_inlet = np.tan(self.angle_of_inflow - np.pi / 2.) slope_outlet = np.tan(np.pi / 2. - self.angle_of_outflow) p = self.max_camber_position a_4 = (((p * (4 - 3 * p) - 1) * slope_inlet + p * (3 * p - 2) * slope_outlet) / (2 * p * (2 * p) * (p - 1))) a_3 = slope_inlet - slope_outlet - 2 * a_4 a_2 = -slope_inlet - a_3 - a_4 a_1 = slope_inlet return a_1, a_2, a_3, a_4 @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, a_3, a_4 = self.__get_coefficients() return x * (x * (4 * a_4 * x + 3 * a_3) + 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, a_3, a_4 = self.__get_coefficients() y = x * (x * (x * (a_4 * x + a_3) + a_2) + a_1) return np.reshape(np.append(x, y), (-1, 2), "F")