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_AndersenThermostat_create; 41 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_AndersenThermostat_destroy; 42 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_AndersenThermostat_getDefaultCollisionFrequency; 43 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_AndersenThermostat_getDefaultTemperature; 44 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_AndersenThermostat_getRandomNumberSeed; 45 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_AndersenThermostat_setDefaultCollisionFrequency; 46 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_AndersenThermostat_setDefaultTemperature; 47 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_AndersenThermostat_setRandomNumberSeed; 48 49 /** 50 * This class uses the Andersen method to maintain constant temperature. 51 */ 52 public class AndersenThermostat extends Force { 53 54 /** 55 * OpenMM AndersenThermostat constructor. 56 * 57 * @param temperature the default temperature of the heat bath (in Kelvin). 58 * @param frequency the default collision frequency (in 1/ps) 59 */ 60 public AndersenThermostat(double temperature, double frequency) { 61 pointer = OpenMM_AndersenThermostat_create(temperature, frequency); 62 } 63 64 /** 65 * Set the default temperature of the heat bath. This will affect any new Contexts 66 * you create, but not ones that already exist. 67 * 68 * @param temperature the default temperature of the heat bath (in Kelvin). 69 */ 70 public void setDefaultTemperature(double temperature) { 71 OpenMM_AndersenThermostat_setDefaultTemperature(pointer, temperature); 72 } 73 74 /** 75 * Get the default temperature of the heat bath (in Kelvin). 76 * 77 * @return the default temperature of the heat bath, measured in Kelvin. 78 */ 79 public double getDefaultTemperature() { 80 return OpenMM_AndersenThermostat_getDefaultTemperature(pointer); 81 } 82 83 /** 84 * Set the default collision frequency. This will affect any new Contexts you create, 85 * but not ones that already exist. 86 * 87 * @param frequency the default collision frequency (in 1/ps). 88 */ 89 public void setDefaultCollisionFrequency(double frequency) { 90 OpenMM_AndersenThermostat_setDefaultCollisionFrequency(pointer, frequency); 91 } 92 93 /** 94 * Get the default collision frequency (in 1/ps). 95 * 96 * @return the default collision frequency (in 1/ps). 97 */ 98 public double getDefaultCollisionFrequency() { 99 return OpenMM_AndersenThermostat_getDefaultCollisionFrequency(pointer); 100 } 101 102 /** 103 * Set the random number seed. The precise meaning of this parameter is undefined, and is left up 104 * to each Platform to interpret in an appropriate way. It is guaranteed that if two simulations 105 * are run with different random number seeds, the sequence of collisions will be different. On 106 * the other hand, no guarantees are made about the behavior of simulations that use the same seed. 107 * In particular, Platforms are permitted to use non-deterministic algorithms which produce different 108 * results on successive runs, even if those runs were initialized identically. 109 * <p> 110 * If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context 111 * is created from this Force. This is done to ensure that each Context receives unique random seeds 112 * without you needing to set them explicitly. 113 * 114 * @param seed the random number seed. 115 */ 116 public void setRandomNumberSeed(int seed) { 117 OpenMM_AndersenThermostat_setRandomNumberSeed(pointer, seed); 118 } 119 120 /** 121 * Get the random number seed. See setRandomNumberSeed() for details. 122 */ 123 public int getRandomNumberSeed() { 124 return OpenMM_AndersenThermostat_getRandomNumberSeed(pointer); 125 } 126 127 /** 128 * Returns whether this force makes use of periodic boundary conditions. 129 * 130 * @returns the Andersen Thermostat always returns false. 131 */ 132 public boolean usesPeriodicBoundaryConditions() { 133 return false; 134 } 135 136 /** 137 * Destroy the force. 138 */ 139 public void destroy() { 140 if (pointer != null) { 141 OpenMM_AndersenThermostat_destroy(pointer); 142 pointer = null; 143 } 144 } 145 }