-
Notifications
You must be signed in to change notification settings - Fork 2
/
interpolate_poscar.m
executable file
·35 lines (28 loc) · 1.13 KB
/
interpolate_poscar.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [ status ] = interpolate_poscar( filename1, filename2, N )
%INTERPOLATE_POSCAR Interpolate a chain of images between two POSCAR files.
% status = interpolate_poscar(filename1,filename2,N) interpolates a chain
% of N images between two POSCAR files. The interpolated geometries are
% placed in 00/POSCAR, 01/POSCAR ... N+1/POSCAR. This is useful for
% setting up NEB calculations.
%
% See also PERMUTE_COORDS.
[ geo1 ] = import_poscar( filename1 );
[ geo2 ] = import_poscar( filename2 );
if sum(sum(geo1.lattice~=geo2.lattice))~=0
fprintf('Warning: lattice parameters are not equal.');
end
if sum(geo1.atomcount)~=sum(geo2.atomcount)
error('Atom counts not equal.');
end
shift = geo2.coords - geo1.coords;
shift = shift + repmat([0.5 0.5 0.5], sum(geo1.atomcount), 1);
shift = mod(shift,1) - repmat([0.5 0.5 0.5], sum(geo1.atomcount), 1);
geo = geo1;
for i = 0:(N+1)
w = i/(N+1);
geo.coords = geo1.coords + w*shift;
dir = sprintf('%02d',i);
mkdir(dir);
status = export_poscar( [dir '/POSCAR'], geo );
end
end