def test_partial(self):
        spec_type = 'DOS'

        ws = SimulatedDensityOfStates(File=self._file_name, SpectrumType=spec_type, Ions='H,C,O')

        workspaces = ws.getNames()
        self.assertEquals(len(workspaces), 3)
Ejemplo n.º 2
0
    def test_scale(self):
        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       Scale=10)
        ref = SimulatedDensityOfStates(PHONONFile=self._phonon_file)
        ref = Scale(ref, Factor=10)

        self.assertEqual(CheckWorkspacesMatch(wks, ref), 'Success!')
Ejemplo n.º 3
0
    def test_bond_table(self):
        wks = SimulatedDensityOfStates(CASTEPFile=self._castep_file,
                                       SpectrumType='BondTable')

        self.assertTrue(isinstance(wks, ITableWorkspace))
        self.assertEqual(wks.columnCount(), 6)
        self.assertEqual(wks.rowCount(), 74)
Ejemplo n.º 4
0
 def test_lorentzian_function(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    Function='Lorentzian')
     self.assertEquals(wks.getNumberHistograms(), 2)
     v_axis_values = wks.getAxis(1).extractValues()
     self.assertEquals(v_axis_values[0], 'Lorentzian')
     self.assertEquals(v_axis_values[1], 'Stick')
Ejemplo n.º 5
0
    def test_bond_table(self):
        wks = SimulatedDensityOfStates(CASTEPFile=self._castep_file,
                                       SpectrumType='BondTable')

        self.assertTrue(isinstance(wks, ITableWorkspace))
        self.assertEqual(wks.columnCount(), 6)
        self.assertEqual(wks.rowCount(), 74)
    def test_scale(self):
        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       Scale=10)
        ref = SimulatedDensityOfStates(PHONONFile=self._phonon_file)
        ref = Scale(ref, Factor=10)

        self.assertTrue(CompareWorkspaces(wks, ref)[0])
Ejemplo n.º 7
0
 def test_lorentzian_function(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    Function='Lorentzian')
     self.assertEquals(wks.getNumberHistograms(), 2)
     v_axis_values = wks.getAxis(1).extractValues()
     self.assertEquals(v_axis_values[0], 'Lorentzian')
     self.assertEquals(v_axis_values[1], 'Stick')
    def test_partial_cross_section_scale(self):
        spec_type = 'DOS'

        ws = SimulatedDensityOfStates(File=self._file_name, SpectrumType=spec_type, Ions='H,C,O', ScaleByCrossSection='Incoherent')

        workspaces = ws.getNames()
        self.assertEquals(len(workspaces), 3)
Ejemplo n.º 9
0
 def test_ir_active(self):
     spec_type = 'IR_Active'
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    SpectrumType=spec_type)
     self.assertEquals(wks.getNumberHistograms(), 2)
     v_axis_values = wks.getAxis(1).extractValues()
     self.assertEquals(v_axis_values[0], 'Gaussian')
     self.assertEquals(v_axis_values[1], 'Stick')
Ejemplo n.º 10
0
 def test_ir_active(self):
     spec_type = 'IR_Active'
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    SpectrumType=spec_type)
     self.assertEquals(wks.getNumberHistograms(), 2)
     v_axis_values = wks.getAxis(1).extractValues()
     self.assertEquals(v_axis_values[0], 'Gaussian')
     self.assertEquals(v_axis_values[1], 'Stick')
Ejemplo n.º 11
0
    def test_partial(self):
        spec_type = 'DOS'

        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       SpectrumType=spec_type,
                                       Ions='H,C,O')

        workspaces = wks.getNames()
        self.assertEquals(len(workspaces), 3)
Ejemplo n.º 12
0
    def test_bin_width(self):
        import math

        ref = SimulatedDensityOfStates(File=self._file_name)
        ws = SimulatedDensityOfStates(File=self._file_name, BinWidth=2)

        size = ws.blocksize()
        ref_size = ref.blocksize()

        self.assertEquals(size, math.ceil(ref_size/2.0))
