{"action":"created","issue":{"url":"https://api.github.com/repos/choderalab/perses/issues/57","labels_url":"https://api.github.com/repos/choderalab/perses/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/choderalab/perses/issues/57/comments","events_url":"https://api.github.com/repos/choderalab/perses/issues/57/events","html_url":"https://github.com/choderalab/perses/issues/57","id":121621071,"number":57,"title":"System factory for torsion proposals","user":{"login":"jchodera","id":3656088,"avatar_url":"https://avatars.githubusercontent.com/u/3656088?v=3","gravatar_id":"","url":"https://api.github.com/users/jchodera","html_url":"https://github.com/jchodera","followers_url":"https://api.github.com/users/jchodera/followers","following_url":"https://api.github.com/users/jchodera/following{/other_user}","gists_url":"https://api.github.com/users/jchodera/gists{/gist_id}","starred_url":"https://api.github.com/users/jchodera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jchodera/subscriptions","organizations_url":"https://api.github.com/users/jchodera/orgs","repos_url":"https://api.github.com/users/jchodera/repos","events_url":"https://api.github.com/users/jchodera/events{/privacy}","received_events_url":"https://api.github.com/users/jchodera/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-11T02:15:15Z","updated_at":"2015-12-11T13:56:55Z","closed_at":null,"body":"If you need some reference code on how to construct a `System` factory for torsion proposals, you can start with [this old version of `alchemy.py`](https://github.com/choderalab/yank/blob/4ee3a26f920ff67e50a2142c1b7cef0577b1d89f/Yank/alchemy.py#L765-L800\r\n), which would be something like this:\r\n```python\r\n        # Create new deep copy reference system to modify.\r\n        system = openmm.System()\r\n\r\n        # Set periodic box vectors.\r\n        [a,b,c] = reference_system.getDefaultPeriodicBoxVectors()\r\n        system.setDefaultPeriodicBoxVectors(a,b,c)\r\n\r\n        # Add atoms.\r\n        for atom_index in range(reference_system.getNumParticles()):\r\n            mass = reference_system.getParticleMass(atom_index)\r\n            system.addParticle(mass)\r\n\r\n        # Add constraints\r\n        for constraint_index in range(reference_system.getNumConstraints()):\r\n            [iatom, jatom, r0] = reference_system.getConstraintParameters(constraint_index)\r\n            system.addConstraint(iatom, jatom, r0)\r\n\r\n        # Copy selected appropriate.\r\n        nforces = reference_system.getNumForces()\r\n        for force_index in range(nforces):\r\n            reference_force = reference_system.getForce(force_index)\r\n            force_name = reference_force.__class__.__name__\r\n            if force_name == 'HarmonicBondForce':\r\n                new_force = openmm.HarmonicBondForce()\r\n                system.addForce(new_force)\r\n                for bond_index in range(reference_force.getNumBonds()):\r\n                    [particle1, particle2, r, K] = reference_force.getBondParameters(bond_index)\r\n                    if set([particle1, particle2]) in atom_set:\r\n                        new_force.addBond(particle1, particle2, r, K)\r\n```"},"comment":{"url":"https://api.github.com/repos/choderalab/perses/issues/comments/163941837","html_url":"https://github.com/choderalab/perses/issues/57#issuecomment-163941837","issue_url":"https://api.github.com/repos/choderalab/perses/issues/57","id":163941837,"user":{"login":"jchodera","id":3656088,"avatar_url":"https://avatars.githubusercontent.com/u/3656088?v=3","gravatar_id":"","url":"https://api.github.com/users/jchodera","html_url":"https://github.com/jchodera","followers_url":"https://api.github.com/users/jchodera/followers","following_url":"https://api.github.com/users/jchodera/following{/other_user}","gists_url":"https://api.github.com/users/jchodera/gists{/gist_id}","starred_url":"https://api.github.com/users/jchodera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jchodera/subscriptions","organizations_url":"https://api.github.com/users/jchodera/orgs","repos_url":"https://api.github.com/users/jchodera/repos","events_url":"https://api.github.com/users/jchodera/events{/privacy}","received_events_url":"https://api.github.com/users/jchodera/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T13:56:55Z","updated_at":"2015-12-11T13:56:55Z","body":"As we discussed yesterday, we could also make this more efficient by recoding all forces as CustomForce classes and allowing atom contributions to be turned on one at a time.  @pgrinaway would need to preenumerate the order in which atoms (or sets of atoms) should be turned on---not sure how hard this is. A Context parameter would then control how atom contributions are turned on.\r\n\r\nEven more interesting could be to also make these additional atomic interactions alchemically switched on between integral values of this context parameter. This would be reasonably straightforward."}}