-
Notifications
You must be signed in to change notification settings - Fork 0
/
recording_magnetostriction.py
58 lines (40 loc) · 2.01 KB
/
recording_magnetostriction.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python
# -*- coding: utf-8 -*-
import numpy as np
import os
import subprocess
import shutil
def toFixed(f, n=0):
a, b = str(f).split('.')
return '{}.{}{}'.format(a, b[:n], '0'*(n-len(b)))
Name = 'FeGa'
EPSILON_Z = np.array([-0.015, -0.010, -0.005, 0.0, 0.005, 0.010, 0.015])
# Считываем вектора трансляций и пааметр решетки #
f = open('POSCAR',"r")
lines = f.readlines()
f.close()
primitive_vectors = np.array([[float(lines[2].split()[0]), float(lines[2].split()[1]), float(lines[2].split()[2])],
[float(lines[3].split()[0]), float(lines[3].split()[1]), float(lines[3].split()[2])],
[float(lines[4].split()[0]), float(lines[4].split()[1]), float(lines[4].split()[2])]])
a0 = float(lines[1].split()[0])
V0 = primitive_vectors[0,0]*a0 * primitive_vectors[1,1]*a0 * primitive_vectors[2,2]*a0
os.mkdir('Distortion')
for ez in EPSILON_Z:
os.mkdir('Distortion/' + str(ez))
T = np.array([[1-0.5*ez, 0, 0],
[0,1 -0.5*ez, 0],
[0, 0, 1 + ez]])
newcell = np.dot(primitive_vectors, T)
V = newcell[0,0]*a0 * newcell[1,1]*a0 * newcell[2,2]*a0
#print V0, V
lines[2] = toFixed(newcell[0,0], 5) + ' ' + toFixed(newcell[0,1], 5) + ' ' + toFixed(newcell[0,2], 5) + '\n'
lines[3] = toFixed(newcell[1,0], 5) + ' ' + toFixed(newcell[1,1], 5) + ' ' + toFixed(newcell[1,2], 5) + '\n'
lines[4] = toFixed(newcell[2,0], 5) + ' ' + toFixed(newcell[2,1], 5) + ' ' + toFixed(newcell[2,2], 5) + '\n'
file = open('Distortion/' + str(ez) + '/POSCAR', "wb")
for line in lines:
file.write(line)
file.close()
shutil.copyfile(os.getcwd()+'/POTCAR', 'Distortion/' + str(ez) + '/POTCAR')
shutil.copyfile(os.getcwd()+'/KPOINTS', 'Distortion/' + str(ez) + '/KPOINTS')
shutil.copyfile(os.getcwd()+'/INCAR', 'Distortion/' + str(ez) + '/INCAR')
shutil.copyfile(os.getcwd()+'/vasp_qsub_1', 'Distortion/' + str(ez) + '/vasp_qsub_1')