예제 #1
0
def DMSP_directory_builder(filepath,
                           dmsp_predictions_dict,
                           criteria=no_criteria):
    ''' Builds out the dmsp directory tree inside the given filepath '''
    ''' Saves the POSCAR to the appropriate locations within the directory tree '''
    ''' Needs the dictionary values to be lists of pymatgen.alchemy.materials.TransformedStructure objects '''
    ''' This way the 'source' tag in the .history dictionary can be used to name the directories '''
    ''' If an mp-id directory already exists, count is added to the end of the path during directory creation '''
    ''' References the oxide_check functions as criteria; no_criteria always returns True, meaning criteria was passed '''

    dls = DLSVolumePredictor(min_scaling=0.5, max_scaling=2)

    for key in dmsp_predictions_dict.keys():
        compound_directory_name = key.replace(' ', '_')
        compound_directory_path = filepath + '/%s' % compound_directory_name

        for structure_object in dmsp_predictions_dict[
                key]:  # for pymatgen.alchemy.materials.TransformedStructure object
            structure = structure_object.final_structure
            prim_check = SpacegroupAnalyzer(structure)

            if prim_check.find_primitive() != None:
                structure = prim_check.find_primitive(
                )  # get the primitive structure, if it exists
            else:
                continue

            criteria_check = criteria(structure)

            if os.path.isdir(
                    compound_directory_path
            ) or criteria_check == False:  # pre-existing directories, non-oxides
                continue

            else:
                os.mkdir(compound_directory_path)
                structure_directory_name = structure_object.history[0][
                    'source']
                structure_directory_path = compound_directory_path + '/%s' % structure_directory_name
                scaled_structure = dls.get_predicted_structure(structure)
                count = 1

                if os.path.isdir(structure_directory_path
                                 ):  # if mp-id directory already exists
                    numbered_directory_path = structure_directory_path + '_%s' % count
                    os.mkdir(numbered_directory_path)
                    scaled_structure.to(fmt='poscar',
                                        filename=numbered_directory_path +
                                        '/POSCAR')
                    count += 1

                else:
                    os.mkdir(structure_directory_path)
                    scaled_structure.to(fmt='poscar',
                                        filename=structure_directory_path +
                                        '/POSCAR')

    return
예제 #2
0
def refine_and_resize_structure(struct, refine_cell=True, resize_volume=True):
    if resize_volume:
        dls = DLSVolumePredictor()
        struct = dls.get_predicted_structure(struct)
        struct.apply_strain(0.5)

    if refine_cell:
        sga = SpacegroupAnalyzer(struct)
        # SpacegroupAnalyzer.get_primitive_standard_structure may return incorrect structures
        # So we avoid to use SpacegroupAnalyzer.get_primitive_standard_structure
        struct = sga.get_refined_structure()

    return struct
예제 #3
0
def volume_predict(structure: Structure) -> (Structure, float):
    '''
    Returns the scaled structure and volume of given structure according to
    pymatgen's prediction

    @in
      - structure, Structure, given structure
    @out
      - Structure, scaled structure
      - float, volume of the scaled strcture
    '''
    dls = DLSVolumePredictor()
    st = structure
    dls_st = dls.get_predicted_structure(st)
    volume = dls.predict(st)
    return (dls_st, volume)
예제 #4
0
    def test_predict(self):
        p = DLSVolumePredictor()
        p_fast = DLSVolumePredictor(
            cutoff=0.0)  # for speed on compressed cells

        fen = Structure.from_file(os.path.join(dir_path, "FeN_mp-6988.cif"))
        self.assertAlmostEqual(p.predict(fen), 18.2252568873)
        fen.scale_lattice(3.0)
        self.assertAlmostEqual(p.predict(fen), 18.2252568873)
        fen.scale_lattice(0.24)
        self.assertAlmostEqual(p.predict(fen), 18.2252568873)

        lfpo = PymatgenTest.get_structure("LiFePO4")
        lfpo.scale_lattice(10.1)
        self.assertAlmostEqual(p.predict(lfpo), 291.62094410192924)
        lfpo.scale_lattice(0.2)
        self.assertAlmostEqual(p_fast.predict(lfpo), 291.62094410192924)
        lmpo = PymatgenTest.get_structure("LiFePO4")
        lmpo.replace_species({"Fe": "Mn"})
        self.assertAlmostEqual(p.predict(lmpo), 290.795329052)
