xtalgrowth -- 2次元結晶成長シミュレーション

xtalgrowthは2次元結晶成長をシミュレートするXアプリケーションです。 xtalgrowthを起動すると、画面の上からランダムに剛体球が落ちてきて画面 の底に降り積もり、2次元の結晶が成長します。コマンドラインオプションで 計算条件を変更することができます。図1のような賞状の形をした計算結果が PostScriptファイルとして標準出力 (stdout) から出力されます。 オープンキャンパスや研究所の一般公開の来場者参加型の展示物に適しています。 xtalgrowthはLinuxやmacOSなどのUNIX系のコンピュータで動く フリーソフトウエアです。

使用方法:

$ xtalgrowth --help
$ xtalgrowth -d 0.033 -c 3
$ xtalgrowth -d 0.033 -c 2
$ xtalgrowth -d 0.010 -c 1
$ xtalgrowth -g 'Mr. Takeshi Nishimatsu' | lpr

賞状が必要な場合はカレントディレクトリにパッケージに同梱されているような certification.eps を置いてください。賞状のタイトルとして使われ、-g オプションで指定した名前と今日の日付が賞状に入ります。 (-gオプションで指定した文字列は疑似乱数の生成のための種としても使われます。)

Linuxで印刷がうまくいかないときは、次のようにgs(1)コマンドを間に入れると正常に印刷できるることがあります:

$ xtalgrowth [オプション...] | gs -q -sDEVICE=pswrite -sOutputFile=- -dNOPAUSE -dBATCH - | lpr

macOSで印刷がうまくいかない場合は、lprに-lオプションを付けると正常に印刷できるることがあります:

$ xtalgrowth [オプション...] | lpr -l
figures/example.jpg
図1 xtalgrowthによって出力される賞状の例。 名前と今日の日付が入ります。

Contents:

ホームページとダウンロード

xtalgrowthのホームページは http://loto.sourceforge.net/xtalgrowth/ です。 最新のtar.gzパッケージ (xtalgrowth-X.Y.Z.tar.gz) を http://sourceforge.net/projects/loto/files/xtalgrowth/ からダウンロードすることができます。

コンパイルおよびインストールの方法

コンパイルには

が必要です。必要なものがそろっていれば

$ tar xf xtalgrowth-X.Y.Z.tar.gz
$ cd xtalgrowth-X.Y.Z
$ ./configure
$ make

とすることで src/xtalgrowth ができるはずです。

$ cd src
$ ./xtalgrowth --help
$ ./xtalgrowth

と試しに実行してみましょう。 さらに /usr/local/bin/xtalgrowth をインストールしたい場合は

$ sudo make install
$ make installcheck

としてください。

macOSにXQuartzでX Serverをインストールしている場合は

$ ./configure CPPFLAGS=-I/opt/X11/include LDFLAGS=-L/opt/X11/lib

と、さらにpoptライブラリをMacPorstsでインストールしている場合は

$ ./configure CPPFLAGS='-I/opt/X11/include -I/opt/local/include' LDFLAGS='-L/opt/X11/lib -L/opt/local/lib'

などとCPPFLAGSとLDFLAGSを調節してください。

シミュレーションの計算条件と結果

x方向(箱の幅方向)は周期的境界条件です。 球と球とが接したかどうかの計算とその後の軌道計算が大雑把です。 この大雑把な計算精度が「乱雑さ」として表れます。

基板は球を等間隔に並べています。そのため、球の大きさがキツキツだと きれいに並ばないことが多くなります:

$ xtalgrowth -d 0.033333

球の直径 (diameter) は箱の幅に対する比で与えます。 球の大きさにゆとりを与え、「落下速度」を遅くすると、きれいに並ぶことが多くなります:

$ xtalgrowth -d 0.033 -v 0.0001

-cオプションで球が動かなくなる条件を変えることができます。 3つ以上の球と接したら動かなくなるようにすると、きれいに並ぶことが多くなります:

$ xtalgrowth -d 0.033 -c 3

2つ以上の球と接したら動かなくなるようにすると、空孔ができやすくなります:

$ xtalgrowth -d 0.033 -c 2

1つでも球と接したら動かなくなるようにすると、フラクタル的になります(参考文献[1]):

$ xtalgrowth -d 0.010 -c 1

-gオプションで指定した名前が入った賞状が標準出力からPostScriptファイルとして出力されます。 また、-gオプションで指定した文字列をhashpjw.cで2つの整数に変換して、 その2つの整数を種としてuni64.cで疑似乱数を生成しています(参考文献[4,5])。

