LoginSignup
0
1

More than 5 years have passed since last update.

Autodesk CFDのPython APIを使う

Posted at

Autodesk CFDについて

Autodesk社のCFD(数値流体力学)ソフトです。学生は3年間無償で利用できます。
Python APIが使えるようだったので試してみました。最終的には空調制御シミュレーションに使いたい。
APIは以下のリンクからダウンロードしました。
2016 Python API マニュアル CFD Autodesk

結果を取得

まずはチュートリアルのシミュレーションを動かしました。
チュートリアル: 居住者快適性換気スタディ

シミュレーション結果にPython APIを使ってアクセスします。
コードはGUIの[セットアップ]-->[デザインスタディツール]-->[スクリプトエディタ]に作成

モニターポイントを作成してその座標の値を取得します。
上のリンクのAPIのサンプルコードを参考にしています。

monitorPoint.py
from CFD import Setup
from CFD import Results
from CFD import DSE

def CreateMonitorPoint():
  study = Setup.DesignStudy.Create()
  scenario = study.getActiveScenario() # get active scenario of the study
  results = scenario.results()   # get results from scenario
  if results is None:
    DSE.UI.ShowMessage( "There are no results !" )
    return
  results.activate()  # activate the current results

  mp = Results.MonitorPoint.Create(results, "Point1") # create monitor point
  mp.setCoordinates(-24.8, 86.8, 179) # set coordinates
  vl  =Results.MonitorPoint.value(mp, "Temperature") # get temperature
  print(vl)

 # Call the above function
CreateMonitorPoint()

境界条件を変更

APIを使って境界条件を変更しながらシミュレーションを実行できます。
チュートリアルのモデルを使って非定常解析をしました。

changeBoundaryCondition.py
def main():
  study = Setup.DesignStudy.Create()
  scenario = study.getActiveScenario() # get active scenario of the study

  ## change scenario
  n_stopTime = 30
  scenario.stopTime = n_stopTime

  ## change boundary condition
  bc = Setup.BoundaryCondition("Temperature")
  bc.setValue(64, "Fahrenheit")
  ents = Setup.EntityIdList()
  ents.append(48)
  scenario.applyBoundaryCondition(bc, ents, Setup.Entity.Surface)
  scenario.run() 

  results = scenario.results()   # get results from scenario
  results.activate()

 # Call the above function
main()

データの書き出しと境界条件の変更を組み合わせて色々できそうです。

メモ

本当はやりたかったこと

  • 全ての節点データをAPIを使ってエクスポート
    • APIに相当するコマンドがない。GUIではできるけれど自動化したい。
  • Cutplaneを作成
    • CutPlaneクラスのsaveTableを試したところ空のファイルが出力される。これを使いたい...

もう少し使いこなしたいところ

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1