Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2009 Edward d'Auvergne # 4 # # 5 # This file is part of the program relax. # 6 # # 7 # relax is free software; you can redistribute it and/or modify # 8 # it under the terms of the GNU General Public License as published by # 9 # the Free Software Foundation; either version 2 of the License, or # 10 # (at your option) any later version. # 11 # # 12 # relax is distributed in the hope that it will be useful, # 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 # GNU General Public License for more details. # 16 # # 17 # You should have received a copy of the GNU General Public License # 18 # along with relax; if not, write to the Free Software # 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 20 # # 21 ############################################################################### 22 23 # Module docstring. 24 """Functions for calculating various optimisation potentials.""" 25 2628 """Calculate the flat-bottom quadratic energy potential. 29 30 The formula used is:: 31 32 / (x - x+)^2 if x > x+, 33 | 34 V_pQuad(x;x+,x-) = < (x - x-)^2 if x < x-, 35 | 36 \ 0 otherwise. 37 38 Where x+ and x- are the absolute bounds. 39 40 41 @param values: An array of values of x. 42 @type values: numpy float array 43 @param pot: The array to place the potential values (V_pQuad) into. This should have the 44 same dimensions as the values array. 45 @type pot: numpy float array 46 @param lower: The array of lower bounds. This should have the same dimensions as the values 47 array. 48 @type lower: numpy float array 49 @param upper: The array of upper bounds. This should have the same dimensions as the values 50 array. 51 @type upper: numpy float array 52 """ 53 54 # Loop over the x values. 55 for i in xrange(len(values)): 56 # First condition. 57 if values[i] > upper[i]: 58 pot[i] = (values[i] - upper[i])**2 59 60 # Second contition. 61 elif values[i] < lower[i]: 62 pot[i] = (values[i] - lower[i])**2 63 64 # Otherwise clear the array element. 65 else: 66 pot[i] = 0.067
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Apr 10 14:17:18 2013 | http://epydoc.sourceforge.net |