예제 #1
0
def read_simulation(NEB, step_to_use, i, state):
    '''
    This function will read in the forces of atoms from a lammps simulation.
    Further, it only reads in the forces associated with the benzene atoms.

    **Parameters**

        NEB: :class:`NEB`
            An NEB container holding the main NEB simulation
        step_to_use: *int*
            Which iteration in the NEB sequence the output to be read in is on.
        i: *int*
            The index corresponding to which image on the frame is to be
            simulated.
        state: *list,* :class:`structures.Atom`
            A list of atoms describing the image on the frame associated with
            index *i*.

    **Returns**

        new_energy: *float*
            The energy of the system in Hartree (Ha).
        new_atoms: *list,* :class:`structures.Atom`
            A list of atoms with the forces attached in units of Hartree per
            Angstrom (Ha/Ang).            
    '''
    new_atoms = lammps_job.read_dump("lammps/solv_box-%d-%d/forces.dump" %
                                     (step_to_use, i),
                                     extras=['fx', 'fy', 'fz'])[0]
    for atom in new_atoms:
        atom.fx = units.convert("kcal/ang", "Ha/ang", float(atom.extras['fx']))
        atom.fy = units.convert("kcal/ang", "Ha/ang", float(atom.extras['fy']))
        atom.fz = units.convert("kcal/ang", "Ha/ang", float(atom.extras['fz']))

    energy = open("lammps/solv_box-%d-%d/energy.profile" % (step_to_use, i),
                  'r').read().strip().split("\n")[-1]
    new_energy = float(energy.strip().split()[-1].strip())

    # Add the forces onto our state
    for a, b in zip(state, new_atoms):
        a.fx, a.fy, a.fz = b.fx, b.fy, b.fz

    return units.convert_energy("kcal/mol", "Ha", new_energy), new_atoms
예제 #2
0
 def f(x):
     return units.convert("Ha/Ang", "eV/Ang", x)