-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_cutoff_energies_radius.py
More file actions
executable file
·53 lines (38 loc) · 1.54 KB
/
find_cutoff_energies_radius.py
File metadata and controls
executable file
·53 lines (38 loc) · 1.54 KB
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
# script to read cutoff_radius_energy.txt files generated by my castep_pseudopotential_convergence_test script
# written by Pascal Salzbrenner, pts28@cam.ac.uk
import sys
# get paths to the directories where the two calculations were run as inputs
first_path = sys.argv[1].rstrip("/")
second_path = sys.argv[2].rstrip("/")
# get structure names
first_structure = first_path.split("/")[-1]
second_structure = second_path.split("/")[-1]
# set up dictionaries containing as key-value pairs the cutoff radius and the cutoff energy
first_dict = {}
second_dict = {}
# read info from files
first_file = open("{}/cutoff_radius_energy.txt".format(first_path), "r")
second_file = open("{}/cutoff_radius_energy.txt".format(second_path), "r")
# skip first line (comment line)
first_file.readline()
second_file.readline()
#radius in Bohr is used
for line in first_file:
data = line.split()
first_dict[float(data[0])] = int(data[-1])
for line in second_file:
data = line.split()
second_dict[float(data[0])] = int(data[-1])
first_file.close()
second_file.close()
# set up list for the data for all radii calculated in both structures
common_radii = []
# compare dictionaries
for radius, energy in first_dict.items():
if radius in second_dict.keys():
common_radii.append((radius, energy, second_dict[radius]))
# write out the data
outfile = open("common_calculations_{}_{}_cutoff_radius_energy.txt".format(first_structure, second_structure), "w")
for data in common_radii:
outfile.write("{} {} {}\n".format(data[0], data[1], data[2]))
outfile.close()