コード例 #1
0
class TestNaCl(unittest.TestCase):
    #  Test data is from the Navy's Crystal Lattie Structures website:
    #  http://cst-www.nrl.navy.mil/lattice/struk.xmol/b1.pos
    #  All distances are written in Angstroms.
    latticevecs = ([0.00000000, 2.81500000, 2.81500000],
                   [2.81500000, 0.00000000, 2.81500000],
                   [2.81500000, 2.81500000, 0.00000000])
    basis = (('Na', array([0.00000000, 0.00000000, 0.00000000])),
             ('Cl', array([2.81500000, 2.81500000, 2.81500000])))

    #          (n1,n2,n3, [Symbol, position, Symbol, position, etc.])
    images = ( (1, 0, 0, ['Na', array([ 0.   , 2.815, 2.815]),
                          'Cl', array([ 2.815, 5.63 , 5.63 ])]),
               (0, 1, 0, ['Na', array([ 2.815, 0.   , 2.815]),
                          'Cl', array([ 5.63 , 2.815, 5.63 ])]),
               (0, 0, 1, ['Na', array([ 2.815, 2.815, 0.   ]),
                          'Cl', array([ 5.63 , 5.63 , 2.815])]),
               (-2, 3, -1, ['Na', array([ 5.63 , -8.445, 2.815]),
                            'Cl', array([ 8.445, -5.63 , 5.63 ])]) )

    def setUp(self):
        self.crystal = Crystal(self.latticevecs, self.basis)

    def test_images(self):
        for (n1, n2, n3, solution) in self.images:
            computed = self.crystal.cell_n((n1, n2, n3))
            print computed[1::2], solution[1::2]
            self.assertEqual(computed[0::2], solution[0::2])
            assert_array_almost_equal(computed[1::2], solution[1::2], decimal=15)
コード例 #2
0
ファイル: TiO2.py プロジェクト: danielsjensen1/crystalpy
from periodic.crystal import Crystal


latticevecs = ((4.59373000,  0.00000000,  0.00000000),
               (0.00000000,  4.59373000,  0.00000000),
               (0.00000000,  0.00000000,  2.95812000))
basis = (('Ti',  (0.00000000,  0.00000000,  0.00000000)),
         ('Ti',  (2.29686500,  2.29686500,  1.47906000)),
         ('O',   (1.40246577,  1.40246577,  0.00000000)),
         ('O',   (-1.40246577, -1.40246577,  0.00000000)),
         ('O',   (3.69933077,  0.89439923,  1.47906000)),
         ('O',   (0.89439923,  3.69933077,  1.47906000)))


if __name__ == '__main__':
    TiO2 = Crystal(latticevecs, basis)
    rcutoff = 2e0
    atomlist = TiO2.tile_radially(rcutoff)
    filename = 'TiO2_rcut_{0:.2f}.xyz'.format(rcutoff)
    with open(filename, 'w') as f:
        f.write(str(len(atomlist))+'\n')
        f.write('crystal.py-generated xyz file'+'\n')
        for (symbol, position) in atomlist:
            f.write(symbol+'   '+str(position)[1:-1]+'\n')
コード例 #3
0
 def setUp(self):
     self.crystal = Crystal(self.latticevecs, self.basis)