예제 #1
0
    def __init__(
            self,
            surface,
            name=DEFAULT,
            identifiers=tuple(),
            added_atoms=DEFAULT,
            periodicity=tuple(tuple()),
            charge=0,
            initial_state=DEFAULT,
            parameters=DEFAULT,
            ):
        if added_atoms is DEFAULT:
            added_atoms = Atoms([])
        self.__identifiers = convertShorthand(identifiers)
        surface = surface.copy()
        self.__periodicity = np.array(periodicity)
        self.__added_atoms = added_atoms.copy()
        self.__initial_state = initial_state
        self.__charge=charge

        API.System.__init__(
                self,
                name=name,
                sub_systems=[surface],
                initial_state=initial_state,
                parameters=parameters,
                )
예제 #2
0
 def __init__(self, symbol):
     self.__symbol = symbol
     bond_length = {'O': 1.21}[symbol]
     atoms = Atoms(symbol*2, positions=[[0,-bond_length/2., 0], [0, bond_length/2., 0]],
             cell=(10, 10, 10+bond_length)
             )
     atoms.set_initial_magnetic_moments([1,1])
     Molecule.__init__(self, atoms)
예제 #3
0
    def __init__(self, symbol):
        self.__symbol = symbol
        atoms = Atoms(symbols=symbol + '10H15',
                      pbc=np.array([False, False, False], dtype=bool),
                      cell=np.array(
                      [[ 42.,   0.,   0.],
                       [  0.,  43.,   0.],
                       [  0.,   0.,  31.]]),

                       positions=np.array([
                            [  0.00000000 ,  0.00000000 ,  0.00000000],
                            [  2.18427300 , -0.00001600 ,- 1.00453600],
                            [ -1.09434500 ,  1.89303000 ,- 1.00282400],
                            [ -1.09431700 , -1.89301600 ,- 1.00282400],
                            [  4.43153700 , -0.00001800 ,- 1.81223000],
                            [  1.10633700 ,  1.91978200 ,- 1.81223000],
                            [ -2.21886300 ,  3.83958200 ,- 1.81223000],
                            [  1.10633700 , -1.91981800 ,- 1.81223000],
                            [ -2.21886300 , -0.00001800 ,- 1.81223000],
                            [ -2.21886300 , -3.83961800 ,- 1.81223000],
                            [  5.36233700 , -0.00001800 ,- 0.66163000],
                            [  4.66473700 , -1.20821800 ,- 2.63453000],
                            [  4.66473700 ,  1.20818200 ,- 2.63453000],
                            [  1.10613700 ,  1.91938200 ,- 3.29223000],
                            [  1.80393700 ,  3.12808200 ,- 1.31863000],
                            [ -2.68466300 ,  4.64548200 ,- 0.66163000],
                            [ -1.28896300 ,  4.64588200 ,- 2.63423000],
                            [ -3.38166300 ,  3.43748200 ,- 2.63483000],
                            [  1.80393700 , -3.12811800 ,- 1.31863000],
                            [  1.10613700 , -1.91941800 ,- 3.29223000],
                            [ -2.21846300 , -0.00001800 ,- 3.29223000],
                            [ -3.61406300 , -0.00001800 ,- 1.31863000],
                            [ -2.68466300 , -4.64551800 ,- 0.66163000],
                            [ -3.38166300 , -3.43751800 ,- 2.63483000],
                            [ -1.28896300 , -4.64591800 ,- 2.63423000],
                            ]))

        normal_vector = np.array([0,0,1])
        constraints = []
        for i in range(4, 10):
            constraint = FixedPlane(i, normal_vector)
            constraints.append(constraint)
        atoms.set_constraint(constraints)

        Molecule.__init__(self, atoms)
예제 #4
0
    def __init__(
            self,
            atoms,
            parameters=DEFAULT,
            ):
        assert all(atoms.pbc == np.array([True, True, True]))
        self.__atoms = Atoms(atoms)

        Crystal.__init__(self, sub_systems=tuple(), parameters=parameters)