Ejemplo n.º 13
0
 def test_isotopes_are_parsed_correctly(self):
     """
     Test that isotopes in the file in the format `element:P` are valid
     """
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._isotope_phonon,
                                        SpectrumType='DOS',
                                        Ions='H:P,C:P,O')
     self.assertEqual(3, wks_grp.size())
     self.assertTrue(_is_name_material_in_group(wks_group = wks_grp, \
                                                name_to_find = 'wks_grp_C(13)', material_to_find = '(C13)'))
Ejemplo n.º 14
0
    def test_partial_cross_section_scale(self):
        spec_type = 'DOS'

        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       SpectrumType=spec_type,
                                       Ions='H,C,O',
                                       ScaleByCrossSection='Incoherent')

        workspaces = wks.getNames()
        self.assertEquals(len(workspaces), 3)
Ejemplo n.º 15
0
    def test_zero_threshold(self):
        import numpy as np

        ws = SimulatedDensityOfStates(File=self._file_name, ZeroThreshold=20)

        x = ws.readX(0)
        y = ws.readY(0)

        mask = np.where(x < 20)
        self.assertEquals(sum(y[mask]), 0)
Ejemplo n.º 16
0
 def test_isotopes_are_parsed_correctly(self):
     """
     Test that isotopes in the file in the format `element:P` are valid
     """
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._isotope_phonon,
                                        SpectrumType='DOS',
                                        Ions='H:P,C:P,O')
     self.assertEqual(3, wks_grp.size())
     self.assertTrue(_is_name_material_in_group(wks_group = wks_grp, \
                                                name_to_find = 'wks_grp_C(13)', material_to_find = '(C13)'))
Ejemplo n.º 17
0
 def test_isotopes_are_parsed_correctly(self):
     """
     Test that isotopes in the file in the format `element:P` are valid
     """
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._isotope_phonon,
                                        SpectrumType='DOS',
                                        Ions='H:P,C:P,O')
     self.assertEqual(3, wks_grp.size())
     self.assertEqual('wks_grp_C(13)', wks_grp.getItem(0).getName())
     self.assertEqual('(C13)', wks_grp.getItem(0).sample().getMaterial().name())
Ejemplo n.º 18
0
 def test_isotope_element_indices_loading(self):
     """
     """
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._isotope_phonon,
                                        SpectrumType='DOS',
                                        CalculateIonIndices=True,
                                        Ions='H:P,C:P')
     self.assertEqual(2, len(wks_grp))
     self.assertEqual('wks_grp_C(13)_0', wks_grp.getItem(0).getName())
     self.assertEqual('wks_grp_H(2)_1' , wks_grp.getItem(1).getName())
Ejemplo n.º 19
0
    def test_bin_width(self):
        import math

        ref = SimulatedDensityOfStates(PHONONFile=self._phonon_file)
        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       BinWidth=2)

        size = wks.blocksize()
        ref_size = ref.blocksize()

        self.assertEquals(size, math.ceil(ref_size/2.0))
Ejemplo n.º 20
0
    def test_zero_threshold(self):
        import numpy as np

        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       ZeroThreshold=20)

        x_data = wks.readX(0)
        y_data = wks.readY(0)

        mask = np.where(x_data < 20)
        self.assertEquals(sum(y_data[mask]), 0)
Ejemplo n.º 21
0
    def test_zero_threshold(self):
        import numpy as np

        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       ZeroThreshold=20)

        x_data = wks.readX(0)
        y_data = wks.readY(0)

        mask = np.where(x_data < 20)
        self.assertEquals(sum(y_data[mask]), 0)
Ejemplo n.º 22
0
    def test_sum_partial_contributions(self):
        spec_type = 'DOS'
        tolerance = 1e-10

        summed = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                          SpectrumType=spec_type,
                                          Ions='H,C,O',
                                          SumContributions=True)
        total = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                         SpectrumType=spec_type)

        self.assertTrue(CompareWorkspaces(summed, total, tolerance)[0])
Ejemplo n.º 23
0
    def test_ion_table(self):
        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       SpectrumType='IonTable')

        self.assertTrue(isinstance(wks, ITableWorkspace))
        self.assertEqual(wks.columnCount(), 10)
        self.assertEqual(wks.rowCount(), 20)

        all_species = wks.column('Species')

        self.assertEqual(all_species.count('H'), 4)
        self.assertEqual(all_species.count('C'), 8)
        self.assertEqual(all_species.count('O'), 8)
