Esempio n. 1
0
 def test_get_labels(self):
     one = {
         'M': 1,
         'X': 2,
         'Y': 3,
         'Area': 15.0,
         'Energy': -56.9,
         'Label': "one"
     }
     two = {
         'M': 1,
         'X': 2,
         'Y': 3,
         'Area': 15.0,
         'Energy': -56.9,
         'Label': "two"
     }
     three = {
         'M': 1,
         'X': 2,
         'Y': 3,
         'Area': 15.0,
         'Energy': -56.9,
         'Label': "three"
     }
     data = [one, two, three]
     ticks = np.array([1, 2, 3])
     labels = ut.get_labels(ticks, data)
     expected = ['one', 'two', 'three']
     assert labels == expected
Esempio n. 2
0
def calculate(data, bulk, deltaX, deltaY, x_energy, y_energy, mu_z, exp_x,
              exp_y):
    """Initialise the free energy calculation.

    Parameters
    ----------
    data : :py:attr:`list`
        List containing the :py:class:`surfinpy.data.DataSet` objects for each phase
    bulk : :py:class:`surfinpy.data.ReferenceDataSet`
        Reference dataset
    x : :py:attr:`dict`
        X axis chemical potential values
    y : :py:attr:`dict`
        Y axis chemical potential values
    nphases : :py:attr:`int`
        Number of phases
    x_energy : :py:attr:`float`
        DFT 0K energy for species x
    y_energy : :py:attr:`float`
        DFT 0K energy for species y
    mu_z :  :py:attr:`float`
        Set chemical potential for species y
    exp_x : :py:attr:`float`
        Experimental correction for species x
    exp_y : :py:attr:`float`
        Experimental correction for species y

    Returns
    -------
    system : :py:class:`surfinpy.plotting.MuTPlot`
        Plotting object
    """
    nphases = len(data)

    X = np.arange(deltaX['Range'][0], deltaX['Range'][1], 0.01, dtype="float")
    Y = np.arange(deltaY['Range'][0], deltaY['Range'][1], 0.01, dtype="float")
    vd.recalculate_vib(data, bulk)
    phases, SE = evaluate_phases(
        data,
        bulk,
        X,
        Y,
        nphases,
        x_energy,
        y_energy,
        mu_z,
        exp_x,
        exp_y,
    )
    ticks = np.unique([phases])
    colors = ut.list_colors(data, ticks)
    phases = ut.transform_numbers(phases, ticks)
    Z = np.reshape(phases, (Y.size, X.size))
    SE = np.reshape(SE, (Y.size, X.size))
    labels = ut.get_labels(ticks, data)
    system = plotting.MuTPlot(X, Y, Z, labels, ticks, colors, deltaX['Label'],
                              deltaY['Label'])
    return system
Esempio n. 3
0
def calculate(data, bulk, deltaX, deltaY, x_energy=0, y_energy=0,
              temperature=0, output="Phase_Diagram.png"):
    """Initialise the surface energy calculation.

    Parameters
    ----------
    data : list
        List of dictionaries for each phase
    bulk : dictionary
        Dictionary containing data for bulk
    deltaX : dictionary
        Range of chemical potential/label for species X 
    DeltaY : dictionary
        Range of chemical potential/label for species Y 
    x_energy : float
        DFT energy of adsorbing species
    y_energy : float
        DFT energy of adsorbing species
    temperature : int
        Temperature
    output : str
        Output file name

    Returns
    -------
    system : class obj
        Plotting object
    """
    data = sorted(data, key=lambda k: (k['Y']))
    nsurfaces = len(data)
    X = np.arange(deltaX['Range'][0], deltaX['Range'][1],
                  0.025, dtype="float")
    Y = np.arange(deltaY['Range'][0], deltaY['Range'][1],
                  0.025, dtype="float")
    X = X - x_energy
    Y = Y - y_energy
    phases = evaluate_phases(data, bulk, X, Y,
                             nsurfaces, x_energy, y_energy)
    ticks = np.unique([phases])
    phases = ut.transform_numbers(phases, ticks)
    Z = np.reshape(phases, (Y.size, X.size))
    labels = ut.get_labels(ticks, data)
    system = chemical_potential_plot.ChemicalPotentialPlot(X,
                                                           Y,
                                                           Z,
                                                           labels,
                                                           ticks,
                                                           deltaX['Label'],
                                                           deltaY['Label'])
    return system
Esempio n. 4
0
def calculate(data, bulk, deltaX, deltaY, x_energy=0, y_energy=0, increments=0.025):
    """Initialise the surface energy calculation.

    Parameters
    ----------
    data : :py:attr:`list`
        List of :py:class:`surfinpy.data.DataSet` for each phase
    bulk : :py:class:`surfinpy.data.ReferenceDataSet`
        Data for bulk
    deltaX : :py:attr:`dict`
        Range of chemical potential/label for species X 
    DeltaY : :py:attr:`dict`
        Range of chemical potential/label for species Y 
    x_energy : :py:attr:`float`
        DFT energy of adsorbing species
    y_energy : :py:attr:`float`
        DFT energy of adsorbing species

    Returns
    -------
    system : :py:class:`surfinpy.plotting.ChemicalPotentialPlot`
        Plotting object
    """
    nsurfaces = len(data)
    
    X = np.arange(deltaX['Range'][0], deltaX['Range'][1],
                  increments, dtype="float")
    Y = np.arange(deltaY['Range'][0], deltaY['Range'][1],
                  increments, dtype="float")
    X = X - x_energy
    Y = Y - y_energy
    phases, SE = evaluate_phases(data, bulk, X, Y,
                             nsurfaces, x_energy, y_energy)
    ticks = np.unique([phases])
    colors = ut.list_colors(data, ticks)
    phases = ut.transform_numbers(phases, ticks)
    Z = np.reshape(phases, (Y.size, X.size))
    SE = np.reshape(SE, (Y.size, X.size))
    labels = ut.get_labels(ticks, data)
    system = plotting.ChemicalPotentialPlot(X,
                                            Y,
                                            Z,
                                            labels,
                                            ticks,
                                            colors,
                                            deltaX['Label'],
                                            deltaY['Label'])
    return system, SE
Esempio n. 5
0
 def test_get_labels(self):
     H20 = data.DataSet(cation=24,
                        x=48,
                        y=2,
                        area=60.22,
                        energy=-570.00,
                        label="One",
                        nspecies=1)
     H2O_2 = data.DataSet(cation=24,
                          x=48,
                          y=4,
                          area=60.22,
                          energy=-570.00,
                          label="Two",
                          nspecies=1)
     dataset = [H20, H2O_2]
     ticks = np.array([1, 2])
     labels = ut.get_labels(ticks, dataset)
     expected = ['One', 'Two']
     assert labels == expected