{"action":"created","comment":{"url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/comments/110795581","pull_request_review_id":31993392,"id":110795581,"diff_hunk":"@@ -0,0 +1,193 @@\n+# Copyright 2016 Autodesk Inc.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+from __future__ import absolute_import\n+\n+import moldesign as mdt\n+from moldesign import units as u\n+from moldesign.molecules import Trajectory\n+import numpy as np\n+\n+from .base import IntegratorBase, ConstantTemperatureBase\n+\n+try:\n+    from lammps import lammps, PyLammps\n+    # WARNING: this is the real library, not our interface - this works because of absolute\n+    # imports. We should probably rename this interface\n+except ImportError:\n+    print 'LAMMPS could not be imported; using remote docker container'\n+    force_remote = True\n+else:  # this should be configurable\n+    force_remote = False  # debugging\n+\n+import tempfile\n+import os\n+from copy import deepcopy\n+from itertools import islice\n+\n+def exports(o):\n+    __all__.append(o.__name__)\n+    return o\n+__all__ = []\n+\n+\n+@exports\n+class LAMMPSNvt(ConstantTemperatureBase):\n+\n+    NAME_RESULT = \"result\"  # Name used for dump\n+    NAME_AFFECTED_ATOMS = \"affected_atoms\"  # Name used for grouped atoms\n+    NAME_NVT_SIM = \"nvt_sim\"    # Name used for nvt\n+    NAME_ADDFORCE = \"add_user_force\"    # Name used for addforce\n+    \n+    # TODO: raise exception if any constraints are requested ...\n+    def __init__(self, *args, **kwargs):\n+        super(LAMMPSNvt, self).__init__(*args, **kwargs)\n+        self._prepped = False # is the model prepped?\n+        self._model = None\n+\n+        self.lammps_system = None\n+        self.total_iter = None      # How many iterations of timesteps before end of simulation\n+        self.output_iter = None     # How often we dump the positions of the atoms during the simulation\n+        self.traj = None\n+\n+    def run(self, run_for):\n+        \"\"\"\n+        Users won't call this directly - instead, use mol.run\n+        Propagate position, momentum by a single timestep using LAMMPS NVT\n+        \n+        Arguments:\n+            run_for (int): number of timesteps OR amount of time to run for\n+            self.params.timestep (float): timestep length\n+\n+        \"\"\"\n+        self.total_iter = self.time_to_steps(run_for, self.params.timestep)\n+        self.output_iter = self.time_to_steps(self.params.frame_interval, self.params.timestep)\n+\n+        if self.total_iter < self.output_iter:\n+            raise ValueError(\"Run duration {0} \"\n+                             \"can\\'t be smaller than frame interval {1}\".format(self.total_iter, self.output_iter))\n+\n+        # Prepare lammps system\n+        self.prep()\n+        self._configure_system()\n+        lmps = self.lammps_system\n+\n+        predictable_filename = \"dump.result\"\n+        dump_filepath = os.path.join(self.mol.energy_model.tmpdir, predictable_filename)\n+        self.mol.energy_model.files.append(dump_filepath)\n+\n+        dump_command = \"dump {0} all custom {1} {2} id x y z vx vy vz\".format(self.NAME_RESULT,\n+                                                                            self.output_iter, dump_filepath)\n+\n+        lmps.command(dump_command)\n+        lmps.command(\"dump_modify {0} sort id\".format(self.NAME_RESULT))\n+\n+        # run simulation\n+        lmps.run(self.total_iter, \"post no\")\n+\n+        # Reset lammps system by undumping and unfixing\n+        for dmp in lmps.dumps:\n+            lmps.command(\"undump \" + dmp.get('name'))\n+\n+        for fix in lmps.fixes:\n+            lmps.command(\"unfix \" + fix.get('name'))\n+\n+        # Create trajectory object\n+        self.traj = Trajectory(self.mol, unit_system=self._model.unit_system)\n+        self.mol.calculate()\n+\n+        # Dynamics loop over the dump file\n+        dump = open(dump_filepath, \"rw+\")\n+        content = dump.readlines()\n+        for istep in xrange(self.total_iter/self.output_iter):\n+            self.step(istep, content)\n+            self.traj.new_frame()\n+        dump.close()\n+\n+        # Set time\n+        self.mol.time += self.time\n+\n+        return self.traj\n+\n+    def prep(self):\n+        \"\"\"\n+        Prepare the LAMMPS system by configuring it for NVT simulation\n+        \n+        Arguments:\n+            run_for (int): number of timesteps OR amount of time to run for\n+            self.params.timestep (float): timestep length\n+\n+        \"\"\"\n+        # prepare lammps model prior to preparing the integrator\n+        self._model = self.mol.energy_model\n+        self._model.prep()\n+\n+        self.time = 0.0 * self.params.timestep\n+\n+        self._prepped = True\n+\n+    def _configure_system(self):\n+        # Get lammps object from model","path":"moldesign/integrators/lammps_integrator.py","position":140,"original_position":140,"commit_id":"418f02287f23b678fc37264abaa6908958bbfb6c","original_commit_id":"bc562c3d97edf2c50aa9485857f3f333796907ff","user":{"login":"dane1122","id":8815429,"avatar_url":"https://avatars3.githubusercontent.com/u/8815429?v=3","gravatar_id":"","url":"https://api.github.com/users/dane1122","html_url":"https://github.com/dane1122","followers_url":"https://api.github.com/users/dane1122/followers","following_url":"https://api.github.com/users/dane1122/following{/other_user}","gists_url":"https://api.github.com/users/dane1122/gists{/gist_id}","starred_url":"https://api.github.com/users/dane1122/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dane1122/subscriptions","organizations_url":"https://api.github.com/users/dane1122/orgs","repos_url":"https://api.github.com/users/dane1122/repos","events_url":"https://api.github.com/users/dane1122/events{/privacy}","received_events_url":"https://api.github.com/users/dane1122/received_events","type":"User","site_admin":false},"body":"Fixed with ae97b6b9b66e9abdc96f5ec49f9052614823217d ","created_at":"2017-04-11T00:53:00Z","updated_at":"2017-04-11T00:53:00Z","html_url":"https://github.com/Autodesk/molecular-design-toolkit/pull/129#discussion_r110795581","pull_request_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/comments/110795581"},"html":{"href":"https://github.com/Autodesk/molecular-design-toolkit/pull/129#discussion_r110795581"},"pull_request":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129","id":104206426,"html_url":"https://github.com/Autodesk/molecular-design-toolkit/pull/129","diff_url":"https://github.com/Autodesk/molecular-design-toolkit/pull/129.diff","patch_url":"https://github.com/Autodesk/molecular-design-toolkit/pull/129.patch","issue_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/129","number":129,"state":"open","locked":false,"title":"Interactive simulation","user":{"login":"dane1122","id":8815429,"avatar_url":"https://avatars3.githubusercontent.com/u/8815429?v=3","gravatar_id":"","url":"https://api.github.com/users/dane1122","html_url":"https://github.com/dane1122","followers_url":"https://api.github.com/users/dane1122/followers","following_url":"https://api.github.com/users/dane1122/following{/other_user}","gists_url":"https://api.github.com/users/dane1122/gists{/gist_id}","starred_url":"https://api.github.com/users/dane1122/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dane1122/subscriptions","organizations_url":"https://api.github.com/users/dane1122/orgs","repos_url":"https://api.github.com/users/dane1122/repos","events_url":"https://api.github.com/users/dane1122/events{/privacy}","received_events_url":"https://api.github.com/users/dane1122/received_events","type":"User","site_admin":false},"body":"Pull request!","created_at":"2017-02-01T19:40:52Z","updated_at":"2017-04-11T00:53:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74916e06d042ae2e4be1d1c5d05db7fb4572d814","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129/commits","review_comments_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129/comments","review_comment_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/129/comments","statuses_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/statuses/418f02287f23b678fc37264abaa6908958bbfb6c","head":{"label":"Autodesk:interactive_simulation","ref":"interactive_simulation","sha":"418f02287f23b678fc37264abaa6908958bbfb6c","user":{"login":"Autodesk","id":7914533,"avatar_url":"https://avatars1.githubusercontent.com/u/7914533?v=3","gravatar_id":"","url":"https://api.github.com/users/Autodesk","html_url":"https://github.com/Autodesk","followers_url":"https://api.github.com/users/Autodesk/followers","following_url":"https://api.github.com/users/Autodesk/following{/other_user}","gists_url":"https://api.github.com/users/Autodesk/gists{/gist_id}","starred_url":"https://api.github.com/users/Autodesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Autodesk/subscriptions","organizations_url":"https://api.github.com/users/Autodesk/orgs","repos_url":"https://api.github.com/users/Autodesk/repos","events_url":"https://api.github.com/users/Autodesk/events{/privacy}","received_events_url":"https://api.github.com/users/Autodesk/received_events","type":"Organization","site_admin":false},"repo":{"id":63356659,"name":"molecular-design-toolkit","full_name":"Autodesk/molecular-design-toolkit","owner":{"login":"Autodesk","id":7914533,"avatar_url":"https://avatars1.githubusercontent.com/u/7914533?v=3","gravatar_id":"","url":"https://api.github.com/users/Autodesk","html_url":"https://github.com/Autodesk","followers_url":"https://api.github.com/users/Autodesk/followers","following_url":"https://api.github.com/users/Autodesk/following{/other_user}","gists_url":"https://api.github.com/users/Autodesk/gists{/gist_id}","starred_url":"https://api.github.com/users/Autodesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Autodesk/subscriptions","organizations_url":"https://api.github.com/users/Autodesk/orgs","repos_url":"https://api.github.com/users/Autodesk/repos","events_url":"https://api.github.com/users/Autodesk/events{/privacy}","received_events_url":"https://api.github.com/users/Autodesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Autodesk/molecular-design-toolkit","description":"Notebook-integrated tools for molecular simulation and visualization","fork":false,"url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit","forks_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/forks","keys_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/teams","hooks_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/hooks","issue_events_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/events","assignees_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/tags","blobs_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/languages","stargazers_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/stargazers","contributors_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/contributors","subscribers_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/subscribers","subscription_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/subscription","commits_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/merges","archive_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/downloads","issues_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/labels{/name}","releases_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/releases{/id}","deployments_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/deployments","created_at":"2016-07-14T17:35:49Z","updated_at":"2017-04-08T03:48:06Z","pushed_at":"2017-04-11T00:50:45Z","git_url":"git://github.com/Autodesk/molecular-design-toolkit.git","ssh_url":"git@github.com:Autodesk/molecular-design-toolkit.git","clone_url":"https://github.com/Autodesk/molecular-design-toolkit.git","svn_url":"https://github.com/Autodesk/molecular-design-toolkit","homepage":"http://moldesign.bionano.autodesk.com","size":66977,"stargazers_count":34,"watchers_count":34,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":18,"forks":10,"open_issues":18,"watchers":34,"default_branch":"master"}},"base":{"label":"Autodesk:master","ref":"master","sha":"7d0b12a89cb56b8dead72f72fbd0d623fdfaebbe","user":{"login":"Autodesk","id":7914533,"avatar_url":"https://avatars1.githubusercontent.com/u/7914533?v=3","gravatar_id":"","url":"https://api.github.com/users/Autodesk","html_url":"https://github.com/Autodesk","followers_url":"https://api.github.com/users/Autodesk/followers","following_url":"https://api.github.com/users/Autodesk/following{/other_user}","gists_url":"https://api.github.com/users/Autodesk/gists{/gist_id}","starred_url":"https://api.github.com/users/Autodesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Autodesk/subscriptions","organizations_url":"https://api.github.com/users/Autodesk/orgs","repos_url":"https://api.github.com/users/Autodesk/repos","events_url":"https://api.github.com/users/Autodesk/events{/privacy}","received_events_url":"https://api.github.com/users/Autodesk/received_events","type":"Organization","site_admin":false},"repo":{"id":63356659,"name":"molecular-design-toolkit","full_name":"Autodesk/molecular-design-toolkit","owner":{"login":"Autodesk","id":7914533,"avatar_url":"https://avatars1.githubusercontent.com/u/7914533?v=3","gravatar_id":"","url":"https://api.github.com/users/Autodesk","html_url":"https://github.com/Autodesk","followers_url":"https://api.github.com/users/Autodesk/followers","following_url":"https://api.github.com/users/Autodesk/following{/other_user}","gists_url":"https://api.github.com/users/Autodesk/gists{/gist_id}","starred_url":"https://api.github.com/users/Autodesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Autodesk/subscriptions","organizations_url":"https://api.github.com/users/Autodesk/orgs","repos_url":"https://api.github.com/users/Autodesk/repos","events_url":"https://api.github.com/users/Autodesk/events{/privacy}","received_events_url":"https://api.github.com/users/Autodesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Autodesk/molecular-design-toolkit","description":"Notebook-integrated tools for molecular simulation and visualization","fork":false,"url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit","forks_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/forks","keys_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/teams","hooks_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/hooks","issue_events_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/events","assignees_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/tags","blobs_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/languages","stargazers_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/stargazers","contributors_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/contributors","subscribers_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/subscribers","subscription_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/subscription","commits_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/merges","archive_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/downloads","issues_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/labels{/name}","releases_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/releases{/id}","deployments_url":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/deployments","created_at":"2016-07-14T17:35:49Z","updated_at":"2017-04-08T03:48:06Z","pushed_at":"2017-04-11T00:50:45Z","git_url":"git://github.com/Autodesk/molecular-design-toolkit.git","ssh_url":"git@github.com:Autodesk/molecular-design-toolkit.git","clone_url":"https://github.com/Autodesk/molecular-design-toolkit.git","svn_url":"https://github.com/Autodesk/molecular-design-toolkit","homepage":"http://moldesign.bionano.autodesk.com","size":66977,"stargazers_count":34,"watchers_count":34,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":18,"forks":10,"open_issues":18,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129"},"html":{"href":"https://github.com/Autodesk/molecular-design-toolkit/pull/129"},"issue":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/129"},"comments":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/Autodesk/molecular-design-toolkit/statuses/418f02287f23b678fc37264abaa6908958bbfb6c"}}}}
{"actor":{"display_login":"dane1122"}}