Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial implementation of lammps support #114

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions mdbenchmark/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
"Parameter paths must be absolute. Only crude file checks are performed! "
"If you use the {} option make sure you use the GPU compatible NAMD module!"
)

LAMMPS_WARNING = (
"LAMMPS support is experimental."
"All input files must be in the same directory and have the same base name!"
"We hope you know what you're doing..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"We hope you know what you're doing..."

)

def validate_name(ctx, param, name=None):
"""Validate that we are given a name argument."""
Expand Down Expand Up @@ -222,9 +226,11 @@ def generate(
# click does the validation for us
template = utils.retrieve_host_template(host)

# Warn the user that NAMD support is still experimental.
# Warn the user that NAMD and LAMMPS support is still experimental.
if any(["namd" in m for m in module]):
console.warn(NAMD_WARNING, "--gpu")
if any(["lammps" in m for m in module]):
console.warn(LAMMPS_WARNING)

module = mdengines.normalize_modules(module, skip_validation)

Expand Down
7 changes: 4 additions & 3 deletions mdbenchmark/mdengines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import six

from . import gromacs, namd
from . import gromacs, namd, lammps
from .. import console

SUPPORTED_ENGINES = {"gromacs": gromacs, "namd": namd}
SUPPORTED_ENGINES = {"gromacs": gromacs, "namd": namd, "lammps": lammps}


def detect_md_engine(modulename):
Expand Down Expand Up @@ -63,6 +63,7 @@ def prepare_module_name(module, skip_validation=False):
"--skip-validation",
"gromacs/dummy",
"namd/dummy",
"lammps/dummy"
)
console.error("We were not able to determine the module name.")

Expand Down Expand Up @@ -120,7 +121,7 @@ def normalize_modules(modules, skip_validation):
if detect_md_engine(engine_name) is None:
console.error(
"There is currently no support for '{}'. "
"Supported MD engines are: gromacs, namd.",
"Supported MD engines are: gromacs, namd, lammps.",
engine_name,
)

Expand Down
64 changes: 64 additions & 0 deletions mdbenchmark/mdengines/lammps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8
#
# MDBenchmark
# Copyright (c) 2017 Max Linke & Michael Gecht and contributors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Copyright (c) 2017 Max Linke & Michael Gecht and contributors
# Copyright (c) 2017-2018 The MDBenchmark development team and contributors

# (see the file AUTHORS for the full list of names)
#
# MDBenchmark is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MDBenchmark is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MDBenchmark. If not, see <http://www.gnu.org/licenses/>.
import os
import re
from glob import glob
from shutil import copyfile

import mdsynthesis as mds
import numpy as np

from .. import console

NAME = "lammps"


def prepare_benchmark(name, *args, **kwargs):
sim = kwargs["sim"]

full_filename = name + ".in"
if name.endswith(".in"):
full_filename = name
name = name[:-3]

input_file_list = glob("{}*".format(name))
for fn in input_file_list:
copyfile(full_filename, sim[fn].relpath)

return name


def check_input_file_exists(name):
"""Check and append the correct file extensions for the LAMMPS module."""
# Check whether the needed files are there.
fn = name
if fn.endswith(".in"):
fn = name[:-4]

infile = fn + ".in"
if not os.path.exists(infile):
console.error(
"File {} does not exist, but is needed for LAMMPS benchmarks.", infile
)

input_files = glob("{}*".format(fn))
console.info("The following files will be used to generate the benchmarks:\n {}", ", ".join(input_files))

return True
4 changes: 4 additions & 0 deletions mdbenchmark/mdengines/namd.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def analyze_namd_file(fh):
def check_input_file_exists(name):
"""Check and append the correct file extensions for the NAMD module."""
# Check whether the needed files are there.
input_files = []
for extension in ["namd", "psf", "pdb"]:
if name.endswith(".{}".format(extension)):
name = name[: -2 + len(extension)]
Expand All @@ -86,5 +87,8 @@ def check_input_file_exists(name):
console.error(
"File {} does not exist, but is needed for NAMD benchmarks.", fn
)
input_files.append(fn)

console.info("The following files will be used to generate the benchmarks: {}", ", ".join(input_files))

return True
8 changes: 8 additions & 0 deletions mdbenchmark/mdengines/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
FILES_TO_KEEP = {
"gromacs": [".*/bench\.job", ".*\.tpr", ".*\.mdp"],
"namd": [".*/bench\.job", ".*\.namd", ".*\.psf", ".*\.pdb"],
"lammps": [".*/bench\.job", ".*\.in"],
}

PARSE_ENGINE = {
Expand All @@ -48,6 +49,13 @@
"ncores_return": lambda line: int(line.split()[3]),
"analyze": "*out*",
},
"lammps": {
"performance": "Performance",
"performance_return": lambda line: 1 / float(line.split()[1]),
"ncores": "Loop",
"ncores_return": lambda line: int(line.split()[5]),
"analyze": "*log*",
}
}


