LoginSignup
1
7

More than 5 years have passed since last update.

OpenMDAO(version1.7.1)のインストール

Posted at
1 / 9

OpenMDAOの概説

OpenMDAOとは?

  • 複合領域の設計・解析・最適化に関するPythonのフレームワーク
  • 開発元:NASA グレンリサーチセンター
  • ライセンス:Apach Licence 2.0
  • プラットフォーム:Windows、Linux、OS X
  • 勾配法だけでなく遺伝的アルゴリズムや粒子群最適化をサポートする
  • MPIベースの並列計算が可能

対抗馬

* Dakota かな?


OpenMDAOの歴史

年/月 version 出来事
2010/7 0.0.1 リリース
2015/1 0.12.0 GUIやめました!
2015/4 0.13.0 次version 1.0ですから
2015/7 1.0.0 フレームワーク見直しました!(後方互換性なし)
2016/7 1.7.1 リリース

以上のようにバージョン0.13以前と1.0.0以降では全く別物になってしまった.
本記事では,バージョン1.7.1のインストールについてまとめる.
蛇足ではあるが0.13.0以前のバージョンのインストールについてこちらのslideshareを参照.


OpenMDAOのインストール

前提環境

事前にGit(オプション), Python, Pip, Numpy, Scipyがインストールされていれば良いらしい.(未確認)
本家のドキュメントには次のように記載されている.

  • サポートOS(テストしているOS)  
OS Versions 
Mac OS X Mavericks(10.9.5) Yosemite(10.10.5) El Capitan(10.11.x)
Ubuntu Trusty Tahr (14.04.2 LTS) Vivid Vervet (15.04) Xenial Xerus (16.04 LTS)
Windows 7 8 10

尚,RHELやMintなど他のディストリビューションへもインストールはできるとのこと.
実際CentOS6.4へのインストールは特に問題なくできた.


  • 各ソフトやPythonパッケージのバージョン
packages versions
Python 2.7.9 以上, 3.4.3以上
Numpy 1.9.2以上
Scipy 0.15.1以上
Git(Optional) -

今回はUbuntu 14.04 LTS上で作成したAnaconda環境を用いる.

conda create -n py27 python=2.7 anaconda
source activate py27

pyenv環境下にAnacondaをインストールしている場合, 
y_samaさんのpyenvとanacondaを共存させる時のactivate衝突問題の回避策3種類を参照のこと.


インストール

PyPIに登録されているのでpipでインストール.
condaではインストールしない(anacondaには旧バージョン(0.13)が登録されいる)

pip install openmdao

動作確認

下記を実行後,動作確認stdoutが確認できればOK.

PY27=`which conda`
cp ${PY27:0:-10}/lib/python2.7/site-packages/openmdao/examples/paraboloid_example.py .
python paraboloid_example.py
動作確認stdout
##############################################
Setup: Checking root problem for potential issues...
No recorders have been specified, so no data will be saved.
Setup: Check of root problem complete.
##############################################
-15.0

MPI関連のインストール

condaを用いてインストール. condaの mpi4pyのMPIはMPICH2を用いている

conda install mpi4py
conda install -c mutirri petsc4py

petsc4pyの動作確認

下記petsc4py_test.pyを準備する

petsc4py_test.py
from petsc4py import PETSc
rank = PETSc.COMM_WORLD.getRank()
num_ranks = PETSc.COMM_WORLD.getSize()
x = PETSc.Vec().createMPI(4) # VecCreateMPI: Creates a parallel vector.  size=4
x.setValues([0,1,2,3], [10,20,30,40]) # VecSetValues: Inserts or adds values into certain locations of a vector.  x[0]=10, x[1]=20, x[2]=30, x[3]=40
print ('Rank',rank,'has this portion of the MPI vector:', x.getArray() ) # VecGetArray: Returns a pointer to a contiguous array that contains this processor's portion of the vector data.
vec_sum = x.sum() # VecSum: Computes the sum of all the components of a vector. 10+20+30+40=100

if rank == 0:
    print ('Sum of all elements of vector x is',vec_sum,'and was computed using',num_ranks,'MPI processes.')

下記を実行後,下に示す結果を確認できればpetscの動作確認はOK.

mpirun -np 2 python petsc_test.py
petsc動作確認stdout
(('Rank', 1, 'has this portion of the MPI vector:',
 'Rank', 0, 'has this portion of the MPI vector:', 
array([ 10.,  20.]))
array([ 30.,  40.]))
('Sum of all elements of vector x is', 
100.0, 'and was computed using'

OpenMDAOのMPI動作確認

下記を実行後,log.doeの末尾が下記通りであればOK.
(stdoutにWarningが出力される)

PY27=`which conda`
cp ${PY27:0:-10}/lib/python2.7/site-packages/openmdao/examples/doe_example.py .
mpirun -np 5 python doe_example.py >log.doe
tail -10 log.doe

tailのstdout
  const.c: 3.0
  dut.y: 13304.993403
  indep_var.x: 4434.99780099
Timestamp: 1480262524.502128
Iteration Coordinate: rank3:Driver|1
Iteration succeeded: yes
Unknowns:
  const.c: 3.0
  dut.y: 13266.2297346
  indep_var.x: 4422.07657819

まとめ

  • OpenMDAOの概説を行った
  • OpenMDAOのインストール,動作確認を行った
1
7
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
1
7