|
[Sponsors] |
[Scripting]: How to get the coordinates of a 2D airfoil @ different angles of attack? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 25, 2017, 01:37 |
[Scripting]: How to get the coordinates of a 2D airfoil @ different angles of attack?
|
#1 | |
New Member
Join Date: Oct 2017
Posts: 15
Rep Power: 9 |
I have this piece of code which calculates the coordinates of a point(qx,qy) after it is rotated around an origin(ox, oy) by an angle(angle):
Code:
import math def rotate(origin, point, angle): ox, oy = origin px, py = point qx = ox + math.cos(angle) * (px - ox) - math.sin(angle) * (py - oy) qy = oy + math.sin(angle) * (px - ox) + math.cos(angle) * (py - oy) return qx, qy print(rotate((ox, oy), (px, py), math.radians(angle))) I have this code that lets the script to open the .txt file with the coordinates at 0 angle of attack: Code:
coordsAt0 = [] with open('coordinatesAt0.txt') as fin: fin.readline() for l in fin: coords = map(float,l.split()) coordsAt0.append(coords[:2]) Quote:
Any hint or a simpler piece of code on how to do it would be greatly appreciated! Regards, CfdIntro |
||
November 26, 2017, 15:43 |
|
#2 |
Senior Member
Mikko
Join Date: Jul 2014
Location: The Hague, The Netherlands
Posts: 243
Rep Power: 13 |
Hi,
Looks like a familiar piece of code :-) After line Code:
coords = map(float,l.split()) Code:
angle = 10 # degrees origin = (0,0) coords0 = rotate(coords[:2], origin, math.radians(angle)) coordsAt0.append(coords0) |
|
December 12, 2017, 11:23 |
|
#3 | |
New Member
Join Date: Oct 2017
Posts: 15
Rep Power: 9 |
Quote:
I was trying to have the script open the .txt file with the coordinates at 0 AoA, rotate the coordinates by the desired AoA, print the results into a new .txt file, then read the coordinates at the new AoA and finally export the results into a .geo format file. That being said, your suggestion saved me about 30 lines of code! Thanks again for the tip Regards, CfdIntro |
||
Tags |
airfoil 2d, angle of attack, coordinates from .txt, python script |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Ffd_control_point_2d | feiyi | SU2 | 4 | September 30, 2019 13:42 |
High drag for airfoil compared to XFOIL and wind tunnel data | Ry10 | SU2 | 15 | October 30, 2016 18:27 |
2D FFD Optimization | RLangtry | SU2 | 2 | August 5, 2014 10:48 |
Automatic Simulation of 2D Airfoil Section at Different Angles of Attack | Hybrid | ANSYS | 3 | May 10, 2012 23:26 |
Airfoil simulation in High Angles of Attack | Yasser Nabavi | FLUENT | 0 | April 21, 2006 18:28 |