-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFind_TSs.m
72 lines (66 loc) · 2.38 KB
/
Find_TSs.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
function [ts]=Find_TSs(locals,model)
%==========================================================================
% Find transition points and label the SEPs
% 1. Find transition points
% 2. Determine the optimal cutting level for making K clusters
% 3. Construct an adjacent matrix
%
% ts.x [N x dim] transition points
% ts.f [N x 1] squared radius on the TS points
% ts.neighbor [N x 2] index of neighbor SEPs
% ts.purturb [N x 2*dim] purturbed points from the TS
%
%==========================================================================
% January 13, 2009
% Implemented by Daewon Lee
% WWW: http://sites.google.com/site/daewonlee/
%==========================================================================
epsilon=model.options.epsilon;
R=model.r+10^(-7);
options = optimset('LargeScale','on','Display','off','GradObj','on','Hessian','on');
options2 = optimset('Jacobian','on','LargeScale','on','Display','off');
% ts matrix
ts.x=[]; % transition states
ts.f=[]; % f value in x
ts.neighbor=[]; % index of two neighbor local mins;
ts.purturb=[];
[N,attr]=size(locals);
tmp_x=[];
% Find all corresponding equilibrium points for points sampled from
% lines between pairs of SEPs.
for i=1:N
for j=i:N
for k=1:10
x0=locals(i,:)+0.1*k*(locals(j,:)-locals(i,:));
[sep]= fsolve(@fsolve_R,x0,options2,model);
tmp_x=[tmp_x;sep];
end
end
end
[dummy,I,J]=unique(round(tmp_x*10),'rows');
tmp_x=tmp_x(I,:);
for i=1:size(tmp_x,1)
sep=tmp_x(i,:);
[f,g,H]=my_R(sep,model);
[V,D]=eig(H);
if sum(diag(D)<0)==1 % find index-1 transition states
sep1=sep+epsilon*V(:,find(diag(D)<0))';
sep2=sep-epsilon*V(:,find(diag(D)<0))';
if attr==2
[temp1, val]=fminsearch(@my_R,sep1,[],model);
[temp2, val]=fminsearch(@my_R,sep2,[],model);
else
[temp1, val]=fminunc(@my_R,sep1,options,model);
[temp2, val]=fminunc(@my_R,sep2,options,model);
end
[dummy,ind1]=min(dist2(temp1,locals));
[dummy,ind2]=min(dist2(temp2,locals));
if ind1~=ind2
% find transition states and ther neighbor local mins
ts.x=[ts.x;sep];
ts.f=[ts.f;f];
ts.neighbor=[ts.neighbor;ind1 ind2];
ts.purturb=[ts.purturb;sep1 sep2];
end
end
end