Ejemplo n.º 1
0
    def get_extremal_mode_vectors(self, save2file=True):
        """
        This function gets the values of the displacements of the irreducible
        sites of the structures between which we are interpolating.
        """
        if self.modeValues is not None:
            print("Extremal modes have already been extracted.")
            return None

        if 'modevals_dict.npy' in os.listdir("."):
            if self.verbose:
                print("Reading end-member mode values from .npy file.")

            self.modeValues = list(
                np.load('modevals_dict.npy', allow_pickle="TRUE"))
        else:
            # Initialise Isodistort instance with HTT
            iso = isodistort(self.HS, silent=self.silent)
            self.modeValues = []

            for lsFile in [self.LS1, self.LS2]:
                iso.load_lowsym_structure(lsFile)
                iso.get_mode_labels()
                self.modeValues.append(iso.modevalues)

            iso.close()

            if self.verbose:
                return self.modeValues
            elif save2file:
                #Save to binary file if requested
                np.save('modevals_dict.npy', self.modeValues)
Ejemplo n.º 2
0
    def print_interp_cif(self, extent='all'):
        # Launch ISODISTORT class instance
        # Load HS and starting-point LS structures
        itp = isodistort(self.HS, silent=self.silent)
        itp.load_lowsym_structure(self.LS1)
        itp.get_mode_labels()

        if extent == 'all':
            for key in self.interpList:
                if self.verbose:
                    print(key)
                # Define filename
                fname = "La2MgO4_interpolated_{:.3f}_{:.3f}.cif".\
                        format(key[0], key[1])

                # Pass if filename already in directory
                if fname in os.listdir('.'):
                    continue

                assert 'subgroup_cif(1).txt' not in os.listdir('.'),\
                    "New structure 'subgroup_cif.txt' downloaded " + \
                    "before previous one was converted."

                # Set the mode values for this interpolation
                # Iterate over interpolation entries
                itp.modevalues = self.interpList[key]
                itp.set_amplitudes()
                itp.save_cif(fname=fname)

        elif extent in self.interpList:
            key = extent
            if self.verbose:
                print(key)

            # Set the mode values for this interpolation
            # Iterate over interpolation entries
            itp.modevalues = self.interpList[key]
            itp.set_amplitudes()
            fname = "La2MgO4_interpolated_{:1.3f}_{:1.3f}.cif".\
                    format(key[0], key[1])
            itp.save_cif(fname=fname)

        # Close ISODISTORT page instance.
        time.sleep(2)
        itp.close()
        return None
Ejemplo n.º 3
0
    def reduce_common_subgroup(self):
        """
        This function reduces the two low-symmetry files to a common subgroup
        with common lattice parameters.

        Parameters:
        ----------
        subgroup: int
            The number corresponding to the space group of the common subgroup
            to both low-symmetry structures.

        cellparams: int
            The lattice parameters to use for the common reduction of both
            low-symmetry structures. 0: high-symmetry file, 1: low-symmetry
            file 1, 2: low-symmetry file 2.

        Returns:
        --------
        LS#file_"subgroup".cif: file
            Two CIF files in the same directory for the two reduced structures
        """

        for sfile in [self.LS1, self.LS2]:
            # Initialise ISODISTORT and get reduced structure
            iso = isodistort(sfile, silent=self.silent)
            iso.choose_by_spacegroup(self.subgroup)
            iso.select_space_group()

            # Save CIF file and get new name
            sfile = sfile.replace('.cif', '_{}.cif'.format(self.subgroup))
            iso.save_cif(fname=sfile, close=True)
            count = 0
            while sfile not in os.listdir("."):
                time.sleep(1)
                assert count < 10, "Printing CIF file took too long."

        return None
Ejemplo n.º 4
0
    def check_mode_vector(self, filename, mode):
        """
        This function checks whether the mode amplitude of the generated file
        has the expected angle and magnitude.

        Parameters:
        -----------
        filename: str
            CIF file given as interpolated_rho_theta.cif

        Returns:
        """
        seed = filename.strip("interpolated_").strip(".cif")
        (rho, theta) = (float(seed.split("_")[0]), float(seed.split("_")[1]))

        isocheck = isodistort(self.HS, silent=self.silent)
        isocheck.load_lowsym_structure(filename)
        isocheck.get_mode_labels()

        modevalues = isocheck.modevalues[mode]
        isocheck.close()
        N = len(modevalues)
        norm = round(la.norm(modevalues), 3)
        try:
            thetas = (180 / np.pi)*np.array([np.arctan(modevalues[i]/\
                modevalues[i+1]) for i in range(0, N, 2)])
        except ZeroDivisionError:
            thetas = np.array([0.0, 0.0, 0.0])
        #assert abs(rho - norm) < 1e-3, "The magnitudes of the modes are not"+\
        #        "the same as what is expected. The expected norm is" + str(rho) + \
        #       " and the calculated norm is " + str(norm)

        #assert abs(thetas[0] - theta) > 1e-3, "The angles are not the same "+\
        #"The expected angle is {.1f} and the calculated angle is {.1f}." % \
        #(theta, thetas[0])
        return modevalues, rho, theta, norm, thetas
Ejemplo n.º 5
0
import sys
from isodistortfile import isodistort

"""
Script for representing a cif file as a lower symmetry space group by
inputing zero amplitude distortions using isodistort

e.g.
./iso_index_as.py input.cif output.cif 31

To make an output file that is space group 31 from input.cif

or ./iso_index_as.py input.cif output.cif 31 2

If you know that the particular SG 31 cell you want is the third option.
"""

HSfile = os.getcwd()+'/'+sys.argv[1]
outputfile = sys.argv[2]
SG = int(sys.argv[3])
if len(sys.argv) > 4:
    list_id = int(sys.argv[4])
else:
    list_id = 0

iso = isodistort(HSfile, silent=True)
iso.choose_by_spacegroup(SG)
iso.select_space_group(list_id=list_id)
iso.set_amplitudes(outputfile, {})
iso.close()