Example #1
0
def parse_set_of_forces(num_atoms, forces_filenames, verbose=True):
    """Parse forces from output files."""
    hook = "Forces :"
    is_parsed = True
    force_sets = []

    for i, filename in enumerate(forces_filenames):
        if verbose:
            sys.stdout.write("%d. " % (i + 1))
        f = open(filename)
        elk_forces = collect_forces(f,
                                    num_atoms,
                                    hook, [3, 4, 5],
                                    word="total force")
        if check_forces(elk_forces, num_atoms, filename, verbose=verbose):
            drift_force = get_drift_forces(elk_forces,
                                           filename=filename,
                                           verbose=verbose)
            force_sets.append(np.array(elk_forces) - drift_force)
        else:
            is_parsed = False

    if is_parsed:
        return force_sets
    else:
        return []
Example #2
0
File: elk.py Project: gcgs1/phonopy
def parse_set_of_forces(num_atoms, forces_filenames, verbose=True):
    hook = 'Forces :'
    is_parsed = True
    force_sets = []

    for i, filename in enumerate(forces_filenames):
        if verbose:
            sys.stdout.write("%d. " % (i + 1))
        f = open(filename)
        elk_forces = collect_forces(f,
                                    num_atoms,
                                    hook,
                                    [3, 4, 5],
                                    word='total force')
        if check_forces(elk_forces, num_atoms, filename, verbose=verbose):
            drift_force = get_drift_forces(elk_forces,
                                           filename=filename,
                                           verbose=verbose)
            force_sets.append(np.array(elk_forces) - drift_force)
        else:
            is_parsed = False

    if is_parsed:
        return force_sets
    else:
        return []
Example #3
0
def parse_set_of_forces(num_atoms, forces_filenames, verbose=True):
    hook = '1 #'
    is_parsed = True
    force_sets = []

    for i, filename in enumerate(forces_filenames):
        if verbose:
            sys.stdout.write("%d. " % (i + 1))
        f = open(filename)
        fleur_forces = collect_forces(f,
                                      num_atoms,
                                      hook, [0, 1, 2],
                                      word='force')
        if check_forces(fleur_forces, num_atoms, filename, verbose=verbose):
            drift_force = get_drift_forces(fleur_forces,
                                           filename=filename,
                                           verbose=verbose)
            force_sets.append(np.array(fleur_forces) - drift_force)
        else:
            is_parsed = False

    if is_parsed:
        return force_sets
    else:
        return []
Example #4
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
Example #5
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
Example #6
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
Example #7
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
Example #8
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
Example #9
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
Example #10
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
Example #11
0
File: elk.py Project: 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
Example #12
0
def parse_set_of_forces(num_atoms, forces_filenames, verbose=True):
    hook = '# Atom   Kind   Element'

    force_sets = []

    for i, filename in enumerate(forces_filenames):
        if verbose:
            sys.stdout.write("%d. " % (i + 1))

        with open(filename) as fhandle:
            cp2k_forces = collect_forces(fhandle, num_atoms, hook, [3, 4, 5])
            if check_forces(cp2k_forces, num_atoms, filename, verbose=verbose):
                drift_force = get_drift_forces(cp2k_forces,
                                               filename=filename,
                                               verbose=verbose)
                force_sets.append(np.array(cp2k_forces) - drift_force)
            else:
                return []  # if one file is invalid, the whole thing is broken

    return force_sets
Example #13
0
def parse_set_of_forces(num_atoms, forces_filenames, verbose=True):
    hook = 'cartesian forces (eV/Angstrom)'
    is_parsed = True
    force_sets = []
    for i, filename in enumerate(forces_filenames):
        if verbose:
            sys.stdout.write("%d. " % (i + 1))

        f = open(filename)
        abinit_forces = collect_forces(f, num_atoms, hook, [1, 2, 3])
        if check_forces(abinit_forces, num_atoms, filename, verbose=verbose):
            drift_force = get_drift_forces(abinit_forces,
                                           filename=filename,
                                           verbose=verbose)
            force_sets.append(np.array(abinit_forces) - drift_force)
        else:
            is_parsed = False

    if is_parsed:
        return force_sets
    else:
        return []
Example #14
0
def parse_set_of_forces(num_atoms, forces_filenames, verbose=True):
    hook = 'cartesian forces (eV/Angstrom)'
    is_parsed = True
    force_sets = []
    for i, filename in enumerate(forces_filenames):
        if verbose:
            sys.stdout.write("%d. " % (i + 1))

        f = open(filename)
        abinit_forces = collect_forces(f, num_atoms, hook, [1, 2, 3])
        if check_forces(abinit_forces, num_atoms, filename, verbose=verbose):
            drift_force = get_drift_forces(abinit_forces,
                                           filename=filename,
                                           verbose=verbose)
            force_sets.append(np.array(abinit_forces) - drift_force)
        else:
            is_parsed = False

    if is_parsed:
        return force_sets
    else:
        return []