001/*
002*   NACA67Series -- An arbitrary NACA 67 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 67 series
032*      airfoil section such as a NACA 67-020 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 NACA67Series extends NACA6Series {
060        
061        //-----------------------------------------------------------------------------------
062        
063        /**
064        *  Create a NACA 67 series airfoil with the specified parameters.
065        *
066        *  @param  CLi        Design lift coefficient (e.g.: 67-206 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 NACA67Series(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 "67";
080        }
081        
082        //      Phi & eps vectors for 67 series airfoil.
083    private static final double[] philde = {
084                0.,.01495,.0299,
085                .04485,.0598,.07476,.08971,.10468,
086                .11964,.13461,.14959,.1528,
087                .15601,.15922,.16243,.16565,.16886,
088                .17207,.17529,.1785,.18172,
089                .18687,.19201,.19716,.20231,.20747,
090                .21262,.21777,.22293,.22808,
091                .23323,.24276,.25229,.26182,.27135,
092                .28088,.29041,.29994,.30947,
093                .319,.32853,.3418,.35507,.36834,
094                .38162,.39489,.40817,.42144,
095                .43472,.44799,.46127,.47164,.48201,
096                .49238,.50274,.51311,.52348,
097                .53385,.54422,.55458,.56495,.57385,
098                .58275,.59165,.60055,.60945,
099                .61835,.62725,.63615,.64505,.65395,
100                .66928,.68461,.69994,.71527,
101                .7306,.74593,.76126,.77658,.79191,
102                .80724,.82061,.83397,.84734,
103                .8607,.87407,.88743,.9008,.91416,
104                .92753,.94089,.95309,.9653,
105                .9775,.9897,1.0019,1.0141,1.0263,
106                1.0385,1.0507,1.06289,1.07435,
107                1.0858,1.09726,1.10871,1.12017,
108                1.13162,1.14308,1.15453,1.16599,
109                1.17744,1.1884,1.19936,1.21033,
110                1.22129,1.23225,1.24321,1.25417,
111                1.26513,1.27609,1.28706,1.2977,
112                1.30835,1.319,1.32965,1.3403,1.35094,
113                1.36159,1.37224,1.38289,1.39353,
114                1.40401,1.4145,1.42498,1.43546,
115                1.44594,1.45642,1.4669,1.47738,
116                1.48786,1.49834,1.50878,1.51921,
117                1.52965,1.54008,1.55052,1.56095,
118                1.57139,1.58182,1.59226,1.60269,
119                1.61319,1.62369,1.6342,1.6447,1.6552,
120                1.6657,1.6762,1.6867,1.6972,
121                1.7077,1.71841,1.72913,1.73984,
122                1.75056,1.76127,1.77199,1.7827,
123                1.79341,1.80413,1.81484,1.82589,
124                1.83694,1.84799,1.85904,1.87009,
125                1.88113,1.89218,1.90323,1.91427,
126                1.92531,1.93688,1.94844,1.95999,
127                1.97155,1.98311,1.99467,2.00622,
128                2.01778,2.02933,2.04089,2.05305,
129                2.06522,2.07739,2.08956,2.10172,
130                2.11389,2.12606,2.13824,2.15041,
131                2.16259,2.17534,2.1881,2.20085,
132                2.21361,2.22637,2.23914,2.2519,
133                2.26467,2.27744,2.29021,2.30376,
134                2.31733,2.33089,2.34445,2.35802,
135                2.37159,2.38516,2.39874,2.41232,
136                2.4259,2.44078,2.45566,2.47054,
137                2.48542,2.50029,2.51515,2.53,2.54483,
138                2.55965,2.57444,2.59147,2.60847,
139                2.62544,2.64239,2.65933,2.67625,
140                2.69317,2.71007,2.72698,2.74389,
141                2.78356,2.82326,2.86298,2.90274,
142                2.94251,2.98231,3.02211,3.06193,
143                3.10176,3.14159 };
144                
145    private static final double[] epslde = {
146                0.,.00161,.00322,
147                .00482,.0064,.00796,.00949,.011,
148                .01246,.01388,.01525,.01554,
149                .01582,.0161,.01637,.01664,.0169,
150                .01714,.01738,.01761,.01782,
151                .01813,.01841,.01865,.01888,.01908,
152                .01927,.01945,.01962,.01979,
153                .01996,.02029,.02063,.02097,.02131,
154                .02164,.02195,.02224,.02249,
155                .02269,.02285,.02298,.02301,.02296,
156                .02284,.02267,.02245,.0222,
157                .02194,.02168,.02143,.02125,.02108,
158                .02093,.02079,.02067,.02055,
159                .02045,.02035,.02026,.02017,.0201,
160                .02004,.01998,.01992,.01987,
161                .01983,.01979,.01975,.01972,.0197,
162                .01967,.01966,.01967,.01969,
163                .01973,.01978,.01985,.01992,.02001,
164                .0201,.02019,.02029,.02039,
165                .02051,.02062,.02075,.02088,.02102,
166                .02117,.02133,.02148,.02164,
167                .0218,.02198,.02216,.02234,.02254,
168                .02274,.02295,.02316,.02337,
169                .02359,.02381,.02404,.02427,.02451,
170                .02476,.02501,.02527,.02553,
171                .02579,.02606,.02632,.0266,.02688,
172                .02716,.02745,.02775,.02805,
173                .02836,.02866,.02897,.02928,.0296,
174                .02992,.03025,.03059,.03093,
175                .03128,.03163,.03199,.03235,.03271,
176                .03309,.03346,.03385,.03424,
177                .03464,.03505,.03546,.03588,.0363,
178                .03673,.03717,.03762,.03807,
179                .03852,.03899,.03945,.03993,.04041,
180                .0409,.04139,.0419,.04241,
181                .04293,.04346,.044,.04455,.04511,
182                .0457,.04629,.0469,.04752,
183                .04815,.0488,.04945,.05011,.05078,
184                .05145,.05216,.05288,.0536,
185                .05434,.05509,.05584,.05661,.05739,
186                .05818,.05899,.05985,.06072,
187                .0616,.0625,.0634,.06432,.06524,
188                .06617,.06711,.06805,.06905,
189                .07005,.07105,.07204,.07302,.07398,
190                .07493,.07586,.07677,.07765,
191                .07854,.07939,.0802,.08097,.08171,
192                .0824,.08305,.08365,.08421,
193                .08471,.0852,.08563,.08601,.08634,
194                .08662,.08685,.08703,.08716,
195                .08726,.08731,.08731,.08725,.0871,
196                .08684,.08646,.08594,.08525,
197                .08439,.08333,.08205,.08029,.07826,
198                .07599,.07351,.07088,.06811,
199                .06526,.06235,.05943,.05653,.04995,
200                .04366,.03763,.03183,.02623,
201                .02079,.01548,.01026,.00511,0. };
202        
203        /**
204        *  Fill in phi, eps vectors for 67 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 67 series airfoil.
226    private static final double[] philds = {
227                0.,.01499,.02998,
228                .04497,.05995,.07492,.08988,.10483,
229                .11976,.13468,.14959,.1528,
230                .15601,.15923,.16244,.16565,.16886,
231                .17208,.17529,.1785,.18172,
232                .18686,.19201,.19716,.20231,.20746,
233                .21262,.21777,.22293,.22808,
234                .23323,.24277,.25229,.26182,.27135,
235                .28088,.29041,.29993,.30946,
236                .31899,.32853,.34178,.35505,.36832,
237                .38159,.39486,.40814,.42142,
238                .4347,.44798,.46127,.47164,.482,
239                .49237,.50274,.51311,.52348,
240                .53384,.54421,.55458,.56495,.57385,
241                .58275,.59165,.60055,.60945,
242                .61835,.62725,.63615,.64505,.65395,
243                .66928,.68461,.69994,.71527,
244                .7306,.74593,.76125,.77658,.79191,
245                .80724,.82061,.83397,.84734,
246                .8607,.87407,.88743,.9008,.91416,
247                .92753,.94089,.95309,.96529,
248                .97749,.98969,1.00189,1.01409,1.02629,
249                1.03849,1.05069,1.06289,1.07435,
250                1.0858,1.09726,1.10871,1.12017,
251                1.13162,1.14308,1.15453,1.16599,
252                1.17744,1.1884,1.19936,1.21032,
253                1.22129,1.23225,1.24321,1.25417,
254                1.26513,1.27609,1.28706,1.2977,
255                1.30835,1.319,1.32965,1.34029,1.35094,
256                1.36159,1.37224,1.38289,1.39353,
257                1.40401,1.41449,1.42498,1.43546,
258                1.44594,1.45642,1.4669,1.47738,
259                1.48786,1.49834,1.50878,1.51921,
260                1.52965,1.54008,1.55052,1.56095,
261                1.57139,1.58182,1.59226,1.60269,
262                1.61319,1.62369,1.63419,1.64469,
263                1.65519,1.66569,1.67619,1.68669,
264                1.69719,1.7077,1.71841,1.72912,
265                1.73984,1.75055,1.76127,1.77198,
266                1.7827,1.79341,1.80412,1.81484,
267                1.82589,1.83694,1.84798,1.85903,
268                1.87008,1.88113,1.89218,1.90322,
269                1.91427,1.92531,1.93688,1.94844,1.96,
270                1.97156,1.98312,1.99468,2.00623,
271                2.01779,2.02934,2.04089,2.05308,
272                2.06526,2.07745,2.08962,2.1018,
273                2.11397,2.12613,2.13829,2.15044,
274                2.16259,2.17538,2.18816,2.20093,
275                2.2137,2.22646,2.23922,2.25197,
276                2.26472,2.27746,2.29021,2.30379,
277                2.31737,2.33095,2.34453,2.3581,
278                2.37167,2.38523,2.39879,2.41235,
279                2.4259,2.44078,2.45566,2.47053,
280                2.48539,2.50025,2.5151,2.52995,
281                2.54478,2.55962,2.57444,2.59138,
282                2.60831,2.62523,2.64216,2.65909,
283                2.67603,2.69297,2.70993,2.7269,
284                2.74389,2.78335,2.8229,2.86255,
285                2.90227,2.94205,2.98189,3.02178,
286                3.0617,3.10164,3.14159 };
287                
288    private static final double[] psilds = {
289                .18028,.18026,.18018,
290                .18002,.17976,.17938,.17885,
291                .17815,.17725,.17614,.1748,.17447,
292                .17414,.1738,.17345,.1731,
293                .17276,.17241,.17207,.17174,.17141,
294                .17092,.17045,.17001,.16959,
295                .16918,.16879,.1684,.16802,.16764,
296                .16726,.16653,.16578,.16502,
297                .16426,.16349,.16272,.16196,.16121,
298                .16048,.15978,.15885,.15798,
299                .15717,.15641,.15572,.15507,.15449,
300                .15396,.15348,.15306,.15277,
301                .15251,.15228,.15207,.15188,.15171,
302                .15156,.15142,.15129,.15116,
303                .15105,.15095,.15085,.15075,.15066,
304                .15057,.15049,.15041,.15034,
305                .15027,.15016,.15007,.15,.14994,
306                .1499,.14986,.14984,.14982,
307                .14982,.14982,.14982,.14983,.14985,
308                .14986,.14988,.14991,.14993,
309                .14996,.14999,.15002,.15005,.15008,
310                .15011,.15014,.15018,.15021,
311                .15024,.15028,.15031,.15035,.15038,
312                .15042,.15045,.15048,.15052,
313                .15056,.15059,.15063,.15067,.1507,
314                .15074,.15077,.15081,.15084,
315                .15088,.15091,.15094,.15096,.15099,
316                .15101,.15103,.15104,.15106,
317                .15107,.15108,.15108,.15109,.15109,
318                .1511,.1511,.1511,.1511,.1511,
319                .15109,.15109,.15108,.15107,
320                .15106,.15104,.15102,.151,.15097,
321                .15094,.1509,.15086,.15081,
322                .15076,.15071,.15065,.15059,.15053,
323                .15046,.15038,.1503,.15022,
324                .15013,.15003,.14993,.14982,.1497,
325                .14957,.14943,.14929,.14914,
326                .14897,.1488,.14862,.14842,.14822,
327                .148,.14776,.14752,.14725,
328                .14698,.14669,.14639,.14607,.14574,
329                .14539,.14502,.14462,.1442,
330                .14376,.14329,.14279,.14227,.14171,
331                .14111,.14048,.13981,.13905,
332                .13825,.13739,.13648,.13551,.13449,
333                .13341,.13227,.13106,.1298,
334                .12839,.12692,.12538,.1238,.12216,
335                .12048,.11876,.117,.11523,
336                .11343,.1115,.10955,.10758,.10559,
337                .10358,.10154,.09948,.09738,
338                .09526,.0931,.0907,.08825,.08576,
339                .08324,.08068,.07808,.07545,
340                .07278,.07008,.06735,.0642,.06102,
341                .05782,.05463,.05145,.0483,
342                .04518,.04212,.03912,.0362,.02979,
343                .02391,.01859,.01386,.00977,
344                .00635,.00362,.00163,4.1e-4,0. };
345        
346        /**
347        *  Fill in the psi vector for a 67 series airfoil.
348        *
349        *  @param phi  An array filled in by phep().
350        *  @param psi  An existing array with 201 elements to be filled in
351        *              by this method.
352        **/
353    @Override
354        protected final void phps(double[] phi, double[] psi) {
355                double[] bb = new double[251];
356                double[] cc = new double[251];
357                double[] dd = new double[251];
358                spline(251, philds, psilds, bb, cc, dd);
359                for (int i=0; i < 201; ++i) {
360                        psi[i] = seval(251, phi[i], philds, psilds, bb, cc, dd); 
361                }
362        }
363        
364        /**
365        *  Simple method to test this class.
366        **/
367        public static void main(String[] args) {
368        
369                DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance();
370                nf.setMaximumFractionDigits(5);
371                nf.setMinimumFractionDigits(5);
372                
373                System.out.println("Start NACA67Series...");
374                
375                System.out.println("Creating a NACA 67-212 airfoil...");
376                Airfoil af = new NACA67Series(0.2, 0.12, 1);
377                
378                System.out.println("Airfoil = " + af.toString());
379                
380                //      Output the upper surface of the airfoil.
381                List<Point2D> upper = af.getUpper();
382                List<Double> ypArr = af.getUpperYp();
383                System.out.println("upper.size() = " + upper.size() + ", ypArr.size() = " + ypArr.size());
384                
385                System.out.println("        X    \t    Y    \t    dy/dx");
386                int length = upper.size();
387                for (int i=0; i < length; ++i) {
388                        Point2D o = upper.get(i);
389                        System.out.println("    " + nf.format(o.getX()) + "\t" + nf.format(o.getY()) +
390                                                                        "\t" + nf.format(ypArr.get(i)));
391                }
392                
393                System.out.println("# ordinates = " + length);
394                System.out.println("Done!");
395        }
396}
397
398