LoginSignup
0
0

More than 1 year has passed since last update.

LIME を Ubuntu 18.04 にインストールしてテスト計算を行えるようにする

Last updated at Posted at 2021-08-12

LIME (Line Modeling Engine) (https://github.com/lime-rt/lime) は non-LTE 輻射輸送を解く public code. Documentation の手順だけではインストールできなかったので備忘録のために方法を記しておく。

環境とバージョン

  • Ubuntu 18.04 LTS
  • LIME 1.9.4+ master track version (ここ)

LIMEは適当なディレクトリに git clone する。

必要なパッケージのインストール

LIMEのREADMEによれば、以下の3つのパッケージのインストールが必要なよう。
- qhull
- cfitsio
- gsl

まず上のリンクからこれらをすべてダウンロードして解凍して適当なディレクトリに置いておく。

qhull

READMEにある方法ではダウンロード不可(最新版ではconfigure scriptがない)なので、MakefileをいじってPREFIXという変数をLIMEのbase directoryにしておく。

Makefile
# Do not replace tabs with spaces.  Needed for build rules
# Unix line endings (\n)

PREFIX ?= path/to/lime/base/directory # ココ
BINDIR ?= bin
INCDIR ?= include
LIBDIR ?= lib
DOCDIR ?= share/doc/qhull
MANDIR ?= share/man/man1
PCDIR  ?= $(LIBDIR)/pkgconfig

で、Makefileがあるところで

make
make install

cfitsio, gsl

READMEに従って素直にやればよい。

./configure --prefix=path/to/lime/base/directory
make
make install

LIMEのコンパイルとテスト計算

LIMEのdirectoryに行ってconfigure.

cd path/to/lime/base/deirectory
./configure

PATHを通して

echo export PATH=<path/to/lime/base/directory>:${PATH} >> ~/.bashrc

templateのモデルが lime-1.9.5/example/model.c にあるので、example ディレクトリで

example
lime model.c

すると動くと思いきや、qhull_a.h とかいうライブラリがありません、とか言われる。どうもsrc/lime.h 内で include するときに qhull のパスが適切に設定されていないっぽくて(ここを参照)、lime.h の最初の方で

src/lime.h
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <signal.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_linalg.h>
#include <libqhull/qhull_a.h> # ココ、元は #include <qhull_a.h>
#include <fitsio.h>

に修正。これでいけるか、と思いきや、今度は -lqull がありませんとか言われる。ここによると、よくわからんがLIMEは qhull でなくて qhullstatic を使うらしいので、LIMEのbase directoryに生成された Makefile.defs の1行目を qhull から qhullstatic に書き換える。(2021/08/13追記:というか、configure scriptを書き換えるのが正しい方法ですね。base directoryにある configure ファイルのそれっぽいところを書き換えればよい。)

Makefile.defs
LIB_QHULL = qhullstatic # ココ、元は qhull
PYCCFLAGS = -I/home/yamato/.pyenv/versions/3.8.10/include/python3.8 -I/home/yamato/.pyenv/versions/3.8.10/include/python3.8  -Wno-unused-result -Wsign-compare  -DNDEBUG -g -fwrapv -O3 -Wall
PYLDFLAGS = -L/home/yamato/.pyenv/versions/3.8.10/lib/python3.8/config-3.8-x86_64-linux-gnu -L/home/yamato/.pyenv/versions/3.8.10/lib  -lcrypt -lpthread -ldl  -lutil -lm -lm 

これで晴れて

example
lime model.c

すると、こんなん

*** LIME, The versatile line modeling engine, version 1.9.4+ (master track)



    Building grid      : ######################### | [ok]   |      Molecular data
    Smoothing grid     : ######################### | [ok]   |
                                                            |  HCO+
    Statistics         :                                    |  1 collision partner:
                                                            |  H2 
    Iterations         : #                                  |
    Propagating photons: ###                       |        |  Model provides: 
                                                            |  1 density profile
                                                            |
    Ray-tracing model  :                           |        |
                                                            |

が出てきて、無事走る。めでたしめでたし。

その他

lime コマンドはダストオパシティのデータファイルがあるところで動かさないとうまくいかないっぽい。

(以下、2021/08/13 追記)

pylime

pylimeはLIMEのpython wrapper. python2.7しかサポートしていないようなので、例えばpyenvで管理しているなら

pyenv global 2.7.18

とかして、base directoryで

./configure
make pylime

すればよい。ただし、例えば以前に別のバージョンのpython環境で make した場合、パス関係がうまくいかないっぽいので、上のコマンドを実行する前に

make distclean

してください。

続いて、どうも上でインストールしたパッケージのライブラリのディレクトリへのパスが通ってないようなので、base directoryにある pylimerc.sh (cshを使っているなら pylimerc.csh )に、以下を追記。

pylimerc.sh
export LD_LIBRARY_PATH="<path/to/lime/base/directory>/lib"

最後に

. ./pylimerc.sh
source ./pylimerc.sh

すれば、example フォルダに行って、

example
pylime model.py

が以下のようにうまく走ります。

example
*** LIME, The versatile line modeling engine, version 1.9.4+ (master track)
   Building grid: DONE                               

   Smoothing grid: DONE                              

   Molecule: HCO+
   1 collision partner:
      H2
    Model provides: 1 density profile

  Iteration 1 / max 14: Starting
      Statistics: Min(SNR)    0.000                     
      Statistics: Median(SNR) 0.000                     
  Iteration 1 / max 14: DONE

  Iteration 2 / max 14: Starting
      Statistics: Min(SNR)    0.000                     
      Statistics: Median(SNR) 0.000                     
  Iteration 2 / max 14: DONE

  Iteration 3 / max 14: Starting
      Statistics: Min(SNR)    0.101                     
      Statistics: Median(SNR) 2.041                     
  Iteration 3 / max 14: DONE
...

参考

0
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
0
0