001/*
002*   NACA64ASeries -- An arbitrary NACA 64A series airfoil.
003*
004*   Copyright (C) 2010-2012 by Joseph A. Huwaldt
005*   All rights reserved.
006*   
007*   This library is free software; you can redistribute it and/or
008*   modify it under the terms of the GNU Lesser General Public
009*   License as published by the Free Software Foundation; either
010*   version 2.1 of the License, or (at your option) any later version.
011*   
012*   This library is distributed in the hope that it will be useful,
013*   but WITHOUT ANY WARRANTY; without even the implied warranty of
014*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015*   Lesser General Public License for more details.
016*
017*   You should have received a copy of the GNU Lesser General Public License
018*   along with this program; if not, write to the Free Software
019*   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020*   Or visit:  http://www.gnu.org/licenses/lgpl.html
021**/
022package jahuwaldt.aero.airfoils;
023
024import java.util.List;
025import java.awt.geom.Point2D;
026import java.text.DecimalFormat;
027import java.text.NumberFormat;
028
029
030/**
031*  <p> This class represents an arbitrary NACA 64A series
032*      airfoil section such as a NACA 64A020 airfoil.
033*  </p>
034*
035*  <p> Ported from FORTRAN "NACA6.FOR" to Java by:
036*                Joseph A. Huwaldt, June 4, 2010     </p>
037*
038*  <p> Original FORTRAN "NACA4" code had the following note:  </p>
039*
040*  <pre>
041*         AUTHORS - Charles L.Ladson and Cuyler W. Brooks, NASA Langley
042*                   Liam Hardy, NASA Ames
043*                   Ralph Carmichael, Public Domain Aeronautical Software
044*         Last FORTRAN version:  23Nov96  2.0   RLC
045*
046*         NOTES - This program has also been known as LADSON and SIXSERIES and
047*                 as SIXSERIE on systems with a 8-letter name limit.
048*         REFERENCES-  NASA Technical Memorandum TM X-3069 (September, 1974),
049*                      by Charles L. Ladson and Cuyler W. Brooks, Jr., NASA Langley Research Center.
050*
051*                      "Theory of Wing Sections", by Ira Abbott and Albert Von Doenhoff.
052*  </pre>
053*
054*  <p>  Modified by:  Joseph A. Huwaldt  </p>
055*
056*  @author  Joseph A. Huwaldt   Date:  June 6, 2010
057*  @version September 15, 2012
058**/
059public class NACA64ASeries extends NACA6ASeries {
060        
061        //-----------------------------------------------------------------------------------
062        
063        /**
064        *  Create a NACA 64A series airfoil with the specified parameters.
065        *
066        *  @param  CLi        Design lift coefficient (e.g.: 64A206 has CLi = 0.2).
067        *  @param  thickness  The thickness to chord ratio (e.g.: 0.20 ==> 20% t/c).
068        *  @param  length     The chord length.
069        **/
070        public NACA64ASeries(double CLi, double thickness, double length) {
071                super(CLi, thickness, length);
072        }
073        
074        /**
075        *  Returns a String that represents the profile type of this airfoil.
076        **/
077    @Override
078        public String getProfile() {
079                return "64A";
080        }
081        
082        //      Phi & eps vectors for 64A series airfoil.
083    private static final double[] philde = {
084                0.,.01468,.02936,
085                .04403,.05872,.0734,.08808,.10277,
086                .11746,.13216,.14686,.15019,
087                .15352,.15685,.16018,.16351,.16684,
088                .17017,.1735,.17684,.18017,
089                .18528,.19039,.19551,.20062,.20574,
090                .21086,.21598,.22109,.22621,
091                .23133,.2409,.25046,.26003,.26959,
092                .27915,.28871,.29827,.30783,
093                .31739,.32695,.3404,.35384,.36728,
094                .38072,.39417,.40761,.42105,
095                .4345,.44794,.46139,.47194,.48249,
096                .49304,.50359,.51414,.52469,
097                .53523,.54578,.55633,.56688,.57595,
098                .58502,.5941,.60317,.61224,
099                .62131,.63038,.63945,.64852,.65759,
100                .67317,.68874,.70432,.71989,
101                .73546,.75104,.76661,.78218,.79776,
102                .81333,.82695,.84057,.85419,
103                .86781,.88142,.89504,.90866,.92228,
104                .93589,.94951,.96194,.97437,
105                .98679,.99922,1.01165,1.02407,1.0365,
106                1.04892,1.06135,1.07377,1.08546,
107                1.09714,1.10882,1.1205,1.13219,
108                1.14387,1.15555,1.16723,1.17891,
109                1.19059,1.2018,1.21301,1.22423,
110                1.23544,1.24665,1.25786,1.26907,
111                1.28028,1.29149,1.3027,1.31357,
112                1.32444,1.33531,1.34618,1.35705,
113                1.36792,1.37878,1.38965,1.40052,
114                1.41139,1.42204,1.43268,1.44333,
115                1.45397,1.46462,1.47527,1.48591,
116                1.49656,1.50721,1.51785,1.52834,
117                1.53883,1.54932,1.5598,1.57029,
118                1.58078,1.59127,1.60176,1.61225,
119                1.62274,1.63312,1.64349,1.65387,
120                1.66425,1.67463,1.68501,1.69539,
121                1.70577,1.71615,1.72653,1.73692,
122                1.74732,1.75771,1.76811,1.77851,
123                1.7889,1.7993,1.8097,1.82009,1.83049,
124                1.841,1.8515,1.86201,1.87252,
125                1.88303,1.89354,1.90405,1.91455,
126                1.92506,1.93557,1.9463,1.95704,
127                1.96777,1.9785,1.98923,1.99996,
128                2.01069,2.02142,2.03215,2.04288,
129                2.05401,2.06514,2.07627,2.0874,
130                2.09853,2.10965,2.12078,2.13191,
131                2.14304,2.15416,2.16592,2.17767,
132                2.18943,2.20118,2.21293,2.22469,
133                2.23644,2.24819,2.25994,2.27169,
134                2.28447,2.29725,2.31002,2.32279,
135                2.33557,2.34834,2.36111,2.37389,
136                2.38666,2.39943,2.41397,2.4285,
137                2.44304,2.45757,2.4721,2.48663,
138                2.50115,2.51568,2.5302,2.54471,
139                2.56262,2.58052,2.59842,2.61631,
140                2.6342,2.65209,2.66997,2.68785,
141                2.70573,2.72362,2.76541,2.8072,
142                2.84899,2.89079,2.93259,2.97439,
143                3.01619,3.05799,3.09979,3.14159 };
144                
145    private static final double[] epslde = {
146                0.,.00149,.00297,
147                .00445,.00591,.00736,.00878,.01018,
148                .01156,.0129,.0142,.01449,
149                .01477,.01505,.01532,.01558,.01583,
150                .01606,.01628,.01648,.01667,
151                .0169,.01709,.01724,.01736,.01745,
152                .01752,.01758,.01762,.01767,
153                .01772,.01782,.01796,.01811,.01828,
154                .01845,.01861,.01877,.01891,
155                .01903,.01912,.01919,.0192,.01916,
156                .01908,.01897,.01886,.01874,
157                .01862,.01854,.01848,.01846,.01847,
158                .01851,.01856,.01864,.01873,
159                .01883,.01895,.01907,.01921,.01933,
160                .01945,.01958,.01972,.01985,
161                .01999,.02013,.02028,.02043,.02058,
162                .02084,.02111,.02139,.02169,
163                .02199,.02231,.02264,.02299,.02335,
164                .02373,.02408,.02444,.02482,
165                .0252,.0256,.02601,.02643,.02685,
166                .02728,.02772,.02812,.02852,
167                .02893,.02935,.02977,.0302,.03064,
168                .03108,.03153,.03198,.03242,
169                .03286,.03332,.03378,.03425,.03472,
170                .03521,.03571,.03622,.03674,
171                .03724,.03776,.03828,.03882,.03936,
172                .0399,.04045,.041,.04156,.04212,
173                .04266,.0432,.04375,.04429,
174                .04484,.04539,.04594,.04649,.04704,
175                .0476,.04814,.04869,.04923,
176                .04978,.05032,.05087,.05141,.05194,
177                .05248,.05301,.05352,.05403,
178                .05454,.05504,.05552,.056,.05647,
179                .05693,.05738,.05781,.05822,
180                .05862,.05901,.05939,.05976,.06011,
181                .06045,.06079,.06111,.06143,
182                .06174,.06204,.06233,.06262,.06289,
183                .06316,.06341,.06365,.06389,
184                .06411,.06432,.06452,.06471,.06489,
185                .06505,.0652,.06534,.06546,
186                .06557,.06567,.06575,.06582,.06587,
187                .06591,.06594,.06595,.06594,
188                .06593,.0659,.06586,.0658,.06573,
189                .06565,.06555,.06544,.06531,
190                .06517,.06502,.06485,.06466,.06445,
191                .06422,.06398,.06371,.06344,
192                .06314,.06283,.06251,.06216,.0618,
193                .0614,.06097,.06053,.06007,
194                .0596,.05912,.05862,.05811,.0576,
195                .05707,.05646,.05584,.0552,
196                .05454,.05384,.05312,.05235,.05154,
197                .05068,.04977,.04856,.04728,
198                .04592,.04451,.04304,.04154,.04,
199                .03844,.03687,.0353,.03165,
200                .02804,.02446,.02091,.01739,.01389,
201                .0104,.00693,.00346,0. };
202        
203        /**
204        *  Fill in phi, eps vectors for 64A series airfoil.
205        *
206        *  @param phi  An existing array with 201 elements to be filled in
207        *              by this method.
208        *  @param eps  An existing array with 201 elements to be filled in
209        *              by this method.
210        **/
211    @Override
212        protected final void phep(double[] phi, double[] eps) {
213                double[] bb = new double[251];
214                double[] cc = new double[251];
215                double[] dd = new double[251];
216                
217                spline(251,philde,epslde,bb,cc,dd);
218                for (int i=0; i < 201; ++i) {
219                        phi[i] = i*Math.PI/200.;
220                        eps[i] = seval(251,phi[i],philde,epslde,bb,cc,dd);
221                }
222        }
223        
224        
225        //      Phi & eps vectors for 64A series airfoil.
226    private static final double[] philds = {
227                0.,.0147,.0294,
228                .0441,.0588,.07349,.08818,.10286,
229                .11753,.1322,.14686,.15019,
230                .15352,.15685,.16019,.16352,.16685,
231                .17018,.17351,.17684,.18017,
232                .18528,.1904,.19551,.20063,.20574,
233                .21086,.21598,.22109,.22621,
234                .23133,.24088,.25044,.26,.26956,
235                .27912,.28869,.29825,.30782,
236                .31739,.32695,.34039,.35384,.36728,
237                .38072,.39416,.40761,.42105,
238                .4345,.44794,.46139,.47194,.48249,
239                .49303,.50358,.51413,.52468,
240                .53523,.54578,.55633,.56688,.57595,
241                .58502,.59409,.60317,.61224,
242                .62131,.63038,.63945,.64852,.65759,
243                .67316,.68874,.70431,.71989,
244                .73546,.75103,.76661,.78218,.79776,
245                .81333,.82695,.84057,.85418,
246                .8678,.88142,.89504,.90866,.92228,
247                .93589,.94951,.96194,.97436,
248                .98679,.99922,1.01164,1.02407,1.0365,
249                1.04892,1.06135,1.07377,1.08546,
250                1.09714,1.10882,1.1205,1.13218,
251                1.14386,1.15554,1.16723,1.17891,
252                1.19059,1.2018,1.21301,1.22422,
253                1.23543,1.24665,1.25786,1.26907,
254                1.28028,1.29149,1.3027,1.31357,
255                1.32444,1.33531,1.34618,1.35705,
256                1.36792,1.37879,1.38966,1.40052,
257                1.41139,1.42204,1.43269,1.44334,
258                1.45398,1.46463,1.47528,1.48592,
259                1.49657,1.50721,1.51785,1.52835,
260                1.53884,1.54933,1.55982,1.5703,
261                1.58079,1.59128,1.60177,1.61225,
262                1.62274,1.63312,1.6435,1.65388,
263                1.66426,1.67464,1.68502,1.6954,
264                1.70578,1.71615,1.72653,1.73693,
265                1.74732,1.75772,1.76812,1.77851,
266                1.78891,1.79931,1.8097,1.82009,
267                1.83049,1.841,1.85151,1.86202,1.87253,
268                1.88304,1.89354,1.90405,1.91456,
269                1.92507,1.93557,1.94631,1.95704,
270                1.96777,1.9785,1.98923,1.99996,
271                2.01069,2.02142,2.03215,2.04288,
272                2.05401,2.06514,2.07627,2.0874,
273                2.09852,2.10965,2.12078,2.13191,
274                2.14304,2.15416,2.16592,2.17767,
275                2.18942,2.20117,2.21293,2.22468,
276                2.23643,2.24819,2.25994,2.27169,
277                2.28447,2.29724,2.31001,2.32278,
278                2.33556,2.34833,2.36111,2.37388,
279                2.38666,2.39943,2.41396,2.42849,
280                2.44302,2.45754,2.47207,2.4866,
281                2.50113,2.51566,2.53019,2.54471,
282                2.5626,2.58049,2.59837,2.61626,
283                2.63415,2.65203,2.66993,2.68782,
284                2.70572,2.72362,2.76535,2.80711,
285                2.84888,2.89067,2.93247,2.97428,
286                3.0161,3.05793,3.09976,3.14159 };
287                
288    private static final double[] psilds = {
289                .15365,.15355,.15324,
290                .15275,.15209,.15129,.15035,
291                .1493,.14816,.14693,.14565,.14535,
292                .14505,.14475,.14444,.14414,
293                .14384,.14353,.14323,.14293,.14263,
294                .14218,.14174,.1413,.14087,
295                .14044,.14003,.13963,.13924,.13886,
296                .13849,.13783,.13722,.13665,
297                .13612,.13562,.13516,.13473,.13432,
298                .13395,.13359,.13313,.13271,
299                .13233,.13199,.13167,.13139,.13113,
300                .1309,.13069,.13051,.13037,
301                .13024,.13013,.13003,.12993,.12985,
302                .12977,.12971,.12966,.12961,
303                .12958,.12955,.12953,.12952,.12951,
304                .1295,.12949,.12949,.12949,
305                .12949,.12948,.12947,.12947,.12946,
306                .12945,.12944,.12943,.12942,
307                .12941,.1294,.12939,.12939,.12938,
308                .12937,.12936,.12934,.12932,
309                .1293,.12927,.12923,.1292,.12915,
310                .1291,.12905,.12899,.12892,
311                .12885,.12878,.12869,.12861,.12852,
312                .12843,.12833,.12822,.12811,
313                .128,.12788,.12775,.12761,.12747,
314                .12733,.12718,.12702,.12685,
315                .12668,.1265,.12631,.12611,.1259,
316                .12569,.12547,.12524,.125,
317                .12475,.12448,.1242,.1239,.12358,
318                .12325,.12289,.12252,.12212,
319                .12171,.12128,.12083,.12036,.11988,
320                .11938,.11887,.11834,.11781,
321                .11727,.11672,.11615,.11557,.11499,
322                .11439,.11378,.11316,.11253,
323                .11189,.11125,.11059,.10993,.10925,
324                .10857,.10788,.10719,.10648,
325                .10577,.10505,.10433,.1036,.10286,
326                .10212,.10137,.10061,.09985,
327                .09908,.09831,.09752,.09672,.09592,
328                .09512,.09431,.09349,.09267,
329                .09184,.09101,.09017,.08931,.08845,
330                .08758,.0867,.08583,.08495,
331                .08406,.08318,.08229,.0814,.08048,
332                .07955,.07863,.0777,.07678,
333                .07585,.07493,.07401,.07309,.07217,
334                .0712,.07023,.06927,.06831,
335                .06735,.06639,.06545,.0645,.06356,
336                .06262,.06161,.0606,.0596,
337                .05861,.05762,.05664,.05567,.0547,
338                .05375,.05279,.05172,.05066,
339                .0496,.04855,.04749,.04644,.04538,
340                .04432,.04324,.04216,.04081,
341                .03945,.03809,.03675,.03543,.03414,
342                .03291,.03173,.03061,.02958,
343                .02751,.02589,.02465,.02374,.02312,
344                .02273,.02252,.02243,.02242,
345                .02243 };
346        
347        /**
348        *  Fill in the psi vector for a 64A series airfoil.
349        *
350        *  @param phi  An array filled in by phep().
351        *  @param psi  An existing array with 201 elements to be filled in
352        *              by this method.
353        **/
354    @Override
355        protected final void phps(double[] phi, double[] psi) {
356                double[] bb = new double[251];
357                double[] cc = new double[251];
358                double[] dd = new double[251];
359                spline(251, philds, psilds, bb, cc, dd);
360                for (int i=0; i < 201; ++i) {
361                        psi[i] = seval(251, phi[i], philds, psilds, bb, cc, dd); 
362                }
363        }
364        
365        /**
366        *  Simple method to test this class.
367        **/
368        public static void main(String[] args) {
369        
370                DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance();
371                nf.setMaximumFractionDigits(5);
372                nf.setMinimumFractionDigits(5);
373                
374                System.out.println("Start NACA64ASeries...");
375                
376                System.out.println("Creating a NACA 64A206 airfoil...");
377                Airfoil af = new NACA64ASeries(0.2, 0.06, 1);
378                
379                System.out.println("Airfoil = " + af.toString());
380                
381                //      Output the upper surface of the airfoil.
382                List<Point2D> upper = af.getUpper();
383                List<Double> ypArr = af.getUpperYp();
384                System.out.println("upper.size() = " + upper.size() + ", ypArr.size() = " + ypArr.size());
385                
386                System.out.println("        X    \t    Y    \t    dy/dx");
387                int length = upper.size();
388                for (int i=0; i < length; ++i) {
389                        Point2D o = upper.get(i);
390                        System.out.println("    " + nf.format(o.getX()) + "\t" + nf.format(o.getY()) +
391                                                                        "\t" + nf.format(ypArr.get(i)));
392                }
393                
394                System.out.println("# ordinates = " + length);
395                System.out.println("Done!");
396        }
397}
398
399