Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2016-2017 The VES code team 3 : (see the PEOPLE-VES file at the root of this folder for a list of names) 4 : 5 : See http://www.ves-code.org for more information. 6 : 7 : This file is part of VES code module. 8 : 9 : The VES code module is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : The VES code module is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with the VES code module. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : 23 : #include "BasisFunctions.h" 24 : 25 : #include "core/ActionRegister.h" 26 : 27 : 28 : namespace PLMD { 29 : namespace ves { 30 : 31 : //+PLUMEDOC VES_BASISF BF_CHEBYSHEV_RATIONAL_FULL_INFINITE 32 : /* 33 : Rational Chebyshev basis functions on a full-infinite interval 34 : 35 : \par Examples 36 : 37 : */ 38 : //+ENDPLUMEDOC 39 : 40 : 41 2 : class BF_RationalChebyshevFullInf : public BasisFunctions { 42 : double mapf_; 43 : double center_; 44 : public: 45 : static void registerKeywords(Keywords&); 46 : explicit BF_RationalChebyshevFullInf(const ActionOptions&); 47 : void getAllValues(const double, double&, bool&, std::vector<double>&, std::vector<double>&) const; 48 : }; 49 : 50 : 51 7836 : PLUMED_REGISTER_ACTION(BF_RationalChebyshevFullInf,"BF_CHEBYSHEV_RATIONAL_FULL_INFINITE") 52 : 53 : 54 3 : void BF_RationalChebyshevFullInf::registerKeywords(Keywords& keys) { 55 3 : BasisFunctions::registerKeywords(keys); 56 12 : keys.add("compulsory","MAP_PARAMETER","Constant map parameter that defines the interval on which is the bias is active (should match the width of the function to be expanded)."); 57 12 : keys.add("optional","CENTER","the location of the center of the Hermite functions. By default it is 0.0"); 58 3 : } 59 : 60 2 : BF_RationalChebyshevFullInf::BF_RationalChebyshevFullInf(const ActionOptions&ao): 61 : PLUMED_VES_BASISFUNCTIONS_INIT(ao), 62 : mapf_(0.0), 63 2 : center_(0.0) 64 : { 65 2 : setNumberOfBasisFunctions(getOrder()+1); 66 2 : setIntrinsicInterval(intervalMin(),intervalMax()); 67 : // 68 6 : parse("MAP_PARAMETER",mapf_); addKeywordToList("MAP_PARAMETER",mapf_); 69 2 : if(mapf_ <= 0.0) {plumed_merror("MAP_PARAMETER should be larger than 0");} 70 2 : center_=0.0; 71 4 : parse("CENTER",center_); 72 3 : if(center_!=0.0) {addKeywordToList("CENTER",center_);} 73 : // 74 : setNonPeriodic(); 75 : setOrthogonal(); 76 : setIntervalBounded(); 77 4 : setType("rational-chebyshev-full-inf"); 78 4 : setDescription("Rational Chebyshev basis functions on an infinite interval"); 79 4 : setLabelPrefix("TB"); 80 2 : setupBF(); 81 2 : checkRead(); 82 2 : } 83 : 84 : 85 1163335 : void BF_RationalChebyshevFullInf::getAllValues(const double arg, double& argT, bool& inside_range, std::vector<double>& values, std::vector<double>& derivs) const { 86 : // plumed_assert(values.size()==numberOfBasisFunctions()); 87 : // plumed_assert(derivs.size()==numberOfBasisFunctions()); 88 1163335 : inside_range=true; 89 1163335 : argT=checkIfArgumentInsideInterval(arg,inside_range); 90 1163335 : argT -= center_; 91 1163335 : double sqtmp = sqrt(mapf_*mapf_+argT*argT); 92 1163335 : double derivf = (mapf_*mapf_)/pow(sqtmp,3); 93 1163335 : argT = argT/sqtmp; 94 : // 95 1163335 : std::vector<double> derivsT(derivs.size()); 96 : // 97 1163335 : values[0]=1.0; 98 1163335 : derivsT[0]=0.0; 99 1163335 : derivs[0]=0.0; 100 1163335 : values[1]=argT; 101 1163335 : derivsT[1]=1.0; 102 1163335 : derivs[1]=derivf; 103 24430035 : for(unsigned int i=1; i < getOrder(); i++) { 104 88413460 : values[i+1] = 2.0*argT*values[i]-values[i-1]; 105 66310095 : derivsT[i+1] = 2.0*values[i]+2.0*argT*derivsT[i]-derivsT[i-1]; 106 22103365 : derivs[i+1] = derivf*derivsT[i+1]; 107 : } 108 1166259 : if(!inside_range) {for(unsigned int i=0; i<derivs.size(); i++) {derivs[i]=0.0;}} 109 1163335 : } 110 : 111 : 112 : 113 : 114 : } 115 5874 : }