001/*
002*   NACA67Series -- An arbitrary NACA 67 series airfoil.
003*
004*   Copyright (C) 2010-2025, by Joseph A. Huwaldt. All rights reserved.
005*   
006*   This library is free software; you can redistribute it and/or
007*   modify it under the terms of the GNU Lesser General Public
008*   License as published by the Free Software Foundation; either
009*   version 2.1 of the License, or (at your option) any later version.
010*   
011*   This library is distributed in the hope that it will be useful,
012*   but WITHOUT ANY WARRANTY; without even the implied warranty of
013*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014*   Lesser General Public License for more details.
015*
016*   You should have received a copy of the GNU Lesser General Public License
017*   along with this program; if not, write to the Free Software
018*   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019*   Or visit:  http://www.gnu.org/licenses/lgpl.html
020*/
021package jahuwaldt.aero.airfoils;
022
023import java.util.List;
024import java.awt.geom.Point2D;
025import java.text.DecimalFormat;
026import java.text.NumberFormat;
027
028
029/**
030*  <p> This class represents an arbitrary NACA 67 series
031*      airfoil section such as a NACA 67-020 airfoil.
032*  </p>
033*
034*  <p> Ported from FORTRAN "NACA6.FOR" to Java by:
035*                Joseph A. Huwaldt, June 4, 2010     </p>
036*
037*  <p> Original FORTRAN "NACA4" code had the following note:  </p>
038*
039*  <pre>
040*         AUTHORS - Charles L.Ladson and Cuyler W. Brooks, NASA Langley
041*                   Liam Hardy, NASA Ames
042*                   Ralph Carmichael, Public Domain Aeronautical Software
043*         Last FORTRAN version:  23Nov96  2.0   RLC
044*
045*         NOTES - This program has also been known as LADSON and SIXSERIES and
046*                 as SIXSERIE on systems with a 8-letter name limit.
047*         REFERENCES-  NASA Technical Memorandum TM X-3069 (September, 1974),
048*                      by Charles L. Ladson and Cuyler W. Brooks, Jr., NASA Langley Research Center.
049*
050*                      "Theory of Wing Sections", by Ira Abbott and Albert Von Doenhoff.
051*  </pre>
052*
053*  <p>  Modified by:  Joseph A. Huwaldt  </p>
054*
055*  @author  Joseph A. Huwaldt   Date:  June 6, 2010
056*  @version February 23, 2025
057*/
058public class NACA67Series extends NACA6Series {
059        
060        //-----------------------------------------------------------------------------------
061        
062        /**
063        *  Create a NACA 67 series airfoil with the specified parameters.
064        *
065        *  @param  CLi        Design lift coefficient (e.g.: 67-206 has CLi = 0.2).
066        *  @param  thickness  The thickness to chord ratio (e.g.: 0.20 == 20% t/c).
067        *  @param  length     The chord length.
068        */
069        public NACA67Series(double CLi, double thickness, double length) {
070                super(CLi, thickness, length);
071        }
072        
073        /**
074        *  Returns a String that represents the profile type of this airfoil.
075        */
076    @Override
077        public String getProfile() {
078                return "67";
079        }
080        
081        //      Phi & eps vectors for 67 series airfoil.
082    private static final double[] philde = {
083                0.,.01495,.0299,
084                .04485,.0598,.07476,.08971,.10468,
085                .11964,.13461,.14959,.1528,
086                .15601,.15922,.16243,.16565,.16886,
087                .17207,.17529,.1785,.18172,
088                .18687,.19201,.19716,.20231,.20747,
089                .21262,.21777,.22293,.22808,
090                .23323,.24276,.25229,.26182,.27135,
091                .28088,.29041,.29994,.30947,
092                .319,.32853,.3418,.35507,.36834,
093                .38162,.39489,.40817,.42144,
094                .43472,.44799,.46127,.47164,.48201,
095                .49238,.50274,.51311,.52348,
096                .53385,.54422,.55458,.56495,.57385,
097                .58275,.59165,.60055,.60945,
098                .61835,.62725,.63615,.64505,.65395,
099                .66928,.68461,.69994,.71527,
100                .7306,.74593,.76126,.77658,.79191,
101                .80724,.82061,.83397,.84734,
102                .8607,.87407,.88743,.9008,.91416,
103                .92753,.94089,.95309,.9653,
104                .9775,.9897,1.0019,1.0141,1.0263,
105                1.0385,1.0507,1.06289,1.07435,
106                1.0858,1.09726,1.10871,1.12017,
107                1.13162,1.14308,1.15453,1.16599,
108                1.17744,1.1884,1.19936,1.21033,
109                1.22129,1.23225,1.24321,1.25417,
110                1.26513,1.27609,1.28706,1.2977,
111                1.30835,1.319,1.32965,1.3403,1.35094,
112                1.36159,1.37224,1.38289,1.39353,
113                1.40401,1.4145,1.42498,1.43546,
114                1.44594,1.45642,1.4669,1.47738,
115                1.48786,1.49834,1.50878,1.51921,
116                1.52965,1.54008,1.55052,1.56095,
117                1.57139,1.58182,1.59226,1.60269,
118                1.61319,1.62369,1.6342,1.6447,1.6552,
119                1.6657,1.6762,1.6867,1.6972,
120                1.7077,1.71841,1.72913,1.73984,
121                1.75056,1.76127,1.77199,1.7827,
122                1.79341,1.80413,1.81484,1.82589,
123                1.83694,1.84799,1.85904,1.87009,
124                1.88113,1.89218,1.90323,1.91427,
125                1.92531,1.93688,1.94844,1.95999,
126                1.97155,1.98311,1.99467,2.00622,
127                2.01778,2.02933,2.04089,2.05305,
128                2.06522,2.07739,2.08956,2.10172,
129                2.11389,2.12606,2.13824,2.15041,
130                2.16259,2.17534,2.1881,2.20085,
131                2.21361,2.22637,2.23914,2.2519,
132                2.26467,2.27744,2.29021,2.30376,
133                2.31733,2.33089,2.34445,2.35802,
134                2.37159,2.38516,2.39874,2.41232,
135                2.4259,2.44078,2.45566,2.47054,
136                2.48542,2.50029,2.51515,2.53,2.54483,
137                2.55965,2.57444,2.59147,2.60847,
138                2.62544,2.64239,2.65933,2.67625,
139                2.69317,2.71007,2.72698,2.74389,
140                2.78356,2.82326,2.86298,2.90274,
141                2.94251,2.98231,3.02211,3.06193,
142                3.10176,3.14159 };
143                
144    private static final double[] epslde = {
145                0.,.00161,.00322,
146                .00482,.0064,.00796,.00949,.011,
147                .01246,.01388,.01525,.01554,
148                .01582,.0161,.01637,.01664,.0169,
149                .01714,.01738,.01761,.01782,
150                .01813,.01841,.01865,.01888,.01908,
151                .01927,.01945,.01962,.01979,
152                .01996,.02029,.02063,.02097,.02131,
153                .02164,.02195,.02224,.02249,
154                .02269,.02285,.02298,.02301,.02296,
155                .02284,.02267,.02245,.0222,
156                .02194,.02168,.02143,.02125,.02108,
157                .02093,.02079,.02067,.02055,
158                .02045,.02035,.02026,.02017,.0201,
159                .02004,.01998,.01992,.01987,
160                .01983,.01979,.01975,.01972,.0197,
161                .01967,.01966,.01967,.01969,
162                .01973,.01978,.01985,.01992,.02001,
163                .0201,.02019,.02029,.02039,
164                .02051,.02062,.02075,.02088,.02102,
165                .02117,.02133,.02148,.02164,
166                .0218,.02198,.02216,.02234,.02254,
167                .02274,.02295,.02316,.02337,
168                .02359,.02381,.02404,.02427,.02451,
169                .02476,.02501,.02527,.02553,
170                .02579,.02606,.02632,.0266,.02688,
171                .02716,.02745,.02775,.02805,
172                .02836,.02866,.02897,.02928,.0296,
173                .02992,.03025,.03059,.03093,
174                .03128,.03163,.03199,.03235,.03271,
175                .03309,.03346,.03385,.03424,
176                .03464,.03505,.03546,.03588,.0363,
177                .03673,.03717,.03762,.03807,
178                .03852,.03899,.03945,.03993,.04041,
179                .0409,.04139,.0419,.04241,
180                .04293,.04346,.044,.04455,.04511,
181                .0457,.04629,.0469,.04752,
182                .04815,.0488,.04945,.05011,.05078,
183                .05145,.05216,.05288,.0536,
184                .05434,.05509,.05584,.05661,.05739,
185                .05818,.05899,.05985,.06072,
186                .0616,.0625,.0634,.06432,.06524,
187                .06617,.06711,.06805,.06905,
188                .07005,.07105,.07204,.07302,.07398,
189                .07493,.07586,.07677,.07765,
190                .07854,.07939,.0802,.08097,.08171,
191                .0824,.08305,.08365,.08421,
192                .08471,.0852,.08563,.08601,.08634,
193                .08662,.08685,.08703,.08716,
194                .08726,.08731,.08731,.08725,.0871,
195                .08684,.08646,.08594,.08525,
196                .08439,.08333,.08205,.08029,.07826,
197                .07599,.07351,.07088,.06811,
198                .06526,.06235,.05943,.05653,.04995,
199                .04366,.03763,.03183,.02623,
200                .02079,.01548,.01026,.00511,0. };
201        
202        /**
203        *  Fill in phi, eps vectors for 67 series airfoil.
204        *
205        *  @param phi  An existing array with 201 elements to be filled in
206        *              by this method.
207        *  @param eps  An existing array with 201 elements to be filled in
208        *              by this method.
209        */
210    @Override
211        protected final void phep(double[] phi, double[] eps) {
212                double[] bb = new double[251];
213                double[] cc = new double[251];
214                double[] dd = new double[251];
215                
216                spline(251,philde,epslde,bb,cc,dd);
217                for (int i=0; i < 201; ++i) {
218                        phi[i] = i*Math.PI/200.;
219                        eps[i] = seval(251,phi[i],philde,epslde,bb,cc,dd);
220                }
221        }
222        
223        
224        //      Phi & eps vectors for 67 series airfoil.
225    private static final double[] philds = {
226                0.,.01499,.02998,
227                .04497,.05995,.07492,.08988,.10483,
228                .11976,.13468,.14959,.1528,
229                .15601,.15923,.16244,.16565,.16886,
230                .17208,.17529,.1785,.18172,
231                .18686,.19201,.19716,.20231,.20746,
232                .21262,.21777,.22293,.22808,
233                .23323,.24277,.25229,.26182,.27135,
234                .28088,.29041,.29993,.30946,
235                .31899,.32853,.34178,.35505,.36832,
236                .38159,.39486,.40814,.42142,
237                .4347,.44798,.46127,.47164,.482,
238                .49237,.50274,.51311,.52348,
239                .53384,.54421,.55458,.56495,.57385,
240                .58275,.59165,.60055,.60945,
241                .61835,.62725,.63615,.64505,.65395,
242                .66928,.68461,.69994,.71527,
243                .7306,.74593,.76125,.77658,.79191,
244                .80724,.82061,.83397,.84734,
245                .8607,.87407,.88743,.9008,.91416,
246                .92753,.94089,.95309,.96529,
247                .97749,.98969,1.00189,1.01409,1.02629,
248                1.03849,1.05069,1.06289,1.07435,
249                1.0858,1.09726,1.10871,1.12017,
250                1.13162,1.14308,1.15453,1.16599,
251                1.17744,1.1884,1.19936,1.21032,
252                1.22129,1.23225,1.24321,1.25417,
253                1.26513,1.27609,1.28706,1.2977,
254                1.30835,1.319,1.32965,1.34029,1.35094,
255                1.36159,1.37224,1.38289,1.39353,
256                1.40401,1.41449,1.42498,1.43546,
257                1.44594,1.45642,1.4669,1.47738,
258                1.48786,1.49834,1.50878,1.51921,
259                1.52965,1.54008,1.55052,1.56095,
260                1.57139,1.58182,1.59226,1.60269,
261                1.61319,1.62369,1.63419,1.64469,
262                1.65519,1.66569,1.67619,1.68669,
263                1.69719,1.7077,1.71841,1.72912,
264                1.73984,1.75055,1.76127,1.77198,
265                1.7827,1.79341,1.80412,1.81484,
266                1.82589,1.83694,1.84798,1.85903,
267                1.87008,1.88113,1.89218,1.90322,
268                1.91427,1.92531,1.93688,1.94844,1.96,
269                1.97156,1.98312,1.99468,2.00623,
270                2.01779,2.02934,2.04089,2.05308,
271                2.06526,2.07745,2.08962,2.1018,
272                2.11397,2.12613,2.13829,2.15044,
273                2.16259,2.17538,2.18816,2.20093,
274                2.2137,2.22646,2.23922,2.25197,
275                2.26472,2.27746,2.29021,2.30379,
276                2.31737,2.33095,2.34453,2.3581,
277                2.37167,2.38523,2.39879,2.41235,
278                2.4259,2.44078,2.45566,2.47053,
279                2.48539,2.50025,2.5151,2.52995,
280                2.54478,2.55962,2.57444,2.59138,
281                2.60831,2.62523,2.64216,2.65909,
282                2.67603,2.69297,2.70993,2.7269,
283                2.74389,2.78335,2.8229,2.86255,
284                2.90227,2.94205,2.98189,3.02178,
285                3.0617,3.10164,3.14159 };
286                
287    private static final double[] psilds = {
288                .18028,.18026,.18018,
289                .18002,.17976,.17938,.17885,
290                .17815,.17725,.17614,.1748,.17447,
291                .17414,.1738,.17345,.1731,
292                .17276,.17241,.17207,.17174,.17141,
293                .17092,.17045,.17001,.16959,
294                .16918,.16879,.1684,.16802,.16764,
295                .16726,.16653,.16578,.16502,
296                .16426,.16349,.16272,.16196,.16121,
297                .16048,.15978,.15885,.15798,
298                .15717,.15641,.15572,.15507,.15449,
299                .15396,.15348,.15306,.15277,
300                .15251,.15228,.15207,.15188,.15171,
301                .15156,.15142,.15129,.15116,
302                .15105,.15095,.15085,.15075,.15066,
303                .15057,.15049,.15041,.15034,
304                .15027,.15016,.15007,.15,.14994,
305                .1499,.14986,.14984,.14982,
306                .14982,.14982,.14982,.14983,.14985,
307                .14986,.14988,.14991,.14993,
308                .14996,.14999,.15002,.15005,.15008,
309                .15011,.15014,.15018,.15021,
310                .15024,.15028,.15031,.15035,.15038,
311                .15042,.15045,.15048,.15052,
312                .15056,.15059,.15063,.15067,.1507,
313                .15074,.15077,.15081,.15084,
314                .15088,.15091,.15094,.15096,.15099,
315                .15101,.15103,.15104,.15106,
316                .15107,.15108,.15108,.15109,.15109,
317                .1511,.1511,.1511,.1511,.1511,
318                .15109,.15109,.15108,.15107,
319                .15106,.15104,.15102,.151,.15097,
320                .15094,.1509,.15086,.15081,
321                .15076,.15071,.15065,.15059,.15053,
322                .15046,.15038,.1503,.15022,
323                .15013,.15003,.14993,.14982,.1497,
324                .14957,.14943,.14929,.14914,
325                .14897,.1488,.14862,.14842,.14822,
326                .148,.14776,.14752,.14725,
327                .14698,.14669,.14639,.14607,.14574,
328                .14539,.14502,.14462,.1442,
329                .14376,.14329,.14279,.14227,.14171,
330                .14111,.14048,.13981,.13905,
331                .13825,.13739,.13648,.13551,.13449,
332                .13341,.13227,.13106,.1298,
333                .12839,.12692,.12538,.1238,.12216,
334                .12048,.11876,.117,.11523,
335                .11343,.1115,.10955,.10758,.10559,
336                .10358,.10154,.09948,.09738,
337                .09526,.0931,.0907,.08825,.08576,
338                .08324,.08068,.07808,.07545,
339                .07278,.07008,.06735,.0642,.06102,
340                .05782,.05463,.05145,.0483,
341                .04518,.04212,.03912,.0362,.02979,
342                .02391,.01859,.01386,.00977,
343                .00635,.00362,.00163,4.1e-4,0. };
344        
345        /**
346        *  Fill in the psi vector for a 67 series airfoil.
347        *
348        *  @param phi  An array filled in by phep().
349        *  @param psi  An existing array with 201 elements to be filled in
350        *              by this method.
351        */
352    @Override
353        protected final void phps(double[] phi, double[] psi) {
354                double[] bb = new double[251];
355                double[] cc = new double[251];
356                double[] dd = new double[251];
357                spline(251, philds, psilds, bb, cc, dd);
358                for (int i=0; i < 201; ++i) {
359                        psi[i] = seval(251, phi[i], philds, psilds, bb, cc, dd); 
360                }
361        }
362        
363        /**
364        *  Simple method to test this class.
365        *
366        * @param args the command-line arguments.
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 NACA67Series...");
375                
376                System.out.println("Creating a NACA 67-212 airfoil...");
377                Airfoil af = new NACA67Series(0.2, 0.12, 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