Beispiel #1
0
def parse_QPOINTS(filename="QPOINTS"):
    with open(filename, 'r') as f:
        num_qpoints = int(f.readline().strip())
        qpoints = []
        for i in range(num_qpoints):
            qpoints.append([fracval(x) for x in f.readline().strip().split()])
        return np.array(qpoints)
Beispiel #2
0
def parse_QPOINTS(filename="QPOINTS"):
    f = open(filename, 'r')
    num_qpoints = int(f.readline().strip())
    qpoints = []
    for i in range(num_qpoints):
        qpoints.append([fracval(x) for x in f.readline().strip().split()])
    return np.array(qpoints)
Beispiel #3
0
def parse_QPOINTS(filename="QPOINTS"):
    from phonopy.cui.settings import fracval

    with open(filename, 'r') as f:
        num_qpoints = int(f.readline().strip())
        qpoints = []
        for i in range(num_qpoints):
            qpoints.append([fracval(x) for x in f.readline().strip().split()])
        return np.array(qpoints)
Beispiel #4
0
def parse_QPOINTS(filename="QPOINTS"):
    from phonopy.cui.settings import fracval

    f = open(filename, 'r')
    num_qpoints = int(f.readline().strip())
    qpoints = []
    for i in range(num_qpoints):
        qpoints.append([fracval(x) for x in f.readline().strip().split()])
    return np.array(qpoints)
Beispiel #5
0
    def _get_numerical_values(self, char_string, num_type='float'):
        m = 1

        if '*' in char_string:
            m = int(char_string.split('*')[0])
            str_val = char_string.split('*')[1]
        else:
            m = 1
            str_val = char_string

        if num_type == 'float':
            a = fracval(str_val)
        else:
            a = int(str_val)

        return [a] * m
Beispiel #6
0
    def _get_numerical_values(self, char_string, num_type='float'):
        m = 1

        if '*' in char_string:
            m = int(char_string.split('*')[0])
            str_val = char_string.split('*')[1]
        else:
            m = 1
            str_val = char_string

        if num_type == 'float':
            a = fracval(str_val)
        else:
            a = int(str_val)

        return [a] * m
Beispiel #7
0
    def _get_numerical_values(self, char_string, num_type="float"):
        m = 1

        if "*" in char_string:
            m = int(char_string.split("*")[0])
            str_val = char_string.split("*")[1]
        else:
            m = 1
            str_val = char_string

        if num_type == "float":
            a = fracval(str_val)
        else:
            a = int(str_val)

        return [a] * m
Beispiel #8
0
    def _get_numerical_values(self, char_string, num_type="float"):
        vals = []
        m = 1

        if "*" in char_string:
            m = int(char_string.split("*")[0])
            str_val = char_string.split("*")[1]
        else:
            m = 1
            str_val = char_string

        if num_type == "float":
            a = fracval(str_val)
        else:
            a = int(str_val)

        return [a] * m
