半径Rの構造クラスターをASEで作る。
例として単体アルミニウムを使う。
import math from ase.spacegroup import crystal from ase.visualize import view # parameters LC = 4.05 R = 7. NSL = math.ceil( 2. * R / LC ) # make bulk structure aluminium = crystal( 'Al', [ ( 0, 0, 0 ) ], spacegroup=225, cellpar=[ LC, LC, LC, 90, 90, 90 ] ) al_sc = aluminium.repeat( ( NSL, NSL, NSL ) ) # super cell # cut to make sphere v_com = al_sc.get_center_of_mass() al_sc.translate( v_com ) al_sc.wrap() # take outside atoms into unit cell by periodic boundary condition distances = al_sc.get_all_distances()[0] # distances from the atom at the origin del al_sc[ [ i for i, dis in enumerate( distances ) if dis > R ] ] al_sc.translate( - v_com ) view(al_sc)
ここでは原点の原子を中心として構造クラスターを得るようにしている。
unit cell の重心は atoms.get_center_of_mass() ですぐ求まるし、距離もatoms.get_all_distances()で丸ごと求まる。
atoms.wrap()は unit cell の外側にある原子を周期的境界条件で内側に入れ込むというもの。
atoms.translate( xyz ) だけでは、ただ並進移動するだけで、unit cell の外側に原子がはみ出たままになる。
この状態でwrap をしないと、del で不要な原子を除いた時に形がおかしくなる。
最後は一応、元の原点に戻るようにしている。