def test_cs_fit(self): data = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 3, 5], [5, 3, 8]]) y = np.array([1, 2, 3, 4]) x = ut.cs_fit(data[:, 0], data[:, 2], y) expected = np.array([1., 2., 3., 5.]) assert_almost_equal(x, expected, decimal=2)
def inititalise(thermochem, adsorbant, max_t, min_p, max_p): '''Builds the numpy arrays for each calculation. Parameters ---------- thermochem : :py:attr:`array_like` array containing NIST_JANAF thermochemical data adsorbant : :py:attr:`float` dft energy of adsorbing species max_t : :py:attr:`int` Maximum temperature of phase diagram min_p : :py:attr:`int` Minimum pressure of phase diagram max_p : :py:attr:`int` Maximum pressure of phase diagram Returns ------- lnP : :py:attr:`array_like` numpy array of pressure values logP : :py:attr:`array_like` log of lnP (hard coded range -13 - 5.0) T : :py:attr:`array_like` array of temperature values (hard coded range 2 - 1000 K) adsrobant_t : :py:attr:`array_like` dft values of adsorbant scaled to temperature ''' T = np.arange(2, max_t) shift = ut.cs_fit(thermochem[:, 0], thermochem[:, 2], T) shift = (T * (shift / 1000)) / 96.485 adsorbant_t = adsorbant - shift logP = np.arange(min_p, max_p, 0.1) lnP = np.log(10**logP) return lnP, logP, T, adsorbant_t
def temperature_correction(T, thermochem, adsorbant): """Make the energy of the adsorbing species a temperature dependent term by scaling it with experimental data. Parameters ---------- T : :py:attr:`int` Temperature to scale the energy to thermochem : :py:attr:`array_like` nist_janaf table adsorbant : :py:attr:`float` DFT energy of adsorbant Returns ------- adsorbant : :py:attr:`float` Scaled energy of adsorbant """ temperature_range = np.arange(2, np.amax(thermochem[:, 0])) shift = ut.cs_fit(thermochem[:, 0], thermochem[:, 2], temperature_range) shift = (T * (shift[(T - 1)] / 1000)) / 96.485 adsorbant = adsorbant - shift return adsorbant