コード例 #1
0
ファイル: wien2k.py プロジェクト: mospring/phonopy
def parse_set_of_forces(displacements,
                        forces_filenames,
                        supercell,
                        disp_keyword='first_atoms',
                        is_distribute=True,
                        symprec=1e-5):
    natom = supercell.get_number_of_atoms()
    lattice = supercell.get_cell()
    force_sets = []

    for wien2k_filename, disp in zip(forces_filenames,
                                     displacements[disp_keyword]):
        # Parse wien2k case.scf file
        wien2k_forces = get_forces_wien2k(wien2k_filename, lattice)
        if is_distribute:
            forces = _distribute_forces(supercell,
                                        [disp['number'], disp['displacement']],
                                        wien2k_forces, wien2k_filename,
                                        symprec)
            if not forces:
                return []
        else:
            if not (natom == len(wien2k_forces)):
                print("%s contains only forces of %d atoms" %
                      (wien2k_filename, len(wien2k_forces)))
                return []
            else:
                forces = wien2k_forces

        drift_force = get_drift_forces(forces, filename=wien2k_filename)
        force_sets.append(np.array(forces) - drift_force)

    return force_sets
コード例 #2
0
ファイル: wien2k.py プロジェクト: supersonic594/phonopy
def create_FORCE_SETS(forces_filenames,
                      displacements,
                      supercell,
                      filename='FORCE_SETS',
                      is_distribute=True,
                      symprec=1e-5):
    natom = supercell.get_number_of_atoms()
    lattice = supercell.get_cell()

    for wien2k_filename, disp in zip(forces_filenames,
                                     displacements['first_atoms']):
        # Parse wien2k case.scf file
        wien2k_forces = get_forces_wien2k(wien2k_filename, lattice)
        if is_distribute:
            force_set = distribute_forces(
                supercell, [disp['number'], disp['displacement']],
                wien2k_forces, wien2k_filename, symprec)
            if not force_set:
                return False
        else:
            if not (natom == len(wien2k_forces)):
                print "%s contains only forces of %d atoms" % (
                    wien2k_filename, len(wien2k_forces))
                return False
            else:
                force_set = wien2k_forces

        drift_force = get_drift_forces(force_set, filename=wien2k_filename)
        disp['forces'] = np.array(force_set) - drift_force

    write_FORCE_SETS(displacements, filename=filename)
    return True
コード例 #3
0
ファイル: wien2k.py プロジェクト: Maofei/phonopy
def create_FORCE_SETS(forces_filenames,
                      displacements,
                      supercell,
                      filename='FORCE_SETS',
                      is_distribute=True,
                      symprec=1e-5):
    natom = supercell.get_number_of_atoms()
    lattice = supercell.get_cell()

    for wien2k_filename, disp in zip(forces_filenames,
                                     displacements['first_atoms']):
        # Parse wien2k case.scf file
        wien2k_forces = get_forces_wien2k(wien2k_filename, lattice)
        if is_distribute:
            force_set = distribute_forces(
                supercell,
                [disp['number'], disp['displacement']],
                wien2k_forces,
                wien2k_filename,
                symprec)
            if not force_set:
                return False
        else:
            if not (natom == len(wien2k_forces)):
                print "%s contains only forces of %d atoms" % (
                    wien2k_filename, len(wien2k_forces))
                return False
            else:
                force_set = wien2k_forces

        drift_force = get_drift_forces(force_set, filename=wien2k_filename)
        disp['forces'] = np.array(force_set) - drift_force
                
    write_FORCE_SETS(displacements, filename=filename)
    return True
コード例 #4
0
ファイル: wien2k.py プロジェクト: chueter/phonopy
def parse_set_of_forces(displacements,
                        forces_filenames,
                        supercell,
                        disp_keyword='first_atoms',
                        is_distribute=True,
                        symprec=1e-5):
    natom = supercell.get_number_of_atoms()
    lattice = supercell.get_cell()
    force_sets = []

    for wien2k_filename, disp in zip(forces_filenames,
                                     displacements[disp_keyword]):
        # Parse wien2k case.scf file
        wien2k_forces = get_forces_wien2k(wien2k_filename, lattice)
        if is_distribute:
            forces = _distribute_forces(
                supercell,
                [disp['number'], disp['displacement']],
                wien2k_forces,
                wien2k_filename,
                symprec)
            if not forces:
                return []
        else:
            if not (natom == len(wien2k_forces)):
                print("%s contains only forces of %d atoms" %
                      (wien2k_filename, len(wien2k_forces)))
                return []
            else:
                forces = wien2k_forces

        drift_force = get_drift_forces(forces, filename=wien2k_filename)
        force_sets.append(np.array(forces) - drift_force)
                
    return force_sets
