コード例 #1
0
    def test2_anatase(self):

        filename = path + '/TiO2_mp-390_conventional_standard.cif'
        atoms = read(filename)

        PC = PrototypeClassification(atoms)

        prototype, parameters = PC.get_classification()

        prototype_ref = {
            'p_name': 'AB2_4_a_e_141',
            'structure_name': '141_Ti_a_O_e',
            'spacegroup': 141,
            'wyckoffs': ['a', 'e'],
            'species': ['Ti', 'O']
        }

        parameters_ref = {
            'a': 3.80270954,
            'b': 3.80270954,
            'c': 9.74775206,
            'alpha': 90,
            'beta': 90,
            'gamma': 90,
            'ze1': 0.206163
        }

        for key, value in prototype_ref.items():
            assert prototype[key] == value

        for key, value in parameters_ref.items():
            assert np.isclose(parameters[key], value, rtol=1e-5)
コード例 #2
0
    def test3_manganese_oxide(self):
        filename = path + '/Mn3O4_mp-18759_conventional_standard.cif'
        atoms = read(filename)

        PC = PrototypeClassification(atoms)

        prototype, parameters = PC.get_classification()

        prototype_ref = {
            'p_name': 'A3B4_4_bc_h_141',
            'structure_name': '141_Mn_b_Mn_c_O_h',
            'spacegroup': 141,
            'wyckoffs': ['b', 'c', 'h'],
            'species': ['Mn', 'Mn', 'O']
        }

        parameters_ref = {
            'a': 5.87521306,
            'b': 5.87521306,
            'c': 9.58660398,
            'alpha': 90.0,
            'beta': 90.0,
            'gamma': 90.0,
            'yh2': 0.221099,
            'zh2': 0.88255
        }

        for key, value in prototype_ref.items():
            print(prototype[key], value)
            assert prototype[key] == value

        for key, value in parameters_ref.items():
            assert np.isclose(parameters[key], value, rtol=1e-5)
コード例 #3
0
    def test6_primitive(self):
        filename = path + '/Cr2O3_mp-19399_primitive.cif'
        atoms = read(filename)

        PC = PrototypeClassification(atoms)

        prototype, parameters = PC.get_classification()

        prototype_ref = {
            'p_name': 'A2B3_6_c_e_167',
            'structure_name': '167_Cr_c_O_e',
            'spacegroup': 167,
            'wyckoffs': ['c', 'e'],
            'species': ['Cr', 'O']
        }

        parameters_ref = {
            'a': 5.09424496,
            'b': 5.09424496,
            'c': 13.78071749,
            'alpha': 90,
            'beta': 90,
            'gamma': 120,
            'zc0': 0.150269 + 0.5,
            'xe1': 0.300642
        }

        for key, value in prototype_ref.items():
            assert prototype[key] == value

        for key, value in parameters_ref.items():
            assert np.isclose(parameters[key], value, rtol=1e-5)
コード例 #4
0
    def test4_nickel_oxide(self):
        filename = path + '/NiO_mp-19009_conventional_standard.cif'
        atoms = read(filename)

        PC = PrototypeClassification(atoms)

        prototype, parameters = PC.get_classification()

        prototype_ref = {
            'p_name': 'AB_4_a_b_225',
            'structure_name': '225_Ni_a_O_b',
            'spacegroup': 225,
            'wyckoffs': ['a', 'b'],
            'species': ['Ni', 'O']
        }

        parameters_ref = {
            'a': 4.2042588,
            'b': 4.2042588,
            'c': 4.2042588,
            'alpha': 90.0,
            'beta': 90.0,
            'gamma': 90.0
        }

        for key, value in prototype_ref.items():
            assert prototype[key] == value

        for key, value in parameters_ref.items():
            assert np.isclose(parameters[key], value, rtol=1e-5)
コード例 #5
0
    def test5_ternary_alloy(self):

        filename = path + '/Mn2CrCo_mp-864955_conventional_standard.cif'
        atoms = read(filename)

        PC = PrototypeClassification(atoms)

        prototype, parameters = PC.get_classification()

        prototype_ref = {
            'p_name': 'ABC2_4_a_b_c_225',
            'structure_name': '225_Cr_a_Co_b_Mn_c',
            'spacegroup': 225,
            'wyckoffs': ['a', 'b', 'c'],
            'species': ['Cr', 'Co', 'Mn']
        }

        parameters_ref = {
            'a': 5.74961404,
            'b': 5.74961404,
            'c': 5.74961404,
            'alpha': 90.0,
            'beta': 90.0,
            'gamma': 90.0
        }

        for key, value in prototype_ref.items():
            assert prototype[key] == value

        for key, value in parameters_ref.items():
            assert np.isclose(parameters[key], value, rtol=1e-5)
コード例 #6
0
ファイル: submit.py プロジェクト: kirstenwinther/Protosearch
    def __init__(
        self,
        atoms,
        basepath,
        calc_parameters=None,
    ):

        self.atoms = atoms

        PC = PrototypeClassification(self.atoms)
        prototype, cell_parameters = PC.get_classification()

        self.spacegroup = prototype['spacegroup']
        self.wyckoffs = prototype['wyckoffs']
        self.species = prototype['species']

        self.cell_param_list = []
        self.cell_value_list = []
        for param in sorted(cell_parameters):
            value = cell_parameters[param]
            if value in self.cell_value_list or value in [90, 120]:
                continue
            self.cell_value_list += [cell_parameters[param]]
            self.cell_param_list += [param]

        self.basepath = basepath
        self.calculator = 'vasp'
        self.master_parameters = calc_parameters
