A Python interface for XFOIL aerodynamic analysis
Project description
PythonXfoil
PythonXfoil is a Python module that provides an interface to natively and intuitively run concurrent aerodynamic analyses using XFOIL. It allows users to define airfoil geometries, set analysis parameters, and execute XFOIL simulations programmatically. Its focus is to provide an intuitive and easy-to-use alternative to similar modules.
This project is still a WIP (Work-In-Progress)
Features
- Automatic Multithreading for multiple concurrent analyses
- Define airfoil geometries using custom coordinates.
- Set analysis parameters such as Reynolds number, Mach number, and angle of attack.
- Run XFOIL simulations in batch mode.
- Parse and retrieve aerodynamic coefficients from XFOIL output.
Prerequisites
- Python 3.x
- XFOIL executable (
xfoil.exefor Windows orxfoilfor Unix-based systems) must be accessible in your system's PATH or in the same directory as the script.
Installation
From PyPI (Recommended)
You can install PythonXfoil directly from PyPI:
pip install python-xfoil
From Source
Alternatively, you can clone the repository and install from source:
git clone https://github.com/cc-aero/pythonxfoil.git
cd pythonxfoil
pip install -e .
Usage
Example Script
The following example demonstrates how to use the PythonXfoil module to load airfoil coordinates, set analysis parameters, and run an XFOIL analysis.
# example.py
from pythonxfoil import Airfoil
from pythonxfoil import Utils
# Load airfoil coordinates from a .dat file
with open("example-airfoils/naca2412.dat") as airfoil_file:
airfoil_data = airfoil_file.read()
# Parse the coordinates
coords = Utils.parse_coords(airfoil_data)
# Create an Airfoil object
airfoil = Airfoil(name="NACA 2412", coords=coords)
# Set analysis parameters
airfoil.set_analysis_params(
Re=50000,
alpha_start=0,
M=0.0 # Incompressible flow
)
# Run the XFOIL analysis
results = airfoil.run_analysis()
# Print the results
print(results)
This example script does the same, but using the concurrent analysis feature.
# example_multithreaded.py
from pythonxfoil import Airfoil
from pythonxfoil import Utils
# Load airfoil coordinates from a .dat file
with open("example-airfoils/naca2412.dat") as airfoil_file:
airfoil_data = airfoil_file.read()
# Parse the coordinates
coords = Utils.parse_coords(airfoil_data)
# Create an Airfoil object
airfoil = Airfoil(name="NACA 2412", coords=coords)
# Set analysis parameters with lists of values
Re_list = [30000, 100000, 120000]
alpha_start_list = [1, 1, 1]
M_list = [0.5, 0.3, 0.1]
airfoil.set_analysis_params(
Re=Re_list,
alpha_start=alpha_start_list,
M=M_list,
)
# Run the multithreaded XFOIL analysis
results = airfoil.run_multithreaded_analysis()
# Print the results
for result in results:
print(result)
Module Overview
pythonxfoil.py
This module contains the Airfoil class and utility functions for running XFOIL analyses.
Airfoil Class
- Initialization: Create an airfoil object with a name and coordinates.
- Set Analysis Parameters: Define Reynolds number, Mach number, and angle of attack range.
- Run Analysis: Execute the XFOIL analysis and retrieve results.
- Run Multithreaded Analysis: Execute multiple XFOIL analyses concurrently.
Utils Class
- parse_coords: Converts multiline text of coordinates into a list of (x, y) tuples.
Example Airfoil Data
An example airfoil data file (naca2412.dat) is provided in the example-airfoils directory.
NACA 2412
1.0000 0.0013
0.9500 0.0114
...
1.0000 -0.0013
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
@cc-aero
For any questions or issues, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_xfoil-0.1.0.tar.gz.
File metadata
- Download URL: python_xfoil-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0efeef68dac4b366c59e5620af27d7fe694ac0f144d7ecf2f578058f6f791226
|
|
| MD5 |
e1b0bbc81ad405153c302a9793e75795
|
|
| BLAKE2b-256 |
b3d225952b036464627860e820e35728ca56994894bce7708dcba002358c563c
|
File details
Details for the file python_xfoil-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_xfoil-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a030b4722bb94b5b12bba92000e0fa76e843a619c86f15e17e85d958bc2eb34
|
|
| MD5 |
2137f7973fce7a7de9277dda6a540a40
|
|
| BLAKE2b-256 |
7cf76c5d976d494ad41e3dcd40b73e96cd1b9ef82ff9f0296a29dd1d5da365e0
|