001/*
002*   NACA64Series -- An arbitrary NACA 64 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 64 series
031*      airfoil section such as a NACA 64-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 5, 2010
056*  @version February 22, 2025
057*/
058public class NACA64Series extends NACA6Series {
059        
060        //-----------------------------------------------------------------------------------
061        
062        /**
063        *  Create a NACA 64 series airfoil with the specified parameters.
064        *
065        *  @param  CLi        Design lift coefficient (e.g.: 64-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 NACA64Series(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 "64";
079        }
080        
081        //      Phi & eps vectors for 64 series airfoil.
082    private static final double[] philde = {
083        0.,.01568,.03136,
084                .04705,.06274,.07843,.09414,.10985,
085                .12558,.14132,.15708,.17274,
086                .18842,.20411,.21981,.23552,.25124,
087                .26697,.2827,.29843,.31416,
088                .32987,.34558,.36129,.377,.39271,
089                .40842,.42412,.43983,.45553,
090                .47124,.48695,.50266,.51837,.53408,
091                .54979,.56549,.5812,.59691,
092                .61262,.62832,.64403,.65975,.67546,
093                .69117,.70688,.72258,.73829,
094                .75399,.7697,.7854,.80111,.81683,
095                .83254,.84825,.86396,.87967,
096                .89537,.91108,.92678,.94248,.9582,
097                .97391,.98962,1.00533,1.02104,
098                1.03675,1.05245,1.06816,1.08386,
099                1.09956,1.11528,1.13099,1.14671,
100                1.16242,1.17813,1.19384,1.20954,
101                1.22524,1.24094,1.25664,1.27236,
102                1.28807,1.30378,1.31949,1.3352,
103                1.35091,1.36661,1.38232,1.39802,
104                1.41372,1.42942,1.44512,1.46083,
105                1.47653,1.49223,1.50794,1.52365,
106                1.53936,1.55508,1.5708,1.58649,
107                1.60218,1.61788,1.63358,1.64929,1.665,
108                1.68072,1.69643,1.71216,1.72788,
109                1.74358,1.75928,1.77498,1.79068,
110                1.80639,1.8221,1.83781,1.85353,
111                1.86924,1.88496,1.90066,1.91637,
112                1.93207,1.94778,1.96349,1.9792,
113                1.99491,2.01062,2.02633,2.04204,
114                2.05775,2.07346,2.08917,2.10488,
115                2.12059,2.1363,2.152,2.16771,2.18341,
116                2.19911,2.21483,2.23055,2.24627,
117                2.26198,2.2777,2.2934,2.30911,2.32481,
118                2.3405,2.35619,2.37192,2.38765,
119                2.40337,2.41909,2.4348,2.45051,
120                2.46621,2.4819,2.49759,2.51327,
121                2.52901,2.54474,2.56047,2.57619,
122                2.5919,2.6076,2.6233,2.63899,2.65467,
123                2.67035,2.68609,2.70182,2.71755,
124                2.73327,2.74898,2.76468,2.78038,
125                2.79607,2.81175,2.82743,2.84316,
126                2.85889,2.87461,2.89032,2.90603,
127                2.92173,2.93743,2.95313,2.96882,
128                2.98451,3.00023,3.01594,3.03165,
129                3.04736,3.06307,3.07878,3.09448,
130                3.11018,3.12589,3.14159 };
131                
132    private static final double[] epslde = {
133                0.,.00233,.00464,
134                .00692,.00914,.01129,.01336,.01531,
135                .01714,.01883,.02035,.02169,
136                .02287,.0239,.0248,.02557,.02624,
137                .02682,.02731,.02774,.02812,
138                .02846,.02877,.02905,.02931,.02957,
139                .02982,.03007,.03033,.0306,
140                .0309,.03122,.03158,.03196,.03236,
141                .0328,.03326,.03375,.03427,
142                .03481,.03538,.03598,.0366,.03725,
143                .03792,.03862,.03935,.0401,
144                .04087,.04167,.0425,.04335,.04423,
145                .04512,.04605,.04699,.04796,
146                .04896,.04998,.05102,.05208,.05317,
147                .05428,.05541,.05657,.05774,
148                .05894,.06016,.0614,.06267,.06395,
149                .06526,.06658,.06793,.06931,
150                .0707,.07213,.07357,.07505,.07655,
151                .07808,.07964,.08123,.08284,
152                .08447,.08613,.0878,.08949,.09119,
153                .0929,.09462,.09635,.09808,
154                .0998,.10151,.10321,.10488,.10653,
155                .10815,.10972,.11125,.11273,
156                .11415,.11553,.11686,.11814,.11938,
157                .12057,.12171,.12281,.12386,
158                .12487,.12583,.12675,.12762,.12844,
159                .12922,.12994,.13062,.13125,
160                .13182,.13234,.13281,.13322,.13358,
161                .13389,.13414,.13434,.13448,
162                .13456,.13459,.13456,.13447,.13433,
163                .13413,.13387,.13354,.13316,
164                .13272,.13222,.13166,.13104,.13035,
165                .1296,.12879,.12792,.12698,
166                .12598,.12492,.1238,.12261,.12136,
167                .12004,.11866,.11722,.11572,
168                .11416,.11254,.11087,.10914,.10735,
169                .1055,.1036,.10164,.09963,
170                .09757,.09545,.09328,.09105,.08878,
171                .08645,.08406,.08162,.07913,
172                .0766,.07402,.07139,.06873,.06603,
173                .06329,.06052,.0577,.05486,
174                .05198,.04907,.04614,.04318,.0402,
175                .0372,.03417,.03113,.02807,
176                .02499,.02189,.01879,.01567,.01255,
177                .00942,.00628,.00314,0. };
178        
179        /**
180        *  Fill in phi, eps vectors for 64 series airfoil.
181        *
182        *  @param phi  An existing array with 201 elements to be filled in
183        *              by this method.
184        *  @param eps  An existing array with 201 elements to be filled in
185        *              by this method.
186        */
187    @Override
188        protected final void phep(double[] phi, double[] eps) {
189                System.arraycopy(philde, 0, phi, 0, 201);
190                System.arraycopy(epslde, 0, eps, 0, 201);
191        }
192        
193        
194        //      Phi & eps vectors for 64 series airfoil.
195    private static final double[] philds = {
196                0.,.01573,.03145,
197                .04717,.06289,.07861,.09432,.11002,
198                .12572,.1414,.15708,.1728,
199                .18851,.20422,.21992,.23562,.25132,
200                .26702,.28272,.29844,.31416,
201                .32984,.34553,.36122,.37693,.39264,
202                .40836,.42408,.4398,.45552,
203                .47124,.48695,.50266,.51837,.53408,
204                .54979,.56549,.5812,.59691,
205                .61261,.62832,.64403,.65973,.67544,
206                .69115,.70686,.72257,.73827,
207                .75398,.76969,.7854,.80111,.81682,
208                .83252,.84823,.86394,.87965,
209                .89536,.91106,.92677,.94248,.95819,
210                .9739,.98961,1.00531,1.02102,
211                1.03673,1.05244,1.06815,1.08385,
212                1.09956,1.11527,1.13098,1.14669,
213                1.1624,1.17811,1.19381,1.20952,
214                1.22523,1.24093,1.25664,1.27236,
215                1.28808,1.30379,1.31951,1.33522,
216                1.35093,1.36663,1.38233,1.39803,
217                1.41372,1.42946,1.44519,1.46091,
218                1.47663,1.49234,1.50804,1.52374,
219                1.53943,1.55512,1.5708,1.58653,
220                1.60226,1.61798,1.6337,1.64941,
221                1.66511,1.68081,1.69651,1.7122,
222                1.72788,1.74361,1.75933,1.77505,
223                1.79076,1.80647,1.82218,1.83788,
224                1.85357,1.86927,1.88496,1.90068,
225                1.9164,1.93211,1.94782,1.96353,
226                1.97924,1.99494,2.01064,2.02634,
227                2.04204,2.05775,2.07346,2.08917,
228                2.10488,2.12059,2.13629,2.152,2.1677,
229                2.18341,2.19911,2.21481,2.23051,
230                2.24622,2.26192,2.27763,2.29334,
231                2.30905,2.32476,2.34047,2.35619,
232                2.37188,2.38757,2.40327,2.41897,
233                2.43468,2.45039,2.4661,2.48182,
234                2.49754,2.51327,2.52895,2.54464,
235                2.56034,2.57604,2.59174,2.60745,
236                2.62317,2.63889,2.65462,2.67035,
237                2.68603,2.70172,2.71741,2.73311,
238                2.74882,2.76453,2.78024,2.79597,
239                2.8117,2.82743,2.84312,2.85881,
240                2.87451,2.89021,2.90591,2.92163,
241                2.93734,2.95306,2.96878,2.98451,
242                3.00021,3.01591,3.03162,3.04732,
243                3.06303,3.07874,3.09445,3.11016,
244                3.12588,3.14159 };
245                
246    private static final double[] psilds = {
247                .25269,.25265,.25251,
248                .25227,.25193,.25147,.2509,
249                .2502,.24937,.24841,.2473,.24605,
250                .24467,.24321,.2417,.24016,
251                .23864,.23715,.23573,.23442,.23325,
252                .23224,.23138,.23066,.23006,
253                .22956,.22916,.22884,.22858,.22836,
254                .22818,.22802,.22788,.22775,
255                .22764,.22755,.22747,.2274,.22736,
256                .22732,.2273,.22729,.2273,
257                .22731,.22733,.22736,.22739,.22742,
258                .22745,.22748,.22751,.22753,
259                .22755,.22756,.22756,.22755,.22753,
260                .22751,.22747,.22742,.22736,
261                .22729,.2272,.22709,.22697,.22683,
262                .22668,.2265,.2263,.22608,
263                .22584,.22557,.22528,.22497,.22462,
264                .22426,.22386,.22345,.223,
265                .22253,.22203,.2215,.22094,.22034,
266                .21969,.21899,.21823,.21741,
267                .21652,.21554,.21449,.21334,.21211,
268                .2108,.2094,.20794,.20641,
269                .20481,.20315,.20143,.19966,.19784,
270                .19596,.19405,.19209,.19008,
271                .18804,.18596,.18384,.18169,.1795,
272                .17727,.17501,.17273,.17041,
273                .16806,.16569,.16329,.16087,.15843,
274                .15596,.15347,.15095,.14842,
275                .14587,.1433,.14072,.13812,.13551,
276                .13288,.13024,.12759,.12492,
277                .12225,.11957,.11688,.11418,.11149,
278                .10878,.10608,.10338,.10068,
279                .09798,.09529,.0926,.08992,.08725,
280                .08459,.08195,.07932,.07671,
281                .07412,.07156,.06901,.06649,.06399,
282                .06152,.05908,.05667,.05428,
283                .05193,.04962,.04734,.0451,.04289,
284                .04073,.0386,.03651,.03447,
285                .03247,.03051,.02861,.02675,.02494,
286                .02318,.02148,.01983,.01825,
287                .01672,.01525,.01385,.01252,.01125,
288                .01006,.00892,.00786,.00686,
289                .00593,.00506,.00426,.00353,.00287,
290                .00227,.00174,.00128,8.9e-4,
291                5.7e-4,3.2e-4,1.4e-4,4e-5,0. };
292        
293        /**
294        *  Fill in the psi vector for a 64 series airfoil.
295        *
296        *  @param phi  An array filled in by phep().
297        *  @param psi  An existing array with 201 elements to be filled in
298        *              by this method.
299        */
300    @Override
301        protected final void phps(double[] phi, double[] psi) {
302                double[] bb = new double[201];
303                double[] cc = new double[201];
304                double[] dd = new double[201];
305                spline(201, philds, psilds, bb, cc, dd);
306                for (int i=0; i < 201; ++i) {
307                        psi[i] = seval(201, phi[i], philds, psilds, bb, cc, dd); 
308                }
309        }
310        
311        /**
312        *  Simple method to test this class.
313        *
314        * @param args the command-line arguments
315        */
316        public static void main(String[] args) {
317        
318                DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance();
319                nf.setMaximumFractionDigits(5);
320                nf.setMinimumFractionDigits(5);
321                
322                System.out.println("Start NACA64Series...");
323                
324                System.out.println("Creating a NACA 64-012 airfoil...");
325                Airfoil af = new NACA64Series(0.0, 0.12, 1);
326                
327                System.out.println("Airfoil = " + af.toString());
328                
329                //      Output the upper surface of the airfoil.
330                List<Point2D> upper = af.getUpper();
331                List<Double> ypArr = af.getUpperYp();
332                System.out.println("upper.size() = " + upper.size() + ", ypArr.size() = " + ypArr.size());
333                
334                System.out.println("        X    \t    Y    \t    dy/dx");
335                int length = upper.size();
336                for (int i=0; i < length; ++i) {
337                        Point2D o = upper.get(i);
338                        System.out.println("    " + nf.format(o.getX()) + "\t" + nf.format(o.getY()) +
339                                                                        "\t" + nf.format(ypArr.get(i)));
340                }
341                
342                System.out.println("# ordinates = " + length);
343                System.out.println("Done!");
344        }
345}
346
347