Example #1
0
    def test_get_grid_point_from_address(self):
        self._mesh = (10, 10, 10)
        print("Compare get_grid_point_from_address from spglib and that "
              "written in python")
        print("with mesh numbers [%d %d %d]" % self._mesh)

        for address in list(np.ndindex(self._mesh)):
            gp_spglib = get_grid_point_from_address(address, self._mesh)
            gp_py = get_grid_point_from_address_py(address, self._mesh)
            # print("%s %d %d" % (address, gp_spglib, gp_py))
            self.assertEqual(gp_spglib, gp_py)
Example #2
0
def get_phono3py_configurations(settings):
    primitive_matrix = settings.get_primitive_matrix()
    supercell_matrix = settings.get_supercell_matrix()
    phonon_supercell_matrix = settings.get_phonon_supercell_matrix()
    masses = settings.get_masses()
    mesh = settings.get_mesh_numbers()
    mesh_divs = settings.get_mesh_divisors()
    coarse_mesh_shifts = settings.get_coarse_mesh_shifts()
    grid_points = settings.get_grid_points()
    grid_addresses = settings.get_grid_addresses()
    if grid_addresses is not None:
        grid_points = [
            get_grid_point_from_address(ga, mesh) for ga in grid_addresses
        ]
    band_indices = settings.get_band_indices()

    # Brillouin zone integration: Tetrahedron (default) or smearing method
    sigma = settings.get_sigma()
    if sigma is None:
        sigmas = []
    elif isinstance(sigma, float):
        sigmas = [sigma]
    else:
        sigmas = sigma
    if settings.get_is_tetrahedron_method():
        sigmas = [None] + sigmas
    if len(sigmas) == 0:
        sigmas = [None]

    sigma_cutoff = settings.get_sigma_cutoff_width()

    if settings.get_temperatures() is None:
        if settings.get_is_joint_dos():
            temperature_points = None
            temperatures = None
        else:
            t_max = settings.get_max_temperature()
            t_min = settings.get_min_temperature()
            t_step = settings.get_temperature_step()
            temperature_points = [0.0, 300.0]  # For spectra
            temperatures = np.arange(t_min, t_max + float(t_step) / 10, t_step)
    else:
        temperature_points = settings.get_temperatures()  # For spectra
        temperatures = settings.get_temperatures()  # For others

    if settings.get_frequency_conversion_factor() is None:
        frequency_factor_to_THz = VaspToTHz
    else:
        frequency_factor_to_THz = settings.get_frequency_conversion_factor()

    if settings.get_num_frequency_points() is None:
        if settings.get_frequency_pitch() is None:
            num_frequency_points = 201
            frequency_step = None
        else:
            num_frequency_points = None
            frequency_step = settings.get_frequency_pitch()
    else:
        num_frequency_points = settings.get_num_frequency_points()
        frequency_step = None

    if settings.get_frequency_scale_factor() is None:
        frequency_scale_factor = None
    else:
        frequency_scale_factor = settings.get_frequency_scale_factor()

    if settings.get_cutoff_frequency() is None:
        cutoff_frequency = 1e-2
    else:
        cutoff_frequency = settings.get_cutoff_frequency()

    conf = {}
    conf['primitive_matrix'] = primitive_matrix
    conf['supercell_matrix'] = supercell_matrix
    conf['phonon_supercell_matrix'] = phonon_supercell_matrix
    conf['masses'] = masses
    conf['mesh'] = mesh
    conf['mesh_divs'] = mesh_divs
    conf['coarse_mesh_shifts'] = coarse_mesh_shifts
    conf['grid_points'] = grid_points
    conf['band_indices'] = band_indices
    conf['sigmas'] = sigmas
    conf['sigma_cutoff'] = sigma_cutoff
    conf['temperature_points'] = temperature_points
    conf['temperatures'] = temperatures
    conf['frequency_factor_to_THz'] = frequency_factor_to_THz
    conf['num_frequency_points'] = num_frequency_points
    conf['frequency_step'] = frequency_step
    conf['frequency_scale_factor'] = frequency_scale_factor
    conf['cutoff_frequency'] = cutoff_frequency

    return conf
Example #3
0
def get_default_values(settings):
    mesh_numbers = settings.mesh_numbers
    grid_points = settings.grid_points
    grid_addresses = settings.grid_addresses
    if grid_addresses is not None:
        grid_points = [
            get_grid_point_from_address(ga, mesh_numbers)
            for ga in grid_addresses
        ]

    # Brillouin zone integration: Tetrahedron (default) or smearing method
    sigma = settings.sigma
    if sigma is None:
        sigmas = []
    elif isinstance(sigma, float):
        sigmas = [sigma]
    else:
        sigmas = sigma
    if settings.is_tetrahedron_method:
        sigmas = [None] + sigmas
    if len(sigmas) == 0:
        sigmas = [None]

    if settings.temperatures is None:
        if settings.is_joint_dos:
            temperature_points = None
            temperatures = None
        else:
            t_max = settings.max_temperature
            t_min = settings.min_temperature
            t_step = settings.temperature_step
            temperature_points = [0.0, 300.0]  # For spectra
            temperatures = np.arange(t_min, t_max + float(t_step) / 10, t_step)
    else:
        temperature_points = settings.temperatures  # For spectra
        temperatures = settings.temperatures  # For others

    if settings.frequency_conversion_factor is None:
        frequency_factor_to_THz = VaspToTHz
    else:
        frequency_factor_to_THz = settings.frequency_conversion_factor

    if settings.num_frequency_points is None:
        if settings.frequency_pitch is None:
            num_frequency_points = 201
            frequency_step = None
        else:
            num_frequency_points = None
            frequency_step = settings.frequency_pitch
    else:
        num_frequency_points = settings.num_frequency_points
        frequency_step = None

    if settings.num_points_in_batch is None:
        num_points_in_batch = 10
    else:
        num_points_in_batch = settings.num_points_in_batch

    if settings.frequency_scale_factor is None:
        frequency_scale_factor = None
    else:
        frequency_scale_factor = settings.frequency_scale_factor

    if settings.cutoff_frequency is None:
        cutoff_frequency = 1e-2
    else:
        cutoff_frequency = settings.cutoff_frequency

    params = {}
    params['grid_points'] = grid_points
    params['sigmas'] = sigmas
    params['temperature_points'] = temperature_points
    params['temperatures'] = temperatures
    params['frequency_factor_to_THz'] = frequency_factor_to_THz
    params['num_frequency_points'] = num_frequency_points
    params['num_points_in_batch'] = num_points_in_batch
    params['frequency_step'] = frequency_step
    params['frequency_scale_factor'] = frequency_scale_factor
    params['cutoff_frequency'] = cutoff_frequency

    return params