Ejemplo n.º 24
0
 def test_non_isotpe_element_indices_loading(self):
     """
     Test that the individual indices for each element can be loaded seperately
     Tests parse_chemical_and_ws_name for non-isotope + indices
     """
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                        SpectrumType='DOS',
                                        CalculateIonIndices=True,
                                        Ions='H,C,O')
     self.assertEqual(20, len(wks_grp))
     self.assertEqual('wks_grp_H_0' , wks_grp.getItem(0).getName())
     self.assertEqual('wks_grp_C_4' , wks_grp.getItem(4).getName())
     self.assertEqual('wks_grp_O_12', wks_grp.getItem(12).getName())
Ejemplo n.º 25
0
    def test_ion_table(self):
        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       SpectrumType='IonTable')

        self.assertTrue(isinstance(wks, ITableWorkspace))
        self.assertEqual(wks.columnCount(), 10)
        self.assertEqual(wks.rowCount(), 20)

        all_species = wks.column('Species')

        self.assertEqual(all_species.count('H'), 4)
        self.assertEqual(all_species.count('C'), 8)
        self.assertEqual(all_species.count('O'), 8)
Ejemplo n.º 26
0
    def test_sum_partial_contributions_cross_section_scale(self):
        spec_type = 'DOS'
        tolerance = 1e-10

        summed = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                          SpectrumType=spec_type,
                                          Ions='H,C,O',
                                          SumContributions=True,
                                          ScaleByCrossSection='Incoherent')
        total = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                         SpectrumType=spec_type,
                                         ScaleByCrossSection='Incoherent')

        self.assertTrue(CompareWorkspaces(summed, total, tolerance)[0])
Ejemplo n.º 27
0
 def test_bin_ranges_are_correct(self):
     """
     Test that the bin ranges are correct when draw peak function is called
     """
     bin_width = 3
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                        SpectrumType='DOS',
                                        BinWidth=bin_width,
                                        Ions='H,C,O')
     expected_x_min = -0.051481
     for idx in range(wks_grp.getNumberOfEntries()):
         ws = wks_grp.getItem(idx)
         self.assertAlmostEqual(expected_x_min,ws.readX(0)[0])
         self.assertAlmostEqual(bin_width,(ws.readX(0)[1] - ws.readX(0)[0]))
 def test_bin_ranges_are_correct(self):
     """
     Test that the bin ranges are correct when draw peak function is called
     """
     bin_width = 3
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                        SpectrumType='DOS',
                                        BinWidth=bin_width,
                                        Ions='H,C,O')
     expected_x_min = -0.051481
     for idx in range(wks_grp.getNumberOfEntries()):
         ws = wks_grp.getItem(idx)
         self.assertAlmostEqual(expected_x_min,ws.readX(0)[0])
         self.assertAlmostEqual(bin_width,(ws.readX(0)[1] - ws.readX(0)[0]))
 def test_isotope_element_indices_loading(self):
     """
     """
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._isotope_phonon,
                                        SpectrumType='DOS',
                                        CalculateIonIndices=True,
                                        Ions='H:P,C:P')
     self.assertEqual(2, len(wks_grp))
     self.assertTrue(_is_name_in_group(wks_group=wks_grp, name_to_find='wks_grp_C(13)_0'))
     self.assertTrue(_is_name_in_group(wks_group=wks_grp, name_to_find='wks_grp_H(2)_1'))
 def test_non_isotpe_element_indices_loading(self):
     """
     Test that the individual indices for each element can be loaded seperately
     Tests parse_chemical_and_ws_name for non-isotope + indices
     """
     wks_grp = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                        SpectrumType='DOS',
                                        CalculateIonIndices=True,
                                        Ions='H,C,O')
     self.assertEqual(20, len(wks_grp))
     self.assertTrue(_is_name_in_group(wks_group=wks_grp, name_to_find='wks_grp_H_0'))
     self.assertTrue(_is_name_in_group(wks_group=wks_grp, name_to_find='wks_grp_C_4'))
     self.assertTrue(_is_name_in_group(wks_group=wks_grp, name_to_find='wks_grp_O_12'))
