Пример #1
0
    def run_method(self):
        from method import structure_compare_donet
        from method import read
        from method.plot_crystal import plot_atoms

        tolerance = float(self.tolerance.text())
        percent = float(self.percent.text())
        arrow_location, arrow = structure_compare_donet.exec(self.path.save_path,
                                                             self.host.text(), self.doped.text(), tolerance, percent)

        self.figure.clear()
        ax = self.figure.add_subplot(111, projection='3d')
        structure = read.poscar(self.host.text())
        draw_crystal_in_ax(ax, structure)
        structure = read.poscar(self.doped.text())
        plot_atoms(ax, structure)
        ax.quiver(arrow_location[0], arrow_location[1], arrow_location[2], arrow[0], arrow[1], arrow[2])
        self.canvas.draw()
def exec(inputPath, outputPath, types, subs, center, tolerance):
    import platform
    structure = read.poscar(inputPath, types=poscar_is_vasp5(inputPath))
    doped_result, view_result = substitution(structure, types, subs, center, tolerance)
    for doped_structure in doped_result:
        output_name = os.path.join(outputPath, doped_structure.name)
        if platform.system() == 'Windows':
            output_name = output_name.replace('\\', '/')
        poscar(doped_structure, file_name=output_name, vasp5=True)
    return view_result
Пример #3
0
    def readdoped(self):
        from method import read
        file_name, file_type = QFileDialog.getOpenFileName(None, 'Open', './', 'All Files (*)')
        self.path.open_path = file_name
        self.doped.setText(file_name)

        self.figure.clear()
        self.structure = read.poscar(self.path.open_path, types=poscar_is_vasp5(self.path.open_path))
        ax = self.figure.add_subplot(111, projection='3d')
        draw_crystal_in_ax(ax, self.structure)
        self.canvas.draw()
def exec(inputPath, outputPath, insert, center, position, tolerance):
    import platform

    structure = read.poscar(inputPath, types=poscar_is_vasp5(inputPath))
    doped_result, view_result = interstitial(structure, insert, position=position, center=center, tolerance=tolerance)
    for doped_structure in doped_result:
        output_name = os.path.join(outputPath, doped_structure.name)
        if platform.system() == 'Windows':
            output_name = output_name.replace('\\', '/')
        poscar(doped_structure, file_name=output_name, vasp5=True)
    poscar(view_result, file_name='inequivalent interstitial sites.vasp', vasp5=True)
    return view_result
Пример #5
0
    def time_stop(self):
        from method import read
        self.bar.setValue(100)
        self.timer.stop()
        self.status.setText('Finished.')
        self.run_btn.setText('Run')

        self.structure = read.poscar(self.write_path, types=poscar_is_vasp5(self.write_path))
        self.figure.clear()
        ax = self.figure.add_subplot(111, projection='3d')
        draw_crystal_in_ax(ax, self.structure)
        self.canvas.draw()

        with open('interstitial log.txt', 'w') as file:
            file.writelines('0%')
Пример #6
0
        raise error.RuntimeError("Cannot find specie to substitute in structure!")
    view_structure = structure.copy()
    for specie in types:
        indices = symmetrically_inequivalent_indices(structure, center=center, species=specie, symprec=tolerance)
        for index in indices:
            if subs is None:
                doped_structure = structure.copy()
                del doped_structure[index]
                doped_structure.name = 'vacancy_of_{0}_in_site{1}'.format(specie, index+1)
                result.append(doped_structure)

                view_structure[index].type = 'Vac'
            else:
                for sub_specie in subs:
                    doped_structure = structure.copy()
                    doped_structure[index].type = sub_specie
                    doped_structure.name = 'substitution_{0}_in_site{1}'.format(sub_specie, index+1)
                    result.append(doped_structure)

                view_structure[index].type = 'Sub'
    return result, view_structure


if __name__ == "__main__":
    from method.read import poscar
    structure1 = poscar('R-3c.vasp')
    # inequivalent = interstitial(structure1, 'O', center=[0.5, 0.5, 0.5])
    test = substitution(structure1)


Пример #7
0
def read_poscar(raw):
    from method import read
    with open('POSCAR', 'w') as f:
        f.write(raw)
    structure = read.poscar('POSCAR', types=poscar_is_vasp5('POSCAR'))
    return structure
Пример #8
0
                for atom in value:
                    atom_json = json.loads(atom)
                    atom_list.append(Atom(atom_json['pos'], type=atom_json['type'], num=atom_json['num']))
                element_json[key] = atom_list
        result.append(element_json)
    return result


