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_SEMI_INFINITE 32 : /* 33 : Rational Chebyshev basis functions on a semi-infinite interval 34 : 35 : \par Examples 36 : 37 : */ 38 : //+ENDPLUMEDOC 39 : 40 : 41 2 : class BF_RationalChebyshevSemiInf : public BasisFunctions { 42 : double mapf_; 43 : public: 44 : static void registerKeywords(Keywords&); 45 : explicit BF_RationalChebyshevSemiInf(const ActionOptions&); 46 : void getAllValues(const double, double&, bool&, std::vector<double>&, std::vector<double>&) const; 47 : }; 48 : 49 : 50 7836 : PLUMED_REGISTER_ACTION(BF_RationalChebyshevSemiInf,"BF_CHEBYSHEV_RATIONAL_SEMI_INFINITE") 51 : 52 : 53 3 : void BF_RationalChebyshevSemiInf::registerKeywords(Keywords& keys) { 54 3 : BasisFunctions::registerKeywords(keys); 55 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)."); 56 3 : } 57 : 58 2 : BF_RationalChebyshevSemiInf::BF_RationalChebyshevSemiInf(const ActionOptions&ao): 59 : PLUMED_VES_BASISFUNCTIONS_INIT(ao), 60 2 : mapf_(0.0) 61 : { 62 2 : setNumberOfBasisFunctions(getOrder()+1); 63 2 : setIntrinsicInterval(intervalMin(),intervalMax()); 64 : // 65 6 : parse("MAP_PARAMETER",mapf_); addKeywordToList("MAP_PARAMETER",mapf_); 66 2 : if(mapf_ <= 0.0) {plumed_merror("MAP_PARAMETER should be larger than 0");} 67 : // 68 : setNonPeriodic(); 69 : setOrthogonal(); 70 : setIntervalBounded(); 71 4 : setType("rational-chebyshev-semi-inf"); 72 4 : setDescription("Rational Chebyshev basis functions on a semi-infinite interval"); 73 4 : setLabelPrefix("TL"); 74 2 : setupBF(); 75 2 : checkRead(); 76 2 : } 77 : 78 : 79 1163335 : void BF_RationalChebyshevSemiInf::getAllValues(const double arg, double& argT, bool& inside_range, std::vector<double>& values, std::vector<double>& derivs) const { 80 : // plumed_assert(values.size()==numberOfBasisFunctions()); 81 : // plumed_assert(derivs.size()==numberOfBasisFunctions()); 82 1163335 : inside_range=true; 83 1163335 : argT=checkIfArgumentInsideInterval(arg,inside_range); 84 1163335 : argT -= intervalMin(); 85 1163335 : double derivf = (2.0*mapf_)/((argT+mapf_)*(argT+mapf_)); 86 1163335 : argT = (argT-mapf_)/(argT+mapf_); 87 : // 88 1163335 : std::vector<double> derivsT(derivs.size()); 89 : // 90 1163335 : values[0]=1.0; 91 1163335 : derivsT[0]=0.0; 92 1163335 : derivs[0]=0.0; 93 1163335 : values[1]=argT; 94 1163335 : derivsT[1]=1.0; 95 1163335 : derivs[1]=derivf; 96 24430035 : for(unsigned int i=1; i < getOrder(); i++) { 97 88413460 : values[i+1] = 2.0*argT*values[i]-values[i-1]; 98 66310095 : derivsT[i+1] = 2.0*values[i]+2.0*argT*derivsT[i]-derivsT[i-1]; 99 22103365 : derivs[i+1] = derivf*derivsT[i+1]; 100 : } 101 1165829 : if(!inside_range) {for(unsigned int i=0; i<derivs.size(); i++) {derivs[i]=0.0;}} 102 1163335 : } 103 : 104 : 105 : 106 : 107 : } 108 5874 : }