Ejemplo n.º 31
0
    def runTest(self):
        with tempfile.TemporaryDirectory() as tmp_prefix:

            if not euphonic_available():
                self._install_euphonic_to_tmp_prefix(tmp_prefix)

            import pint  # noqa: F401
            import euphonic  # noqa: F401

            SimulatedDensityOfStates(ForceConstantsFile=find_file('phonopy-Al.yaml'),
                                     Function='Gaussian',
                                     SpectrumType='DOS',
                                     OutputWorkspace='phonopy-Al_DOS')
Ejemplo n.º 32
0
    def test_bin_width(self):
        import math

        ref = SimulatedDensityOfStates(PHONONFile=self._phonon_file)
        wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                       BinWidth=2)

        size = wks.blocksize()
        ref_size = ref.blocksize()

        self.assertEquals(size, math.ceil(ref_size / 2.0))
Ejemplo n.º 33
0
 def test_peak_width_function(self):
     ws = SimulatedDensityOfStates(File=self._file_name, PeakWidth='0.1*energy')
     self.assertEquals(ws.getNumberHistograms(), 1)
Ejemplo n.º 34
0
 def test_lorentzian_function(self):
     ws = SimulatedDensityOfStates(File=self._file_name, Function='Lorentzian')
     self.assertEquals(ws.getNumberHistograms(), 1)
Ejemplo n.º 35
0
 def test_ir_active(self):
     spec_type = 'IR_Active'
     ws = SimulatedDensityOfStates(File=self._file_name, SpectrumType=spec_type)
     self.assertEquals(ws.getNumberHistograms(), 1)
Ejemplo n.º 36
0
 def test_castep_load(self):
     ws = SimulatedDensityOfStates(File='squaricn.castep')
     self.assertEquals(ws.getNumberHistograms(), 1)
Ejemplo n.º 37
0
 def test_phonon_load(self):
     ws = SimulatedDensityOfStates(File=self._file_name)
     self.assertEquals(ws.getNumberHistograms(), 1)
 def test_phonon_load(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file)
     self.assertEqual(wks.getNumberHistograms(), 2)
     v_axis_values = wks.getAxis(1).extractValues()
     self.assertEqual(v_axis_values[0], 'Gaussian')
     self.assertEqual(v_axis_values[1], 'Stick')
Ejemplo n.º 39
0
 def test_castep_load(self):
     wks = SimulatedDensityOfStates(CASTEPFile=self._castep_file)
     self.assertEquals(wks.getNumberHistograms(), 2)
     v_axis_values = wks.getAxis(1).extractValues()
     self.assertEquals(v_axis_values[0], 'Gaussian')
     self.assertEquals(v_axis_values[1], 'Stick')
Ejemplo n.º 40
0
 def test_castep_load(self):
     wks = SimulatedDensityOfStates(CASTEPFile=self._castep_file)
     self.assertEquals(wks.getNumberHistograms(), 2)
     v_axis_values = wks.getAxis(1).extractValues()
     self.assertEquals(v_axis_values[0], 'Gaussian')
     self.assertEquals(v_axis_values[1], 'Stick')
Ejemplo n.º 41
0
 def test_temperature(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    Temperature=50)
     self.assertEquals(wks.getNumberHistograms(), 2)
Ejemplo n.º 42
0
 def test_peak_width_function(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    PeakWidth='0.1*energy')
     self.assertEquals(wks.getNumberHistograms(), 2)
Ejemplo n.º 43
0
 def test_temperature(self):
     ws = SimulatedDensityOfStates(File=self._file_name, Temperature=50)
     self.assertEquals(ws.getNumberHistograms(), 1)
Ejemplo n.º 44
0
 def test_peak_width_function(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    PeakWidth='0.1*energy')
     self.assertEquals(wks.getNumberHistograms(), 2)
 def test_peak_width(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    PeakWidth='0.3')
     self.assertEqual(wks.getNumberHistograms(), 2)
Ejemplo n.º 46
0
 def test_temperature(self):
     wks = SimulatedDensityOfStates(PHONONFile=self._phonon_file,
                                    Temperature=50)
     self.assertEquals(wks.getNumberHistograms(), 2)
 def runTest(self):
     SimulatedDensityOfStates(CASTEPFile=find_file('Na2SiF6_CASTEP.phonon'),
                              Function='Gaussian',
                              SpectrumType='DOS',
                              OutputWorkspace='Na2SiF6_DOS')