コード例 #7
0
    def test6_all_spacegroups(self):

        images = []
        spacegroups = range(195, 230)

        spacegroups, spacegroup_letters = get_wyckoff_letters(spacegroups)

        for sg in spacegroups:
            wyckoffs = spacegroup_letters[sg - 1][::-1][:5]
            species = metals[:len(wyckoffs)]
            print('----------', sg, '------------')

            BB = BuildBulk(sg, wyckoffs, species)
            atoms = BB.get_atoms(primitive_cell=False)

            PC = PrototypeClassification(atoms)

            prototype = PC.get_classification(include_parameters=False)

            if not prototype['spacegroup'] == sg:
                print('  change in spacegroup', sg, '----->',
                      prototype['spacegroup'])
                print('    ', prototype['p_name'])
            else:
                assert prototype['wyckoffs'] == wyckoffs, \
                    '{} --->> {}'.format(prototype['wyckoffs'], wyckoffs)
コード例 #8
0
    def submit_atoms(self, atoms, ncpus=None, batch_no=None,
                     calc_parameters=None, **kwargs):
        """Submit a calculation for an atoms object"""
        PC = PrototypeClassification(atoms)
        prototype, cell_parameters = PC.get_classification()

        if self.is_calculated(formula=atoms.get_chemical_formula(),
                              p_name=prototype['p_name']):
            return

        Sub = self.Submitter(atoms=atoms,
                             ncpus=ncpus,
                             calc_parameters=calc_parameters)

        Sub.submit_calculation()

        key_value_pairs = {'p_name': prototype['p_name'],
                           'path': Sub.excpath,
                           'spacegroup': prototype['spacegroup'],
                           'wyckoffs': json.dumps(prototype['wyckoffs']),
                           'species': json.dumps(prototype['species']),
                           'ncpus': Sub.ncpus}

        key_value_pairs.update(kwargs)

        if batch_no:
            key_value_pairs.update({'batch': batch_no})

        self.write_submission(key_value_pairs)
コード例 #9
0
    def save_failed_calculation(self, runpath, calcid):

        key_value_pairs = {'completed': -1,
                           'runpath': runpath}
        param_dict = params2dict(runpath + '/parameters.json')
        atoms = ase.io.read(runpath + '/initial.POSCAR')

        PC = PrototypeClassification(atoms)
        prototype, cell_parameters = PC.get_classification()

        key_value_pairs.update(prototype)
        key_value_pairs.update(cell_parameters)
        key_value_pairs.update(param_dict)

        key_value_pairs = clean_key_value_pairs(
            key_value_pairs)
        data = {}
        if os.path.isfile(runpath + '/err'):
            with open(runpath + '/err', 'r') as errorf:
                data.update({'error': errorf.read().replace("'", '')})

        if os.path.isfile(runpath + '/err.relax'):
            with open(runpath + '/err.relax', 'r') as errorf:
                data.update({'error_relax': errorf.read().replace("'", '')})

        self.ase_db.update(id=calcid,
                           **key_value_pairs,
                           data=data)
コード例 #10
0
    def save_completed_calculation(self, atoms, runpath, calcid,
                                   read_params=True):

        batch_no = self.ase_db.get(id=calcid).get('batch', None)

        PC = PrototypeClassification(atoms)
        prototype, cell_parameters = PC.get_classification()

        key_value_pairs = self.ase_db.get(id=calcid).get('key_value_pairs', {})

        key_value_pairs.update({'relaxed': 1,
                                'completed': 1,
                                'initial_id': calcid,
                                'runpath': runpath})
        key_value_pairs.update(prototype)
        key_value_pairs.update(cell_parameters)

        if batch_no:
            key_value_pairs.update({'batch': batch_no})

        param_dict = {}
        if read_params:
            param_dict = params2dict(runpath + '/parameters.json')
            key_value_pairs.update(param_dict)

        atoms = set_calculator_info(atoms, param_dict)

        key_value_pairs = clean_key_value_pairs(key_value_pairs)

        newcalcid = self.ase_db.write(atoms, key_value_pairs)
        self.ase_db.update(id=calcid,
                           final_id=newcalcid,
                           completed=1)

        return newcalcid
コード例 #11
0
    def reclassify(self, tolerance=0.5e-3):
        """Reclassify prototypes of all completed structures"""
        self._collect()
        con = self.connection or self._connect()
        self._initialize(con)

        for row in self.ase_db.select(relaxed=1):

            PC = PrototypeClassification(row.toatoms())
            prototype, cell_parameters = PC.get_classification()
            prototype.update(cell_parameters)
            prototype = clean_key_value_pairs(prototype)
            self.ase_db.update(row.id, **prototype)
コード例 #12
0
    def test7_weird_cell(self):

        filename = path + '/IrO_167.cif'

        atoms = read(filename)
        PC = PrototypeClassification(atoms)

        prototype_ref, parameters_ref = PC.get_classification()

        filename = path + '/000__id-unique_8p8evt9pcg__id-short_207.cif'

        atoms = read(filename)
        PC = PrototypeClassification(atoms, tolerance=0.09)

        prototype, parameters = PC.get_classification()

        for key, value in prototype_ref.items():
            assert prototype[key] == value
コード例 #13
0
from ase.io import read
from sys import argv
from protosearch.build_bulk.classification import PrototypeClassification

# Script to print structure prototype and parameters

atoms = read(argv[1])
PC = PrototypeClassification(atoms)

prototype, parameters = PC.get_classification()
print('Prototype:', prototype, '\nParameters:', parameters)