예제 #5
0
 def __init__(
         self,
         atoms,
         parameters=DEFAULT,
         ):
     assert all(atoms.pbc == np.array([False, False, True]))
     self.__atoms = Atoms(atoms)
     API.System.__init__(
             self,
             sub_systems=tuple(),
             parameters=parameters,
             )
예제 #6
0
def makeEnes(number):
    atoms = Atoms(
        [
            Atom("H", (-1.0 * np.cos(np.pi / 6.0), 0.7 + 1.0 * np.sin(np.pi / 6.0), 0.0)),
            Atom("H", (-1.0 * np.cos(np.pi / 6.0), -0.7 - 1.0 * np.sin(np.pi / 6.0), 0.0)),
        ],
        cell=(2.41, 16.00, 10),
        pbc=[False, False, False],
    )
    atoms_unit = Atoms(
        [
            Atom("C", (0.0, 0.7, 0.0)),
            Atom("C", (0.0, -0.7, 0.0)),
            Atom("H", (1.2, -2.4, 0.0)),
            Atom("C", (1.2, -1.4, 0.0)),
            Atom("C", (1.2, 1.4, 0.0)),
            Atom("H", (1.2, 2.4, 0.0)),
        ],
        cell=(2.41, 16.00, 10),
        pbc=[False, False, True],
    )
    atoms += atoms_unit.repeat((number + 1, 1, 1))
    atoms = atoms[:-4]
    max_x = atoms.positions[-1, 0]

    postpend = Atoms(
        [
            Atom("H", (max_x + 1.0 * np.cos(np.pi / 6.0), 0.7 + 1.0 * np.sin(np.pi / 6.0), 0.0)),
            Atom("H", (max_x + 1.0 * np.cos(np.pi / 6.0), -0.7 - 1.0 * np.sin(np.pi / 6.0), 0.0)),
        ],
        cell=(2.41, 16.00, 10),
        pbc=[False, False, True],
    )
    atoms += postpend

    maxi = atoms.positions.max(axis=0)
    mini = atoms.positions.min(axis=0)
    av = (maxi + mini) / 2.0
    ran = maxi - mini

    atoms.positions -= av
    atoms.cell[0, 0] = ran[0] + 10
    atoms.cell[1, 1] = ran[1] + 10
    atoms.cell[2, 2] = ran[2] + 10

    return atoms
예제 #7
0
class Crystal1D(Crystal):
    def __init__(
            self,
            atoms,
            parameters=DEFAULT,
            ):
        assert all(atoms.pbc == np.array([False, False, True]))
        self.__atoms = Atoms(atoms)
        API.System.__init__(
                self,
                sub_systems=tuple(),
                parameters=parameters,
                )

    def setUpBasisChanger(self):
        atoms = self.atoms()
        cell = atoms.cell

        basis_changer = BasisChanger(
                transformations=[Transformation(to='orth_crystal', fro='crystal', trans_matrix=cell.transpose())]
                )
        return basis_changer

    def pbc(self):
        return [False, False, True]

    def defaultParameters(self, parameters=DEFAULT):
        if parameters is DEFAULT:
            parameters = CrystalParameters1D()

        vectors = parameters['vectors']
        if parameters['vectors'] is DEFAULT:
            vectors = ((1,),)

        kpts = parameters['kpts']
        if kpts is DEFAULT:
            kpts = parameters.neededKpts(self.__atoms.cell[self.__atoms.pbc])

        parameters = parameters.copy(kpts=kpts, vectors=vectors)

        return parameters

    def inputAtoms(self):
        return self.__atoms.copy()

    def relaxationFactor(self):
        if self.relaxation() is None:
            return 1.0
        lr = vectorLength(self.relaxation().get_cell()[2])
        lu = vectorLength(self.__atoms.get_cell()[2])

        return lr/lu

    def atoms(self, constrained=True, parameters=DEFAULT):
        if parameters is DEFAULT:
            parameters = self.parameters()
        parameters = self.defaultParameters(parameters)
        vectors = np.array(parameters['vectors'])

        lengths = vectorLength(vectors, 1)
        assert lengths.all()

        atoms = self.__atoms.copy()
        pos = atoms.get_positions()
        size = np.array([pos[:, i].max() - pos[:,i].min() for i in range(3)])
        size = size + parameters['length_scales']['correlation_length']

        repeats = (1, 1, vectors[0][0])
        vectors = atoms.cell[2] * vectors[0][0]

        atoms = atoms.repeat(repeats)
        atoms.set_cell(size)
        atoms.cell[2] = vectors
        atoms = removeCopies(atoms)
        atoms = orderAtoms(atoms)

        atoms = self.makeAtomsRelaxed(atoms, self.relaxation())

        return atoms

    def makeAtomsRelaxed(self, atoms, relaxation, tolerance=1):
        factor = self.relaxationFactor()
        atoms.positions *= factor
        atoms.cell[2] *= factor
        atoms = makeAtomsRelaxed(atoms, self.relaxation(), tolerance=tolerance)

        return atoms

    def unitCell(self, coordinates='orth_crystal'):
        if self.isRelaxed():
            unit_cell = self.relaxation().get_cell()
        else:
            unit_cell = self.__atoms.get_cell()

        unit_cell = unit_cell[np.array(self.pbc())]

        return self.change(unit_cell, to=coordinates, fro='orth_crystal')
