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

Interactive simulation #129

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0a1e163
integrating LAMMPS into MDT
dane1122 Jan 31, 2017
d3c20d6
hello
dane1122 Feb 1, 2017
f47049a
Created Dockerfile for LAMMPS
dane1122 Feb 1, 2017
a4beceb
added exmaples folder to test LAMMPS integration
dane1122 Feb 1, 2017
7ef8548
Modified models file in accordance with the code review
dane1122 Feb 1, 2017
c53274e
example for lammps usage
dane1122 Feb 2, 2017
26c0bdf
LAMMPS integration into model integrator
dane1122 Feb 2, 2017
b694311
Added docstring for describing functions inside LAMMPS integrator
dane1122 Feb 2, 2017
1941f51
Modified model and integrator
dane1122 Feb 2, 2017
80f74e4
Merge branch 'workflow_fixes' into interactive_simulation
dane1122 Feb 2, 2017
b680740
example
dane1122 Feb 2, 2017
4f7ad81
Remove it
dane1122 Feb 2, 2017
b7d66bf
Merged with lammps branch to get yml file in this repository
dane1122 Feb 2, 2017
902f015
Modified LAMMPS model
dane1122 Feb 2, 2017
0d1ebb6
Cleanup
dane1122 Feb 2, 2017
526d24f
Specified units
dane1122 Feb 3, 2017
8507817
Modified model and integrator. TODO: Trajectory for integrator. It se…
dane1122 Feb 3, 2017
6ade6dd
Modified example files
dane1122 Feb 3, 2017
38fdc70
example
dane1122 Feb 3, 2017
0345f16
Merge branch 'master' into interactive_simulation
dane1122 Feb 3, 2017
85fb4cf
Modified integrator and model
dane1122 Feb 4, 2017
aa2ddbe
Modified. TODO: Fix LAMMPS simulation error
dane1122 Feb 4, 2017
0487c04
Modified docker makefile for lammps
dane1122 Feb 6, 2017
a5082a0
Modified example
dane1122 Feb 6, 2017
0fc2b0d
Modified xlo, xhi, ylo, yhi, zlo, zhi since the molecule wrapped arou…
dane1122 Feb 6, 2017
7e309f9
Modified shake
dane1122 Feb 7, 2017
55242fa
Merge remote-tracking branch 'origin/master' into interactive_simulation
dane1122 Feb 7, 2017
992dfb8
Modified integrator and model
dane1122 Feb 7, 2017
15ddfcf
Created model for interactive simulation
dane1122 Feb 9, 2017
8952f7c
Modified lammps model so the user can apply force
dane1122 Feb 9, 2017
c6f8f26
Modified force equation
dane1122 Feb 10, 2017
5b850ee
Modified model
dane1122 Feb 13, 2017
06707ab
Interactive slide bar
dane1122 Feb 13, 2017
2a7fe6f
Trajectory way
dane1122 Feb 14, 2017
a408c99
Stretch factor for nearby atoms
dane1122 Feb 14, 2017
7566047
Removed print that was used for debugging
dane1122 Feb 14, 2017
c994e54
Modified model for better visual effects
dane1122 Feb 14, 2017
9b1118d
Fixed model
dane1122 Feb 17, 2017
0f5e422
Modified for web assembly usage
dane1122 Feb 18, 2017
23a22b5
Removed export since not required anymore
dane1122 Feb 22, 2017
4e8813e
fixed simulation boz
dane1122 Mar 3, 2017
51cd6df
Create a function to possibly use for LAMMPS-related workflows
Apr 3, 2017
4454121
Lammps model and integrator
Apr 7, 2017
bc562c3
Set simulation box larger than atom xlo, xhi, ylo, yhi, zlo, zhi coor…
Apr 7, 2017
ae97b6b
Revert "Set simulation box larger than atom xlo, xhi, ylo, yhi, zlo, …
Apr 10, 2017
418f022
Fixed bug: can still run dynamics with potential model
Apr 11, 2017
674d66f
Removed moldesign-examples directory since examples should be in mold…
Apr 11, 2017
0e4f1f4
Updated test
Apr 11, 2017
842c637
Merge branch 'master' into interactive_simulation
Apr 11, 2017
7210046
Fixed error caused by merging master.
Apr 11, 2017
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
114 changes: 114 additions & 0 deletions moldesign/integrators/lammps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright 2016 Autodesk Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import moldesign as mdt
from moldesign import units as u
from moldesign.molecules import Trajectory