Beispiel #9
0
    def _parse_conf(self):
        confs = self._confs

        for conf_key in confs.keys():
            if conf_key == 'dim_fc2':
                matrix = [int(x) for x in confs['dim_fc2'].split()]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error(
                        "Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error(
                            "Determinant of supercell matrix has " +
                            "to be positive.")
                    else:
                        self.set_parameter('dim_fc2', matrix)

            if conf_key == 'boundary_mfp':
                self.set_parameter('boundary_mfp',
                                   float(confs['boundary_mfp']))

            if conf_key == 'constant_averaged_pp_interaction':
                self.set_parameter(
                    'constant_averaged_pp_interaction',
                    float(confs['constant_averaged_pp_interaction']))

            if conf_key == 'cutoff_fc3_distance':
                self.set_parameter('cutoff_fc3_distance',
                                   float(confs['cutoff_fc3_distance']))

            if conf_key == 'cutoff_pair_distance':
                self.set_parameter('cutoff_pair_distance',
                                   float(confs['cutoff_pair_distance']))

            if conf_key == 'grid_addresses':
                vals = [
                    int(x)
                    for x in confs['grid_addresses'].replace(',', ' ').split()
                ]
                if len(vals) % 3 == 0 and len(vals) > 0:
                    self.set_parameter('grid_addresses',
                                       np.reshape(vals, (-1, 3)))
                else:
                    self.setting_error("Grid addresses are incorrectly set.")

            if conf_key == 'grid_points':
                vals = [
                    int(x)
                    for x in confs['grid_points'].replace(',', ' ').split()
                ]
                self.set_parameter('grid_points', vals)

            if conf_key == 'ion_clamped':
                if confs['ion_clamped'] == '.true.':
                    self.set_parameter('ion_clamped', True)

            if conf_key == 'bterta':
                if confs['bterta'] == '.true.':
                    self.set_parameter('is_bterta', True)

            if conf_key == 'imag_self_energy':
                if confs['imag_self_energy'] == '.true.':
                    self.set_parameter('is_imag_self_energy', True)

            if conf_key == 'isotope':
                if confs['isotope'] == '.true.':
                    self.set_parameter('is_isotope', True)

            if conf_key == 'lbte':
                if confs['lbte'] == '.true.':
                    self.set_parameter('is_lbte', True)

            if conf_key == 'linewidth':
                if confs['linewidth'] == '.true.':
                    self.set_parameter('is_linewidth', True)

            if conf_key == 'frequency_shift':
                if confs['frequency_shift'] == '.true.':
                    self.set_parameter('is_frequency_shift', True)

            if conf_key == 'mass_variances':
                vals = [fracval(x) for x in confs['mass_variances'].split()]
                if len(vals) < 1:
                    self.setting_error(
                        "Mass variance parameters are incorrectly set.")
                else:
                    self.set_parameter('mass_variances', vals)

            if conf_key == 'max_freepath':
                self.set_parameter('max_freepath',
                                   float(confs['max_freepath']))

            if conf_key == 'mesh_divisors':
                vals = [x for x in confs['mesh_divisors'].split()]
                if len(vals) == 3:
                    self.set_parameter('mesh_divisors', [int(x) for x in vals])
                elif len(vals) == 6:
                    divs = [int(x) for x in vals[:3]]
                    is_shift = [x.lower() == 't' for x in vals[3:]]
                    for i in range(3):
                        if is_shift[i] and (divs[i] % 2 != 0):
                            is_shift[i] = False
                            self.setting_error(
                                "Coarse grid shift along the " +
                                ["first", "second", "third"][i] +
                                " axis is not allowed.")
                    self.set_parameter('mesh_divisors', divs + is_shift)
                else:
                    self.setting_error("Mesh divisors are incorrectly set.")

            if conf_key == 'no_kappa_stars':
                if confs['no_kappa_stars'] == '.true.':
                    self.set_parameter('no_kappa_stars', True)

            if conf_key == 'pinv_cutoff':
                self.set_parameter('pinv_cutoff', float(confs['pinv_cutoff']))

            if conf_key == 'read_amplitude':
                if confs['read_amplitude'] == '.true.':
                    self.set_parameter('read_amplitude', True)

            if conf_key == 'read_collision':
                if confs['read_collision'] == 'all':
                    self.set_parameter('read_collision', 'all')
                else:
                    vals = [int(x) for x in confs['read_collision'].split()]
                    self.set_parameter('read_collision', vals)

            if conf_key == 'read_gamma':
                if confs['read_gamma'] == '.true.':
                    self.set_parameter('read_gamma', True)

            if conf_key == 'run_with_g':
                if confs['run_with_g'] == '.false.':
                    self.set_parameter('run_with_g', False)

            if conf_key == 'scattering_event_class':
                self.set_parameter('scattering_event_class',
                                   confs['scattering_event_class'])

            if conf_key == 'temperatures':
                vals = [fracval(x) for x in confs['temperatures'].split()]
                if len(vals) < 1:
                    self.setting_error("Temperatures are incorrectly set.")
                else:
                    self.set_parameter('temperatures', vals)

            if conf_key == 'average_pp_interaction':
                if confs['average_pp_interaction'] == '.true.':
                    self.set_parameter('average_pp_interaction', True)

            if conf_key == 'write_amplitude':
                if confs['write_amplitude'] == '.true.':
                    self.set_parameter('write_amplitude', True)

            if conf_key == 'write_detailed_gamma':
                if confs['write_detailed_gamma'] == '.true.':
                    self.set_parameter('write_detailed_gamma', True)

            if conf_key == 'write_gamma':
                if confs['write_gamma'] == '.true.':
                    self.set_parameter('write_gamma', True)

            if conf_key == 'write_collision':
                if confs['write_collision'] == '.true.':
                    self.set_parameter('write_collision', True)
