#! /usr/bin/env python # def naca4_mpt ( code ): #*****************************************************************************80 # ## NACA4_MPT returns the parameters stored in a NACA 4 digit airfoil code. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 July 2018 # # Author: # # John Burkardt # # Parameters: # # Input, integer CODE, the NACA4 code. # 0 <= CODE <= 9999. # # Output, real M, the maximum camber, as a percentage of the chord length. # 0 <= M <= 1.0. # # Output, real P, the relative distance of the occurrence of the maximum # camber from the beginning of the chord. # 0 <= P <= 1.0. # # Output, real T, the maximum thickness relative to the chord length. # 0 <= T <= 1.0. # from sys import exit if ( code < 0 or 9999 < code ): print ( '' ) print ( 'NACA4_MPT - Fatal error!' ) print ( ' CODE should be an integer between 0 and 9999.' ) exit ( 'NACA4_MPT - Fatal error!' ) m = ( code // 1000 ) code = code - m * 1000 m = m / 100.0 p = ( code // 100 ) code = code - p * 100 p = p / 10.0 t = code / 100.0 return m, p, t def naca4_mpt_test ( ): #*****************************************************************************80 # ## NACA4_MPT_TEST tests NACA4_MPT. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 July 2018 # # Author: # # John Burkardt # import numpy as np print ( '' ) print ( 'NACA4_MPT_TEST' ) print ( ' NACA4_MPT converts a NACA 4-digit code to' ) print ( ' M, P, T values.' ) codes = np.array ( [ \ 6, 8, 9, 10, 12, \ 15, 18, 21, 24, 1408, \ 1410, 1412, 2408, 2410, 2411, \ 2412, 2414, 2415, 2418, 2421, \ 2424, 4412, 4415, 4418, 4421, \ 4424, 6409, 6412 ] ) print ( '' ) print ( ' CODE M P T' ) print ( '' ) for code in codes: m, p, t = naca4_mpt ( code ) print ( ' %04d %6.2f %6.2f %6.2f' % ( code, m, p, t ) ) if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) naca4_mpt_test ( ) timestamp ( )