Skip to content

Commit

Permalink
align
Browse files Browse the repository at this point in the history
  • Loading branch information
ensemble-learning committed Mar 4, 2017
1 parent 61b9334 commit 28c961c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 298 deletions.
39 changes: 39 additions & 0 deletions lib/align.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Calculated Rotation Matrix to align Vector A to Vector B in 3d using
Rodrigues' rotation formula.
octave code:
v1 = [1 1 1]';
v2 = [0 0 1]';
w = cross(v1,v2);
w = w/norm(w);
w_hat = [0,-w(3),w(2);w(3),0,-w(1);-w(2),w(1),0];
cos_tht = v1'*v2/norm(v1)/norm(v2);
tht = acos(cos_tht);
R = eye(size(v1,1)) + w_hat*sin(tht) + w_hat^2*(1-cos(tht));
t1 = R*v1;
t1 = t1/norm(t1)*norm(v2);
"""
import math
import numpy as np

def align_axis(v1, v2):
w = np.cross(v1,v2)
w = w/np.linalg.norm(w)
w_hat = np.matrix([[ 0, -w[2], w[1]],
[ w[2], 0, -w[0]],
[-w[1], w[0], 0]])
cos_tht = np.dot(v1, v2)/np.linalg.norm(v1)/np.linalg.norm(v2)
tht = np.arccos(cos_tht)
R = np.identity(3) + w_hat*np.sin(tht) + w_hat*w_hat*(1-np.cos(tht))
return R

def test():
v1 = np.array([1.0, 1.0, 1.0])
v2 = np.array([0.0, 0.0, 1.0])
R = align_axis(v1, v2)
print R

if __name__ == "__main__":
test()
297 changes: 0 additions & 297 deletions lib/tt

This file was deleted.

2 changes: 1 addition & 1 deletion tools/vasp/get_potcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"Br":"Br", "D": "H", "Si": "Si", "Ni": "Ni", "Pt":"Pt_pv", "Co":"Co", "Cr":"Cr",
"I":"I", "K":"K_pv", "F":"F", "W":"W", "Au":"Au", "Cs":"Cs_sv", "Mg":"Mg",
"Ag":"Ag", "Se":"Se", "B":"B", "He":"He", "Ar":"Ar", "Xe":"Xe", "Kr":"Kr",
"Mo": "Mo",}
"Mo": "Mo", "Fe": "Fe",}

if socket.gethostname() == "cluster.hpc.org":
POT_DATA_BASE = "/project/source/VASP/vasp.5.3.5/potcar/potpaw_PBE"
Expand Down

0 comments on commit 28c961c

Please sign in to comment.