001/*
002*   NACA65ASeries -- An arbitrary NACA 65A 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 65A series
032*      airfoil section such as a NACA 65A020 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 NACA65ASeries extends NACA6ASeries {
060        
061        //-----------------------------------------------------------------------------------
062        
063        /**
064        *  Create a NACA 65A series airfoil with the specified parameters.
065        *
066        *  @param  CLi        Design lift coefficient (e.g.: 65A206 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 NACA65ASeries(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 "65A";
080        }
081        
082        //      Phi & eps vectors for 65A series airfoil.
083    private static final double[] philde = {
084                0.,.01453,.02907,
085                .0436,.05814,.07267,.08721,.10175,
086                .1163,.13084,.14539,.14877,
087                .15214,.15552,.15889,.16227,.16564,
088                .16902,.1724,.17578,.17916,
089                .18436,.18956,.19477,.19997,.20518,
090                .21039,.21559,.2208,.22601,
091                .23122,.24077,.25032,.25987,.26941,
092                .27896,.28851,.29805,.3076,
093                .31714,.32669,.33996,.35322,.36649,
094                .37976,.39302,.40629,.41956,
095                .43283,.4461,.45937,.46976,.48015,
096                .49054,.50093,.51132,.52171,
097                .5321,.54249,.55288,.56327,.57223,
098                .58118,.59014,.59909,.60805,
099                .617,.62596,.63491,.64387,.65282,
100                .66829,.68376,.69923,.7147,
101                .73017,.74564,.7611,.77657,.79204,
102                .8075,.82106,.83461,.84816,
103                .86172,.87527,.88882,.90237,.91593,
104                .92948,.94303,.95538,.96772,
105                .98007,.99242,1.00476,1.01711,1.02945,
106                1.0418,1.05415,1.06649,1.0781,
107                1.08971,1.10132,1.11293,1.12454,
108                1.13615,1.14776,1.15937,1.17098,
109                1.18259,1.19373,1.20486,1.216,1.22713,
110                1.23827,1.2494,1.26054,1.27167,
111                1.28281,1.29394,1.30473,1.31552,
112                1.32631,1.33711,1.3479,1.35869,
113                1.36948,1.38027,1.39106,1.40185,
114                1.41248,1.42312,1.43375,1.44438,
115                1.45501,1.46564,1.47628,1.48691,
116                1.49754,1.50817,1.51872,1.52927,
117                1.53983,1.55038,1.56093,1.57148,
118                1.58203,1.59258,1.60314,1.61369,
119                1.62418,1.63467,1.64516,1.65565,
120                1.66614,1.67663,1.68712,1.69762,
121                1.70811,1.7186,1.72914,1.73967,1.7502,
122                1.76074,1.77127,1.78181,1.79234,
123                1.80288,1.81341,1.82395,1.8346,
124                1.84526,1.85591,1.86657,1.87722,
125                1.88788,1.89853,1.90919,1.91985,
126                1.9305,1.94138,1.95225,1.96313,
127                1.97401,1.98488,1.99576,2.00664,
128                2.01751,2.02839,2.03927,2.04786,
129                2.05645,2.06504,2.07363,2.08222,
130                2.09081,2.0994,2.10799,2.11658,
131                2.12517,2.13979,2.15441,2.16903,
132                2.18365,2.19826,2.21288,2.2275,
133                2.24211,2.25673,2.27134,2.28424,
134                2.29714,2.31003,2.32292,2.33582,
135                2.34871,2.3616,2.37449,2.38739,
136                2.40028,2.4149,2.42952,2.44413,
137                2.45875,2.47336,2.48798,2.50259,
138                2.51719,2.5318,2.5464,2.56435,2.58229,
139                2.60023,2.61816,2.6361,2.65402,
140                2.67195,2.68987,2.70779,2.72571,
141                2.76731,2.80891,2.8505,2.89209,
142                2.93368,2.97526,3.01684,3.05843,
143                3.10001,3.14159 };
144                
145    private static final double[] epslde = {
146                0.,.00137,.00274,
147                .0041,.00545,.00679,.00811,.00941,
148                .0107,.01195,.01318,.01346,
149                .01374,.01401,.01427,.01453,.01477,
150                .015,.01521,.01541,.01559,
151                .01583,.01602,.01618,.0163,.0164,
152                .01648,.01654,.0166,.01665,
153                .01671,.01683,.01698,.01715,.01732,
154                .01749,.01766,.01782,.01796,
155                .01807,.01814,.01819,.01816,.01807,
156                .01793,.01775,.01755,.01732,
157                .01708,.01684,.01661,.01644,.01628,
158                .01614,.01601,.01589,.01578,
159                .01569,.01561,.01554,.01549,.01546,
160                .01543,.01541,.01541,.01541,
161                .01542,.01544,.01547,.01551,.01555,
162                .01565,.01577,.0159,.01607,
163                .01625,.01645,.01668,.01693,.0172,
164                .0175,.01778,.01807,.01837,
165                .01869,.01902,.01936,.0197,.02005,
166                .0204,.02076,.02108,.02141,
167                .02174,.02207,.0224,.02274,.02309,
168                .02344,.02381,.02418,.02454,
169                .02491,.02528,.02567,.02607,.02647,
170                .02689,.02731,.02775,.02819,
171                .02863,.02907,.02952,.02998,.03044,
172                .03091,.03138,.03185,.03232,
173                .0328,.03326,.03371,.03417,.03463,
174                .0351,.03557,.03604,.03652,
175                .03701,.0375,.038,.03851,.03902,
176                .03954,.04007,.0406,.04114,
177                .04169,.04224,.04279,.04335,.04391,
178                .04447,.04502,.04558,.04614,
179                .04669,.04723,.04777,.0483,.04882,
180                .04933,.04984,.05033,.05082,
181                .0513,.05177,.05224,.0527,.05316,
182                .05361,.05406,.05449,.05493,
183                .05535,.05577,.05618,.05657,.05696,
184                .05734,.05771,.05807,.05842,
185                .05876,.05908,.05939,.05969,.05997,
186                .06023,.06049,.06073,.06095,
187                .06116,.06135,.06153,.0617,.06185,
188                .06199,.06212,.06224,.06232,
189                .0624,.06247,.06254,.06259,.06264,
190                .06268,.06272,.06274,.06276,
191                .06277,.06275,.06271,.06264,.06255,
192                .06242,.06226,.06207,.06185,
193                .06159,.06134,.06106,.06075,.06042,
194                .06007,.0597,.05932,.05891,
195                .0585,.05807,.05756,.05704,.0565,
196                .05592,.05531,.05466,.05397,
197                .05323,.05244,.05159,.05046,.04925,
198                .04795,.04659,.04517,.0437,
199                .0422,.04065,.03909,.03751,.03383,
200                .03013,.0264,.02266,.01891,
201                .01514,.01136,.00758,.00379,0. };
202        
203        /**
204        *  Fill in phi, eps vectors for 65A 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 65A series airfoil.
226    private static final double[] philds = {
227                0.,.01455,.0291,
228                .04364,.05819,.07273,.08727,.10181,
229                .11634,.13087,.14539,.14877,
230                .15214,.15552,.1589,.16227,.16565,
231                .16903,.1724,.17578,.17916,
232                .18436,.18956,.19477,.19997,.20518,
233                .21039,.2156,.2208,.22601,
234                .23122,.24077,.25032,.25986,.26941,
235                .27896,.2885,.29805,.3076,
236                .31714,.32669,.33995,.35322,.36648,
237                .37974,.39301,.40628,.41955,
238                .43282,.44609,.45937,.46975,.48014,
239                .49053,.50092,.51131,.5217,
240                .5321,.54249,.55288,.56327,.57223,
241                .58118,.59014,.59909,.60805,
242                .617,.62596,.63491,.64387,.65282,
243                .66829,.68376,.69923,.7147,
244                .73016,.74563,.7611,.77657,.79204,
245                .8075,.82106,.83461,.84816,
246                .86171,.87527,.88882,.90237,.91592,
247                .92948,.94303,.95538,.96772,
248                .98007,.99241,1.00476,1.01711,1.02945,
249                1.0418,1.05414,1.06649,1.0781,
250                1.08971,1.10132,1.11293,1.12454,
251                1.13615,1.14776,1.15937,1.17098,
252                1.18259,1.19372,1.20486,1.21599,
253                1.22713,1.23827,1.2494,1.26054,
254                1.27167,1.28281,1.29394,1.30473,
255                1.31552,1.32631,1.3371,1.3479,1.35869,
256                1.36948,1.38027,1.39106,1.40185,
257                1.41248,1.42311,1.43375,1.44438,
258                1.45501,1.46564,1.47628,1.48691,
259                1.49754,1.50817,1.51872,1.52928,
260                1.53983,1.55038,1.56094,1.57149,
261                1.58204,1.59259,1.60314,1.61369,
262                1.62418,1.63468,1.64517,1.65566,
263                1.66616,1.67665,1.68714,1.69763,
264                1.70811,1.7186,1.72914,1.73968,
265                1.75021,1.76075,1.77128,1.78182,
266                1.79235,1.80289,1.81342,1.82395,
267                1.83461,1.84527,1.85592,1.86658,
268                1.87723,1.88789,1.89854,1.9092,
269                1.91985,1.9305,1.94138,1.95226,
270                1.96314,1.97402,1.98489,1.99577,
271                2.00664,2.01752,2.02839,2.03927,
272                2.05056,2.06185,2.07314,2.08444,
273                2.09573,2.10702,2.11831,2.1296,
274                2.14089,2.15217,2.16409,2.17601,
275                2.18793,2.19985,2.21176,2.22368,
276                2.2356,2.24751,2.25943,2.27134,
277                2.28424,2.29713,2.31002,2.32292,
278                2.33581,2.3487,2.36159,2.37449,
279                2.38738,2.40028,2.41489,2.4295,
280                2.44411,2.45872,2.47334,2.48795,
281                2.50256,2.51717,2.53178,2.5464,
282                2.56432,2.58225,2.60018,2.6181,
283                2.63603,2.65396,2.67189,2.68983,
284                2.70777,2.72571,2.76723,2.80877,
285                2.85033,2.8919,2.9335,2.9751,3.01671,
286                3.05834,3.09996,3.14159 };
287                
288    private static final double[] psilds = {
289                .14761,.14748,.14709,
290                .14649,.1457,.14476,.14369,
291                .14253,.14131,.14007,.13882,.13854,
292                .13826,.13798,.1377,.13743,
293                .13716,.1369,.13665,.1364,.13616,
294                .13581,.13547,.13515,.13484,
295                .13455,.13426,.13398,.13371,.13345,
296                .13318,.1327,.13221,.13172,
297                .13124,.13075,.13026,.12976,.12926,
298                .12876,.12825,.12753,.12681,
299                .1261,.12541,.12475,.12415,.12359,
300                .12311,.1227,.12239,.12221,
301                .12209,.12202,.12199,.12199,.12203,
302                .12209,.12216,.12224,.12233,
303                .1224,.12246,.12253,.12259,.12265,
304                .12271,.12277,.12283,.12289,
305                .12295,.12305,.12316,.12326,.12337,
306                .12348,.12359,.1237,.12381,
307                .12391,.12401,.1241,.12418,.12426,
308                .12434,.12441,.12448,.12455,
309                .12461,.12467,.12472,.12477,.12482,
310                .12486,.12489,.12492,.12495,
311                .12498,.125,.12501,.12502,.12503,
312                .12503,.12502,.12501,.125,
313                .12498,.12495,.12492,.12489,.12485,
314                .12481,.12476,.12471,.12465,
315                .12459,.12452,.12445,.12437,.12428,
316                .12419,.12409,.12398,.12387,
317                .12375,.12362,.12349,.12334,.12319,
318                .12303,.12286,.12268,.12249,
319                .12229,.12208,.12186,.12163,.12138,
320                .12113,.12085,.12057,.12027,
321                .11996,.11964,.1193,.11894,.11857,
322                .11818,.11778,.11736,.11693,
323                .11648,.11602,.11554,.11504,.11453,
324                .114,.11346,.11291,.11234,
325                .11175,.11115,.11054,.10991,.10928,
326                .10863,.10797,.1073,.10662,
327                .10594,.10524,.10453,.10381,.10308,
328                .10235,.10161,.10086,.1001,
329                .09933,.09856,.09778,.09698,.09617,
330                .09535,.09452,.09369,.09285,
331                .09201,.09116,.0903,.08943,.08853,
332                .08763,.08671,.08579,.08487,
333                .08394,.08301,.08207,.08113,.08019,
334                .07919,.07818,.07717,.07616,
335                .07515,.07413,.07311,.07209,.07106,
336                .07004,.06892,.06781,.0667,
337                .06559,.06448,.06338,.06229,.06119,
338                .06011,.05904,.05783,.05664,
339                .05545,.05427,.05309,.05191,.05072,
340                .04953,.04834,.04713,.04564,
341                .04413,.04263,.04114,.03967,.03823,
342                .03683,.03549,.03421,.033,
343                .03052,.02844,.02675,.02539,.02434,
344                .02355,.02301,.02266,.02248,
345                .02242 };
346        
347        /**
348        *  Fill in the psi vector for a 65A 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 NACA65ASeries...");
375                
376                System.out.println("Creating a NACA 65A206 airfoil...");
377                Airfoil af = new NACA65ASeries(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