-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlattice-checker.m
164 lines (135 loc) · 5.65 KB
/
lattice-checker.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
function abcf = lattice_checker(film_file, substrate_file)
%Lattice Checker Program, inputs two files of lists of names, crystal groups and lattice constants, and outpus fixes within tol mistmach
%Written by Gabriel A. Devenyi
%August 10, 2013
tol = 8;
%command_line=argv();
%film_file = command_line(1,1);
%substrate_file = command_line(2,1);
fid = fopen (substrate_file, 'r');
i = 1;
sub_name = char(zeros(10,100));
sub_type = char(zeros(1,100));
while (~feof(fid))
[a, sub_type(i), sub_a(i), sub_c(i)] = fscanf (fid, '%s %s %f %f', 'C');
sub_name(i,1:length(a)) = a;
i=i+1;
end
fclose (fid);
fid = fopen (film_file, 'r');
i = 1;
film_name = char(zeros(10,100));
film_type = char(zeros(1,100));
while (~feof(fid))
[a, film_type(i), film_a(i), film_c(i)] = fscanf (fid, '%s %s %f %f', 'C');
film_name(i,1:length(a)) = a;
i = i + 1;
end
fclose (fid);
disp(sprintf('Film,Symmetry,Substrate,Symmetry,Mismatch(%%),Rounded Ratio,Original Ratio'));
%Iterate through Substrates
for i=1:length(sub_a)
%Iterate through Films
for j=1:length(film_a)
if (strtrim(film_name(j,:)) == strtrim(sub_name(i,:)))
continue;
end
%Cubic on Cubic Check
if (film_type(j) == 'C' && sub_type(i) == 'C')
original_ratio = sub_a(i)/film_a(j);
if (original_ratio < 1)
ratio = 1/round(1/original_ratio);
else
ratio = round(original_ratio);
end
%(sub_a(i) - ratio*film_a(j))/(ratio*film_a(j)) * 100;
(ratio*film_a(j) - sub_a(i)) / sub_a(i) *100;
if (abs(ans) < tol)
disp(sprintf('%s,C,%s,C,%g,%g,%g',strtrim(film_name(j,:)), strtrim(sub_name(i,:)), ans, ratio, original_ratio));
end
end
%Cubic on Hexagonal
if (film_type(j) == 'C' && sub_type(i) == 'H')
original_ratio = sub_a(i)/(film_a(j)*sqrt(2));
if (original_ratio < 1);
ratio = 1/round(1/original_ratio);
else
ratio = round(original_ratio);
end
%(sub_a(i) - ratio*film_a(j)*sqrt(2))/(ratio*film_a(j)*sqrt(2)) * 100;
(ratio*film_a(j)*sqrt(2) - sub_a(i)) / sub_a(i) * 100;
if (abs(ans) < tol)
disp(sprintf('%s,C,%s,H,%g,%g,%g',strtrim(film_name(j,:)), strtrim(sub_name(i,:)), ans, ratio, original_ratio));
end
end
%Tetragonal on Cubic Check
if (film_type(j) == 'T' && sub_type(i) == 'C')
original_ratio = sub_a(i)/film_a(j);
if (original_ratio < 1)
ratio = 1/round(1/original_ratio);
else
ratio = round(original_ratio);
end
%(sub_a(i) - ratio*film_a(j))/(ratio*film_a(j)) * 100;
(ratio*film_a(j) - sub_a(i)) / sub_a(i) *100;
if (abs(ans) < tol)
disp(sprintf('%s,T,%s,C,%g,%g,%g',strtrim(film_name(j,:)), strtrim(sub_name(i,:)), ans, ratio, original_ratio));
end
end
%Hexagonal on Hexagonal Check
if (film_type(j) == 'H' && sub_type(i) == 'H')
original_ratio = sub_a(i)/film_a(j);
if (original_ratio < 1)
ratio = 1/round(1/original_ratio);
else
ratio = round(original_ratio);
end
%(sub_a(i) - ratio*film_a(j))/(ratio*film_a(j)) * 100;
(ratio*film_a(j) - sub_a(i)) / sub_a(i) *100;
if (abs(ans) < tol)
disp(sprintf('%s,H,%s,H,%g,%g,%g',strtrim(film_name(j,:)), strtrim(sub_name(i,:)), ans, ratio, original_ratio));
end
end
%Hexagonal on Cubic Check
if (film_type(j) == 'H' && sub_type(i) == 'C')
original_ratio = (sub_a(i)*sqrt(2))/film_a(j);
if (original_ratio < 1)
ratio = 1/round(1/original_ratio);
else
ratio = round(original_ratio);
end
%(sub_a(i)*sqrt(2) - ratio*film_a(j))/(ratio*film_a(j)) * 100;
(ratio*film_a(j) - sub_a(i)*sqrt(2))/(sub_a(i)*sqrt(2)) * 100;
if (abs(ans) < tol)
disp(sprintf('%s,H,%s,C,%g,%g,%g',strtrim(film_name(j,:)), strtrim(sub_name(i,:)), ans, ratio, original_ratio));
end
end
%Cubic on Tetragonal Check
if (film_type(j) == 'C' && sub_type(i) == 'T')
original_ratio = (sub_a(i))/film_a(j);
if (original_ratio < 1)
ratio = 1/round(1/original_ratio);
else
ratio = round(original_ratio);
end
(sub_a(i) - ratio*film_a(j))/(ratio*film_a(j)) * 100;
if (abs(ans) < tol)
disp(sprintf('%s,C,%s,T,%g,%g,%g',strtrim(film_name(j,:)), strtrim(sub_name(i,:)), ans, ratio, original_ratio));
end
end
%Tetragonal on Tetragonal Check
if (film_type(j) == 'T' && sub_type(i) == 'T')
original_ratio = (sub_a(i))/film_a(j);
if (original_ratio < 1)
ratio = 1/round(1/original_ratio);
else
ratio = round(original_ratio);
end
%(sub_a(i) - ratio*film_a(j))/(ratio*film_a(j)) * 100;
(ratio*film_a(j) - sub_a(i)) / sub_a(i) *100;
if (abs(ans) < tol)
disp(sprintf('%s,T,%s,T,%g,%g,%g',strtrim(film_name(j,:)), strtrim(sub_name(i,:)), ans, ratio, original_ratio));
end
end
end
end