Exemplo n.º 1
0
def calculate(stoich,
              data,
              SE,
              adsorbant,
              thermochem,
              max_t=1000,
              min_p=-13,
              max_p=5.5,
              coverage=None,
              transform=True):
    '''Collects input variables and intitialises the calculation.

    Parameters
    ----------
    stoich : :py:class:`surfinpy.data.DataSet`
        information about the stoichiometric surface
    data : :py:attr:`list`
        list of :py:class:`surfinpy.data.DataSet` objects on the "adsorbed" surfaces
    SE : :py:attr:`float`
        surface energy of the stoichiomteric surface
    adsorbant : :py:attr:`float`
        dft energy of adsorbing species
    coverage : :py:attr:`array_like` (default None)
        Numpy array containing the different coverages of adsorbant.
    thermochem : :py:attr:`array_like`
        Numpy array containing thermochemcial data downloaded from NIST_JANAF
        for the adsorbing species.
    max_t : :py:attr:`int`
        Maximum temperature in the phase diagram
    min_p : :py:attr:`int`
        Minimum pressure of phase diagram
    max_p : :py:attr:`int`
        Maximum pressure of phase diagram

    Returns
    -------
    system : :py:class:`surfinpy.plotting.PTPlot`
        plotting object
    '''
    if coverage is None:
        coverage = ut.calculate_coverage(data)
    lnP, logP, T, adsorbant_t = inititalise(thermochem, adsorbant, max_t,
                                            min_p, max_p)
    nsurfaces = len(data) + 1
    AE = adsorption_energy(data, stoich, adsorbant_t)
    SE_array, SEABS = calculate_surface_energy(AE, lnP, T, coverage, SE,
                                               nsurfaces)
    ticks = np.unique([SE_array])
    if transform is True:
        SE_array = ut.transform_numbers(SE_array, ticks)

    phase_grid = np.reshape(SE_array, (lnP.size, T.size))
    SEABS = np.reshape(SEABS, (lnP.size, T.size))
    data.insert(0, stoich)
    y = logP
    x = T
    z = phase_grid
    system = plotting.PTPlot(x, y, z)
    return system
Exemplo 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
Exemplo n.º 3
0
def calculate(stoich,
              data,
              SE,
              adsorbant,
              thermochem,
              max_t=1000,
              min_p=-13,
              max_p=5.5,
              coverage=None):
    '''Collects input variables and intitialises the calculation.

    Parameters
    ----------
    stoich : dictionary
        information about the stoichiometric surface
    data : list
        list of dictionaries containing information on the "adsorbed" surfaces
    SE : float
        surface energy of the stoichiomteric surface
    adsorbant : float
        dft energy of adsorbing species
    coverage : array like (default None)
        Numpy array containing the different coverages of adsorbant.
    thermochem : array like
        Numpy array containing thermochemcial data downloaded from NIST_JANAF
        for the adsorbing species.
    max_t : int
        Maximum temperature in the phase diagram
    min_p : int
        Minimum pressure of phase diagram
    max_p : int
        Maximum pressure of phase diagram

    Returns
    -------
    system : class object
        plotting object
    '''
    if coverage is None:
        coverage = ut.calculate_coverage(data)
    lnP, logP, T, adsorbant_t = inititalise(thermochem, adsorbant, max_t,
                                            min_p, max_p)
    nsurfaces = len(data) + 1
    AE = adsorption_energy(data, stoich, adsorbant_t)
    SE_array, SE = calculate_surface_energy(AE, lnP, T, coverage, SE,
                                            nsurfaces)
    ticks = np.unique([SE_array])
    SE_array = ut.transform_numbers(SE_array, ticks)
    phase_grid = np.reshape(SE_array, (lnP.size, T.size))
    data.insert(0, stoich)
    y = logP
    x = T
    z = phase_grid
    system = pvt_plot.PVTPlot(x, y, z)
    return system, SE
Exemplo n.º 4
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
Exemplo n.º 5
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
Exemplo n.º 6
0
 def test_transform_numbers(self):
     Z = np.array([2, 2, 3, 3])
     ticks = np.array([2, 3])
     Z = ut.transform_numbers(Z, ticks)
     expected = np.array([0, 0, 1, 1])
     assert np.array_equal(Z, expected)