Skip to content

Commit

Permalink
final cleanup of other barostats in ThermodynamicState
Browse files Browse the repository at this point in the history
  • Loading branch information
Olllom committed Oct 26, 2019
1 parent 101915a commit d1c1812
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions openmmtools/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ def _initialize(self, system, temperature=None, pressure=None, surface_tension=N
else:
self._pressure = pressure # Pressure here can also be None.

# If surface tension is None, we try to infer the pressure from the barostat.
# If surface tension is None, we try to infer the surface tension from the barostat.
barostat_type = type(barostat)
if surface_tension is None and barostat_type == openmm.MonteCarloMembraneBarostat:
self._surface_tension = barostat.getDefaultSurfaceTension()
Expand Down Expand Up @@ -1648,11 +1648,6 @@ def set_temp(_integrator):

_SUPPORTED_BAROSTATS = {'MonteCarloBarostat', 'MonteCarloAnisotropicBarostat', 'MonteCarloMembraneBarostat'}

@property
def _barostat_type(self):
barostat = self._find_barostat(self._standard_system)
return type(barostat)

@classmethod
def _find_barostat(cls, system, get_index=False):
"""Return the first barostat found in the system.
Expand Down Expand Up @@ -1813,12 +1808,10 @@ def _set_system_surface_tension(self, system, gamma):
raise ThermodynamicsError(ThermodynamicsError.INCOMPATIBLE_ENSEMBLE)
self._set_barostat_surface_tension(barostat, gamma)


def _set_barostat_surface_tension(self, barostat, gamma):
# working around a bug in the unit conversion https://github.com/openmm/openmm/issues/2406
if isinstance(gamma, unit.Quantity):
gamma = gamma.value_in_unit(unit.bar * unit.nanometer)
# barostat = self._find_barostat(system)
if isinstance(barostat, openmm.MonteCarloMembraneBarostat):
barostat.setDefaultSurfaceTension(gamma)
elif gamma is not None:
Expand Down
2 changes: 1 addition & 1 deletion openmmtools/tests/test_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def test_property_system(self):
(self.barostated_toluene, TE.BAROSTATED_NONPERIODIC),
(self.multiple_barostat_alanine, TE.MULTIPLE_BAROSTATS),
(self.unsupported_anisotropic_barostat_alanine, TE.UNSUPPORTED_ANISOTROPIC_BAROSTAT),
#(self.supported_anisotropic_barostat_alanine, TE.INCONSISTENT_BAROSTAT),
(self.supported_anisotropic_barostat_alanine, TE.INCONSISTENT_BAROSTAT),
(self.membrane_barostat_alanine_gamma_zero, TE.INCONSISTENT_BAROSTAT),
(self.inconsistent_pressure_alanine, TE.INCONSISTENT_BAROSTAT),
(self.inconsistent_temperature_alanine, TE.INCONSISTENT_THERMOSTAT),
Expand Down

0 comments on commit d1c1812

Please sign in to comment.