openmm / openmm

OpenMM is a toolkit for molecular simulation using high performance GPU code.
1.49k stars 523 forks source link

implicit solvent with pbc condition? #4046

Closed slweng0321 closed 1 year ago

slweng0321 commented 1 year ago

Dear all, I am running the implicit solvent simulation to relax my configuration. I use the code below:

pdb = app.PDBFile('protein.pdb') ​ forcefield = app.ForceField('amber99sbildn.xml', 'amber99_obc.xml') ​ system = forcefield.createSystem(pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, constraints=app.HBonds) integrator = mm.LangevinMiddleIntegrator(300unit.kelvin, 1.0/unit.picoseconds, 2.0unit.femtoseconds) platform = mm.Platform.getPlatformByName('CUDA') prop = dict(CudaPrecision='mixed') # Use mixed single/double precision simulation = app.Simulation(pdb.topology, system, integrator, platform, prop) ​ simulation.context.setPositions(pdb.positions) simulation.context.setVelocitiesToTemperature(300*unit.kelvin) ​ state = simulation.context.getState(getEnergy=True, getForces=True)

simulation.step(500000) positions = simulation.context.getState(getPositions=True).getPositions() app.PDBFile.writeFile(simulation.topology, positions, open('protein_relaxed.pdb', 'w'))

I have defined the box vector in the pdb file but when I checked the generated pdb with VMD, there were some overlap between periodic copies. Does this imply that the simulation didn't run with pbc condition or it ran correctly and just needed to run a longer time to be equilibrium? Thanks for any help.

peastman commented 1 year ago

In the call to createSystem() you specified nonbondedMethod=app.CutoffNonPeriodic. That means it does not use periodic boundary conditions, and the box vectors are ignored. This is the normal way to run implicit solvent simulations.

slweng0321 commented 1 year ago

Thanks for replying. So if I want to run implicit solvent relaxation with pbc condition, I just turn CutoffNonPeriodic to CutoffPeriodic and leave others the same?

peastman commented 1 year ago

Correct. Though it's unusual to use periodic boundary conditions with implicit solvent. Not that it's necessarily wrong, if you really do want to simulate a periodic system, rather than a molecule in bulk water.

I notice that in your call to createSystem(), you don't specify a cutoff, which means you get the default value of 1 nm. For implicit solvent, you generally need a longer cutoff. 2 nm tends to be a reasonable choice.

slweng0321 commented 1 year ago

Thanks for suggestion. I will try them. Now I think we can close this issue. Thanks again for your help.