LoginSignup
2
0

More than 1 year has passed since last update.

ソースコードからのCanteraのインストール

Last updated at Posted at 2021-11-26

Canteraとは

cantera-logo.png

https://github.com/Cantera/cantera
- 反応動力学および熱力学,輸送過程を解くためのオープンソースかつオブジェクト指向のソフトウェア
- 商用ソフトウェアのCHEMKIN-PROとほとんど同等のことができる.
- ソースコードはC++とFortran 90で書かれている
- PythonとMatlabから使用するためのインターフェースも用意されている.

環境

  • Windows 10
  • Miniconda 4.10.3
  • Cantera 2.5.1

コンパイルのための準備

以下の記事の前半部分を参考にAnacondaの仮想環境を準備する.
https://www.cantera.org/compiling/installation-reqs.html#sec-installation-reqs
conda activate canteraのところまでを実行しておく.

ソースコードのダウンロード

以下の記事を参考にソースコードをダウンロードする
https://www.cantera.org/compiling/source-code.html#sec-source-code
安定板のv2.5.1をダウンロードした.

Canteraのビルド

ソースコードのrootとなる場所にcantera.confというファイルを作成する.
ビルドの際にこのファイルで指定したコマンドが反映される.

$ vim cantera.conf

以下の内容を記述して保存

cantera.conf
python_package = 'full'
boost_inc_dir = 'C:\\Users\\sakir\\miniconda3\\envs\\ct_src\\Library\\include'

boost_inc_dirにはAnacondaでインストールしたboostの場所を指定する.
ビルドは以下のコマンドで行う.

$ scons build

以下のエラーが発生する.

src\base\Units.cpp(27): error C2001: 定数が 2 行目に続いています。
src\base\Units.cpp(27): error C2064: 1 引数を取り込む関数には評価されません。
src\base\Units.cpp(79): error C2059: 構文エラー: ';'
scons: *** [build\src\base\Units.obj] Error 2
scons: building terminated because of errors.

エラーが発生している行は以下のように記述されており,この行を削除もしくはコメントアウトすると解消する.

    {"Å", Units(1e-10, 0, 1, 0)},

無事にビルドが完了すると以下のような出力が得られる.

*******************************************************
Compilation completed successfully.

- To run the test suite, type 'scons test'.
- To install, type 'scons install'.
- To create a Windows MSI installer, type 'scons msi'.
*******************************************************
scons: done building targets.

テストの実行

以下のコマンドでテストを実行する

scons test

実行結果は以下の通りで4つのテストで失敗したとの表示.
失敗した個所はすべて上でコメントアウトしたオングストロームからの変換に関するもの.
エラーのためにビルドを終了したといっているのだが,とりあえずはインストールまで進める.

*****************************
***    Testing Summary    ***
*****************************

Tests passed: 1121
Up-to-date tests skipped: 0
Tests failed: 4
Failed tests:
    - thermo: ThermoFromYaml.DebyeHuckel_bdot_ak
    - thermo: ThermoFromYaml.DebyeHuckel_beta_ij
    - python:test_composite.TestModels.test_load_thermo_models
    - python:test_composite.TestModels.test_restore_thermo_models

*****************************
scons: *** [test_results] One or more tests failed.
scons: building terminated because of errors.

Canteraのインストール

インストールの実行のためには管理者権限が必要になるので,Anacondaのプロンプトを管理者権限で立ち上げる.
以下のコマンドでCanteraをインストールする.

scons install

インストールが正常に終了すると以下の通りの出力を得る.
Anacondaの仮想環境上でインストールを行っているけれども,Canteraはすべてのユーザー向けにインストールされるみたい.

Cantera has been successfully installed.

File locations:

  applications                C:\Program Files\Cantera\bin
  library files               C:\Program Files\Cantera\lib
  C++ headers                 C:\Program Files\Cantera\include
  samples                     C:\Program Files\Cantera\samples
  data files                  C:\Program Files\Cantera\data
  Python package (cantera)    C:\Users\sakir\miniconda3\Lib\site-packages
  Python samples              C:\Users\sakir\miniconda3\Lib\site-packages\cantera\examples
scons: done building targets.

インストールの確認

インストールの確認のために,Pythonでcanteraをインポートしてみる.
無事にインストールできているようだ.

(cantera) PS C:\Users\sakir> python
Python 3.6.13 (default, Sep 23 2021, 07:38:49) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cantera as ct
>>> ct.__version__
'2.5.1'
2
0
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
2
0