votca 2024.2-dev
Loading...
Searching...
No Matches
potentialfunction.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef POTENTIALFUNCTION_H
19#define POTENTIALFUNCTION_H
20
21#include <Eigen/Dense>
22#include <string>
23#include <votca/tools/types.h>
24
25namespace votca {
26namespace csg {
28 public:
29 virtual ~PotentialFunction() = default;
30 // read parameters from the input file
31 virtual void setParam(std::string filename);
32 // save parameters to the file
33 virtual void SaveParam(const std::string &filename);
34 // write potential table
35 virtual void SavePotTab(const std::string &filename, double step);
36 // write potential table for specified interval
37 virtual void SavePotTab(const std::string &filename, double step, double rmin,
38 double rcut);
39 // set all parameters
40 void setParam(const Eigen::VectorXd &param) { lam_ = param; }
41 // set ith parameter
42 void setParam(Index i, double val) { lam_(i) = val; }
43 // set ith parameter among those to be optimized
44 virtual void setOptParam(Index i, double val) { setParam(i, val); }
45 // set minimum r value to avoid large values
46 void setMinDist(double min) { min_ = min; }
47 // set cut-off value
48 void setCutOffDist(double cutoff) { cut_off_ = cutoff; }
49 // calculate function
50 virtual double CalculateF(double r) const = 0;
51 // calculate first derivative w.r.t. ith parameter
52 virtual double CalculateDF(Index i, double r) const = 0;
53 // calculate second derivative w.r.t. ith parameter
54 virtual double CalculateD2F(Index i, Index j, double r) const = 0;
55 // return parameter
56 Eigen::VectorXd &Params() { return lam_; }
57 // return ith parameter
58 double getParam(Index i) const { return lam_(i); }
59 // return ith parameter among those to be optimized
60 virtual double getOptParam(Index i) const { return getParam(i); }
61 // return size of parameters
62 Index getParamSize() const { return lam_.size(); }
63 // return size of parameters to be optimized
64 virtual Index getOptParamSize() const { return getParamSize(); }
65 // return cut-off value
66 double getCutOff() const { return cut_off_; }
67 double getMinDist() const { return min_; }
68
69 protected:
70 PotentialFunction(const std::string &name, Index nlam, double min,
71 double max);
72
73 std::string name_;
74 Eigen::VectorXd lam_;
75 double cut_off_;
76 double min_;
77};
78} // namespace csg
79} // namespace votca
80#endif
virtual void SaveParam(const std::string &filename)
virtual void SavePotTab(const std::string &filename, double step)
void setCutOffDist(double cutoff)
double getParam(Index i) const
virtual double CalculateD2F(Index i, Index j, double r) const =0
PotentialFunction(const std::string &name, Index nlam, double min, double max)
void setParam(Index i, double val)
virtual void setOptParam(Index i, double val)
void setParam(const Eigen::VectorXd &param)
virtual Index getOptParamSize() const
virtual ~PotentialFunction()=default
virtual double CalculateDF(Index i, double r) const =0
virtual double CalculateF(double r) const =0
virtual double getOptParam(Index i) const
virtual void setParam(std::string filename)
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26