Skip to content

Commit c8907d2

Browse files
author
Roberto Di Remigio
committed
Users can now select the scaling factor for the diagonal of the collocation matrices
1 parent 368aff7 commit c8907d2

24 files changed

+192
-63
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
- A runtime check to ensure that all atoms have a nonzero radius.
66
API kills program execution if this is the case.
77
- An API function to retrieve the areas/weights of the cavity finite elements.
8-
The values in the returned array are in Bohr^2. Addresses feature request from @shofener (Issue #13)
8+
The values in the returned array are in Bohr^2. Addresses a feature request from @shofener (Issue #13)
99

1010
### Changed
11+
- Boundary integral operators classes learnt to accept a scaling factor for the diagonal
12+
elements of the approximate collocation matrices. The change is reflected in the
13+
Green's funtion classes and in the input parsing. Addresses a feature request from @shofener (Issue #16)
1114
- GePolCavity learnt to print also the list of spheres used to generate
1215
the cavity.
1316
- Different internal handling of conversion factors from Bohr to Angstrom.

doc/users/input.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,28 @@ Medium section keywords
241241
k}`
242242

243243
* **Type**: double
244-
* **Valide values**: :math:`k > 0.0`
244+
* **Valid values**: :math:`k > 0.0`
245245
* **Valid for**: CPCM solver
246246
* **Default**: 0.0
247247

248+
DiagonalIntegrator
249+
Type of integrator for the diagonal of the boundary integral operators
250+
251+
* **Type**: string
252+
* **Valid values**: COLLOCATION
253+
* **Valid for**: IEFPCM, CPCM
254+
* **Default**: COLLOCATION
255+
* **Notes**: in future releases we will add PURISIMA and NUMERICAL as options
256+
257+
DiagonalScaling
258+
Scaling factor for diagonal of collocation matrices
259+
260+
* **Type**: double
261+
* **Valid values**: :math:`f > 0.0`
262+
* **Valid for**: IEFPCM, CPCM
263+
* **Default**: 1.07
264+
* **Notes**: values commonly used in the literature are 1.07 and 1.0694
265+
248266
ProbeRadius
249267
Radius of the spherical probe approximating a solvent molecule. Used for
250268
generating the solvent-excluded surface (SES) or an approximation of it.

src/bi_operators/CollocationIntegrator.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,18 @@
5050
*
5151
* Calculates the diagonal elements of S as:
5252
* \f[
53-
* S_{ii} = factor_ * \sqrt{\frac{4\pi}{a_i}}
53+
* S_{ii} = factor * \sqrt{\frac{4\pi}{a_i}}
5454
* \f]
5555
* while the diagonal elements of D are:
5656
* \f[
57-
* D_{ii} = -factor_ * \sqrt{\frac{\pi}{a_i}} \frac{1}{R_I}
57+
* D_{ii} = -factor * \sqrt{\frac{\pi}{a_i}} \frac{1}{R_I}
5858
* \f]
5959
*/
6060

6161
struct CollocationIntegrator
6262
{
63-
CollocationIntegrator() : factor_(1.07) {}
63+
CollocationIntegrator() : factor(1.07) {}
64+
CollocationIntegrator(double f) : factor(f) {}
6465
~CollocationIntegrator() {}
6566

6667
/**@{ Single and double layer potentials for a Vacuum Green's function by collocation */
@@ -71,7 +72,7 @@ struct CollocationIntegrator
7172
template <typename DerivativeTraits>
7273
Eigen::MatrixXd singleLayer(const Vacuum<DerivativeTraits, CollocationIntegrator> & gf, const std::vector<Element> & e) const {
7374
return integrator::singleLayer(e,
74-
pcm::bind(integrator::SI, this->factor_, 1.0, pcm::_1),
75+
pcm::bind(integrator::SI, this->factor, 1.0, pcm::_1),
7576
pcm::bind(&Vacuum<DerivativeTraits, CollocationIntegrator>::kernelS, gf, pcm::_1, pcm::_2));
7677
}
7778
/*! \tparam DerivativeTraits how the derivatives of the Greens's function are calculated
@@ -81,7 +82,7 @@ struct CollocationIntegrator
8182
template <typename DerivativeTraits>
8283
Eigen::MatrixXd doubleLayer(const Vacuum<DerivativeTraits, CollocationIntegrator> & gf, const std::vector<Element> & e) const {
8384
return integrator::doubleLayer(e,
84-
pcm::bind(integrator::DI, this->factor_, pcm::_1),
85+
pcm::bind(integrator::DI, this->factor, pcm::_1),
8586
pcm::bind(&Vacuum<DerivativeTraits, CollocationIntegrator>::kernelD, gf, pcm::_1, pcm::_2, pcm::_3));
8687
}
8788
/**@}*/
@@ -94,7 +95,7 @@ struct CollocationIntegrator
9495
template <typename DerivativeTraits>
9596
Eigen::MatrixXd singleLayer(const UniformDielectric<DerivativeTraits, CollocationIntegrator> & gf, const std::vector<Element> & e) const {
9697
return integrator::singleLayer(e,
97-
pcm::bind(integrator::SI, this->factor_, gf.epsilon(), pcm::_1),
98+
pcm::bind(integrator::SI, this->factor, gf.epsilon(), pcm::_1),
9899
pcm::bind(&UniformDielectric<DerivativeTraits, CollocationIntegrator>::kernelS, gf, pcm::_1, pcm::_2));
99100
}
100101
/*! \tparam DerivativeTraits how the derivatives of the Greens's function are calculated
@@ -104,7 +105,7 @@ struct CollocationIntegrator
104105
template <typename DerivativeTraits>
105106
Eigen::MatrixXd doubleLayer(const UniformDielectric<DerivativeTraits, CollocationIntegrator> & gf, const std::vector<Element> & e) const {
106107
return integrator::doubleLayer(e,
107-
pcm::bind(integrator::DI, this->factor_, pcm::_1),
108+
pcm::bind(integrator::DI, this->factor, pcm::_1),
108109
pcm::bind(&UniformDielectric<DerivativeTraits, CollocationIntegrator>::kernelD, gf, pcm::_1, pcm::_2, pcm::_3));
109110
}
110111
/**@}*/
@@ -148,7 +149,7 @@ struct CollocationIntegrator
148149
for (size_t i = 0; i < mat_size; ++i) {
149150
// Fill diagonal
150151
// Diagonal of S inside the cavity
151-
double Sii_I = factor_ * std::sqrt(4 * M_PI / e[i].area());
152+
double Sii_I = factor * std::sqrt(4 * M_PI / e[i].area());
152153
// "Diagonal" of Coulomb singularity separation coefficient
153154
double coulomb_coeff = gf.coefficientCoulomb(e[i].center(), e[i].center());
154155
// "Diagonal" of the image Green's function
@@ -177,9 +178,9 @@ struct CollocationIntegrator
177178
double area = e[i].area();
178179
double radius = e[i].sphere().radius;
179180
// Diagonal of S inside the cavity
180-
double Sii_I = factor_ * std::sqrt(4 * M_PI / area);
181+
double Sii_I = factor * std::sqrt(4 * M_PI / area);
181182
// Diagonal of D inside the cavity
182-
double Dii_I = -factor_ * std::sqrt(M_PI/ area) * (1.0 / radius);
183+
double Dii_I = -factor * std::sqrt(M_PI/ area) * (1.0 / radius);
183184
// "Diagonal" of Coulomb singularity separation coefficient
184185
double coulomb_coeff = gf.coefficientCoulomb(e[i].center(), e[i].center());
185186
// "Diagonal" of the directional derivative of the Coulomb singularity separation coefficient
@@ -205,7 +206,7 @@ struct CollocationIntegrator
205206
/**@}*/
206207

207208
/// Scaling factor for the collocation formulas
208-
double factor_;
209+
double factor;
209210
};
210211

211212
#endif // COLLOCATIONINTEGRATOR_HPP

src/bi_operators/NumericalIntegrator.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353

5454
struct NumericalIntegrator
5555
{
56+
NumericalIntegrator() : factor(1.07) {}
57+
NumericalIntegrator(double f) : factor(f) {}
58+
~NumericalIntegrator() {}
5659
/**@{ Single and double layer potentials for a Vacuum Green's function by collocation: numerical integration of diagonal */
5760
/*! \tparam DerivativeTraits how the derivatives of the Greens's function are calculated
5861
* \param[in] gf Green's function
@@ -183,6 +186,8 @@ struct NumericalIntegrator
183186
return Eigen::MatrixXd::Zero(e.size(), e.size());
184187
}
185188
/**@}*/
189+
/// Scaling factor for the collocation formulas (unused here)
190+
double factor;
186191
};
187192

188193
#endif // NUMERICALINTEGRATOR_HPP

src/bi_operators/PurisimaIntegrator.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
*
5252
* Calculates the diagonal elements of S as:
5353
* \f[
54-
* S_{ii} = factor_ * \sqrt{\frac{4\pi}{a_i}}
54+
* S_{ii} = factor * \sqrt{\frac{4\pi}{a_i}}
5555
* \f]
5656
* while the diagonal elements of D are:
5757
* \f[
@@ -64,7 +64,8 @@
6464

6565
struct PurisimaIntegrator
6666
{
67-
PurisimaIntegrator() : factor_(1.07) {}
67+
PurisimaIntegrator() : factor(1.07) {}
68+
PurisimaIntegrator(double f) : factor(f) {}
6869
~PurisimaIntegrator() {}
6970

7071
/**@{ Single and double layer potentials for a Vacuum Green's function by collocation */
@@ -75,7 +76,7 @@ struct PurisimaIntegrator
7576
template <typename DerivativeTraits>
7677
Eigen::MatrixXd singleLayer(const Vacuum<DerivativeTraits, PurisimaIntegrator> & gf, const std::vector<Element> & e) const {
7778
return integrator::singleLayer(e,
78-
pcm::bind(integrator::SI, this->factor_, 1.0, pcm::_1),
79+
pcm::bind(integrator::SI, this->factor, 1.0, pcm::_1),
7980
pcm::bind(&Vacuum<DerivativeTraits, PurisimaIntegrator>::kernelS, gf, pcm::_1, pcm::_2));
8081
}
8182
/*! \tparam DerivativeTraits how the derivatives of the Greens's function are calculated
@@ -101,7 +102,7 @@ struct PurisimaIntegrator
101102
template <typename DerivativeTraits>
102103
Eigen::MatrixXd singleLayer(const UniformDielectric<DerivativeTraits, PurisimaIntegrator> & gf, const std::vector<Element> & e) const {
103104
return integrator::singleLayer(e,
104-
pcm::bind(integrator::SI, this->factor_, gf.epsilon(), pcm::_1),
105+
pcm::bind(integrator::SI, this->factor, gf.epsilon(), pcm::_1),
105106
pcm::bind(&UniformDielectric<DerivativeTraits, PurisimaIntegrator>::kernelS, gf, pcm::_1, pcm::_2));
106107
}
107108
/*! \tparam DerivativeTraits how the derivatives of the Greens's function are calculated
@@ -159,7 +160,7 @@ struct PurisimaIntegrator
159160
for (size_t i = 0; i < mat_size; ++i) {
160161
// Fill diagonal
161162
// Diagonal of S inside the cavity
162-
double Sii_I = factor_ * std::sqrt(4 * M_PI / e[i].area());
163+
double Sii_I = factor * std::sqrt(4 * M_PI / e[i].area());
163164
// "Diagonal" of Coulomb singularity separation coefficient
164165
double coulomb_coeff = gf.coefficientCoulomb(e[i].center(), e[i].center());
165166
// "Diagonal" of the image Green's function
@@ -188,9 +189,9 @@ struct PurisimaIntegrator
188189
double area = e[i].area();
189190
double radius = e[i].sphere().radius;
190191
// Diagonal of S inside the cavity
191-
double Sii_I = factor_ * std::sqrt(4 * M_PI / area);
192+
double Sii_I = factor * std::sqrt(4 * M_PI / area);
192193
// Diagonal of D inside the cavity
193-
double Dii_I = -factor_ * std::sqrt(M_PI/ area) * (1.0 / radius);
194+
double Dii_I = -factor * std::sqrt(M_PI/ area) * (1.0 / radius);
194195
// "Diagonal" of Coulomb singularity separation coefficient
195196
double coulomb_coeff = gf.coefficientCoulomb(e[i].center(), e[i].center());
196197
// "Diagonal" of the directional derivative of the Coulomb singularity separation coefficient
@@ -216,7 +217,7 @@ struct PurisimaIntegrator
216217
/**@}*/
217218

218219
/// Scaling factor for the collocation formulas
219-
double factor_;
220+
double factor;
220221
/*! Returns off-diagonal elements of the matrix representation of the double layer operator by collocation
221222
* \param[in] elements list of finite elements
222223
* \param[in] kernD function for the evaluation of the off-diagonal of D

src/green/AnisotropicLiquid.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ class AnisotropicLiquid __final : public GreensFunction<DerivativeTraits, Integr
6060
AnisotropicLiquid(const Eigen::Vector3d & eigen_eps, const Eigen::Vector3d & euler_ang) :
6161
GreensFunction<DerivativeTraits, IntegratorPolicy, Anisotropic,
6262
AnisotropicLiquid<DerivativeTraits, IntegratorPolicy> >() { this->profile_ = Anisotropic(eigen_eps, euler_ang); }
63+
/*! \param[in] eigen_eps eigenvalues of the permittivity tensors
64+
* \param[in] euler_ang Euler angles in degrees
65+
*/
66+
AnisotropicLiquid(const Eigen::Vector3d & eigen_eps, const Eigen::Vector3d & euler_ang, double f) :
67+
GreensFunction<DerivativeTraits, IntegratorPolicy, Anisotropic,
68+
AnisotropicLiquid<DerivativeTraits, IntegratorPolicy> >(f) { this->profile_ = Anisotropic(eigen_eps, euler_ang); }
6369
virtual ~AnisotropicLiquid() {}
6470

6571
/*! Calculates the matrix representation of the S operator

src/green/GreenData.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
/*
33
* PCMSolver, an API for the Polarizable Continuum Model
44
* Copyright (C) 2013-2015 Roberto Di Remigio, Luca Frediani and contributors
5-
*
5+
*
66
* This file is part of PCMSolver.
7-
*
7+
*
88
* PCMSolver is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Lesser General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* PCMSolver is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Lesser General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Lesser General Public License
1919
* along with PCMSolver. If not, see <http://www.gnu.org/licenses/>.
20-
*
20+
*
2121
* For information on the complete list of contributors to the
2222
* PCMSolver API, see: <http://pcmsolver.readthedocs.org/>
2323
*/
@@ -45,6 +45,8 @@ struct greenData {
4545
int howProfile;
4646
/*! The permittivity */
4747
double epsilon;
48+
/*! Scaling for the diagonal of the approximate collocation matrices */
49+
double scaling;
4850
/*! Inverse of the Debye length */
4951
double kappa;
5052
/*! Diagonal values of the permittivity tensor with respect to the lab frame */
@@ -77,6 +79,7 @@ struct greenData {
7779
greenData() { empty = true;}
7880
greenData(int how_d, int how_i, int how_p,
7981
double _epsilon = 1.0,
82+
double s = 1.07,
8083
double _kappa = 0.0,
8184
const Eigen::Vector3d & epstens = Eigen::Vector3d::Zero(),
8285
const Eigen::Vector3d & euler = Eigen::Vector3d::Zero(),
@@ -91,7 +94,7 @@ struct greenData {
9194
const Eigen::Vector3d & _o = Eigen::Vector3d::Zero(),
9295
int l = 30) :
9396
howDerivative(how_d), howIntegrator(how_i), howProfile(how_p),
94-
epsilon(_epsilon), kappa(_kappa), epsilonTensor(epstens), eulerAngles(euler),
97+
epsilon(_epsilon), scaling(s), kappa(_kappa), epsilonTensor(epstens), eulerAngles(euler),
9598
epsilonReal(_epsReal), epsilonImaginary(_epsImaginary),
9699
NPspheres(_sphere), NPradii(_sphRadius),
97100
epsilon1(_e1), epsilon2(_e2), center(_c), width(_w), origin(_o), maxL(l) { empty = false; }

src/green/GreensFunction.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class GreensFunction: public IGreensFunction
5454
{
5555
public:
5656
GreensFunction() : delta_(1.0e-04), integrator_(IntegratorPolicy()) {}
57+
GreensFunction(double f) : delta_(1.0e-04), integrator_(IntegratorPolicy(f)) {}
5758
virtual ~GreensFunction() {}
5859
/*! Returns value of the directional derivative of the
5960
* Greens's function for the pair of points p1, p2:
@@ -163,6 +164,7 @@ class GreensFunction<Numerical, IntegratorPolicy, ProfilePolicy, Derived>: publi
163164
{
164165
public:
165166
GreensFunction() : delta_(1.0e-04), integrator_(IntegratorPolicy()) {}
167+
GreensFunction(double f) : delta_(1.0e-04), integrator_(IntegratorPolicy(f)) {}
166168
virtual ~GreensFunction() {}
167169
/*! Returns value of the directional derivative of the
168170
* Greens's function for the pair of points p1, p2:

src/green/IonicLiquid.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class IonicLiquid __final : public GreensFunction<DerivativeTraits, IntegratorPo
5757
public:
5858
IonicLiquid(double eps, double k) : GreensFunction<DerivativeTraits, IntegratorPolicy, Yukawa,
5959
IonicLiquid<DerivativeTraits, IntegratorPolicy> >() { this->profile_ = Yukawa(eps, k); }
60+
IonicLiquid(double eps, double k, double f) : GreensFunction<DerivativeTraits, IntegratorPolicy, Yukawa,
61+
IonicLiquid<DerivativeTraits, IntegratorPolicy> >(f) { this->profile_ = Yukawa(eps, k); }
6062
virtual ~IonicLiquid() {}
6163

6264
/*! Calculates the matrix representation of the S operator

src/green/RegisterGreensFunctionToFactory.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ namespace
5353
struct buildVacuum
5454
{
5555
template <typename T, typename U>
56-
IGreensFunction * operator()(const greenData & /* data */) {
57-
return new Vacuum<T, U>();
56+
IGreensFunction * operator()(const greenData & data) {
57+
return new Vacuum<T, U>(data.scaling);
5858
}
5959
};
6060

@@ -74,7 +74,7 @@ namespace
7474
struct buildUniformDielectric {
7575
template <typename T, typename U>
7676
IGreensFunction * operator()(const greenData & data) {
77-
return new UniformDielectric<T, U>(data.epsilon);
77+
return new UniformDielectric<T, U>(data.epsilon, data.scaling);
7878
}
7979
};
8080

@@ -94,7 +94,7 @@ namespace
9494
struct buildIonicLiquid {
9595
template <typename T, typename U>
9696
IGreensFunction * operator()(const greenData & data) {
97-
return new IonicLiquid<T, U>(data.epsilon, data.kappa);
97+
return new IonicLiquid<T, U>(data.epsilon, data.kappa, data.scaling);
9898
}
9999
};
100100

@@ -114,7 +114,7 @@ namespace
114114
struct buildAnisotropicLiquid {
115115
template <typename T, typename U>
116116
IGreensFunction * operator()(const greenData & data) {
117-
return new AnisotropicLiquid<T, U>(data.epsilonTensor, data.eulerAngles);
117+
return new AnisotropicLiquid<T, U>(data.epsilonTensor, data.eulerAngles, data.scaling);
118118
}
119119
};
120120

@@ -134,7 +134,7 @@ namespace
134134
struct buildSphericalDiffuse {
135135
template <typename T, typename U>
136136
IGreensFunction * operator()(const greenData & data) {
137-
return new SphericalDiffuse<T, U>(data.epsilon1, data.epsilon2, data.width, data.center, data.origin, data.maxL);
137+
return new SphericalDiffuse<T, U>(data.epsilon1, data.epsilon2, data.width, data.center, data.origin, data.maxL, data.scaling);
138138
}
139139
};
140140

0 commit comments

Comments
 (0)