Skip to content

Commit

Permalink
Merge pull request #20 from peastman/hmr
Browse files Browse the repository at this point in the history
Added option for hydrogen mass repartitioning
  • Loading branch information
peastman committed Dec 7, 2020
2 parents d7e3dfb + eb0a56e commit cb256e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 10 additions & 4 deletions openmmsetup/openmmsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def setSimulationOptions():
session['writeData'] = 'writeData' in request.form
session['writeCheckpoint'] = 'writeCheckpoint' in request.form
session['dataFields'] = request.form.getlist('dataFields')
session['hmr'] = 'hmr' in request.form
return createScript()

@app.route('/downloadScript')
Expand Down Expand Up @@ -418,6 +419,8 @@ def configureDefaultOptions():
session['cutoff'] = '2.0' if implicitWater else '1.0'
session['ewaldTol'] = '0.0005'
session['constraintTol'] = '0.000001'
session['hmr'] = True
session['hmrMass'] = '1.5'
if isAmoeba:
session['dt'] = '0.002'
elif isDrude:
Expand Down Expand Up @@ -530,6 +533,8 @@ def write(self, string):
script.append('rigidWater = %s' % ('False' if constraints == 'none' else 'True'))
if constraints != 'none':
script.append('constraintTolerance = %s' % session['constraintTol'])
if session['hmr']:
script.append('hydrogenMass = %s*amu' % session['hmrMass'])

# Integration options

Expand Down Expand Up @@ -586,18 +591,19 @@ def write(self, string):
script.append('modeller.addExtraParticles(forcefield)')
script.append('topology = modeller.topology')
script.append('positions = modeller.positions')
hmrOptions = ', hydrogenMass=hydrogenMass' if session['hmr'] else ''
if fileType == 'pdb':
script.append('system = forcefield.createSystem(topology, nonbondedMethod=nonbondedMethod,%s' % (' nonbondedCutoff=nonbondedCutoff,' if nonbondedMethod != 'NoCutoff' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else '', hmrOptions))
elif fileType == 'amber':
script.append('system = prmtop.createSystem(nonbondedMethod=nonbondedMethod,%s' % (' nonbondedCutoff=nonbondedCutoff,' if nonbondedMethod != 'NoCutoff' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else '', hmrOptions))
elif fileType == 'charmm':
script.append('system = psf.createSystem(params, nonbondedMethod=nonbondedMethod,%s' % (' nonbondedCutoff=nonbondedCutoff,' if nonbondedMethod != 'NoCutoff' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else '', hmrOptions))
elif fileType == 'gromacs':
script.append('system = top.createSystem(nonbondedMethod=nonbondedMethod,%s' % (' nonbondedCutoff=nonbondedCutoff,' if nonbondedMethod != 'NoCutoff' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else ''))
script.append(' constraints=constraints, rigidWater=rigidWater%s%s)' % (', ewaldErrorTolerance=ewaldErrorTolerance' if nonbondedMethod == 'PME' else '', hmrOptions))
if ensemble == 'npt':
script.append('system.addForce(MonteCarloBarostat(pressure, temperature, barostatInterval))')
if fileType == 'pdb' and forcefield.startswith('amoeba'):
Expand Down
9 changes: 9 additions & 0 deletions openmmsetup/templates/simulationOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
<label for="constraintTol">Constraint Error Tolerance</label>
{{ textfield('constraintTol', 'The maximum allowed relative error in constrained distance.') }}
</div>
<div class="form-group">
<label><input type="checkbox" name="hmr" id="hmr" oninput="optionChanged()" {{ 'checked' if session['hmr'] else '' }}> Hydrogen Mass Repartitioning</label>
</div>
<div class="form-group" id="hmrOptions">
<label for="hmrMass">Hydrogen Mass (amu)</label>
{{ textfield('hmrMass', 'The mass of hydrogen atoms.') }}
</div>
</div>


Expand Down Expand Up @@ -235,6 +242,8 @@ <h4 class="modal-title">Platform Not Available</h4>
document.getElementById("ewaldTolRow").hidden = (nonbondedMethod != 'PME');
constraints = document.getElementById("constraints").value;
document.getElementById("constraintTolRow").hidden = (constraints == 'none');
hmr = document.getElementById("hmr").checked;
document.getElementById("hmrOptions").hidden = !hmr;
ensemble = document.getElementById("ensemble").value;
document.getElementById("pressureRow").hidden = (ensemble != 'npt');
document.getElementById("barostatIntervalRow").hidden = (ensemble != 'npt');
Expand Down

0 comments on commit cb256e2

Please sign in to comment.