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.algorithms.mc; 39 40 import java.util.List; 41 42 /** 43 * The MetropolisMC interface defines the basic methods of a Metropolis Monte Carlo application. 44 * Intended to be a framework to allow you to take and revert a single step, and return basic 45 * information about the last step taken. Many of the methods will only return a meaningful result 46 * after the first step. 47 * 48 * @author Michael J. Schnieders 49 * @author Jacob M. Litman 50 * @since 1.0 51 */ 52 public interface MetropolisMC { 53 54 /** 55 * Returns true if the move from e1 to e2 is accepted. For molecular systems, this will mean accept 56 * if e2 is less than e1, or accept with probability of exp(-dU/kbT) if e2 is greater than e1. 57 * 58 * @param e1 Initial energy 59 * @param e2 Trial energy 60 * @return If move accepted 61 */ 62 boolean evaluateMove(double e1, double e2); 63 64 /** 65 * If last step taken was a success. 66 * 67 * @return Acceptance of last move 68 */ 69 boolean getAccept(); 70 71 /** 72 * Return starting energy from last attempted step. 73 * 74 * @return e1 75 */ 76 double getE1(); 77 78 /** 79 * Return trial energy from last attempted step. 80 * 81 * @return e2 82 */ 83 double getE2(); 84 85 /** 86 * Returns temperature of the Monte Carlo criterion. 87 * 88 * @return temperature 89 */ 90 double getTemperature(); 91 92 /** 93 * Sets temperature of Monte Carlo criterion. 94 * 95 * @param temp a double. 96 */ 97 void setTemperature(double temp); 98 99 /** 100 * Returns the energy as of the last step taken (not including any extra potential energy 101 * adjustments). 102 * 103 * @return Last step's energy 104 */ 105 double lastEnergy(); 106 107 /** 108 * Calculates the current system energy and performs an MCMove. 109 * 110 * @param move MCMove to perform 111 * @return If move accepted 112 */ 113 boolean mcStep(MCMove move); 114 115 /** 116 * Performs an MCMove. 117 * 118 * @param move MCMove to perform 119 * @param en1 Initial energy 120 * @return If move accepted 121 */ 122 boolean mcStep(MCMove move, double en1); 123 124 /** 125 * Calculates the current system energy and performs a series of moves sequentially as a single 126 * hybrid step. 127 * 128 * @param moves MCMoves to perform 129 * @return If move/moves accepted 130 */ 131 boolean mcStep(List<MCMove> moves); 132 133 /** 134 * Performs a series of moves sequentially, as a single hybrid step. Should also work with 135 * single-member lists. 136 * 137 * @param moves MCMoves to perform 138 * @param en1 Initial energy 139 * @return If move/moves accepted. 140 */ 141 boolean mcStep(List<MCMove> moves, double en1); 142 143 /** If possible, reverts the last successful Monte Carlo step taken. */ 144 void revertStep(); 145 146 /** 147 * Sets whether the implementation prints its own messages. 148 * 149 * @param print Print energies, accept/reject, etc. 150 */ 151 void setPrint(boolean print); 152 }