$ xtalgrowth -g 'Mr. Takeshi Nishimatsu' > takeshi.ps

なお、コンパイル時にpoptライブラリを使っていれば

$ xtalgrowth --help

でコマンドラインオプションを調べることができます。

figures/xtals.jpg
図2 3通りのコマンドラインオプションとともにxtalgrowthを実行して得られる結晶。

展示方法

500MHzくらいのCPUのパソコンで実行すると球が落ちてくる様子が観察しやすいです。

来場者参加型の展示としては図3と図4のような模型とともに展示するとよいかもしれません。

figures/large.jpg
図3 2枚のアクリル板の間に直径6mmのBB弾(おもちゃのピストルの弾丸)をはさんだもの。 格子欠陥の伝播などが観察できます。
figures/cd.jpg
図4 音楽CDのケースにBB弾をはさんだもの。 手軽に工作できます。大きさの比較のため十円玉を脇に置いてあります。

参考文献

[1] Jean-François Gouyet, Michel Rosso and Bernard Sapoval: "Fractal surfaces and interfaces" in the book of "Fractals and disordered systems" edited by Armin Bunde and Shlomo Havlin, pp. 229-261 (1991), ISBN:0-387-54070-9, Springer-Verlag New York.

[2] Lawrence Bragg and J. F. Nye: "A Dynamical Model of a Crystal Structure", Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences, Vol. 190, No. 1023, pp. 474-481 (Sep. 9, 1947). You can get a free PDF of this article from doi:10.1098/rspa.1947.0089.

[3] Lawrence Bragg and W. M. Lomer: "A Dynamical Model of a Crystal Structure. II", Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences, Vol. 196, No. 1045, pp. 171-181 (Mar. 22, 1949). You can get a free PDF of this article from doi:10.1098/rspa.1949.0022.

[4] Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman: "Compilers: Principles, Techniques, and Tools" (1986), ISBN:0-201-10088-6, Addison Wesley, a.k.a. the Dragon Book.

[5] George Marsaglia and Wai Wan Tsang: "The 64-bit universal RNG", Statistics & Probability Letters, Vol. 66, pp. 183-187 (15 January 2004), doi:10.1016/j.spl.2003.11.001. Note that a part of code in the bottom of p.186, "y=(8888*x)%65579;" should be replaced by "y=(8888*y)%65579;". Consequently, 5 values of "The correct output" in p.187 are incorrect. See http://sci4um.com/about16220-asc.html .

ソースコードリポジトリ、作者そしてソフトウエアの再配布について

https://github.com/t-nissie/xtalgrowthxtalgrowth のソースコードリポジトリです。 例えば、https://github.com/t-nissie/xtalgrowth/blob/master/index.ja.html であなたはこのドキュメントを編集して、プルリクエストを送ることができます。

作者:西松毅 (t_nissie{at}yahoo.co.jp)

Copyright © 2009-2024 by Takeshi Nishimatsu

xtalgrowth is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. You can copy, modify and redistribute xtalgrowth, but only under the conditions described in the GNU General Public License (the "GPL"). For more detail, see COPYING.

本ソフトウエアの開発方法

開発にはGNU Autotoolsが必要です。

開発の手順は次の通りです:

$ git clone https://github.com/t-nissie/xtalgrowth.git
$ cd xtalgrowth
$ autoreconf -v
$ automake --add-missing
$ autoreconf -v            # ☆
$ ./configure
$ make -j9                 # Do development.
$ make check               # Do some tests.
$ make distclean           # Clean up Makefile, etc.
$ ./configure
$ make distcheck           # Check and make a distribution package, xtalgrowth-X.Y.Z.tar.gz.
                           # Give options in DISTCHECK_CONFIGURE_FLAGS.

$ make clean
$ cmake -G Ninja .         # You can also use CMake.
$ cmake -LA .
$ ninja
$ ninja test

新たにconfigure.ac, Makefile.am, src/Makefile.amを書き変えたら☆からやり直す。 実際は☆からやり直さずとも、Makefile に依存関係が書き込まれているので、 make だけで Makefile そのものがうまい具合に更新される。

xtalgrowthではCMake用の src/CMakeLists.txt は src/CMakeLists.txt.in から configure が生成する。 より正確には config.status が生成する。

Acknowledgements

http://loto.sourceforge.net/xtalgrowth/ is hosted by SourceForge.net Logo .