Esempio n. 1
0
def lammps_to_lammps(name, lmppath='', lmpbin='lmp_openmpi', energy=True,
        verbose=False):
    """Test lammps to lammps conversion
    """

    lmp_in = os.path.join('Inputs/Lammps/', name, 'data.lmp')
    if not os.path.isfile(lmp_in):
        raise Exception("File not found: {0}!".format(lmp_in))

    lmp_out = os.path.join('Outputs/LammpsToLammps/', name, 'data.lmp')

    # calc input energies
    if energy:
        e_in = lammps_energies(name, 'in', lmppath, lmpbin, verbose)

    # where the magic happens
    Driver.initSystem(name)
    Driver.load(lmp_in)
    Driver.write(lmp_out)

    # calc output energies
    if energy:
        e_out = lammps_energies(name, 'LtoL', lmppath, lmpbin)

    if energy:
       return combine_energy_results(e_in, e_out)
Esempio n. 2
0
def lammps_to_gromacs(name, gropath='', grosuff='', lmppath='', lmpbin='lmp_openmpi',
        energy=True, clean=True):
    """Test lammps to gromacs conversion
    """
    lmp_in = os.path.join('Inputs/Lammps/', name, 'data.lmp')
    if not os.path.isfile(lmp_in):
        raise Exception("File not found: {0}!".format(lmp_in))

    top_out = os.path.join('Outputs/LammpsToGromacs/', name, 'topol.top')
    gro_out = os.path.join('Outputs/LammpsToGromacs/', name, 'conf.gro')

    # calc input energies
    if energy:
        e_in = lammps_energies(name, 'in', lmppath, lmpbin)

    # where the magic happens
    Driver.initSystem(name)
    Driver.load(lmp_in)
    Driver.write(top_out, gro_out)

    # calc output energies
    if energy:
        e_out = gromacs_energies(name, top_out, gro_out, 'LtoG', gropath, grosuff)

    # delete gromacs backup files
    if clean:
        import glob
        filelist = glob.glob("Inputs/Gromacs/{name}/#*#".format(name=name))
        filelist += glob.glob("Outputs/GromacsToGromacs/{name}/#*#".format(name=name))
        for f in filelist:
            os.remove(f)
    if energy:
       return combine_energy_results(e_in, e_out)