Пример #1
0
def test_celldm_cryst_const():
    cc = np.array([3, 4, 5, 30, 50, 123.0])
    assrt(cc, celldm2cc(cc2celldm(cc)))

    cc = np.array([3, 4, 5, 30, 50, 123.0])
    assrt(cc, celldm2cc(cc2celldm(cc, fac=10), fac=0.1))

    cc = [3, 3, 3, 90, 90, 90]
    assrt(cc2celldm(cc), np.array([3, 1, 1, 0, 0, 0]))

    cc = [3, 4, 5, 90, 90, 120]
    assrt(cc2celldm(cc), np.array([3, 4 / 3., 5 / 3., 0, 0, -0.5]))

    cc = [3, 4, 5, 90, 90, 120]
    assrt(cc2celldm(cc, fac=10), np.array([30, 4 / 3., 5 / 3., 0, 0, -0.5]))
Пример #2
0
def test_celldm_cryst_const():
    cc = np.array([3,4,5, 30, 50, 123.0])
    assrt(cc, celldm2cc(cc2celldm(cc)))
    
    cc = np.array([3,4,5, 30, 50, 123.0])
    assrt(cc, celldm2cc(cc2celldm(cc, fac=10), fac=0.1))

    cc = [3,3,3,90,90,90]
    assrt(cc2celldm(cc), np.array([3,1,1,0,0,0]))

    cc = [3,4,5, 90, 90, 120]
    assrt(cc2celldm(cc), 
          np.array([3, 4/3., 5/3., 0,0, -0.5]))
    
    cc = [3,4,5, 90, 90, 120]
    assrt(cc2celldm(cc, fac=10), 
          np.array([30, 4/3., 5/3., 0,0, -0.5]))
Пример #3
0
def test_ibrav():
    # bogus
    aa = 3.0
    bb = 4.0
    cc = 5.0
    alpha = 66*pi/180
    beta = 77*pi/180
    gamma = 88*pi/180

    ibrav = 1
    celldm = [aa] + [None]*5
    ibrav2cell(ibrav, celldm)
    
    ibrav = 2
    celldm = [aa] + [None]*5
    ibrav2cell(ibrav, celldm)
    
    ibrav = 3
    celldm = [aa] + [None]*5
    ibrav2cell(ibrav, celldm)
    
    ibrav = 4
    celldm = [aa, None, cc/aa, None, None, None]
    ibrav2cell(ibrav, celldm)
    
    ibrav = 5
    celldm = [aa, None, None, cos(alpha), None, None]
    ibrav2cell(ibrav, celldm)
    
    ibrav = 6
    celldm = [aa, None, cc/aa, None, None, None]
    ibrav2cell(ibrav, celldm)
    
    ibrav = 7
    celldm = [aa, None, cc/aa, None, None, None]
    ibrav2cell(ibrav, celldm)
    
    ibrav = 8
    celldm = [aa, bb/aa, cc/aa, None, None, None]
    ibrav2cell(ibrav, celldm)
    
    ibrav = 9
    celldm = [aa, bb/aa, cc/aa, None, None, None]
    ibrav2cell(ibrav, celldm)
    
    ibrav = 10
    celldm = [aa, bb/aa, cc/aa, None, None, None]
    ibrav2cell(ibrav, celldm)
    
    ibrav = 11
    celldm = [aa, bb/aa, cc/aa, None, None, None]
    ibrav2cell(ibrav, celldm)
    
    # celldm(4)=cos(ab) in doc!?
    ibrav = 12 
##    celldm = [aa, bb/aa, cc/aa, cos(alpha), None, None]
    celldm = [aa, bb/aa, cc/aa, None, None, cos(gamma)]
    ibrav2cell(ibrav, celldm)
    
    # celldm(4)=cos(ab) in doc!?
    ibrav = 13
##    celldm = [aa, bb/aa, cc/aa, cos(alpha), None, None]
    celldm = [aa, bb/aa, cc/aa, None, None, cos(gamma)]
    ibrav2cell(ibrav, celldm)
    
    # WOHOO!
    ibrav = 14
    celldm = [aa, bb/aa, cc/aa, cos(alpha), cos(beta), cos(gamma)]
    cell=ibrav2cell(ibrav, celldm)
    np.testing.assert_array_almost_equal(cell, 
                                         crys.cc2cell(crys.celldm2cc(celldm)))
Пример #4
0
def test_ibrav():
    # bogus
    aa = 3.0
    bb = 4.0
    cc = 5.0
    alpha = 66 * pi / 180
    beta = 77 * pi / 180
    gamma = 88 * pi / 180

    ibrav = 1
    celldm = [aa] + [None] * 5
    ibrav2cell(ibrav, celldm)

    ibrav = 2
    celldm = [aa] + [None] * 5
    ibrav2cell(ibrav, celldm)

    ibrav = 3
    celldm = [aa] + [None] * 5
    ibrav2cell(ibrav, celldm)

    ibrav = 4
    celldm = [aa, None, cc / aa, None, None, None]
    ibrav2cell(ibrav, celldm)

    ibrav = 5
    celldm = [aa, None, None, cos(alpha), None, None]
    ibrav2cell(ibrav, celldm)

    ibrav = 6
    celldm = [aa, None, cc / aa, None, None, None]
    ibrav2cell(ibrav, celldm)

    ibrav = 7
    celldm = [aa, None, cc / aa, None, None, None]
    ibrav2cell(ibrav, celldm)

    ibrav = 8
    celldm = [aa, bb / aa, cc / aa, None, None, None]
    ibrav2cell(ibrav, celldm)

    ibrav = 9
    celldm = [aa, bb / aa, cc / aa, None, None, None]
    ibrav2cell(ibrav, celldm)

    ibrav = 10
    celldm = [aa, bb / aa, cc / aa, None, None, None]
    ibrav2cell(ibrav, celldm)

    ibrav = 11
    celldm = [aa, bb / aa, cc / aa, None, None, None]
    ibrav2cell(ibrav, celldm)

    # celldm(4)=cos(ab) in doc!?
    ibrav = 12
    ##    celldm = [aa, bb/aa, cc/aa, cos(alpha), None, None]
    celldm = [aa, bb / aa, cc / aa, None, None, cos(gamma)]
    ibrav2cell(ibrav, celldm)

    # celldm(4)=cos(ab) in doc!?
    ibrav = 13
    ##    celldm = [aa, bb/aa, cc/aa, cos(alpha), None, None]
    celldm = [aa, bb / aa, cc / aa, None, None, cos(gamma)]
    ibrav2cell(ibrav, celldm)

    # WOHOO!
    ibrav = 14
    celldm = [aa, bb / aa, cc / aa, cos(alpha), cos(beta), cos(gamma)]
    cell = ibrav2cell(ibrav, celldm)
    np.testing.assert_array_almost_equal(cell,
                                         crys.cc2cell(crys.celldm2cc(celldm)))