예제 #8
0
class Crystal3D(Crystal):
    def __init__(
            self,
            atoms,
            parameters=DEFAULT,
            ):
        assert all(atoms.pbc == np.array([True, True, True]))
        self.__atoms = Atoms(atoms)

        Crystal.__init__(self, sub_systems=tuple(), parameters=parameters)

    def setUpBasisChanger(self):
        atoms = self.atoms()
        cell = atoms.cell

        basis_changer = BasisChanger(
                transformations=[Transformation(to='orth_crystal', fro='crystal', trans_matrix=cell.transpose())]
                )
        return basis_changer

    def unitCell(self, coordinates='orth_crystal'):
        unit_cell = np.array(self.__atoms.cell[self.__atoms.pbc])
        unit_cell *= relaxationFactor(self.__atoms, self.relaxation())

        if coordinates == 'orth_crystal':
            return unit_cell

        return self.change(unit_cell, to=coordinates, fro='orth_crystal')

    def normalVector(self, miller_indices):
        raise Exception

    def defaultParameters(self, parameters=DEFAULT):
        if parameters is DEFAULT:
            parameters = CrystalParameters3D()

        kpts = parameters['kpts']
        if kpts is DEFAULT:
            kpts = parameters.neededKpts(self.unitCell())

        vectors = parameters['vectors']
        if vectors is DEFAULT:
            vectors = ((1,0,0), (0,1,0), (0,0,1))

        parameters = parameters.copy(kpts=kpts, vectors=vectors)

        return parameters

    def atoms(self, constrained=True, parameters=DEFAULT):
        parameters = self.defaultParameters(parameters)
        vectors = np.array(parameters['vectors'])

        lengths = vectorLength(vectors, 1)
        assert lengths.all()

        atoms = self.__atoms.copy()

        vectors = convertFromBasis(vectors, atoms.cell)
        repeats = findNeededRepetitions(atoms.cell, 1.5*lengths.max())

        atoms = atoms.repeat(repeats)
        atoms.cell[atoms.pbc] = vectors
        atoms.wrap()
        atoms = removeCopies(atoms)
        atoms.setTag('Reference', picker=None)

        padding = np.logical_not(atoms.pbc)
        assert padding.sum() == 0

        atoms = self.makeAtomsRelaxed(atoms, self.relaxation())

        return atoms

    def makeSubsystemsRelaxed(self, atoms):
        return atoms

    def makeAtomsRelaxed(self, atoms, relaxation, tolerance=1.0):
        if relaxation is None:
            return atoms

        factor = relaxationFactor(self.__atoms, relaxation)
        atoms.positions *= factor
        atoms.cell *= factor

        atoms = makeAtomsRelaxed(atoms, relaxation, tolerance=tolerance)

        for electrode in atoms.electrodes():
            electrode.setCell(electrode.cell()*factor)

        return atoms

    def pbc(self):
        return [True, True, True]