예제 #5
0
    def test_predict(self):
        p = DLSVolumePredictor()
        p_fast = DLSVolumePredictor(cutoff=0.0)  # for speed on compressed cells

        fen = Structure.from_file(os.path.join(dir_path, "FeN_mp-6988.cif"))
        self.assertAlmostEqual(p.predict(fen), 18.2252568873)
        fen.scale_lattice(3.0)
        self.assertAlmostEqual(p.predict(fen), 18.2252568873)
        fen.scale_lattice(0.24)
        self.assertAlmostEqual(p.predict(fen), 18.2252568873)

        lfpo = PymatgenTest.get_structure("LiFePO4")
        lfpo.scale_lattice(10.1)
        self.assertAlmostEqual(p.predict(lfpo), 291.62094410192924)
        lfpo.scale_lattice(0.2)
        self.assertAlmostEqual(p_fast.predict(lfpo), 291.62094410192924)
        lmpo = PymatgenTest.get_structure("LiFePO4")
        lmpo.replace_species({"Fe": "Mn"})
        self.assertAlmostEqual(p.predict(lmpo), 290.795329052)
예제 #6
0
    def test_predict(self):
        p = DLSVolumePredictor()
        p_fast = DLSVolumePredictor(cutoff=0.0)  # for speed on compressed cells
        p_nolimit = DLSVolumePredictor(min_scaling=None, max_scaling=None)  # no limits on scaling

        fen = Structure.from_file(os.path.join(dir_path, "FeN_mp-6988.cif"))

        self.assertAlmostEqual(p.predict(fen), 18.2252568873)
        fen.scale_lattice(fen.volume * 3.0)
        self.assertAlmostEqual(p_nolimit.predict(fen), 18.2252568873)
        self.assertAlmostEqual(p.predict(fen), fen.volume * 0.5)
        fen.scale_lattice(fen.volume * 0.1)
        self.assertAlmostEqual(p_nolimit.predict(fen), 18.2252568873)
        self.assertAlmostEqual(p.predict(fen), fen.volume * 1.5)
        self.assertAlmostEqual(p_fast.predict(fen), fen.volume * 1.5)

        lfpo = PymatgenTest.get_structure("LiFePO4")

        lfpo.scale_lattice(lfpo.volume * 3.0)
        self.assertAlmostEqual(p_nolimit.predict(lfpo), 291.62094410192924)
        self.assertAlmostEqual(p.predict(lfpo), lfpo.volume * 0.5)
        lfpo.scale_lattice(lfpo.volume * 0.1)
        self.assertAlmostEqual(p_nolimit.predict(lfpo), 291.62094410192924)
        self.assertAlmostEqual(p.predict(lfpo), lfpo.volume * 1.5)
        self.assertAlmostEqual(p_fast.predict(lfpo), lfpo.volume * 1.5)

        lmpo = PymatgenTest.get_structure("LiFePO4")
        lmpo.replace_species({"Fe": "Mn"})
        self.assertAlmostEqual(p.predict(lmpo), 290.795329052)
예제 #7
0
import numpy as np
import glob
from tqdm import tqdm
from ase.io import read,write
from pymatgen.io.ase import AseAtomsAdaptor
from pymatgen.analysis.structure_prediction.volume_predictor import DLSVolumePredictor

lists = glob.glob('*.cif')
for ll in tqdm(lists):
	atoms = read(ll)

	struct = AseAtomsAdaptor.get_structure(atoms)
	v0 = struct.volume
	dls_predictor = DLSVolumePredictor()

	ref_struct = dls_predictor.get_predicted_structure(struct)
	v1 = ref_struct.volume
	name = ll.split('.')[0]+'_dlsVP.cif'
	ref_struct.to(filename=name)
	print(ll.split('.')[0],(v1/v0)**(1./3.))