[ase-users] Castep calculator cell_constraints format question
フォンスポール J
paulfons at keio.jp
Sun May 10 16:19:09 CEST 2020
I am trying to learn how to apply ASE (3.19.1) to CASTEP (19.11) on Mac OS 10.15.4. I have managed to write a program to optimize the Bi primitive cell.
The program seems to work, however, when I try to introduce cell constraints, the program fails.
The correct form for the cell constraints is as below.
%block cell_constraints
|a| |b| |c|
α β γ
%endblock cell_constraints
I have tried introducing the command
calc.cell.cell_constrains = '1 1 1 2 2 2' (This says keep a=b=c and α=β=γ as I have a rhombohedral cell)
but the program fails with the following output:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0
Couldn't fetch number of kpoints from dryrun CASTEP file
Found error in input
ERROR: cell_read - CELL_CONSTRAINTS for formatted correctly
Current trace stack:
cell_read_wrapped
castep
What is the correct format for cell_constraints? Thanks for any help in advance.
Note that the internal documentation echos this:
In [7]: calc.cell.cell_constraints?
Type: CastepOption
String form: Option: cell_constraints[unset](Block, Basic)
File: ~/opt/anaconda3/lib/python3.7/site-packages/ase/calculators/castep.py
Docstring:
A list of constraints on the unit cell parameters used in a geometry optimisation or molecular dynamics simulation. Example:
%block cell_constraints
1 1 3 ! a=b can vary but tied equal, c free to vary
0 0 0 ! Fix alpha, beta and gamma
%endblock cell_constraints
Below is the program source.
import ase
from ase.calculators import castep
import ase.io.castep
from ase import Atoms
from ase.io import read, write
# define Bi primitive cell
a = 4.81833
alpha = 56.94372
# prepare atom
Bi = Atoms(['Bi','Bi'], positions=[[0.231989,0.231989,0.231989],[0.768011,0.768011,0.768011]], cell = [a,a,a,alpha,alpha,alpha], pbc=[True,True,True], calculator = castep)
calc = ase.calculators.castep.Castep()
directory = 'CASTEP_Bi'
Bi.set_calculator(calc)
# include interface settings in .param file
calc._export_settings = True
# reuse the same directory
calc._directory = directory
calc._rename_existing_dir = False
calc._label = 'Bi_PBE'
# necessary for tasks with changing positions
# such as GeometryOptimization or MolecularDynamics
calc.param.task = 'GeometryOptimization'
# Param settings
calc.param.xc_functional = 'PBE'
calc.param.cut_off_energy = 450
calc.param.fix_occupancy = False
calc.param.elec_energy_tol = 1E-10
calc.param.geom_force_tol = 0.001
calc.param.geom_max_iter = 100
# Prevent CASTEP from writing *wvfn* files
calc.param.num_dump_cycles = 0
# Cell settings
calc.cell.kpoint_mp_grid = '10 10 10'
calc.cell.fix_com = False
calc.cell.fix_all_cell = False
#calc.cell.cell_constraints = '1 1 1 2 2 2'
# Check for correct input
if calc.dryrun_ok():
print("Potential Energy: %12.6f" % ( Bi.get_potential_energy()))
else:
print("Found error in input")
print(calc._error)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20200510/cfd5a9f5/attachment-0001.html>
More information about the ase-users
mailing list