Beispiel #1
0
    def _set_stage1(self, cell):
        prim_cell = get_primitive(cell, tolerance=self._symmetry_tolerance)
        sym_dataset = get_symmetry_dataset(prim_cell)
        self._space_group_type = sym_dataset['international_standard']
        spg_number = sym_dataset['number']
        if (spg_number >= 143 and
            spg_number <= 194 and
            not self._space_group_type[0] == 'R'): # Hexagonal lattice
            self._supercell_dimensions = [[3, 3, 2], [2, 2, 2]]
        else: # Other cases
            self._supercell_dimensions = [[2, 2, 2]]

        # Long cell axis is not multiplied.
        for dimension in self._supercell_dimensions:
            for i, length in enumerate(
                get_lattice_parameters(prim_cell.get_lattice())):
                if length * dimension[i] > 20:
                    dimension[i] = 1

        self._tasks = []
        for i, dimension in enumerate(self._supercell_dimensions):
            task = self._get_phonon_task(prim_cell,
                                         np.diag(dimension),
                                         "phonon-%d" % (i + 1))
            self._phre_tasks.append(task)
            self._tasks.append(task)
    def begin(self):
        if not self._job:
            print "set_job has to be executed."
            raise

        self._overwrite_settings()

        self._status = "stage 1"
        if self._impose_symmetry:
            prim_cell = get_primitive(self._cell,
                                      tolerance=self._symmetry_tolerance)
            self._space_group = get_symmetry_dataset(prim_cell)
            task = self._get_next_task(prim_cell)
        else:
            if self._find_symmetry:
                self._space_group = get_symmetry_dataset(
                    self._cell,
                    self._symmetry_tolerance)
            task = self._get_next_task(self._cell)
        if self._space_group:
            self._comment = self._space_group['international_standard']

        self._so_tasks = [task]
        self._tasks = [task]
        self._write_yaml()
    def next(self):
        if self._status == "terminate":
            self._stress = None
            self._forces = None
            self._energy = None
            self._next_cell = None
        else:
            task = self._tasks[0]
            self._next_cell = task.get_current_cell()
            stress = task.get_stress()
            forces = task.get_forces()
            energy = task.get_energy()
            if not stress == None:
                self._stress = stress
            if not forces == None:
                self._forces = forces
            if not energy == None:
                self._energy = energy

        if self._status == "terminate" and self._traverse == "restart":
            self._traverse = False
            if self._stage > 2:
                self._stage -= 2
                task = self._so_tasks.pop()
                task = self._so_tasks.pop()
                self._next_cell = task.get_cell()
            else:
                self._so_tasks = []
                self._stage = 0
                self._next_cell = self._cell
            self._status = "next"

        if self._next_cell:
            if self._impose_symmetry:
                self._next_cell = get_primitive(self._next_cell, tolerance=self._symmetry_tolerance)
                self._space_group = get_symmetry_dataset(self._next_cell)
            else:
                if self._find_symmetry:
                    self._space_group = get_symmetry_dataset(self._next_cell, tolerance=self._symmetry_tolerance)
            if self._space_group:
                self._comment = self._space_group["international_standard"]

        if self._status == "done":
            if self._stage < self._min_iteration:
                self._status = "next"

        if self._status == "next":
            if self._stage == self._max_iteration:
                self._status = "max_iteration"
            else:
                self._set_next_task()

        self._write_yaml()
        if "stage" in self._status:
            return self._tasks
        else:
            self._tasks = []
            raise StopIteration
Beispiel #4
0
    def _set_stage1(self, cell):
        prim_cell = get_primitive(cell, tolerance=self._symmetry_tolerance)
        sym_dataset = get_symmetry_dataset(prim_cell)
        self._space_group_type = sym_dataset['international_standard']
        spg_number = sym_dataset['number']
        if (spg_number >= 143 and spg_number <= 194
                and not self._space_group_type[0] == 'R'):  # Hexagonal lattice
            self._supercell_dimensions = [[3, 3, 2], [2, 2, 2]]
        else:  # Other cases
            self._supercell_dimensions = [[2, 2, 2]]

        # Long cell axis is not multiplied.
        for dimension in self._supercell_dimensions:
            for i, length in enumerate(
                    get_lattice_parameters(prim_cell.get_lattice())):
                if length * dimension[i] > 20:
                    dimension[i] = 1

        self._tasks = []
        for i, dimension in enumerate(self._supercell_dimensions):
            task = self._get_phonon_task(prim_cell, np.diag(dimension),
                                         "phonon-%d" % (i + 1))
            self._phre_tasks.append(task)
            self._tasks.append(task)
    def next(self):
        if self._status == "terminate":
            self._stress = None
            self._forces = None
            self._energy = None
            self._next_cell = None
        else:
            task = self._tasks[0]
            self._next_cell = task.get_current_cell()
            stress = task.get_stress()
            forces = task.get_forces()
            energy = task.get_energy()
            if not stress == None:
                self._stress = stress
            if not forces == None:
                self._forces = forces
            if not energy == None:
                self._energy = energy

        if "terminate" in self._status and self._traverse == "restart":
            self._traverse = False
            if self._stage > 2:
                self._stage -= 2
                task = self._so_tasks.pop()
                task = self._so_tasks.pop()
                self._next_cell = task.get_cell()
            else:
                self._so_tasks = []
                self._stage = 0
                self._next_cell = self._cell
            self._status = "next"
                
        if self._next_cell:
            if self._impose_symmetry:
                self._next_cell = get_primitive(
                    self._next_cell,
                    tolerance=self._symmetry_tolerance)
                self._space_group = get_symmetry_dataset(self._next_cell)
            else:
                if self._find_symmetry:
                    self._space_group = get_symmetry_dataset(
                        self._next_cell,
                        tolerance=self._symmetry_tolerance)
            if self._space_group:
                self._comment = self._space_group['international_standard']
            
        if self._status == "done":
            if self._stage < self._min_iteration:
                self._status = "next"

        if self._status == "next":
            if self._stage == self._max_iteration:
                self._status = "max_iteration"
            else:
                self._set_next_task()

        self._write_yaml()
        if "stage" in self._status:
            return self._tasks
        else:
            self._tasks = []
            raise StopIteration