if __name__ == "__main__":
    doped_crystal = '2Tisc960.vasp'
    substrate = 'hostsc960.vasp'
    unit_cell_file = 'primitive.vasp'
    doped_element = 'Ti'
    already_compared_structure = True

    doped_structure = poscar(doped_crystal)
    substrate_structure = poscar(substrate)
    primitive = poscar(unit_cell_file)

    original = []
    if already_compared_structure:
        doped_atoms = read_compared_result_from_json()
        for element in doped_atoms:
            if element['type'] == doped_element:
                for pairs in element['sub']:
                    for atom in pairs:
                        if atom.type == doped_element:
                            original.append(atom)
    else:
        doped_atoms = compare_structure(substrate_structure, doped_structure, tolerance=1.0, compare_type='M')
        for element in doped_atoms:
Пример #9
0
from method.read import poscar
from method.compare_structure import compare_structure
from copy import deepcopy
import json
import re

if __name__ == "__main__":
    doped_crystal = '2Tisc960.vasp'
    substrate = 'hostsc960.vasp'

    doped_structure = poscar(doped_crystal)
    substrate_structure = poscar(substrate)
    doped_atoms = compare_structure(substrate_structure, doped_structure, tolerance=1.0, compare_type='Q')
    doped_atoms_json = []
    for element in doped_atoms:
        element_json = deepcopy(element)
        for key, value in element.__dict__.items():
            if re.match('type', key):
                continue
            elif re.match('su', key) or re.match('un', key):
                atom_list = []
                for pair in value:
                    tmp = []
                    for atom in pair:
                        atom_json = json.dumps({'type': atom.type, 'num': atom.num, 'pos': atom.pos.tolist()})
                        tmp.append(atom_json)
                    atom_list.append(tmp)
                element_json.__dict__[key] = atom_list
            else:
                atom_list = []
                for atom in value:
Пример #10
0
def exec(outputPath, host_path, doped_path, tolerance, percent):
    host = read.poscar(host_path, types=poscar_is_vasp5(host_path))
    doped = read.poscar(doped_path, types=poscar_is_vasp5(doped_path))
    arrow_location, arrow, tmp_result = structure_compare(
        outputPath, host, doped, tolerance, percent)
    return arrow_location, arrow
Пример #11
0
        species = []
        nb_atoms = [int(u) for u in line]
        poscar.readline()
        for n in nb_atoms:
            flag = 0
            for i in range(n):
                line = poscar.readline().split()
                if flag is 0:
                    species.append(line[3])
                    flag = 1
        poscar.close()
        return species


def exec(outputPath, host_path, doped_path, tolerance, percent):
    host = read.poscar(host_path, types=poscar_is_vasp5(host_path))
    doped = read.poscar(doped_path, types=poscar_is_vasp5(doped_path))
    arrow_location, arrow, tmp_result = structure_compare(
        outputPath, host, doped, tolerance, percent)
    return arrow_location, arrow


if __name__ == "__main__":
    host_path = 'host'
    doped_path = 'defect'
    host = read.poscar(host_path, types=poscar_is_vasp5(host_path))
    doped = read.poscar(doped_path, types=poscar_is_vasp5(doped_path))
    save_path = ''
    result = structure_compare(save_path, host, doped)
    print(result)
Пример #12
0
    sum2 = special.erfc(eta * coeff3) / coeff3
    sum2[np.isinf(sum2)] = -2 * eta / np.sqrt(np.pi)
    result = np.sum(sum1) + np.sum(sum2)
    if np.imag(result) > 1e-10:
        print(
            '\nERROR: the potential {0} is not a real, unknown problem, please check the code!\n'
            .format(result))
        exit(1)
    return np.real(result)


if __name__ == "__main__":
    tic = time.time()
    file_name = 'YPO4primitive.vasp'
    charge = {'Y': 3, 'O': -2, 'P': 5}
    structure = poscar(file_name)
    atom_list = [[], []]
    multipler = (120, 120, 120)
    eta = 1 * 2 * np.pi
    for atom in structure:
        atom_list[0].append(atom.pos)
        atom_list[1].append(atom.type)
    for atom in structure:
        vectors = atom.pos - np.array(atom_list[0])
        potential = 0.0
        for i in range(len(vectors)):
            potential += charge[atom_list[1][i]] * madelung_potential_new(
                structure.cell.T, vectors[i], extend=multipler, eta=eta)
        print(atom, potential)
    toc = time.time()
    print('Time:{0}'.format(toc - tic))