from .base import IntegratorBase


def exports(o):
__all__.append(o.__name__)
return o
__all__ = []


@exports
class LAMMPSNvt(ConstantTemperatureBase):
def __init__(self, *args, **kwargs):
super(LAMMPSNvt, self).__init__(*args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can omit this __init__ method - the superclass __init__ will get called automatically if you do.


# TODO: raise exception if any constraints are requested ...

def run(self, run_for):
"""
Users won't call this directly - instead, use mol.run
Propagate position, momentum by a single timestep using velocity verlet
:param run_for: number of timesteps OR amount of time to run for
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this docstring came from a piece of code I haven't touched in a while :)

We've switched over to Google's docstring format - see http://google.github.io/styleguide/pyguide.html?showone=Comments#Comments

So you'll want to make sure to write your docstrings in that format (or update mine, as the case may be)

"""
if not self._prepped:
self.prep()
nsteps = self.time_to_steps(run_for, self.params.timestep)

# Set up trajectory and record the first frame
self.mol.time = 0.0 * u.default.time
# self.traj = Trajectory(self.mol)
# self.mol.calculate()
# self.traj.new_frame()
# next_trajectory_frame = self.params.frame_interval

# Dynamics loop
for istep in xrange(nsteps):
self.step()
# if istep + 1 >= next_trajectory_frame:
# self.traj.new_frame()
# next_trajectory_frame += self.params.frame_interval
# return self.traj
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we're ready to get started with the run method, it will need to:

  1. Send the molecule's current positions and momenta to LAMMPS
  2. Create a Trajectory object to store the results.
  3. Run dynamics in LAMMPS, storing new a frame to the Trajectory object at fixed simulation time intervals (defined in self.params.frame_interval )


def prep(self):
if self._prepped and self.model is self.mol.energy_model and self.model._prepped: return

# prepare lammps model prior to preparing the integrator
self.model = self.mol.energy_model
self.model.prep()

self.time = 0.0 * self.params.timestep
self._prepped = True

# get lammps object from model
lammps_system = self.model.lammps_system

# NOTE: Ensure time step is in femtoseconds
lammps_system.command("timestep " + str(self.params.timestep))
lammps_system.command("thermo_style custom step temp pe etotal")
lammps_system.command("thermo " + str(self.params.frame_interval))

# TODO:
nvt_command = "fix 1 all nvt temp {0} {1} {2}" .format(self.params.temperature,
self.params.temperature, 100.0)
lammps_system.command(nvt_command)

# TODO:
if self.params.constrain_hbonds && self.model.group_hbond == True :
Copy link
Contributor

Choose a reason for hiding this comment

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

No && or || in python - it's just and and or

shake_command = "fix 2 hbond shake 0.0001 20 10 t 5 6 m 1.0 a 31"
lammps_system.command(shake_command)

self.lammps_system = lammps_system

# # TODO:
# if self.params.constrain_water && self.model.group_water == True :
# shake_command = "fix 3 water shake 0.00"



def step(self):
# Run Lammps simulation
L = self.lammps_system
L.run(int(self.params.timestep)) # run takes in integer number

# Update position and velocity of each atom
for i in range(0, L.atoms.natom):
self.mol.positions[i] = L.atoms[i].position
self.mol.velocities[i] = L.atoms[i].velocity

self.time += self.params.timestep
self.mol.time = self.time

#################################################
# "Private" methods for managing LAMMPS are below





Loading