1 // ****************************************************************************** 2 // 3 // Title: Force Field X. 4 // Description: Force Field X - Software for Molecular Biophysics. 5 // Copyright: Copyright (c) Michael J. Schnieders 2001-2025. 6 // 7 // This file is part of Force Field X. 8 // 9 // Force Field X is free software; you can redistribute it and/or modify it 10 // under the terms of the GNU General Public License version 3 as published by 11 // the Free Software Foundation. 12 // 13 // Force Field X is distributed in the hope that it will be useful, but WITHOUT 14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 // details. 17 // 18 // You should have received a copy of the GNU General Public License along with 19 // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple 20 // Place, Suite 330, Boston, MA 02111-1307 USA 21 // 22 // Linking this library statically or dynamically with other modules is making a 23 // combined work based on this library. Thus, the terms and conditions of the 24 // GNU General Public License cover the whole combination. 25 // 26 // As a special exception, the copyright holders of this library give you 27 // permission to link this library with independent modules to produce an 28 // executable, regardless of the license terms of these independent modules, and 29 // to copy and distribute the resulting executable under terms of your choice, 30 // provided that you also meet, for each linked independent module, the terms 31 // and conditions of the license of that module. An independent module is a 32 // module which is not derived from or based on this library. If you modify this 33 // library, you may extend this exception to your version of the library, but 34 // you are not obligated to do so. If you do not wish to do so, delete this 35 // exception statement from your version. 36 // 37 // ****************************************************************************** 38 package ffx.openmm; 39 40 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_Boolean.OpenMM_True; 41 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_create; 42 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_destroy; 43 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_getDefaultPressure; 44 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_getDefaultSurfaceTension; 45 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_getDefaultTemperature; 46 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_getFrequency; 47 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_getRandomNumberSeed; 48 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_getXYMode; 49 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_getZMode; 50 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_setDefaultPressure; 51 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_setDefaultSurfaceTension; 52 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_setDefaultTemperature; 53 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_setFrequency; 54 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_setRandomNumberSeed; 55 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_setXYMode; 56 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_setZMode; 57 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_MonteCarloMembraneBarostat_usesPeriodicBoundaryConditions; 58 59 /** 60 * This class uses a Monte Carlo algorithm to adjust the size of the periodic box, 61 * simulating the effect of constant pressure and surface tension on a membrane system. 62 * It assumes the simulation is running at constant temperature, and the box size is 63 * adjusted to maintain constant pressure in the XY plane and constant surface tension 64 * in the Z direction. 65 * <p> 66 * This class is most useful for simulating membrane systems at constant pressure and 67 * surface tension, where the membrane is oriented in the XY plane and the normal 68 * direction is along the Z axis. 69 */ 70 public class MonteCarloMembraneBarostat extends Force { 71 72 /** 73 * Create a MonteCarloMembraneBarostat. 74 * 75 * @param defaultPressure The default pressure acting on the system (in bar). 76 * @param defaultSurfaceTension The default surface tension acting on the membrane (in bar*nm). 77 * @param defaultTemperature The default temperature at which the system is being maintained (in Kelvin). 78 * @param xymode The mode for scaling the XY dimensions (0 = isotropic, 1 = anisotropic). 79 * @param zmode The mode for scaling the Z dimension (0 = constant volume, 1 = constant pressure). 80 * @param frequency The frequency at which Monte Carlo pressure changes should be attempted (in time steps). 81 */ 82 public MonteCarloMembraneBarostat(double defaultPressure, double defaultSurfaceTension, 83 double defaultTemperature, int xymode, int zmode, int frequency) { 84 super(OpenMM_MonteCarloMembraneBarostat_create(defaultPressure, defaultSurfaceTension, defaultTemperature, xymode, zmode, frequency)); 85 } 86 87 /** 88 * Destroy the force. 89 */ 90 public void destroy() { 91 if (pointer != null) { 92 OpenMM_MonteCarloMembraneBarostat_destroy(pointer); 93 pointer = null; 94 } 95 } 96 97 /** 98 * Get the default pressure (in bar). 99 * 100 * @return The default pressure acting on the system. 101 */ 102 public double getDefaultPressure() { 103 return OpenMM_MonteCarloMembraneBarostat_getDefaultPressure(pointer); 104 } 105 106 /** 107 * Get the default surface tension (in bar*nm). 108 * 109 * @return The default surface tension acting on the membrane. 110 */ 111 public double getDefaultSurfaceTension() { 112 return OpenMM_MonteCarloMembraneBarostat_getDefaultSurfaceTension(pointer); 113 } 114 115 /** 116 * Get the default temperature at which the system is being maintained (in Kelvin). 117 * 118 * @return The default temperature. 119 */ 120 public double getDefaultTemperature() { 121 return OpenMM_MonteCarloMembraneBarostat_getDefaultTemperature(pointer); 122 } 123 124 /** 125 * Get the frequency (in time steps) at which Monte Carlo pressure changes should be attempted. 126 * 127 * @return The frequency of pressure change attempts. 128 */ 129 public int getFrequency() { 130 return OpenMM_MonteCarloMembraneBarostat_getFrequency(pointer); 131 } 132 133 /** 134 * Get the random number seed. See setRandomNumberSeed() for details. 135 * 136 * @return The random number seed. 137 */ 138 public int getRandomNumberSeed() { 139 return OpenMM_MonteCarloMembraneBarostat_getRandomNumberSeed(pointer); 140 } 141 142 /** 143 * Get the mode for scaling the XY dimensions. 144 * 145 * @return The XY scaling mode (0 = isotropic, 1 = anisotropic). 146 */ 147 public int getXYMode() { 148 return OpenMM_MonteCarloMembraneBarostat_getXYMode(pointer); 149 } 150 151 /** 152 * Get the mode for scaling the Z dimension. 153 * 154 * @return The Z scaling mode (0 = constant volume, 1 = constant pressure). 155 */ 156 public int getZMode() { 157 return OpenMM_MonteCarloMembraneBarostat_getZMode(pointer); 158 } 159 160 /** 161 * Set the default pressure acting on the system (in bar). 162 * 163 * @param pressure The default pressure acting on the system. 164 */ 165 public void setDefaultPressure(double pressure) { 166 OpenMM_MonteCarloMembraneBarostat_setDefaultPressure(pointer, pressure); 167 } 168 169 /** 170 * Set the default surface tension acting on the membrane (in bar*nm). 171 * 172 * @param surfaceTension The default surface tension acting on the membrane. 173 */ 174 public void setDefaultSurfaceTension(double surfaceTension) { 175 OpenMM_MonteCarloMembraneBarostat_setDefaultSurfaceTension(pointer, surfaceTension); 176 } 177 178 /** 179 * Set the default temperature at which the system is being maintained (in Kelvin). 180 * 181 * @param temperature The default temperature. 182 */ 183 public void setDefaultTemperature(double temperature) { 184 OpenMM_MonteCarloMembraneBarostat_setDefaultTemperature(pointer, temperature); 185 } 186 187 /** 188 * Set the frequency (in time steps) at which Monte Carlo pressure changes should be attempted. 189 * 190 * @param frequency The frequency of pressure change attempts. 191 */ 192 public void setFrequency(int frequency) { 193 OpenMM_MonteCarloMembraneBarostat_setFrequency(pointer, frequency); 194 } 195 196 /** 197 * Set the random number seed. The precise meaning of this parameter is undefined, and is left up 198 * to each Platform to interpret in an appropriate way. It is guaranteed that if two simulations 199 * are run with different random number seeds, the sequence of random numbers will be different. 200 * On the other hand, no guarantees are made about the behavior of simulations that use the same seed. 201 * In particular, Platforms are permitted to use non-deterministic algorithms which produce different 202 * results on successive runs, even if those runs were initialized identically. 203 * <p> 204 * If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context 205 * is created from this Force. This is done to ensure that each Context receives unique random seeds 206 * without you needing to set them explicitly. 207 * 208 * @param seed The random number seed. 209 */ 210 public void setRandomNumberSeed(int seed) { 211 OpenMM_MonteCarloMembraneBarostat_setRandomNumberSeed(pointer, seed); 212 } 213 214 /** 215 * Set the mode for scaling the XY dimensions. 216 * 217 * @param xymode The XY scaling mode (0 = isotropic, 1 = anisotropic). 218 */ 219 public void setXYMode(int xymode) { 220 OpenMM_MonteCarloMembraneBarostat_setXYMode(pointer, xymode); 221 } 222 223 /** 224 * Set the mode for scaling the Z dimension. 225 * 226 * @param zmode The Z scaling mode (0 = constant volume, 1 = constant pressure). 227 */ 228 public void setZMode(int zmode) { 229 OpenMM_MonteCarloMembraneBarostat_setZMode(pointer, zmode); 230 } 231 232 /** 233 * Returns whether this force makes use of periodic boundary conditions. 234 * 235 * @return True if the force uses periodic boundary conditions. 236 */ 237 @Override 238 public boolean usesPeriodicBoundaryConditions() { 239 int pbc = OpenMM_MonteCarloMembraneBarostat_usesPeriodicBoundaryConditions(pointer); 240 return pbc == OpenMM_True; 241 } 242 }