def test_initialise(self): x = ut.read_nist(test_data) a, b, c, d = p_vs_t.inititalise(x, -10.0, 1000, -13, 5.5) assert_almost_equal(d[0], -10.000, decimal=3) assert_almost_equal(d[1], -10.000, decimal=3) assert_almost_equal(d[-1], -10.103, decimal=3) assert_almost_equal(d[-2], -10.103, decimal=3)
def test_calculate(self): stoich = DataSet(cation=24, x=48, y=0, area=60.22, energy=-530.0, label="Stoich") H2O = DataSet(cation=24, x=48, y=2, area=60.22, energy=-620.0, label="Stoich") H2O_2 = DataSet(cation=24, x=48, y=4, area=60.22, energy=-677.0, label="Stoich") data = [H2O, H2O_2] SE = 1.0 adsorbant = -10.0 thermochem = ut.read_nist(test_data) system = p_vs_t.calculate(stoich, data, SE, adsorbant, thermochem) expectedx = np.arange(2, 1000) expectedy = np.arange(-13, 5.5, 0.1) expectedz = np.zeros(((expectedy.size), (expectedx.size))) assert_almost_equal(system.x, expectedx) assert_almost_equal(system.y, expectedy) assert_almost_equal(system.z, expectedz)
def test_wulff_calculate(self): stoich = data.DataSet(cation=20, x=50, y=0, area=60.00, energy=-500.00, label="One") H2O = data.DataSet(cation=20, x=50, y=2, area=60.00, energy=-600.00, label="Two") dataset = [H2O] x = ut.read_nist(test_data) y = wulff.calculate_surface_energy(stoich, dataset, 1.0, -10.0, x, 100, 2) assert_almost_equal(y[0], 1.0) assert_almost_equal(y[1], -9.6914, decimal=4)
def temperature_correction(nist_file, temperature): """Use experimental data to correct the DFT free energy of an adsorbing species to a specific temperature. Parameters ---------- nist_file : array like numpy array containing experiemntal data from NIST_JANAF temperature : int Temperature to correct to Returns ------- gibbs : float correct free energy """ nist_data = ut.read_nist(nist_file) h0 = nist_data[0, 4] fitted_s = ut.fit(nist_data[:, 0], nist_data[:, 2], np.arange(1, 1000)) fitted_h = ut.fit(nist_data[:, 0], nist_data[:, 4], np.arange(1, 1000)) fitted_h = fitted_h + h0 gibbs = ut.calculate_gibbs(np.arange(1, 1000), fitted_s, fitted_h) return gibbs[(temperature - 1)]
def test_calculate(self): stoich = { 'M': 24, 'X': 48, 'Y': 0, 'Area': 60.22, 'Energy': -530.0, 'Label': '0' } H2O = { 'M': 24, 'X': 48, 'Y': 2, 'Area': 60.22, 'Energy': -620.0, 'Label': '1' } H2O_2 = { 'M': 24, 'X': 48, 'Y': 4, 'Area': 60.22, 'Energy': -670.0, 'Label': '2' } data = [H2O, H2O_2] SE = 1.0 adsorbant = -10.0 thermochem = ut.read_nist(test_data) system, SE = p_vs_t.calculate(stoich, data, SE, adsorbant, thermochem) expectedx = np.arange(2, 1000) expectedy = np.arange(-13, 5.5, 0.1) expectedz = np.zeros(((expectedy.size), (expectedx.size))) assert_almost_equal(system.x, expectedx) assert_almost_equal(system.y, expectedy) assert_almost_equal(system.z, expectedz)
def test_read_nist(self): x = ut.read_nist(test_data) assert x[1, 0] == 100 assert x[10, 0] == 1000 assert x[1, 1] == 1
def test_temperature_correction(self): x = ut.read_nist(test_data) adsorbant = wulff.temperature_correction(100, x, -10.0) assert_almost_equal(adsorbant, -10.0010467948, decimal=3)
import numpy as np from surfinpy import p_vs_t as pt from surfinpy import wulff from surfinpy import utils as ut from pymatgen.core.surface import SlabGenerator, generate_all_slabs, Structure, Lattice from pymatgen.analysis.wulff import WulffShape adsorbant = -14.22 thermochem = ut.read_nist('H2O.txt') SE = 1.44 stoich = { 'M': 24, 'X': 48, 'Y': 0, 'Area': 60.22, 'Energy': -575.66, 'Label': 'Stoich' } Adsorbant_1 = { 'M': 24, 'X': 48, 'Y': 2, 'Area': 60.22, 'Energy': -609.23, 'Label': '1 Species' } data = [Adsorbant_1] Surface_100_1 = wulff.calculate_surface_energy(stoich, data, SE, adsorbant, thermochem, 298, 0)
from surfinpy import utils as ut from surfinpy import p_vs_t adsorbant = -14.00 SE = 1.40 stoich = {'Cation': 24, 'X': 48, 'Y': 0, 'Area': 60.22, 'Energy': -575.00, 'Label': 'Bare'} H2O = {'Cation': 24, 'X': 48, 'Y': 2, 'Area': 60.22, 'Energy': -605.00, 'Label': '1 Water'} H2O_2 = {'Cation': 24, 'X': 48, 'Y': 8, 'Area': 60.22, 'Energy': -695.00, 'Label': '2 Water'} data = [H2O, H2O_2] coverage = ut.calculate_coverage(data) thermochem = ut.read_nist("H2O.txt") system = p_vs_t.calculate(stoich, data, SE, adsorbant, thermochem, coverage) system.plot(output="Example_4.png",)