コード例 #5
0
ファイル: siesta.py プロジェクト: supersonic594/phonopy
def parse_set_of_forces(displacements, forces_filenames, num_atom):
    hook = ''
    for siesta_filename, disp in zip(forces_filenames,
                                     displacements['first_atoms']):
        siesta_forces = iter_collect_forces(siesta_filename,
                                            num_atom,
                                            hook, [1, 2, 3],
                                            word='')
        drift_force = get_drift_forces(siesta_forces)
        disp['forces'] = np.array(siesta_forces) - drift_force

    return True
コード例 #6
0
ファイル: abinit.py プロジェクト: gmatteo/phonopy
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = "cartesian forces (eV/Angstrom)"
    force_sets = []
    for filename in forces_filenames:
        f = open(filename)
        abinit_forces = collect_forces(f, num_atoms, hook, [1, 2, 3])
        if not abinit_forces:
            return []

        drift_force = get_drift_forces(abinit_forces)
        force_sets.append(np.array(abinit_forces) - drift_force)

    return force_sets
コード例 #7
0
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = 'cartesian forces (eV/Angstrom)'
    force_sets = []
    for filename in forces_filenames:
        f = open(filename)
        abinit_forces = collect_forces(f, num_atoms, hook, [1, 2, 3])
        if not abinit_forces:
            return []

        drift_force = get_drift_forces(abinit_forces)
        force_sets.append(np.array(abinit_forces) - drift_force)

    return force_sets
コード例 #8
0
ファイル: elk.py プロジェクト: georgeyumnam/phonopy
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = "Forces :"
    force_sets = []
    for filename in forces_filenames:
        f = open(filename)
        elk_forces = collect_forces(f, num_atoms, hook, [3, 4, 5], word="total force")
        if not elk_forces:
            return []

        drift_force = get_drift_forces(elk_forces)
        force_sets.append(np.array(elk_forces) - drift_force)

    return force_sets
コード例 #9
0
def parse_set_of_forces(displacements, forces_filenames, num_atom):
    hook = 'cartesian forces (eV/Angstrom)'
    for abinit_filename, disp in zip(forces_filenames,
                                     displacements['first_atoms']):
        f = open(abinit_filename)
        abinit_forces = collect_forces(f, num_atom, hook, [1, 2, 3])
        if not abinit_forces:
            return False

        drift_force = get_drift_forces(abinit_forces)
        disp['forces'] = np.array(abinit_forces) - drift_force

    return True
コード例 #10
0
ファイル: siesta.py プロジェクト: mospring/phonopy
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = ''  # Just for skipping the first line
    force_sets = []
    for filename in forces_filenames:
        siesta_forces = iter_collect_forces(filename,
                                            num_atoms,
                                            hook, [1, 2, 3],
                                            word='')
        if not siesta_forces:
            return []
        drift_force = get_drift_forces(siesta_forces)
        force_sets.append(np.array(siesta_forces) - drift_force)

    return force_sets
コード例 #11
0
def parse_set_of_forces(displacements,
                        forces_filenames,
                        num_atom):
    hook = 'Forces acting on atoms'
    for pwscf_filename, disp in zip(forces_filenames,
                                    displacements['first_atoms']):
        pwscf_forces = iter_collect_forces(pwscf_filename,
                                           num_atom,
                                           hook,
                                           [6, 7, 8],
                                           word='force')
        drift_force = get_drift_forces(pwscf_forces)
        disp['forces'] = np.array(pwscf_forces) - drift_force

    return True