Expand Down
2 changes: 2 additions & 0 deletions mdbenchmark/templates/cobra
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ module load {{ module }}
srun gmx_mpi mdrun -v -maxh {{ time / 60 }} -deffnm {{ name }}
{%- elif mdengine == "namd" %}
srun namd2 {{ name }}.namd
{%- elif mdengine == "lammps" %}
srun lmp_mpi -v f tmp.out -l my.log -sc none -i in.alloy
{%- endif %}
2 changes: 2 additions & 0 deletions mdbenchmark/templates/draco
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ module load {{ module }}
srun gmx_mpi mdrun -v -maxh {{ time / 60 }} -deffnm {{ name }}
{%- elif mdengine == "namd" %}
srun namd2 {{ name }}.namd
{%- elif mdengine == "lammps" %}
srun lmp_mpi -v f tmp.out -l my.log -sc none -i in.alloy
{%- endif %}
2 changes: 2 additions & 0 deletions mdbenchmark/templates/hydra
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ module load cuda
poe gmx_mpi mdrun -deffnm {{ name }} -maxh {{ time / 60 }}
{%- elif mdengine == "namd" %}
poe namd2 {{ name }}.namd
{%- elif mdengine == "lammps" %}
poe lmp_mpi -v f tmp.out -l my.log -sc none -i {{ name }}.in
{%- endif %}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mdsynthesis": {}, "categories": {"module": "lammps/2016", "gpu": false, "nodes": 1, "host": "draco", "time": 15, "name": "bulk", "started": false}, "tags": []}
25 changes: 25 additions & 0 deletions mdbenchmark/tests/data/analyze-files-lammps/1/bench.job
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -l
# Standard output and error:
#SBATCH -o ./bulk.out.%j
#SBATCH -e ./bulk.err.%j
# Initial working directory:
#SBATCH -D ./
# Job Name:
#SBATCH -J bulk
#
# Queue (Partition):
#SBATCH --partition=express
#
# Number of nodes and MPI tasks per node:
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
# Wall clock limit:
#SBATCH --time=00:20:00

module purge
module load impi
module load cuda
module load lammps/2016

# Run lammps/2016 for 15 minutes
srun lmp_mpi -v f tmp.out -l my.log -sc none -i in.alloy
90 changes: 90 additions & 0 deletions mdbenchmark/tests/data/analyze-files-lammps/1/bulk.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# LAMMPS input script for standardized atomistic simulations
# Created by emc_setup.pl v2.2.12, July 28, 2017 as part of EMC
# on Mon Mar 5 16:29:28 CET 2018

# Variable definitions

variable project index "bulk" # project name
variable source index . # data directory
variable params index . # parameter directory
variable temperature index 300 # system temperature
variable tdamp index 100.0 # temperature damping
variable dielectric index 1 # medium dielectric
variable kappa index 4 # electrostatics kappa
variable cutoff index 9.5 # standard cutoff
variable charge_cutoff index 9.5 # charge cutoff
variable precision index 0.001 # kspace precision
variable lseed index 723853 # langevin seed
variable vseed index 1486234 # velocity init seed
variable tequil index 1000 # equilibration time
variable trun index 5000 # run time
variable frestart index 0 # 0: equil, 1: restart
variable dtrestart index 100000 # delta restart time
variable dtdump index 100 # delta dump time
variable dtthermo index 1000 # delta thermo time
variable timestep index 1 # integration time step
variable tfreq index 10 # profile sampling freq
variable nsample index 1000 # profile conf sampling
variable dtime equal ${tfreq}*${nsample} # profile dtime
variable restart index ${params}/${project}.restart

if "${frestart} != 0" then &
"variable data index ${restart}" &
else &
"variable data index ${params}/${project}.data" &

# LAMMPS atomistic input script

echo screen
units real
atom_style full

# Interaction potential definition

pair_style lj/class2/coul/long ${cutoff} ${charge_cutoff}
bond_style harmonic
special_bonds lj/coul 0 0 1
if "${frestart} != 0" then "read_restart ${data}" else "read_data ${data}"
include ${params}/${project}.params

# Integration conditions (check)

timestep ${timestep}
kspace_style pppm/cg ${precision}
dielectric ${dielectric}
fix mom all momentum 100 linear 1 1 1 angular

# Equilibration

thermo ${dtthermo}
if "${frestart} != 0" then "jump SELF simulate"
velocity all create ${temperature} ${vseed} &
dist gaussian rot yes mom yes sum yes
fix temp all langevin ${temperature} ${temperature} ${tdamp} &
${lseed}
fix int all nve/limit 0.1
run ${tequil}
unfix temp
unfix int
write_restart ${project}.restart2

# Simulation

label simulate
fix temp all langevin ${temperature} ${temperature} ${tdamp} &
${lseed}
fix int all nve

# System sampling: pressure

fix press all ave/time ${tfreq} ${nsample} ${dtime} &
c_thermo_temp &
c_thermo_press[1] c_thermo_press[2] c_thermo_press[3] &
c_thermo_press[4] c_thermo_press[5] c_thermo_press[6] &
file ${project}.pressure

# Run conditions

restart ${dtrestart} ${project}.restart1 ${project}.restart2
dump 1 all custom ${dtdump} ${project}.dump id type x y z
run ${trun}
Loading