ASE on your local PC
2025年7月11日 更新
ここで利用しているファイルはCrySPY_utility/examples/ase_Cu8Au8_EAからダウンロードできる. このチュートリアルでは,計算が軽いASEのPure Python EMT calculatorを用いてローカルPCで動作確認を行う.対象となるシステムはCu8Au8.
cryspy.in
cryspy.in
の例.
[basic]
algo = EA
calc_code = ASE
nstage = 1
njob = 5
jobcmd = zsh
jobfile = job_cryspy
[structure]
atype = Cu Au
nat = 8 8
[EA]
n_pop = 10
n_crsov = 5
n_perm = 2
n_strain = 2
n_rand = 1
n_elite = 1
n_fittest = 5
slct_func = TNM
t_size = 2
maxgen_ea = 0
[ASE]
ase_python = ase_in.py
[option]
algo = EA
を使用.- bash環境では
jobcmd
をbashに変更. - EAでは
tot_struc
は使用しない.構造数はn_pop
で決まる. n_pop
=n_crsov
+n_perm
+n_strain
+n_rand
- [EA]セクションのパラメータについては,入力ファイル > [EA] sectionおよび探索アルゴリズム > 進化的アルゴリズム(EA)を見ること.
calc_in/
calc_in/以下はチュートリアル > ランダムサーチ(RS) > ASE in your local PCと同様
calc_in/ase_in.py
from ase.constraints import FixSymmetry
from ase.filters import FrechetCellFilter
from ase.calculators.emt import EMT
from ase.optimize import BFGS
from ase.io import read, write
# ---------- input structure
# CrySPY outputs 'POSCAR' as an input file in work/xxxxxx directory
atoms = read('POSCAR', format='vasp')
# ---------- setting and run
atoms.calc = EMT()
atoms.set_constraint([FixSymmetry(atoms)])
cell_filter = FrechetCellFilter(atoms, hydrostatic_strain=False)
opt = BFGS(cell_filter)
# ---------- run
converged = opt.run(fmax=0.01, steps=2000)
# ---------- rule in ASE interface
# output file for energy: 'log.tote' in eV/cell
# CrySPY reads the last line of 'log.tote' file
# outimized structure: 'CONTCAR' file in vasp format
# check_opt: 'out_check_opt' file ('done' or 'not yet')
# CrySPY reads the last line of 'out_check_opt' file
# ------ energy
e = cell_filter.atoms.get_total_energy() # eV/cell
with open('log.tote', mode='w') as f:
f.write(str(e))
# ------ struc
opt_atoms = cell_filter.atoms.copy()
opt_atoms.set_constraint(None) # remove constraint for pymatgen
write('CONTCAR', opt_atoms, format='vasp', direct=True)
# ------ check_opt
with open('out_check_opt', mode='w') as f:
if converged:
f.write('done\n')
else:
f.write('not yet\n')
calc_in/job_cryspy
#!/bin/sh
# ---------- ASE
python3 ase_in.py > out.log