Beispiel #10
0
    def _parse_conf(self):
        confs = self._confs

        for conf_key in confs.keys():
            if conf_key == 'dim_extra':
                matrix = [ int(x) for x in confs['dim_extra'].replace(",", " ").split() ]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error("Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error('Determinant of supercell matrix has to be positive.')
                    else:
                        self.set_parameter('dim_extra', matrix)

            if conf_key == "mesh_shift":
                vals = [fracval(x) for x in confs['mesh_shift'].replace(",", " ").split()]
                for i in range(3-len(vals)):
                    vals += [0.0] # Correction for incomplete shift set
                self.set_parameter('mesh_shift', vals[:3])

            if conf_key == 'band_indices':
                vals = []
                for sum_set in confs['band_indices'].replace(",", " ").split(','):
                    vals.append([int(x) - 1 for x in sum_set.replace(",", " ").split()])
                self.set_parameter('band_indices', vals)

            if conf_key == 'grid_points':
                vals = [int(x) for x in confs['grid_points'].replace(",", " ").split()]
                self.set_parameter('grid_points', vals)

            if conf_key == 'bterta':
                if confs['bterta'] == '.true.':
                    self.set_parameter('is_bterta', True)

            if conf_key == 'linewidth':
                if confs['linewidth'] == '.true.':
                    self.set_parameter('is_linewidth', True)

            if conf_key == 'read_fc2':
                if confs['read_fc2']== '.true.':
                    self.set_parameter('read_fc2',True)

            if conf_key == 'read_fc2_extra':
                if confs['read_fc2_extra']== '.true.':
                    self.set_parameter('read_fc2_extra',True)

            if conf_key == 'max_freepath':
                self.set_parameter('max_freepath', float(confs['max_freepath']))

            if conf_key == 'no_kappa_stars':
                if confs['no_kappa_stars'] == '.true.':
                    self.set_parameter('no_kappa_stars', True)

            if conf_key == 'read_gamma':
                if confs['read_gamma'] == '.true.':
                    self.set_parameter('read_gamma', True)

            if conf_key == 'temperature':
                vals = confs['temperature']
                self.set_parameter('temperature', vals)

            if conf_key == 'write_gamma':
                if confs['write_gamma'] == '.true.':
                    self.set_parameter('write_gamma', True)
Beispiel #11
0
    def _parse_conf(self):
        confs = self._confs

        for conf_key in confs.keys():
            if conf_key == 'dim_extra':
                matrix = [ int(x) for x in confs['dim_extra'].replace(",", " ").split() ]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error("Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error('Determinant of supercell matrix has to be positive.')
                    else:
                        self.set_parameter('dim_extra', matrix)

            if conf_key == 'band_indices':
                vals = []
                for sum_set in confs['band_indices'].split(','):
                    vals.append([int(x) - 1 for x in sum_set.split()])
                self.set_parameter('band_indices', vals)

            if conf_key == 'cutoff_pair':
                cutpair=[ float(x) for x in confs['cutoff_pair'].replace(","," ").split()]
                self.set_parameter('cutoff_pair',cutpair)

            if conf_key == 'cutoff_triplet':
                cutfc3 = [ float(x) for x in confs['cutoff_triplet'].replace(","," ").split()]
                self.set_parameter('cutoff_triplet',cutfc3)

            if conf_key == 'cutoff_radius':
                cutfc3q = [ float(x) for x in confs['cutoff_radius'].replace(","," ").split()]
                self.set_parameter('cutoff_radius',cutfc3q)

            if conf_key == "cutoff_delta":
                self.set_parameter("cutoff_delta", float(confs["cutoff_delta"]))

            if conf_key == 'cutoff_frequency':
                self.set_parameter('cutoff_frequency', confs['cutoff_frequency'])

            if conf_key == 'cutoff_hfrequency':
                self.set_parameter('cutoff_hfrequency', confs['cutoff_hfrequency'])

            if conf_key == 'cutoff_lifetime':
                self.set_parameter('cutoff_lifetime', confs['cutoff_lifetime'])

            if conf_key == "diff_kappa":
                self.set_parameter("diff_kappa", confs['diff_kappa'])

            if conf_key == "diff_gamma":
                self.set_parameter("diff_gamma", confs['diff_gamma'])

            if conf_key == 'grid_points':
                vals = [int(x) for x in confs['grid_points'].replace(",", " ").split()]
                self.set_parameter('grid_points', vals)

            if conf_key == 'ion_clamped':
                if confs['ion_clamped'] == '.true.':
                    self.set_parameter('ion_clamped', True)

            if conf_key == "ite":
                if confs['ite'] == ".true.":
                    self.set_parameter('is_ite',True)

            if conf_key == "ite_cg":
                if confs['ite_cg'] == ".true.":
                    self.set_parameter('is_ite_cg',True)

            if conf_key == "length":
                self.set_parameter('length', confs['length'])

            if conf_key == "ise":
                if confs['ise'] == ".true.":
                    self.set_parameter('is_ise',True)

            if conf_key == 'bterta':
                if confs['bterta'] == '.true.':
                    self.set_parameter('is_bterta', True)

            if conf_key == 'linewidth':
                if confs['linewidth'] == '.true.':
                    self.set_parameter('is_linewidth', True)

            if conf_key == 'nu':
                if confs['nu'] is not None:
                    nu  = confs['nu'].strip().upper()[0]
                    if nu == "N" or nu == "U":
                        self.set_parameter('nu',nu)

            if conf_key == 'read_fc2':
                if confs['read_fc2']== '.true.':
                    self.set_parameter('read_fc2',True)

            if conf_key == 'read_fc2_extra':
                if confs['read_fc2_extra']== '.true.':
                    self.set_parameter('read_fc2_extra',True)

            if conf_key == 'read_fc3':
                if confs['read_fc3']== '.true.':
                    self.set_parameter('read_fc3',True)

            if conf_key == 'frequency_shift':
                if confs['frequency_shift'] == '.true.':
                    self.set_parameter('is_frequency_shift', True)

            if conf_key == 'mass_variances':
                vals = [fracval(x) for x in confs['mass_variances'].split()]
                if len(vals) < 1:
                    self.setting_error("Mass variance parameters are incorrectly set.")
                else:
                    self.set_parameter('mass_variances', vals)

            if conf_key == "max_ite":
                self.set_parameter("max_ite", int(confs['max_ite']))

            if conf_key == 'max_freepath':
                self.set_parameter('max_freepath', float(confs['max_freepath']))

            if conf_key == 'mesh_divisors':
                vals = [x for x in confs['mesh_divisors'].split()]
                if len(vals) == 3:
                    self.set_parameter('mesh_divisors', [int(x) for x in vals])
                elif len(vals) == 6:
                    divs = [int(x) for x in vals[:3]]
                    is_shift = [x.lower() == 't' for x in vals[3:]]
                    for i in range(3):
                        if is_shift[i] and (divs[i] % 2 != 0):
                            is_shift[i] = False
                            self.setting_error("Coarse grid shift along the " +
                                               ["first", "second", "third"][i] +
                                               " axis is not allowed.")
                    self.set_parameter('mesh_divisors', divs + is_shift)
                else:
                    self.setting_error("Mesh divisors are incorrectly set.")

            if conf_key == 'multiple_sigmas':
                vals = [fracval(x) for x in confs['multiple_sigmas'].replace(",", " ").split()]
                if len(vals) < 1:
                    self.setting_error("Mutiple sigmas are incorrectly set.")
                else:
                    self.set_parameter('multiple_sigmas', vals)

            if conf_key == "adaptive_sigma_step":
                self.set_parameter("adaptive_sigma_step", int(confs['adaptive_sigma_step']))

            if conf_key == 'kappa_write_step':
                self.set_parameter('kappa_write_step', int(confs['kappa_write_step']))

            if conf_key == 'no_kappa_stars':
                if confs['no_kappa_stars'] == '.true.':
                    self.set_parameter('no_kappa_stars', True)

            if conf_key == 'read_amplitude':
                if confs['read_amplitude'] == '.true.':
                    self.set_parameter('read_amplitude', True)

            if conf_key == 'read_gamma':
                if confs['read_gamma'] == '.true.':
                    self.set_parameter('read_gamma', True)

            if conf_key == 'temperatures':
                vals = [fracval(x) for x in confs['temperatures'].replace(",", " ").split()]
                if len(vals) < 1:
                    self.setting_error("Temperatures are incorrectly set.")
                else:
                    self.set_parameter('temperatures', vals)

            if conf_key == 'write_amplitude':
                if confs['write_amplitude'] == '.true.':
                    self.set_parameter('write_amplitude', True)

            if conf_key == 'write_gamma':
                if confs['write_gamma'] == '.true.':
                    self.set_parameter('write_gamma', True)

            if conf_key == "write_triplet":
                if confs['write_triplet'] == '.true.':
                    self.set_parameter('write_triplet', True)
Beispiel #12
0
    def _parse_conf(self):
        confs = self._confs

        for conf_key in confs.keys():
            if conf_key == 'create_displacements':
                if confs['create_displacements'] == '.true.':
                    self.set_parameter('create_displacements', True)

            if conf_key == 'dim_fc2':
                matrix = [ int(x) for x in confs['dim_fc2'].split() ]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error(
                        "Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error(
                            "Determinant of supercell matrix has " +
                            "to be positive.")
                    else:
                        self.set_parameter('dim_fc2', matrix)

            if conf_key == 'boundary_mfp':
                self.set_parameter('boundary_mfp',
                                   float(confs['boundary_mfp']))

            if conf_key == 'constant_averaged_pp_interaction':
                self.set_parameter(
                    'constant_averaged_pp_interaction',
                    float(confs['constant_averaged_pp_interaction']))

            if conf_key == 'cutoff_fc3_distance':
                self.set_parameter('cutoff_fc3_distance',
                                   float(confs['cutoff_fc3_distance']))

            if conf_key == 'cutoff_pair_distance':
                self.set_parameter('cutoff_pair_distance',
                                   float(confs['cutoff_pair_distance']))

            if conf_key == 'frequency_scale_factor':
                self.set_parameter('frequency_scale_factor',
                                   float(confs['frequency_scale_factor']))

            if conf_key == 'full_pp':
                if confs['full_pp'] == '.true.':
                    self.set_parameter('is_full_pp', True)

            if conf_key == 'gamma_conversion_factor':
                self.set_parameter('gamma_conversion_factor',
                                   float(confs['gamma_conversion_factor']))

            if conf_key == 'grid_addresses':
                vals = [int(x) for x in
                        confs['grid_addresses'].replace(',', ' ').split()]
                if len(vals) % 3 == 0 and len(vals) > 0:
                    self.set_parameter('grid_addresses',
                                       np.reshape(vals, (-1, 3)))
                else:
                    self.setting_error("Grid addresses are incorrectly set.")


            if conf_key == 'grid_points':
                vals = [int(x) for x in
                        confs['grid_points'].replace(',', ' ').split()]
                self.set_parameter('grid_points', vals)

            if conf_key == 'ion_clamped':
                if confs['ion_clamped'] == '.true.':
                    self.set_parameter('ion_clamped', True)

            if conf_key == 'bterta':
                if confs['bterta'] == '.true.':
                    self.set_parameter('is_bterta', True)

            if conf_key == 'frequency_shift':
                if confs['frequency_shift'] == '.true.':
                    self.set_parameter('is_frequency_shift', True)

            if conf_key == 'gruneisen':
                if confs['gruneisen'] == '.true.':
                    self.set_parameter('is_gruneisen', True)

            if conf_key == 'imag_self_energy':
                if confs['imag_self_energy'] == '.true.':
                    self.set_parameter('is_imag_self_energy', True)
                    
            if conf_key == 'isotope':
                if confs['isotope'] == '.true.':
                    self.set_parameter('is_isotope', True)
                    
            if conf_key == 'joint_dos':
                if confs['joint_dos'] == '.true.':
                    self.set_parameter('is_joint_dos', True)

            if conf_key == 'lbte':
                if confs['lbte'] == '.true.':
                    self.set_parameter('is_lbte', True)

            if conf_key == 'linewidth':
                if confs['linewidth'] == '.true.':
                    self.set_parameter('is_linewidth', True)

            if conf_key == 'reducible_collision_matrix':
                if confs['reducible_collision_matrix'] == '.true.':
                    self.set_parameter('is_reducible_collision_matrix', True)

            if conf_key == 'symmetrize_fc2':
                if confs['symmetrize_fc2'] == '.true.':
                    self.set_parameter('is_symmetrize_fc2', True)

            if conf_key == 'symmetrize_fc3_q':
                if confs['symmetrize_fc3_q'] == '.true.':
                    self.set_parameter('is_symmetrize_fc3_q', True)

            if conf_key == 'symmetrize_fc3_r':
                if confs['symmetrize_fc3_r'] == '.true.':
                    self.set_parameter('is_symmetrize_fc3_r', True)

            if conf_key == 'mass_variances':
                vals = [fracval(x) for x in confs['mass_variances'].split()]
                if len(vals) < 1:
                    self.setting_error("Mass variance parameters are incorrectly set.")
                else:
                    self.set_parameter('mass_variances', vals)

            if conf_key == 'max_freepath':
                self.set_parameter('max_freepath', float(confs['max_freepath']))

            if conf_key == 'mesh_divisors':
                vals = [x for x in confs['mesh_divisors'].split()]
                if len(vals) == 3:
                    self.set_parameter('mesh_divisors', [int(x) for x in vals])
                elif len(vals) == 6:
                    divs = [int(x) for x in vals[:3]]
                    is_shift = [x.lower() == 't' for x in vals[3:]]
                    for i in range(3):
                        if is_shift[i] and (divs[i] % 2 != 0):
                            is_shift[i] = False
                            self.setting_error("Coarse grid shift along the " +
                                               ["first", "second", "third"][i] +
                                               " axis is not allowed.")
                    self.set_parameter('mesh_divisors', divs + is_shift)
                else:
                    self.setting_error("Mesh divisors are incorrectly set.")

            if conf_key == 'kappa_star':
                if confs['kappa_star'] == '.false.':
                    self.set_parameter('is_kappa_star', False)

            if conf_key == 'pinv_cutoff':
                self.set_parameter('pinv_cutoff', float(confs['pinv_cutoff']))

            if conf_key == 'pp_conversion_factor':
                self.set_parameter('pp_conversion_factor',
                                   float(confs['pp_conversion_factor']))

            if conf_key == 'read_amplitude':
                if confs['read_amplitude'] == '.true.':
                    self.set_parameter('read_amplitude', True)

            if conf_key == 'read_collision':
                if confs['read_collision'] == 'all':
                    self.set_parameter('read_collision', 'all')
                else:
                    vals = [int(x) for x in confs['read_collision'].split()]
                    self.set_parameter('read_collision', vals)

            if conf_key == 'read_fc2':
                if confs['read_fc2'] == '.true.':
                    self.set_parameter('read_fc2', True)

            if conf_key == 'read_fc3':
                if confs['read_fc3'] == '.true.':
                    self.set_parameter('read_fc3', True)

            if conf_key == 'read_gamma':
                if confs['read_gamma'] == '.true.':
                    self.set_parameter('read_gamma', True)

            if conf_key == 'read_phonon':
                if confs['read_phonon'] == '.true.':
                    self.set_parameter('read_phonon', True)

            if conf_key == 'run_with_g':
                if confs['run_with_g'] == '.false.':
                    self.set_parameter('run_with_g', False)

            if conf_key == 'scattering_event_class':
                self.set_parameter('scattering_event_class',
                                   confs['scattering_event_class'])

            if conf_key == 'temperatures':
                vals = [fracval(x) for x in confs['temperatures'].split()]
                if len(vals) < 1:
                    self.setting_error("Temperatures are incorrectly set.")
                else:
                    self.set_parameter('temperatures', vals)

            if conf_key == 'use_ave_pp':
                if confs['use_ave_pp'] == '.true.':
                    self.set_parameter('use_ave_pp', True)

            if conf_key == 'write_amplitude':
                if confs['write_amplitude'] == '.true.':
                    self.set_parameter('write_amplitude', True)

            if conf_key == 'write_detailed_gamma':
                if confs['write_detailed_gamma'] == '.true.':
                    self.set_parameter('write_detailed_gamma', True)
                    
            if conf_key == 'write_gamma':
                if confs['write_gamma'] == '.true.':
                    self.set_parameter('write_gamma', True)

            if conf_key == 'write_collision':
                if confs['write_collision'] == '.true.':
                    self.set_parameter('write_collision', True)

            if conf_key == 'write_phonon':
                if confs['write_phonon'] == '.true.':
                    self.set_parameter('write_phonon', True)
Beispiel #13
0
    def _parse_conf(self):
        confs = self._confs

        for conf_key in confs.keys():
            if conf_key == 'dim_extra':
                matrix = [
                    int(x)
                    for x in confs['dim_extra'].replace(",", " ").split()
                ]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error(
                        "Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error(
                            'Determinant of supercell matrix has to be positive.'
                        )
                    else:
                        self.set_parameter('dim_extra', matrix)

            if conf_key == "mesh_shift":
                vals = [
                    fracval(x)
                    for x in confs['mesh_shift'].replace(",", " ").split()
                ]
                for i in range(3 - len(vals)):
                    vals += [0.0]  # Correction for incomplete shift set
                self.set_parameter('mesh_shift', vals[:3])

            if conf_key == 'band_indices':
                vals = []
                for sum_set in confs['band_indices'].replace(",",
                                                             " ").split(','):
                    vals.append([
                        int(x) - 1 for x in sum_set.replace(",", " ").split()
                    ])
                self.set_parameter('band_indices', vals)

            if conf_key == 'grid_points':
                vals = [
                    int(x)
                    for x in confs['grid_points'].replace(",", " ").split()
                ]
                self.set_parameter('grid_points', vals)

            if conf_key == 'bterta':
                if confs['bterta'] == '.true.':
                    self.set_parameter('is_bterta', True)

            if conf_key == 'linewidth':
                if confs['linewidth'] == '.true.':
                    self.set_parameter('is_linewidth', True)

            if conf_key == 'read_fc2':
                if confs['read_fc2'] == '.true.':
                    self.set_parameter('read_fc2', True)

            if conf_key == 'read_fc2_extra':
                if confs['read_fc2_extra'] == '.true.':
                    self.set_parameter('read_fc2_extra', True)

            if conf_key == 'max_freepath':
                self.set_parameter('max_freepath',
                                   float(confs['max_freepath']))

            if conf_key == 'no_kappa_stars':
                if confs['no_kappa_stars'] == '.true.':
                    self.set_parameter('no_kappa_stars', True)

            if conf_key == 'read_gamma':
                if confs['read_gamma'] == '.true.':
                    self.set_parameter('read_gamma', True)

            if conf_key == 'temperature':
                vals = confs['temperature']
                self.set_parameter('temperature', vals)

            if conf_key == 'write_gamma':
                if confs['write_gamma'] == '.true.':
                    self.set_parameter('write_gamma', True)
Beispiel #14
0
    def _parse_conf(self):
        confs = self._confs

        for conf_key in confs.keys():
            if conf_key == 'dim_extra':
                matrix = [
                    int(x)
                    for x in confs['dim_extra'].replace(",", " ").split()
                ]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error(
                        "Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error(
                            'Determinant of supercell matrix has to be positive.'
                        )
                    else:
                        self.set_parameter('dim_extra', matrix)

            if conf_key == 'band_indices':
                vals = []
                for sum_set in confs['band_indices'].split(','):
                    vals.append([int(x) - 1 for x in sum_set.split()])
                self.set_parameter('band_indices', vals)

            if conf_key == 'cutoff_pair':
                cutpair = [
                    float(x)
                    for x in confs['cutoff_pair'].replace(",", " ").split()
                ]
                self.set_parameter('cutoff_pair', cutpair)

            if conf_key == 'cutoff_triplet':
                cutfc3 = [
                    float(x)
                    for x in confs['cutoff_triplet'].replace(",", " ").split()
                ]
                self.set_parameter('cutoff_triplet', cutfc3)

            if conf_key == 'cutoff_radius':
                cutfc3q = [
                    float(x)
                    for x in confs['cutoff_radius'].replace(",", " ").split()
                ]
                self.set_parameter('cutoff_radius', cutfc3q)

            if conf_key == "cutoff_delta":
                self.set_parameter("cutoff_delta",
                                   float(confs["cutoff_delta"]))

            if conf_key == 'cutoff_frequency':
                self.set_parameter('cutoff_frequency',
                                   confs['cutoff_frequency'])

            if conf_key == 'cutoff_hfrequency':
                self.set_parameter('cutoff_hfrequency',
                                   confs['cutoff_hfrequency'])

            if conf_key == 'cutoff_lifetime':
                self.set_parameter('cutoff_lifetime', confs['cutoff_lifetime'])

            if conf_key == "diff_kappa":
                self.set_parameter("diff_kappa", confs['diff_kappa'])

            if conf_key == "diff_gamma":
                self.set_parameter("diff_gamma", confs['diff_gamma'])

            if conf_key == 'grid_points':
                vals = [
                    int(x)
                    for x in confs['grid_points'].replace(",", " ").split()
                ]
                self.set_parameter('grid_points', vals)

            if conf_key == 'ion_clamped':
                if confs['ion_clamped'] == '.true.':
                    self.set_parameter('ion_clamped', True)

            if conf_key == "ite":
                if confs['ite'] == ".true.":
                    self.set_parameter('is_ite', True)

            if conf_key == "ite_cg":
                if confs['ite_cg'] == ".true.":
                    self.set_parameter('is_ite_cg', True)

            if conf_key == "length":
                self.set_parameter('length', confs['length'])

            if conf_key == "ise":
                if confs['ise'] == ".true.":
                    self.set_parameter('is_ise', True)

            if conf_key == 'bterta':
                if confs['bterta'] == '.true.':
                    self.set_parameter('is_bterta', True)

            if conf_key == 'linewidth':
                if confs['linewidth'] == '.true.':
                    self.set_parameter('is_linewidth', True)

            if conf_key == 'nu':
                if confs['nu'] is not None:
                    nu = confs['nu'].strip().upper()[0]
                    if nu == "N" or nu == "U":
                        self.set_parameter('nu', nu)

            if conf_key == 'read_fc2':
                if confs['read_fc2'] == '.true.':
                    self.set_parameter('read_fc2', True)

            if conf_key == 'read_fc2_extra':
                if confs['read_fc2_extra'] == '.true.':
                    self.set_parameter('read_fc2_extra', True)

            if conf_key == 'read_fc3':
                if confs['read_fc3'] == '.true.':
                    self.set_parameter('read_fc3', True)

            if conf_key == 'frequency_shift':
                if confs['frequency_shift'] == '.true.':
                    self.set_parameter('is_frequency_shift', True)

            if conf_key == 'mass_variances':
                vals = [fracval(x) for x in confs['mass_variances'].split()]
                if len(vals) < 1:
                    self.setting_error(
                        "Mass variance parameters are incorrectly set.")
                else:
                    self.set_parameter('mass_variances', vals)

            if conf_key == "max_ite":
                self.set_parameter("max_ite", int(confs['max_ite']))

            if conf_key == 'max_freepath':
                self.set_parameter('max_freepath',
                                   float(confs['max_freepath']))

            if conf_key == 'mesh_divisors':
                vals = [x for x in confs['mesh_divisors'].split()]
                if len(vals) == 3:
                    self.set_parameter('mesh_divisors', [int(x) for x in vals])
                elif len(vals) == 6:
                    divs = [int(x) for x in vals[:3]]
                    is_shift = [x.lower() == 't' for x in vals[3:]]
                    for i in range(3):
                        if is_shift[i] and (divs[i] % 2 != 0):
                            is_shift[i] = False
                            self.setting_error(
                                "Coarse grid shift along the " +
                                ["first", "second", "third"][i] +
                                " axis is not allowed.")
                    self.set_parameter('mesh_divisors', divs + is_shift)
                else:
                    self.setting_error("Mesh divisors are incorrectly set.")

            if conf_key == 'multiple_sigmas':
                vals = [
                    fracval(x) for x in confs['multiple_sigmas'].replace(
                        ",", " ").split()
                ]
                if len(vals) < 1:
                    self.setting_error("Mutiple sigmas are incorrectly set.")
                else:
                    self.set_parameter('multiple_sigmas', vals)

            if conf_key == "adaptive_sigma_step":
                self.set_parameter("adaptive_sigma_step",
                                   int(confs['adaptive_sigma_step']))

            if conf_key == 'kappa_write_step':
                self.set_parameter('kappa_write_step',
                                   int(confs['kappa_write_step']))

            if conf_key == 'no_kappa_stars':
                if confs['no_kappa_stars'] == '.true.':
                    self.set_parameter('no_kappa_stars', True)

            if conf_key == 'read_amplitude':
                if confs['read_amplitude'] == '.true.':
                    self.set_parameter('read_amplitude', True)

            if conf_key == 'read_gamma':
                if confs['read_gamma'] == '.true.':
                    self.set_parameter('read_gamma', True)

            if conf_key == 'temperatures':
                vals = [
                    fracval(x)
                    for x in confs['temperatures'].replace(",", " ").split()
                ]
                if len(vals) < 1:
                    self.setting_error("Temperatures are incorrectly set.")
                else:
                    self.set_parameter('temperatures', vals)

            if conf_key == 'write_amplitude':
                if confs['write_amplitude'] == '.true.':
                    self.set_parameter('write_amplitude', True)

            if conf_key == 'write_gamma':
                if confs['write_gamma'] == '.true.':
                    self.set_parameter('write_gamma', True)

            if conf_key == "write_triplet":
                if confs['write_triplet'] == '.true.':
                    self.set_parameter('write_triplet', True)
Beispiel #15
0
    def _parse_conf(self):
        ConfParser.parse_conf(self)
        confs = self._confs

        for conf_key in confs.keys():
            # Boolean
            if conf_key in ('read_fc2', 'read_fc3', 'read_gamma',
                            'read_phonon', 'read_pp', 'use_ave_pp',
                            'collective_phonon', 'write_gamma_detail',
                            'write_gamma', 'write_collision', 'write_phonon',
                            'write_pp', 'write_LBTE_solution', 'full_pp',
                            'ion_clamped', 'bterta', 'compact_fc',
                            'real_self_energy', 'gruneisen',
                            'imag_self_energy', 'isotope', 'joint_dos', 'lbte',
                            'N_U', 'spectral_function',
                            'reducible_collision_matrix', 'symmetrize_fc2',
                            'symmetrize_fc3_q', 'symmetrize_fc3_r',
                            'kappa_star'):
                if confs[conf_key].lower() == '.true.':
                    self.set_parameter(conf_key, True)
                elif confs[conf_key].lower() == '.false.':
                    self.set_parameter(conf_key, False)

            # float
            if conf_key in ('boundary_mfp', 'cutoff_fc3_distance',
                            'cutoff_pair_distance', 'gamma_conversion_factor',
                            'max_freepath', 'pinv_cutoff',
                            'pp_conversion_factor', 'sigma_cutoff_width'):
                self.set_parameter(conf_key, float(confs[conf_key]))

            # int
            if conf_key in ('pinv_solver', 'num_points_in_batch'):
                self.set_parameter(conf_key, int(confs[conf_key]))

            # specials
            if conf_key in ('create_forces_fc2', 'create_forces_fc3'):
                if type(confs[conf_key]) is str:
                    fnames = confs[conf_key].split()
                else:
                    fnames = confs[conf_key]
                self.set_parameter(conf_key, fnames)

            if conf_key == 'dim_fc2':
                matrix = [int(x) for x in confs['dim_fc2'].split()]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error(
                        "Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error(
                            "Determinant of supercell matrix has " +
                            "to be positive.")
                    else:
                        self.set_parameter('dim_fc2', matrix)

            if conf_key in ('constant_averaged_pp_interaction' 'const_ave_pp'):
                self.set_parameter('const_ave_pp',
                                   float(confs['const_ave_pp']))

            if conf_key == 'grid_addresses':
                vals = [
                    int(x)
                    for x in confs['grid_addresses'].replace(',', ' ').split()
                ]
                if len(vals) % 3 == 0 and len(vals) > 0:
                    self.set_parameter('grid_addresses',
                                       np.reshape(vals, (-1, 3)))
                else:
                    self.setting_error("Grid addresses are incorrectly set.")

            if conf_key == 'grid_points':
                vals = [
                    int(x)
                    for x in confs['grid_points'].replace(',', ' ').split()
                ]
                self.set_parameter('grid_points', vals)

            if conf_key == 'lapack_zheev_uplo':
                self.set_parameter('lapack_zheev_uplo',
                                   confs['lapack_zheev_uplo'].upper())

            if conf_key == 'mass_variances':
                vals = [fracval(x) for x in confs['mass_variances'].split()]
                if len(vals) < 1:
                    self.setting_error(
                        "Mass variance parameters are incorrectly set.")
                else:
                    self.set_parameter('mass_variances', vals)

            if conf_key == 'mesh_divisors':
                vals = [x for x in confs['mesh_divisors'].split()]
                if len(vals) == 3:
                    self.set_parameter('mesh_divisors', [int(x) for x in vals])
                elif len(vals) == 6:
                    divs = [int(x) for x in vals[:3]]
                    is_shift = [x.lower() == 't' for x in vals[3:]]
                    for i in range(3):
                        if is_shift[i] and (divs[i] % 2 != 0):
                            is_shift[i] = False
                            self.setting_error(
                                "Coarse grid shift along the " +
                                ["first", "second", "third"][i] +
                                " axis is not allowed.")
                    self.set_parameter('mesh_divisors', divs + is_shift)
                else:
                    self.setting_error("Mesh divisors are incorrectly set.")

            if conf_key == 'read_collision':
                if confs['read_collision'] == 'all':
                    self.set_parameter('read_collision', 'all')
                else:
                    vals = [int(x) for x in confs['read_collision'].split()]
                    self.set_parameter('read_collision', vals)

            if conf_key == 'scattering_event_class':
                self.set_parameter('scattering_event_class',
                                   int(confs['scattering_event_class']))
Beispiel #16
0
    def _parse_conf(self):
        confs = self._confs

        for conf_key in confs.keys():
            if conf_key == 'dim_extra':
                matrix = [ int(x) for x in confs['dim_extra'].split() ]
                if len(matrix) == 9:
                    matrix = np.array(matrix).reshape(3, 3)
                elif len(matrix) == 3:
                    matrix = np.diag(matrix)
                else:
                    self.setting_error(
                        "Number of elements of dim2 has to be 3 or 9.")

                if matrix.shape == (3, 3):
                    if np.linalg.det(matrix) < 1:
                        self.setting_error(
                            "Determinant of supercell matrix has " +
                            "to be positive.")
                    else:
                        self.set_parameter('dim_extra', matrix)

            if conf_key == 'cutoff_fc3_distance':
                self.set_parameter('cutoff_fc3_distance',
                                   float(confs['cutoff_fc3_distance']))

            if conf_key == 'cutoff_pair_distance':
                self.set_parameter('cutoff_pair_distance',
                                   float(confs['cutoff_pair_distance']))

            if conf_key == 'cutoff_frequency':
                self.set_parameter('cutoff_frequency',
                                   float(confs['cutoff_frequency']))

            if conf_key == 'cutoff_lifetime':
                self.set_parameter('cutoff_lifetime',
                                   float(confs['cutoff_lifetime']))

            if conf_key == 'grid_points':
                vals = [int(x) for x in
                        confs['grid_points'].replace(',', ' ').split()]
                self.set_parameter('grid_points', vals)

            if conf_key == 'ion_clamped':
                if confs['ion_clamped'] == '.true.':
                    self.set_parameter('ion_clamped', True)

            if conf_key == 'bterta':
                if confs['bterta'] == '.true.':
                    self.set_parameter('is_bterta', True)

            if conf_key == 'lbte':
                if confs['lbte'] == '.true.':
                    self.set_parameter('is_lbte', True)

            if conf_key == 'linewidth':
                if confs['linewidth'] == '.true.':
                    self.set_parameter('is_linewidth', True)

            if conf_key == 'frequency_shift':
                if confs['frequency_shift'] == '.true.':
                    self.set_parameter('is_frequency_shift', True)

            if conf_key == 'mass_variances':
                vals = [fracval(x) for x in confs['mass_variances'].split()]
                if len(vals) < 1:
                    self.setting_error("Mass variance parameters are incorrectly set.")
                else:
                    self.set_parameter('mass_variances', vals)

            if conf_key == 'max_freepath':
                self.set_parameter('max_freepath', float(confs['max_freepath']))

            if conf_key == 'mesh_divisors':
                vals = [x for x in confs['mesh_divisors'].split()]
                if len(vals) == 3:
                    self.set_parameter('mesh_divisors', [int(x) for x in vals])
                elif len(vals) == 6:
                    divs = [int(x) for x in vals[:3]]
                    is_shift = [x.lower() == 't' for x in vals[3:]]
                    for i in range(3):
                        if is_shift[i] and (divs[i] % 2 != 0):
                            is_shift[i] = False
                            self.setting_error("Coarse grid shift along the " +
                                               ["first", "second", "third"][i] +
                                               " axis is not allowed.")
                    self.set_parameter('mesh_divisors', divs + is_shift)
                else:
                    self.setting_error("Mesh divisors are incorrectly set.")

            if conf_key == 'no_kappa_stars':
                if confs['no_kappa_stars'] == '.true.':
                    self.set_parameter('no_kappa_stars', True)

            if conf_key == 'read_amplitude':
                if confs['read_amplitude'] == '.true.':
                    self.set_parameter('read_amplitude', True)

            if conf_key == 'read_gamma':
                if confs['read_gamma'] == '.true.':
                    self.set_parameter('read_gamma', True)

            if conf_key == 'read_collision':
                if confs['read_collision'] == 'all':
                    self.set_parameter('read_collision', 'all')
                else:
                    vals = [int(x) for x in confs['read_collision'].split()]
                    self.set_parameter('read_collision', vals)

            if conf_key == 'temperatures':
                vals = [fracval(x) for x in confs['temperatures'].split()]
                if len(vals) < 1:
                    self.setting_error("Temperatures are incorrectly set.")
                else:
                    self.set_parameter('temperatures', vals)

            if conf_key == 'write_amplitude':
                if confs['write_amplitude'] == '.true.':
                    self.set_parameter('write_amplitude', True)

            if conf_key == 'write_gamma':
                if confs['write_gamma'] == '.true.':
                    self.set_parameter('write_gamma', True)

            if conf_key == 'write_collision':
                if confs['write_collision'] == '.true.':
                    self.set_parameter('write_collision', True)