def test_calculate(self): xshiftval = 0 yshiftval = 0 deltaX = {'Range': [0, 10], 'Label': 'O'} deltaY = {'Range': [0, 10], 'Label': 'H_2O'} bulk = data.ReferenceDataSet(cation=1, anion=2, energy=-100.00, funits=1) pure = data.DataSet(cation=24, x=48, y=0, area=60.22, energy=-575.00, label="Stoich", nspecies=1) H2O = data.DataSet(cation=24, x=48, y=2, area=60.22, energy=-600.00, label="One", nspecies=1) dataset = [pure, H2O] system, SE = mu_vs_mu.calculate(dataset, bulk, deltaX, deltaY, 0, 0) expected_phase = np.zeros( np.arange(0, 10, 0.025).size * np.arange(0, 10, 0.025).size) expected_phase = np.reshape( expected_phase, (np.arange(0, 10, 0.025).size, np.arange(0, 10, 0.025).size)) assert_almost_equal(system.z, expected_phase)
def test_dataset_1(self): phase_1 = data.DataSet(cation=10, x=0, y=0, energy=-90.0, label="Periclase") assert phase_1.cation == 10.0 assert phase_1.energy == -90.0 assert phase_1.x == 0
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 test_calculate(self): bulk = data.ReferenceDataSet(cation=1, anion=2, energy=-100.00, funits=1) phase_1 = data.DataSet(cation=10, x=0, y=10, energy=-90.0, label="Periclase") phase_2 = data.DataSet(cation=10, x=0, y=10, energy=-100.0, label="Periclase") ref = {'Range': [-3, 2], 'Label': 'test'} calculated = bulk_mu_vs_mu.calculate([phase_1, phase_2], bulk, ref, ref, -10, -10) assert calculated.z[0, 0] == 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
def test_calculate_coverage(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] x = ut.calculate_coverage(dataset) expected = np.array([1.66057788 * 10**18, 3.32115576 * 10**18]) assert_approx_equal(expected[0], x[0], significant=8) assert_approx_equal(expected[1], x[1], significant=8)
def chemical_potential_1(self): bulk = data.ReferenceDataSet(cation=1, anion=2, energy=-100.00, funits=1) phase_1 = data.DataSet(cation=10, x=0, y=10, energy=-90.0, label="Periclase") phase_2 = data.DataSet(cation=10, x=0, y=10, energy=-100.0, label="Periclase") ref = {'Range': [-3, 2], 'Label': 'test'} calculated = bulk_mu_vs_mu.calculate([phase_1, phase_2], bulk, ref, ref, -10, -10) ax = calculated.plot_phase() assert_almost_equal(calculated.x, ax.lines[0].get_xydata().T[0])
def test_dataset_2(self): phase_1 = data.DataSet(cation=10, x=0, y=0, energy=-90.0, label="Periclase", entropy=True, file=test_data, funits=10, temp_range=[100, 120]) assert_almost_equal(phase_1.svib[0], 0.00049717)
def test_normalise_phase_energy(self): bulk = data.ReferenceDataSet(cation=1, anion=2, energy=-100.00, funits=1) phase_1 = data.DataSet(cation=10, x=0, y=0, energy=-90.0, label="Periclase") calculated = bulk_mu_vs_t.normalise_phase_energy(phase_1, bulk) assert calculated == 910.0
def test_evaluate_phases(self): xshiftval = 0 yshiftval = 0 deltaX = {'Range': [0, 10], 'Label': 'O'} deltaY = {'Range': [0, 10], 'Label': 'H_2O'} bulk = data.ReferenceDataSet(cation=1, anion=2, energy=-100.00, funits=1) pure = data.DataSet(cation=24, x=48, y=0, area=60.22, energy=-575.00, label="Stoich", nspecies=1) H2O = data.DataSet(cation=24, x=48, y=2, area=60.22, energy=-600.00, label="One", nspecies=1) dataset = [pure, H2O] nsurfaces = len(dataset) 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 - xshiftval Y = Y - yshiftval phase, SE = mu_vs_mu.evaluate_phases(dataset, bulk, X, Y, nsurfaces, xshiftval, yshiftval) expected_phase = np.zeros(X.size * Y.size) expected_phase = expected_phase + 2 assert_almost_equal(phase, expected_phase)
def test_list_colors(self): H20 = data.DataSet(cation=24, x=48, y=2, area=60.22, color="red", energy=-570.00, label="One", nspecies=1) H2O_2 = data.DataSet(cation=24, x=48, y=4, area=60.22, color="blue", energy=-570.00, label="Two", nspecies=1) dataset = [H20, H2O_2] ticks = np.array([1, 2]) labels = ut.list_colors(dataset, ticks) expected = ['red', 'blue'] assert labels == expected
def test_calculate_bulk_energy(self): bulk = data.ReferenceDataSet(cation=1, anion=2, energy=-100.00, funits=1) phase_1 = data.DataSet(cation=10, x=0, y=0, energy=-90.0, label="Periclase") calculated = bulk_mu_vs_t.calculate_bulk_energy( 10, 10, 10, 10, 10, phase_1, bulk, 10, 10, 10, 10, 10) assert calculated == 110.0
def test_evaluate_phases(self): bulk = data.ReferenceDataSet(cation=1, anion=2, energy=-100.00, funits=1) phase_1 = data.DataSet(cation=10, x=0, y=0, energy=-90.0, label="Periclase") calculated = bulk_mu_vs_mu.evaluate_phases([phase_1], bulk, np.arange(0, 10, 1), np.arange(0, 10, 1), 1, 10, 10)[0] assert calculated[0] == 1