saullocastro / tuduam

Urban air mobility course offered at TU Delft
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Reading Xfoil Aerodynamic Data Issue #1

Closed NeoStellarator closed 6 months ago

NeoStellarator commented 6 months ago

I was performing analysis on a Wortmann airfoil, and encountered the following error:

The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (13373,) + inhomogeneous part.

I think the error traces back to the extract_data_dir(dir_path) function in \tuduam\propulsion.py, that stores aerodynamic data of the airfoil in an array.

Currently, part of the function looks as follows:

    with open(os.path.join(dir_path,file), "r") as f:
        write = False
        for line in f.readlines():
            if  line.count("-") > 3:
                write = True
                continue
            if write:
                value_lst = [float(value) for value in line.split()]
                value_lst.append(reyn)
                data_points.append(value_lst)

If the file with aerodynamic data finishes with blank lines, that is the case for some of my (Xfoil data) files, when the function reads these empty lines, data_points is appended with the Reynolds number only. Then the data_points array, that should contain 8 entries in each row, may have an occasional row with only one entry. Trying to cast to a numpy leads to the above issue.

Furthermore, when studying the extract_data_dir(dir_path) function, I realised that some important aerodynamic data from the file is not stored. Any line with three '-' is identified as the end of the (xfoil) file header, and skipped (if line.count("-") > 3: <...> continue) - if any line of data has three negative signs, it is skipped and not appended to the value_lst, leading

To account for these issues, I propose the following:

    with open(os.path.join(dir_path,file), "r") as f:
        write = False
        for line in f.readlines():
            if  line.count("-") > 10:  # increase the threshold to a number larger than the number of columns in the file
                write = True
                continue
            if line == '\n': # skip any empty line
                continue
            if write:
                value_lst = [float(value) for value in line.split()]
                value_lst.append(reyn)
                data_points.append(value_lst)

Please let me know if I've overlooked anything or if there is anything wrong with the logic.

dmkeijzer commented 6 months ago

Good catch! I'll implement the changes and run all tests. The changes will be implemented in the next release!