def testA2(self):
        import matter
        struct = matter.Structure(
            lattice=matter.Lattice(a=1,
                                   b=1,
                                   c=1,
                                   alpha=acos1_3,
                                   beta=acos1_3,
                                   gamma=acos1_3),
            sgid=229,
            atoms=[matter.Atom('Cu')],
        )
        self.assertEqual(StrukturberichtDesignationFinder().find(struct), A2)

        struct = matter.Structure(
            lattice=matter.Lattice(a=1, b=1, c=1, alpha=90, beta=90, gamma=90),
            sgid=229,
            atoms=[
                matter.Atom('Cu', xyz=[0, 0, 0]),
                matter.Atom('Cu', xyz=[0.5, 0.5, 0.5])
            ],
        )
        self.assertEqual(StrukturberichtDesignationFinder().find(struct), A2)

        return
示例#2
0
    def test3(self):
        # simple cubic
        import matter
        lattice = matter.Lattice(a=3.701,
                                 b=3.701,
                                 c=3.701,
                                 alpha=90,
                                 beta=90,
                                 gamma=90)
        atom1 = matter.Atom('C')
        atom2 = matter.Atom('H', [0.5, 0.5, 0])
        atom3 = matter.Atom('H', [0.5, 0, 0.5])
        atom4 = matter.Atom('H', [0, 0.5, 0.5])
        struct = matter.Structure([atom1, atom2, atom3, atom4],
                                  lattice=lattice,
                                  sgid=221)

        from bvk.BvKBond import BvKBond
        bond = BvKBond()
        bond.matter = struct
        bond.uses_primitive_unitcell = 1
        bond.A = 0
        bond.B = 0
        bond.Boffset = [1, 1, 0]
        bond.Boffset_is_fractional = 0

        # 110
        print 'bond 110 for sc lattice'
        for constraint in findForceContantTensorConstraints(bond):
            print constraint

        return
 def testA1(self):
     import matter
     struct = matter.Structure(
         lattice=matter.Lattice(a=1, b=1, c=1, alpha=60, beta=60, gamma=60),
         sgid=225,
         atoms=[matter.Atom('Cu')],
     )
     self.assertEqual(StrukturberichtDesignationFinder().find(struct), A1)
     return
 def testMethodInStructureClass(self):
     import matter
     struct = matter.Structure(
         lattice=matter.Lattice(a=1, b=1, c=1, alpha=60, beta=60, gamma=60),
         sgid=225,
         atoms=[matter.Atom('Cu')],
     )
     self.assertEqual(struct.StrukturberichtDesignation, A1)
     return
 def testB2(self):
     import matter
     struct = matter.Structure(
         lattice=matter.Lattice(a=1, b=1, c=1, alpha=90, beta=90, gamma=90),
         sgid=221,
         atoms=[matter.Atom('Cs'),
                matter.Atom('Cl', xyz=[0.5, 0.5, 0.5])],
     )
     self.assertEqual(StrukturberichtDesignationFinder().find(struct), B2)
     return
示例#6
0
    def _qVector(self, h, k, l):
        "Returns q-vector from (h, k, l) parameters"
        import matter  # import matter package
        import numpy

        lat = matter.Lattice(self._a, self._b, self._c, self._alpha,
                             self._beta, self._gamma)
        rb = lat.recbase  # Reciprocal matrix
        trb = rb.T  # Should I transpose it?
        q = 2 * PI * (h * trb[0] + k * trb[1] + l * trb[2])
        return numpy.sqrt(numpy.dot(q, q))
示例#7
0
def getLattice(lines):
    # !!! This demands that 2nd line contains lattice parameters
    cell = lines[1]  # Second lines should have lattice parameters
    assert cell.startswith('# CELL')
    cell = cell.replace("#", "")
    par = cell.split()

    # Parse lattice parameters: a, b, c, alpha, beta, gamma
    (_a, _b, _c, _alpha, _beta, _gamma) = \
         (float(par[1]), float(par[2]), float(par[3]),
          float(par[4]), float(par[5]), float(par[6]))
    # lattice
    import matter
    lat = matter.Lattice(_a, _b, _c, _alpha, _beta, _gamma)
    return lat
示例#8
0
    def testWriter(self):
        p = getParser()
        import matter
        a = 1.5
        lattice = matter.Lattice(2 * a, 2 * a, 2 * a, 90, 90, 90)
        atoms = [matter.Atom('Ni'), matter.Atom('Ni', (0.5, 0.5, 0.5))]
        struct = Structure(lattice=lattice, atoms=atoms, sgid=229)

        print 'original unitcell, cartesian coords'
        print '\n'.join(p.toLines(struct))

        print 'original unitcell, fractional coords'
        print '\n'.join(p.toLines(struct, use_fractional_coordinates=1))

        print 'primitive unitcell, cartesian coords'
        print '\n'.join(p.toLines(struct, use_primitive_unitcell=1))

        print 'primitive unitcell, fractional coords'
        print '\n'.join(
            p.toLines(struct,
                      use_primitive_unitcell=1,
                      use_fractional_coordinates=1))

        return