BubbleProfiler  0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
gaussian_potential.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of BubbleProfiler.
3  *
4  * BubbleProfiler is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * BubbleProfiler is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with BubbleProfiler. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef BUBBLEPROFILER_GAUSSIAN_POTENTIAL_HPP_INCLUDED
19 #define BUBBLEPROFILER_GAUSSIAN_POTENTIAL_HPP_INCLUDED
20 
26 #include "potential.hpp"
27 #include "error.hpp"
28 
29 #include <cmath>
30 #include <ginac/ginac.h>
31 
32 namespace BubbleProfiler {
33 
53 class Gaussian_potential : public Potential {
54 public:
55 
63  Gaussian_potential(double gamma_, double lambda_, std::size_t n_fields_);
64  virtual ~Gaussian_potential() = default;
65 
71  return new Gaussian_potential(*this);
72  };
73 
74  virtual double operator()(const Eigen::VectorXd& coords) const override;
75  virtual double partial(const Eigen::VectorXd& coords, int i) const override;
76  virtual double partial(const Eigen::VectorXd& coords, int i, int j) const override;
77  virtual std::size_t get_number_of_fields() const override;
78 
79  virtual void translate_origin(const Eigen::VectorXd&) override;
80  virtual void apply_basis_change(const Eigen::MatrixXd&) override;
81  virtual void add_constant_term(double) override;
82 
83 
84 private:
85  double gamma{2.};
86  double lambda{1.};
87  std::size_t n_fields{0};
88  double constant_term{0.};
89  Eigen::VectorXd origin{};
90  Eigen::VectorXd origin_translation{};
91  Eigen::VectorXd mu{};
92  Eigen::MatrixXd basis_transform{};
93 
94  double gaussian(const Eigen::VectorXd&, const Eigen::VectorXd&) const;
95  double gaussian_deriv(const Eigen::VectorXd&, const Eigen::VectorXd&,
96  int i) const;
97  double gaussian_deriv2(const Eigen::VectorXd&, const Eigen::VectorXd&,
98  int i, int j) const;
99 };
100 
101 }
102 
103 #endif
virtual ~Gaussian_potential()=default
virtual void apply_basis_change(const Eigen::MatrixXd &) override
Apply a change of basis matrix.
virtual double operator()(const Eigen::VectorXd &coords) const override
Evaluate potential at point.
Gaussian_potential * clone() const
return a copy of this potential
double gaussian_deriv(const Eigen::VectorXd &, const Eigen::VectorXd &, int i) const
virtual double partial(const Eigen::VectorXd &coords, int i) const override
Partial derivative WRT coordinate i at a point.
Potential composed of two multivariate Gaussian functions.
virtual void add_constant_term(double) override
Add a constant offset to the potential.
Gaussian_potential(double gamma_, double lambda_, std::size_t n_fields_)
instantiate a new Gaussian potential
double gaussian(const Eigen::VectorXd &, const Eigen::VectorXd &) const
Abstract base class for a generic potential.
Definition: potential.hpp:36
virtual std::size_t get_number_of_fields() const override
double gaussian_deriv2(const Eigen::VectorXd &, const Eigen::VectorXd &, int i, int j) const
virtual void translate_origin(const Eigen::VectorXd &) override
Shift the location of the origin by a specified vector.