Example #1
0
    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)
Example #2
0
 def test_reference_data_1(self):
     bulk = data.ReferenceDataSet(cation=1,
                                  anion=2,
                                  energy=-90.00,
                                  funits=1)
     assert bulk.energy == -90.00
     assert bulk.cation == 1
     assert bulk.anion == 2
Example #3
0
 def test_calculete_normalisation(self):
     bulk = data.ReferenceDataSet(cation=1,
                                  anion=2,
                                  energy=-100.00,
                                  funits=1)
     x = mu_vs_mu.calculate_normalisation(1, 2, bulk, 3)
     expected = 33.5
     assert_almost_equal(expected, x, decimal=4)
Example #4
0
 def test_reference_data_2(self):
     bulk = data.ReferenceDataSet(cation=1,
                                  anion=2,
                                  energy=-90.00,
                                  entropy=True,
                                  file=test_data,
                                  funits=10,
                                  temp_range=[100, 120])
     assert_almost_equal(bulk.svib[0], 0.00049717)
Example #5
0
 def test_calculate_excess(self):
     bulk = data.ReferenceDataSet(cation=1,
                                  anion=2,
                                  energy=-100.00,
                                  funits=1)
     x1 = mu_vs_mu.calculate_excess(1, 2, 3, bulk)
     x2 = mu_vs_mu.calculate_excess(2, 2, 3, bulk, nspecies=1, check=True)
     expected1 = 0.16666666666
     expected2 = -0.3333333333
     assert_almost_equal(expected1, x1, decimal=4)
     assert_almost_equal(expected2, x2, decimal=4)
Example #6
0
 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
Example #7
0
 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
Example #8
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
Example #9
0
 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
Example #10
0
 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])
Example #11
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)