Esempio n. 1
0
def load_datagrid_sim(folder, arr, x):
    '''
    Load cif files from folder into ase crystal objects, simulate crystal
    diffraction and represent data in timeseries
    Args:
        folder (string): Where we load the data from.
        arr (list): List of cif filenames in folder.
        x (nparray): representation of 1/angström for powder simulation.

    Returns:
        fd (datagrid): representation of intensity values and 1/angström
        values in datagrid object.

    '''
    filename_arr = []
    crys_arr = []
    for file in arr:
        filename = os.sep.join([folder, file])
        filename_arr.append(file)
        crys = read(filename)
        crys = Crystal.from_ase(crys)

        diff = powdersim(crys, x)
        diff_norm = diff / diff.max()
        crys_arr.append(diff_norm)

    crys_arr = np.array(crys_arr)

    print(crys_arr)

    return crys_arr
Esempio n. 2
0
def pow_sim(path1):
    filename1 = Path(path1).name
    #filename2 = Path(path2).name    

    # load cif file to an ase object
    cry1 = read(path1)
    #cry2 = read(path2)

    # crystal object for powdersim in skued lib
    crys1 = Crystal.from_ase(cry1)
    #crys2 = Crystal.from_ase(cry2)

    # powder simulation with range of q 
    q = np.linspace(1, 7, 512)
    diff1 = powdersim(crys1, q, fwhm_g = 0.01, fwhm_l=0.03)
    #diff2 = powdersim(crys2, q)

    # matplotlib config
    plt.figure()
    plt.plot(q, diff1/diff1.max(), '-b', label=filename1, alpha= 0.3)
    #plt.plot(q, diff2/diff2.max(), '-r', label=filename2, alpha= 0.3)
    plt.legend()
    plt.xlim([q.min(), q.max()])
    plt.xlabel('$q (1/\AA)$')
    plt.ylabel('Diffracted intensity (A.u.)')
    plt.title('Crystal diffraction ')
    plt.show()
def load_datagrid_sim(folder, arr, x):
    '''
    Load cif files from folder into ase crystal objects, simulate crystal
    diffraction and represent data in timeseries
    Args:
        folder (string): Where we load the data from.
        arr (list): List of cif filenames in folder.
        x (nparray): representation of 1/angström for powder simulation.

    Returns:
        fd (datagrid): representation of intensity values and 1/angström
        values in datagrid object.

    '''
    filename_arr = []
    crys_arr = []
    for file in arr:
        filename = os.sep.join([folder, file])
        filename_arr.append(file)
        crys = read(filename)
        crys = Crystal.from_ase(crys)

        diff = powdersim(crys, x, fwhm_l=50)
        diff_norm = diff / diff.max()
        crys_arr.append(diff_norm)

    crys_arr = np.array(crys_arr)
    fd = FDataGrid(crys_arr,
                   x,
                   dataset_name='Diffraction Curves',
                   argument_names=[r'$q (1/\AA)$'],
                   coordinate_names=['Diffracted intensity (A.u.)'])
    print(fd)

    return fd
Esempio n. 4
0
    def test_back_and_forth(self):
        """ Test conversion to and from ase Atoms """
        to_ase = self.crystal.to_ase()
        crystal2 = Crystal.from_ase(to_ase)

        # ase has different handling of coordinates which can lead to
        # rounding beyond 1e-3. Therefore, we cannot compare directly sets
        # self.assertSetEqual(set(self.crystal), set(crystal2))
        self.assertEqual(len(self.crystal), len(crystal2))
Esempio n. 5
0
def test_ase_atoms_back_and_forth(name):
    """ Test conversion to and from ase Atoms """
    crystal = Crystal.from_database(name)
    to_ase = crystal.to_ase()
    crystal2 = Crystal.from_ase(to_ase)

    # ase has different handling of coordinates which can lead to
    # rounding beyond 1e-3. Therefore, we cannot compare directly sets
    # assertSetEqual(set(crystal), set(crystal2))
    assert len(crystal) == len(crystal2)
Esempio n. 6
0
import numpy as np
from skued import powdersim
#from skued import Crystal

filename1 = r"C:\Python\Projects\crystal-phase-prediction\crystal_data\CIFs\Ag_HfO2_cat_3.125_222_m.cif"
filename2 = r"C:\Python\Projects\crystal-phase-prediction\crystal_data\CIFs\Ag_HfO2_cat_3.125_222_o.cif"



# load cif file to an ase object
s = read(filename1)
s2 = read(filename2)
s1 = crystal(s)

# crystal object for powdersim in skued lib
crys = Crystal.from_ase(s1)
pure_cry = Crystal.from_ase(s2)

# visualize crystal 
view(s)
#print(s.get_positions())
#print(s.get_atomic_numbers())
#print(s.get_cell()[:])

# powder simulation with range of q 
q = np.linspace(1, 5, 100)
diff1 = powdersim(crys, q)
diff2 = powdersim(pure_cry, q)

# diff1 = powdersim(cry1, q, fwhm_g=0.01, fwhm_l=1)
# diff2 = powdersim(cry2, q, fwhm_g=0.01, fwhm_l=1)