Source code for bladedesigner.camberlines.n6scamberline

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


[docs]class N6SCamberLine(bcls.AnalyticalCamberLine): """ The NACA 6-Series camberline is a function of the design lift coefficient :math:`c_l` and the chordwise extent of uniform loading a, the pressure distribution decreases till the position b and remains zero till the trailing edge. """ def __init__(self): super(N6SCamberLine, self).__init__() # properties (initialized by user) self.__lift_coefficient = fdn.Uninit('lift_coefficient') self.__end_const_pressure = fdn.Uninit('end_const_pressure') self.__start_zero_pressure = fdn.Uninit('start_zero_pressure') # add user properties to initialization summary self._properties.extend(['lift_coefficient', 'end_const_pressure']) self._properties.append('start_zero_pressure') @property def end_const_pressure(self): return self.__end_const_pressure @end_const_pressure.setter @fdn.restrict(new_end_const_pressure=fdn.ClosedInterval(0, 1)) def end_const_pressure(self, new_end_const_pressure): if self.__end_const_pressure != new_end_const_pressure: self.__end_const_pressure = new_end_const_pressure self.update() @property def lift_coefficient(self): """ Type: ``int or float`` """ return self.__lift_coefficient @lift_coefficient.setter @fdn.restrict(new_lift_coefficient=(int, float))
[docs] def lift_coefficient(self, new_lift_coefficient): if self.__lift_coefficient != new_lift_coefficient: self.__lift_coefficient = new_lift_coefficient self.update()
@property def start_zero_pressure(self): return self.__start_zero_pressure @start_zero_pressure.setter @fdn.restrict(new_start_zero_pressure=fdn.ClosedInterval(0, 1)) def start_zero_pressure(self, new_start_zero_pressure): if self.__start_zero_pressure != new_start_zero_pressure: self.__start_zero_pressure = new_start_zero_pressure self.update() def __f(self, x): f = lambda y: 0 if y == 0 else y ** 2 * (np.log(np.fabs(y)) - .5) return f(x) if not hasattr(x, '__iter__') else np.array(map(f, x)) def __dfdx(self, x): f = lambda x: 0 if x == 0 else x * np.log(x ** 2) return f(x) if not hasattr(x, '__iter__') else np.array(map(f, x)) @fdn.memoize def get_derivations(self): self._check_initialization() self._cached = True # get helper fuction f with its derivation dfdx f = self.__f dfdx = self.__dfdx # calculate parameters a = self.end_const_pressure b = self.start_zero_pressure c = self.lift_coefficient / 6.28318530718 / (a + b) d = .5 / (b - a) g = -d * (f(a) - f(b)) h = d * (f(1 - a) - f(1 - b)) + g # get distributed x values x = self.distribution(self.sample_rate) z = x[1:-1] # calculate derivations dydx = np.empty(x.shape) dydx[0] = np.inf dydx[1:-1] = c * (d * (dfdx(z - a) - dfdx(z - b)) - np.log(z) - 1 - h) dydx[-1] = -np.inf return dydx @fdn.memoize def as_array(self): self._check_initialization() self._cached = True # get helper fuction f f = self.__f # calculate parameters a = self.end_const_pressure b = self.start_zero_pressure c = self.lift_coefficient / 6.28318530718 / (a + b) d = .5 / (b - a) g = -d * (f(a) - f(b)) h = d * (f(1 - a) - f(1 - b)) + g # get distributed x values x = self.distribution(self.sample_rate) z = x[1:-1] # calculate corresponding y values y = np.zeros(x.shape) y[1:-1] = c * (d * (f(a - z) - f(b - z)) - z * np.log(z) + g - h * z) return np.reshape(np.append(x, y), (-1, 2), "F")