コード例 #12
0
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = 'Forces acting on atoms'
    force_sets = []
    for filename in forces_filenames:
        pwscf_forces = iter_collect_forces(filename,
                                           num_atoms,
                                           hook, [6, 7, 8],
                                           word='force')
        if not pwscf_forces:
            return []

        drift_force = get_drift_forces(pwscf_forces)
        force_sets.append(np.array(pwscf_forces) - drift_force)

    return force_sets
コード例 #13
0
ファイル: siesta.py プロジェクト: chueter/phonopy
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = '' # Just for skipping the first line
    force_sets = []
    for filename in forces_filenames:
        siesta_forces = iter_collect_forces(filename,
                                            num_atoms,
                                            hook,
                                            [1, 2, 3],
                                            word='')
        if not siesta_forces:
            return []
        drift_force = get_drift_forces(siesta_forces)
        force_sets.append(np.array(siesta_forces) - drift_force)

    return force_sets
コード例 #14
0
ファイル: siesta.py プロジェクト: nfh/phonopy
def parse_set_of_forces(displacements,
                        forces_filenames,
                        num_atom):
    hook = ''
    for siesta_filename, disp in zip(forces_filenames,
                                    displacements['first_atoms']):
        siesta_forces = iter_collect_forces(siesta_filename,
                                           num_atom,
                                           hook,
                                           [1, 2, 3],
                                           word='')
        drift_force = get_drift_forces(siesta_forces)
        disp['forces'] = np.array(siesta_forces) - drift_force

    return True
コード例 #15
0
ファイル: abinit.py プロジェクト: Maofei/phonopy
def parse_set_of_forces(displacements,
                        forces_filenames,
                        num_atom):
    hook = 'cartesian forces (eV/Angstrom)'
    for abinit_filename, disp in zip(forces_filenames,
                                     displacements['first_atoms']):
        f = open(abinit_filename)
        abinit_forces = collect_forces(f, num_atom, hook, [1, 2, 3])
        if not abinit_forces:
            return False

        drift_force = get_drift_forces(abinit_forces)
        disp['forces'] = np.array(abinit_forces) - drift_force

    return True
コード例 #16
0
def parse_set_of_forces(displacements, forces_filenames, num_atom):
    hook = 'Forces :'
    for elk_filename, disp in zip(forces_filenames,
                                  displacements['first_atoms']):
        f = open(elk_filename)
        elk_forces = collect_forces(f,
                                    num_atom,
                                    hook, [3, 4, 5],
                                    word='total force')
        if not elk_forces:
            return False

        drift_force = get_drift_forces(elk_forces)
        disp['forces'] = np.array(elk_forces) - drift_force

    return True
コード例 #17
0
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = 'Forces :'
    force_sets = []
    for filename in forces_filenames:
        f = open(filename)
        elk_forces = collect_forces(f,
                                    num_atoms,
                                    hook, [3, 4, 5],
                                    word='total force')
        if not elk_forces:
            return []

        drift_force = get_drift_forces(elk_forces)
        force_sets.append(np.array(elk_forces) - drift_force)

    return force_sets
コード例 #18
0
ファイル: pwscf.py プロジェクト: georgeyumnam/phonopy
def parse_set_of_forces(num_atoms, forces_filenames):
    hook = 'Forces acting on atoms'
    force_sets = []
    for filename in forces_filenames:
        pwscf_forces = iter_collect_forces(filename,
                                           num_atoms,
                                           hook,
                                           [6, 7, 8],
                                           word='force')
        if not pwscf_forces:
            return []

        drift_force = get_drift_forces(pwscf_forces)
        force_sets.append(np.array(pwscf_forces) - drift_force)
        
    return force_sets
コード例 #19
0
ファイル: elk.py プロジェクト: nfh/phonopy
def parse_set_of_forces(displacements,
                        forces_filenames,
                        num_atom):
    hook = 'Forces :'
    for elk_filename, disp in zip(forces_filenames,
                                  displacements['first_atoms']):
        f = open(elk_filename)
        elk_forces = collect_forces(f,
                                    num_atom,
                                    hook,
                                    [3, 4, 5],
                                    word='total force')
        if not elk_forces:
            return False

        drift_force = get_drift_forces(elk_forces)
        disp['forces'] = np.array(elk_forces) - drift_force

    return True