2017-06-28 4 views
0

私は、NACA翼のx、y、z座標からなるポイントでテキストファイルを埋めました。私は最終的に、simflowと呼ばれるソフトウェアを使用して、異なる迎角で翼にcfdシミュレーションを実行したいと考えています。このデータをソフトウェアにインポートするにはどうすればシミュレーションを実行できますか?NACAエーロフォイルのデータポイントをsimflowにアップロードしてcfdシミュレーションを実行するにはどうすればよいですか?

答えて

0

データが区切られており、ヘッダーが含まれていないと想定しています。

1.002 -0.001 -0.002 
0.986 0.246 0.234 
. 
. 
1.200 0.897 0.672 

あなたはPythonがインストールされてUNIXやUNIXライクなシステムであると仮定すると、「convert_to_obj.py」と呼ばれる新しいファイルとして次のコードを保存します。このスクリプトは、エーロフォイルの.datファイルを '.OBJ'ファイルに変換します。このファイルは、メッシングする前に手動でSimFlowにインポートできます。

#!/usr/bin/env python 
''' 
Script to convert a NACA airfoil in the Selig format into an OBJ file 
which can be read by SimFlow. 
''' 
# Make sure that your airfoil .dat file has the '.dat' extension!!!! 

# Argument parser from the command line 
import argparse 

parser = argparse.ArgumentParser(description='Script to convert a NACA' 
            'airfoil in the Selig format into an' 
            ' OBJ file that can be read by SimFlow') 

parser.add_argument('files', type=str, 
        help='Choose files to convert, specify path.' 
        ' Enclose entire path in single-quotes') 


args = parser.parse_args() 

# Import and convert file 
import glob 
AllFiles = glob.glob(args.files) 

for datfile in AllFiles: 

    InFileID = open(datfile, 'r') 

    # If you have header files in the .dat file, specify the number of 
    # header lines below. (for Selig, numheader = 1) 
    numheader = 0 
    for i in range(numheader): 
     InFileID.readline() 

    # Slurp all the remaining lines of the .dat file and close it 
    DataLines = InFileID.readlines() 
    InFileID.close() 

    # Open a new file to write to (change extension) 
    OutFileID = open(datfile[:-4] + '.OBJ', 'w') 

    # Write the name of the group (in our case, its just 'Airfoil') 
    OutFileID.write('g Airfoil\n') 

    for line in DataLines: 
     OutFileID.write('v ' + line) 

    OutFileID.close() 

# This should create an .OBJ file that can be imported into SimFlow. 

このスクリプトを実行するために行う(端末/コマンドラインから)

$ python convert_to_obj.py './relative/path/to/airfoil.dat' 

それとも、上記のスクリプトという時に

$ python convert_to_obj.py './relative/path/to/airfoil*.dat' 

注意をたくさんのファイルを変換することができます頂点を作成します。私はまたあなたの翼が3つの座標を持つ理由について少し混乱しています。翼は2次元である。このスクリプトは3Dデータに対しては機能しますが、頂点だけを作成します。

関連する問題