結晶構造の鳥瞰図投影動画作成

現行の Apple Silicon / macOS / AppleScript では,門馬・泉の作成した VESTA3 のユーザ操作を記録をすることが困難らしい。以下の方法で結晶構造の鳥瞰図 (bird’s eye view) 動画を作成することを試みた。

閲覧者の嗜好によると思われるが,結晶構造投影図を回転させる動画を見せられるとき,幾何学的な対称軸(正方晶・六方晶・菱面体晶の六方晶表現の場合の c 軸,単斜晶の場合の b 軸など)を回転軸として「斜め上」から見下ろした投影図(鳥瞰図)を見せられることが好ましい。

以下のリンクに示す動画は NIST の標準試料として頒布(はんぷ)された SRM660 シリーズの六硼化ランタンについて以下の手順で作成した。ICDD データベースから *.cif (crystallographic information format) ファイルを作成した。*.cif ファイルを VESTA3 で読み込み,*.vesta ファイルを作成した。

https://takashiida.net/wp-content/uploads/2025/12/LaB6.mp4

(1) 以下のように *.vesta ファイルの中の SCENE セクションのみを書き換えて保存するPython コードを作成した。

################################################################################
# rotate_vesta.py
# Coded by T. Ida, Dec. 12, 2025
# Modified by T. Ida, Dec. 12, 2025
################################################################################
import numpy as np
vesta_name = 'LaB6.vesta' # 元の VESTA ファイル名
deg_dep,deg_rot = 5,5 # 俯角と回転角 (deg.)
n = int(360/deg_rot) # フレーム数
f = open(vesta_name,'r') # VESTA ファイルを開く
lines = f.readlines() # VESTA ファイルを読み込む
f.close() # VESTA ファイルを閉じる
scene_index = -1 # 
scene_matrix = np.empty((4,4),dtype=float)
for line in lines:
    if (0 <= scene_index and scene_index < 4):
        print('scene line : ',line,end="")
        data_array = np.fromstring(line,dtype=float,sep=' ')
        scene_matrix[scene_index] = data_array
        scene_index += 1
    if line.startswith("SCENE"):
        print('SCENE')
        scene_index = 0
dep = deg_dep*np.pi/180
cosD,sinD = np.cos(dep),np.sin(dep)
D = np.array([[1,0,0,0],[0,cosD,-sinD,0],[0,sinD,cosD,0],[0,0,0,1]])
for i in range(n):
    file_name = f'{i:03d}.vesta'
    rot = i*deg_rot*np.pi/180
    cosR,sinR = np.cos(rot),np.sin(rot)
    R = np.array([[cosR,0,sinR,0],[0,1,0,0],[-sinR,0,cosR,0],[0,0,0,1]])
    scene = D @ R @ scene_matrix
    scene_index = -1
    lines1 = []
    for line in lines:
        if (0 <= scene_index and scene_index < 4):
            d0 = scene[scene_index][0]
            d1 = scene[scene_index][1]
            d2 = scene[scene_index][2]
            d3 = scene[scene_index][3]
            line1 = f'{d0:9.6f} {d1:9.6f} {d2:9.6f} {d3:9.6f}\n'
            lines1 += [line1]
            scene_index += 1
        else:
            lines1 += [line]
        if line.rstrip() == "SCENE":
            scene_index = 0
    if (i == 1):
        print('D = ',D)
        print('R = ',R)
        print('scene_matrix = ',scene_matrix)
        print('scene = ',scene)
        print(lines1)
    with open(file_name,'w',encoding='utf-8') as f:
        f.writelines(lines1)

上記の Python コードは Anaconda / Jupyter Notebook システムで実行できる。

上記の Python スクリプトで作成される 72 個の *.vesta ファイルをすべて同時に VESTA で開く。

[command]+[shift ↑]+[5] のキー操作でスクリーンショット撮影範囲を選び「オプション▼」ポップダウンメニューで画像の保存先(任意のサブフォルダ)を選び [return ↩︎] キー操作で画像を保存する。[control]+[W] のキー操作で表示されているタブを閉じる。

以降は [command]+[shift ↑]+[5] のキー操作と[return ↩︎] キー操作,[control]+[W] のキー操作を 71 回繰り返す。

QuickTime Player の「ファイル」メニューから,「画像シーケンスを開く…」項目を選択し,指定した画像保存先フォルダ中の 72 個のファイルを [command]+{A] キー操作で全選択する。

作成された動画ファイルを「互換性を優先」(H.264) として保存する。作成される *.mov ファイルは,現在有力なプレゼンテーション・ソフトウェアである Microsoft PowerPoint の「クラウド版」では表示できないかもしれないが,「ダウンロード版」では表示できるようである。


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *