Transform Airfoil Point Data into a Surface in Altair Inspire Using Python

Ricardo Dominguez_22538
Ricardo Dominguez_22538
Altair Employee
edited September 23 in Altair Exchange

Overview

If you're working with airfoil point data and need a quick way to transform it into a surface in Altair Inspire, this Python script is perfect for you! It reads a CSV file containing the X and Y coordinates of an airfoil, scales them down (assuming the points are in millimeters), and creates a spline in Inspire. This spline is then realized as a surface, making it easy to incorporate the airfoil geometry into your model for further analysis or design refinement.

In this guide, you'll find:

  • The Python script for running with Altair Inspire.
  • A sample airfoil point data file (airfoil-points.csv) to get you started.

This script, along with the provided sample file (airfoil-points.csv), will help you quickly and easily transform airfoil point data into a surface in Altair Inspire. Whether you're working with aerodynamic shapes or need to streamline your airfoil design workflow, this tool will save you time and effort.

Pre-Requisite

Prerequisites include:

  • Altair Inspire: You need to have Altair Inspire installed on your system.
  • Sample Airfoil Point Data (CSV): Download the provided sample file (airfoil-points.csv) containing X and Y coordinates for an airfoil.
  • Code for transforming airfoil data into a surface: Download the code provided in this article (airfoil_to_surface.py)
  • Basic Python Knowledge: You should be familiar with running Python scripts inside Inspire’s Python window.

Usage/Installation Instructions

Step 1: Prepare or Use the Sample CSV File

Download the sample CSV file called airfoil-points.csv to help you get started. The file contains the X and Y coordinates of a simple airfoil profile. Here’s how the structure- looks like:

X,Y 750,0 700,11.4 650,20.8 ... 750,0  # Last point matches the first to close the shape.

If you have your own airfoil data, ensure it follows this format, with the first and last points matching for a closed surface.

Step 2: Download and Place the Python Script

Download the Python script. Save it as airfoil_to_surface.py. Make sure to update the file_path in the script to point to the location of your sample CSV file (airfoil-points.csv) or your own airfoil data.

file_path = r"C:\path\to\airfoil-points.csv"

Step 3: Run the Script in Altair Inspire

  1. Open Altair Inspire.
  2. Access the Python window in Inspire.
  3. Copy and paste the Python script into the window.
  4. Press Enter to run the script.
# Python Script to Transform Airfoil Data into a Surface in Inspire import csv from hwx import inspire  def transform_coordinates(file_path):     coordinates = []      # Open and read the CSV file     with open(file_path, newline='') as csvfile:         reader = csv.DictReader(csvfile)          # Check if 'X' and 'Y' columns exist         if 'X' not in reader.fieldnames or 'Y' not in reader.fieldnames:             raise ValueError("CSV file must contain 'X' and 'Y' columns.")          # Iterate over each row in the CSV         for row in reader:             x = float(row['X']) / 1000  # Scale down (assumes data is in mm)             y = float(row['Y']) / 1000             coordinates.append((x, y))      return coordinates  # Assuming the file path is correct file_path = r"C:\path\to\airfoil-points.csv"  # Get the coordinates from the CSV file and store them in 'airfoil' airfoil = transform_coordinates(file_path)  # Integrate into the provided 'inspire' code model = inspire.newModel() s = inspire.Sketch()  # Use 'airfoil' in the spline function spl = s.addSpline(airfoil, degree=3, periodic=False, interpolated=True)  # Realize the sketch into a part sketchPart = s.realize()  # Extract the surface from the sketch featsArea = sketchPart.getFeatures(type='FeatureArea') inspire.geometry.extract(featsArea)  # Orient the view to the top for easier visualization inspire.orientView(direction="top")

Post-Requisite

Inspect and Refine the Surface in Inspire

Once the script runs, your airfoil geometry will be realized as a surface in Inspire. You can:

  • Rotate, inspect, and visualize the airfoil geometry.
  • Further refine or modify the surface using Inspire’s built-in tools.
  • Perform analysis or integrate the surface into your broader design workflow.

Customization Tips:

  • Scaling: If your data is already in meters, remove the scaling step by modifying this part of the script:

x = float(row['X'])  # No need to divide by 1000 if data is in meters y = float(row['Y'])