예제 #1
0
def test_abc():
    # Should get out params back
    a = 9.5
    b = 8.6
    c = 5.2
    alp = 90.000
    bet = 106.239525
    gam = 90.000
    tmpcell = gs.cellABC2cellCART(a, b, c, alp, bet, gam)
    a_out = np.linalg.norm(tmpcell[0])
    b_out = np.linalg.norm(tmpcell[1])
    c_out = np.linalg.norm(tmpcell[2])
    alp_out = np.degrees(
        np.arccos(
            np.dot(tmpcell[1], tmpcell[2]) /
            (np.linalg.norm(tmpcell[1]) * np.linalg.norm(tmpcell[2]))))
    bet_out = np.degrees(
        np.arccos(
            np.dot(tmpcell[0], tmpcell[2]) /
            (np.linalg.norm(tmpcell[0]) * np.linalg.norm(tmpcell[2]))))
    gam_out = np.degrees(
        np.arccos(
            np.dot(tmpcell[0], tmpcell[1]) /
            (np.linalg.norm(tmpcell[0]) * np.linalg.norm(tmpcell[1]))))
    npt.assert_almost_equal(a_out, a)
    npt.assert_almost_equal(b_out, b)
    npt.assert_almost_equal(c_out, c)
    npt.assert_almost_equal(alp_out, alp)
    npt.assert_almost_equal(bet_out, bet)
    npt.assert_almost_equal(gam_out, gam)
예제 #2
0
def test_abc(a, b, c, alp, bet, gam):
    tmpcell = gs.cellABC2cellCART (a, b, c, alp, bet, gam)
    a_out = np.linalg.norm(tmpcell[0])
    b_out = np.linalg.norm(tmpcell[1])
    c_out = np.linalg.norm(tmpcell[2])
    alp_out = np.degrees(np.arccos(np.dot(tmpcell[1],tmpcell[2])/(np.linalg.norm(tmpcell[1])*np.linalg.norm(tmpcell[2]))))
    bet_out = np.degrees(np.arccos(np.dot(tmpcell[0],tmpcell[2])/(np.linalg.norm(tmpcell[0])*np.linalg.norm(tmpcell[2]))))
    gam_out = np.degrees(np.arccos(np.dot(tmpcell[0],tmpcell[1])/(np.linalg.norm(tmpcell[0])*np.linalg.norm(tmpcell[1]))))
    npt.assert_almost_equal(a_out,a)
    npt.assert_almost_equal(b_out,b)
    npt.assert_almost_equal(c_out,c)
    npt.assert_almost_equal(alp_out,alp)
    npt.assert_almost_equal(bet_out,bet)
    npt.assert_almost_equal(gam_out,gam)
예제 #3
0
def test_cell():
    # Should not end up rotates
    incell = [[9.1209595, 0., -2.65670807], [0., 8.6, 0.], [0., 0., 5.2]]
    a, b, c, al, be, ga = gs.cellCART2cellABC(incell)
    outcell = gs.cellABC2cellCART(a, b, c, al, be, ga)
    npt.assert_almost_equal(incell, outcell)
예제 #4
0
def rot_cell(incell):
    a, b, c, al, be, ga = gs.cellCART2cellABC(incell)
    outcell = gs.cellABC2cellCART(a, b, c, al, be, ga)
    return outcell
예제 #5
0
	outVec = np.transpose(rotMat * np.transpose(np.matrix(inVec)))
	outVec = [outVec[0,0], outVec[0,1], outVec[0,2]]
	return outVec

if __name__ == '__main__':
	import sys
	a = float(sys.argv[1])
	b = float(sys.argv[2])
	c = float(sys.argv[3])
	al = float(sys.argv[4])
	be = float(sys.argv[5])
	ga = float(sys.argv[6])
	inFile = file(sys.argv[7], 'r')	
	Cij_in = np.loadtxt(inFile)
	# Get cart vectors for lattice
	(lat_a, lat_b, lat_c) = cellABC2cellCART(a, b, c, al, be, ga)
	print "initial lattice vectors:"
	print lat_a
	print lat_b
	print lat_c
	# rotate by 90 - gamma around z to put b on y axis
	angle = -1.0 * np.radians(90 - ga) 
	lat_a = rotVec(lat_a, 2, angle)
	lat_b = rotVec(lat_b, 2, angle)
	lat_c = rotVec(lat_c, 2, angle)
	Cij = rotCij(Cij_in, 2, angle)
	print "after rotating around z:"
	print lat_a
	print lat_b
	print lat_c
	print Cij
예제 #6
0
def test_cell (incell):
    a, b, c, al, be, ga = gs.cellCART2cellABC (incell)
    outcell = gs.cellABC2cellCART (a, b, c, al, be, ga)
    npt.assert_almost_equal(incell, outcell)
예제 #7
0
def rot_cell(incell):
    a, b, c, al, be, ga = gs.cellCART2cellABC (incell)
    outcell = gs.cellABC2cellCART (a, b, c, al, be, ga)
    return outcell
예제 #8
0
    outVec = [outVec[0, 0], outVec[0, 1], outVec[0, 2]]
    return outVec


if __name__ == '__main__':
    import sys
    a = float(sys.argv[1])
    b = float(sys.argv[2])
    c = float(sys.argv[3])
    al = float(sys.argv[4])
    be = float(sys.argv[5])
    ga = float(sys.argv[6])
    inFile = file(sys.argv[7], 'r')
    Cij_in = np.loadtxt(inFile)
    # Get cart vectors for lattice
    (lat_a, lat_b, lat_c) = cellABC2cellCART(a, b, c, al, be, ga)
    print "initial lattice vectors:"
    print lat_a
    print lat_b
    print lat_c
    # rotate by 90 - gamma around z to put b on y axis
    angle = -1.0 * np.radians(90 - ga)
    lat_a = rotVec(lat_a, 2, angle)
    lat_b = rotVec(lat_b, 2, angle)
    lat_c = rotVec(lat_c, 2, angle)
    Cij = rotCij(Cij_in, 2, angle)
    print "after rotating around z:"
    print lat_a
    print lat_b
    print lat_c
    print Cij