{"action":"created","issue":{"url":"https://api.github.com/repos/choderalab/openmm-constph/issues/19","repository_url":"https://api.github.com/repos/choderalab/openmm-constph","labels_url":"https://api.github.com/repos/choderalab/openmm-constph/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/choderalab/openmm-constph/issues/19/comments","events_url":"https://api.github.com/repos/choderalab/openmm-constph/issues/19/events","html_url":"https://github.com/choderalab/openmm-constph/issues/19","id":137082783,"number":19,"title":"Brainstorm simulation API proposal","user":{"login":"bas-rustenburg","id":3977731,"avatar_url":"https://avatars.githubusercontent.com/u/3977731?v=3","gravatar_id":"","url":"https://api.github.com/users/bas-rustenburg","html_url":"https://github.com/bas-rustenburg","followers_url":"https://api.github.com/users/bas-rustenburg/followers","following_url":"https://api.github.com/users/bas-rustenburg/following{/other_user}","gists_url":"https://api.github.com/users/bas-rustenburg/gists{/gist_id}","starred_url":"https://api.github.com/users/bas-rustenburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bas-rustenburg/subscriptions","organizations_url":"https://api.github.com/users/bas-rustenburg/orgs","repos_url":"https://api.github.com/users/bas-rustenburg/repos","events_url":"https://api.github.com/users/bas-rustenburg/events{/privacy}","received_events_url":"https://api.github.com/users/bas-rustenburg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2016-02-28T18:57:37Z","updated_at":"2016-03-05T03:01:46Z","closed_at":null,"body":"So we can discuss it here:  \r\n\r\n```py\r\n\r\nfrom __future__ import print_function\r\nfrom simtk.openmm import app\r\n# TODO  from constph import ConstpHForceField ?\r\nimport simtk.openmm as mm\r\nfrom simtk import unit\r\nfrom sys import stdout\r\n\r\npdb = app.PDBFile('input.pdb') # preprocessed with right residue names to indicate constph?\r\n\r\nforcefield = app.ConstpHForceField('amber99cph.xml', 'tip3p.xml', 'ligandcph.xml') # subclass of forcefield that supports custom format residues\r\n\r\nsystem = forcefield.createSystem(pdb.topology, \r\n nonbondedMethod=app.PME,nonbondedCutoff=1.0*unit.nanometers, constraints=app.HBonds, rigidWater=True, ewaldErrorTolerance=0.0005, cph_indices=None, ph=7.4)\r\n# cph_indices, if None, all that can be matched set up as constant ph, else, list of indices\r\nintegrator = mm.LangevinIntegrator(300*unit.kelvin, 1.0/unit.picoseconds, 2.0*unit.femtoseconds)\r\nintegrator.setConstraintTolerance(0.00001)\r\n\r\n# TODO define compound integrator here too, or leave for simulation?\r\nncmcintegrator =  VelocityVerletIntegrator(ncmc_timestep)\r\nsystem.addForce(mm.MonteCarloBarostat(1*unit.atmospheres, 300*unit.kelvin, 25))\r\n\r\nplatform = mm.Platform.getPlatformByName('CUDA')\r\nproperties = {'CudaPrecision': 'mixed'}\r\n# compound integrator under the hood, hide system update under the hood\r\nsimulation = app.Simulation(pdb.topology, system, {'md': integrator, 'ph': ncmcintegrator}, platform, properties)\r\nsimulation.context.setPositions(pdb.positions)\r\n\r\nprint('Minimizing...')\r\nsimulation.minimizeEnergy()\r\nsimulation.context.setVelocitiesToTemperature(300*unit.kelvin)\r\n\r\nsimulation.reporters.append(app.DCDReporter('trajectory.dcd', 1000)) # modify this to only write out active protons?\r\n# report protonation states\r\nsimulation.reporters.append(app.StateDataReporter(stdout, 1000, step=True,\r\n    potentialEnergy=True, temperature=True, progress=True, remainingTime=True,\r\n    speed=True, totalSteps=1000, protonationStates=True, separator='\\t'))\r\n\r\nprint('Running Production...')\r\nsimulation.calibrate(10000, ph_every=(100,1)) # 10000 cph calibration steps, updating ref energies\r\nsimulation.step(1000000, ph_every=(6000, 1)) # run mc step every 6000 md steps, 1 attempt\r\nprint('Done!')\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/choderalab/openmm-constph/issues/comments/192556560","html_url":"https://github.com/choderalab/openmm-constph/issues/19#issuecomment-192556560","issue_url":"https://api.github.com/repos/choderalab/openmm-constph/issues/19","id":192556560,"user":{"login":"peastman","id":4379786,"avatar_url":"https://avatars.githubusercontent.com/u/4379786?v=3","gravatar_id":"","url":"https://api.github.com/users/peastman","html_url":"https://github.com/peastman","followers_url":"https://api.github.com/users/peastman/followers","following_url":"https://api.github.com/users/peastman/following{/other_user}","gists_url":"https://api.github.com/users/peastman/gists{/gist_id}","starred_url":"https://api.github.com/users/peastman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peastman/subscriptions","organizations_url":"https://api.github.com/users/peastman/orgs","repos_url":"https://api.github.com/users/peastman/repos","events_url":"https://api.github.com/users/peastman/events{/privacy}","received_events_url":"https://api.github.com/users/peastman/received_events","type":"User","site_admin":false},"created_at":"2016-03-05T03:01:46Z","updated_at":"2016-03-05T03:01:46Z","body":"I don't think it's practical to do this with global parameters.  First, you'd be restricted to only Forces that use global parameters, so no NonbondedForce.  That's ok for implicit solvent, since you could do that with only custom forces, but PME would be out.\r\n\r\nBut even assuming you wanted to use only CustomNonbondedForce and CustomGBForce, what would you do?  There would be possibly dozens of parameters, each controlling the state of one site.  And then you would have to write a huge expression for the energy, involving all of those dozens of global parameters.  It would be insanely inefficient.\r\n\r\n> Is there a way to circumvent the ugly hacks through a clever choice of API?\r\n\r\nWhat about my suggestion of doing it through an integrator?  That would be a lot less hacky, since it could work entirely by calling public methods on the Forces at times when they expected those methods to be called."}}