Skip to content

Allow for other barostats in SystemGenerator #413

Closed

Description

@hannahbaumann

Currently, the barostat in _modify_forces is hard coded to be the MonteCarloBarostat (

# TODO: Make sure we can support other kinds of barostats?
barostat = openmm.MonteCarloBarostat(pressure, temperature, frequency)
).
For protein membrane simulations I want to use the MonteCarloMembraneBarostat. Would it be possible to allow for that here?

Additionally, it may be nice to throw a warning here if no box vectors are found and that it's switching the ff kwargs to nonperiodic:

if topology.getPeriodicBoxVectors() is None:
forcefield_kwargs.update(self.nonperiodic_forcefield_kwargs)

Activity

  1. mattwthompson commented on Oct 20, 2025

    @mattwthompson
    Collaborator

    _modify_forces reads as if nobody's ever used it with a different barostat. I suppose other barostats may have different function signatures so there's more bookkeeping needed to replace this line

    barostat = openmm.MonteCarloBarostat(pressure, temperature, frequency)

    with something like barostat = self.barostat.__class__(*args) but that shouldn't be too hard?

    (Why do we need to remake a new barostat instance here, anyway?)

  2. hannahbaumann commented on Oct 20, 2025

    @hannahbaumann
    ContributorAuthor

    I'm also not sure why we need to remake the barostat here. If it's not necessary, that would of course be easiest!

    I wonder if something like this could work?

    # Get the barostat
    barostat = copy.deepcopy(self.barostat)
    seed = np.random.randint(MAXINT)
    barostat.setRandomNumberSeed(seed)
    system.addForce(barostat)
    
  3. ijpulidos commented on Oct 21, 2025

    @ijpulidos
    Collaborator

    I don't think it's strictly needed, I read it as if we don't pass a barostat instance to the SystemGenerator initializer then it wouldn't add a barostat. That probably means that you need to add the barostat yourself after instantiating it and creating the system. Maybe that's the workaround.

    That said, I think it would be convenient for the method to accept different classes/types of barostats there.

  4. mattwthompson commented on Nov 7, 2025

    @mattwthompson
    Collaborator

    Assuming we can close this as the PR is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions