surfinpy.utils

surfinpy.utils.build_xgrid(x, y)[source]

Builds a 2D grip of values for the x axis.

Parameters:
  • x (array like) – numpy array
  • y (array like) – numpy array
Returns:

xnew – numpy array

Return type:

array like

surfinpy.utils.build_ygrid(x, y)[source]

Builds a 2D grip of values for the y axis.

Parameters:
  • x (array like) – numpy array
  • y (array like) – numpy array
Returns:

xnew – numpy array

Return type:

array like

surfinpy.utils.calculate_coverage(data)[source]

Calcualte the coverage of the adsorbing species on each surface.

Parameters:data (list) – list of dictionaries containing info on each surface calculation
Returns:coverage – numpy array of coverage values in units of \(n/nm^2\)
Return type:array like
surfinpy.utils.calculate_gibbs(t, s, h)[source]

Calculate the gibbs free energy from thermochemcial data obtained from the NIST_JANAF database

Parameters:
  • t (array like) – Temperature range
  • s (array like) – delta s values from nist
  • h (array like) – selta h values from nist
Returns:

g – gibbs energy as a function of temperature

Return type:

array like

surfinpy.utils.fit(x, y, t)[source]

Fit a polynominal function to thermochemical data from NIST_JANAF

Parameters:
  • x (array like) – x axis for fit
  • y (array like) – y axis for fit
  • t (array like) – x axis to be fitted
Returns:

shift – data fitted from x and y to t

Return type:

array like

surfinpy.utils.get_labels(ticks, data)[source]

Reads the phase diagram data and returns the labels that correspond to the phases displayed on the phase diagram.

Parameters:
  • ticks (list) – Phases that are displayed.
  • data (list) – list of dictionaries.
Returns:

labels – list of labels.

Return type:

list

surfinpy.utils.get_levels(X)[source]

Builds the levels used in the contourf plot. This is neccesary to ensure that each color correpsonds to a single phase.

Parameters:X (array like) – 2D array of ints corresponding to each phase.
Returns:levels – numpy array of ints
Return type:array like
surfinpy.utils.get_phase_data(S, nsurfaces)[source]

Determines which surface composition is most stable at a given x and y value.

Parameters:
  • S (array like) – 2D array of surface energies
  • nsurfaces (int) – Total number of surfaces
Returns:

x – array of ints corresponding to the position of the lowest phase

Return type:

array like

surfinpy.utils.get_ticks(X)[source]

I have no idea what this does

surfinpy.utils.pressure(chemical_potential, t)[source]

Converts chemical potential at a specific temperature (T) to a pressure value.

\[P = \frac{\mu}{k * T}\]

where P is the pressure, \(\mu\) is the chemcial potential, k is the Boltzmann constant and T is the temperature.

Parameters:
  • chemical_potential (array like) – delta mu values
  • t (int) – temperature
Returns:

pressure – pressure values as a function of chemcial potential

Return type:

array like

surfinpy.utils.read_nist(File)[source]

Read a downloaded NIST_JANAF thermochemcial table

Parameters:File (str) – filename of table
Returns:data – table as an array
Return type:array_like
surfinpy.utils.transform_numbers(Z, ticks)[source]

transform numbers - Takes the phase diagram array and converts the numbers to numbers scaled 0, 1, 2, etc in order to make plotting easier

Parameters:
  • Z (array like) – array of integers
  • ticks (list) – unique phases
Returns:

Z – Normalised to a continuous set of numbers.

Return type:

array like