Skip to content

Commit cefe1f3

Browse files
committed
Remove code duplication
1 parent 11c71b4 commit cefe1f3

File tree

8 files changed

+43
-50
lines changed

8 files changed

+43
-50
lines changed

Pipfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ name = "pypi"
77

88
[packages]
99

10+
docopt = "*"
11+
pyparsing = "*"
12+
13+
[dev-packages]
14+
1015
Pygments = "*"
1116
breathe = "*"
12-
docopt = "*"
1317
matplotlib = "*"
14-
pyparsing = "*"
1518
PyYAML = "*"
1619
recommonmark = "*"
1720
Sphinx = "*"
1821
sphinx_rtd_theme = "*"
1922
sphinxcontrib-bibtex = "*"
2023
yapf = "*"
2124
fprettify = "*"
22-
23-
[dev-packages]
24-

Pipfile.lock

Lines changed: 19 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/interface/Meddle.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,9 @@ void Meddle::GaussCheck() const {
547547
Eigen::VectorXd nuclear_mep = computeMEP(input_.molecule(), cavity_->elements());
548548
Eigen::VectorXd nuclear_asc = K_0_->computeCharge(nuclear_mep);
549549
double total_nuclear_asc = nuclear_asc.sum() * cavity_->pointGroup().nrIrrep();
550-
double gauss_nuclear_asc =
551-
detail::GaussEstimate(input_.molecule().charges(),
552-
input_.outsideStaticGreenParams().epsilon,
553-
input_.correction());
550+
double gauss_nuclear_asc = GaussEstimate(input_.molecule().charges(),
551+
input_.outsideStaticGreenParams().epsilon,
552+
input_.correction());
554553
double difference = total_nuclear_asc - gauss_nuclear_asc;
555554
std::stringstream tmp;
556555
if (!utils::isZero(difference, 1.0e-2)) {
@@ -651,11 +650,5 @@ void print(const PCMInput & inp) {
651650
std::cout << "outside type " << std::string(inp.outside_type) << std::endl;
652651
std::cout << "epsilon outside " << inp.outside_epsilon << std::endl;
653652
}
654-
655-
double GaussEstimate(const Eigen::VectorXd & charges,
656-
double permittivity,
657-
double correction) {
658-
return (-charges.sum() * (permittivity - 1) / (permittivity + correction));
659-
}
660653
} // namespace detail
661654
} // namespace pcm

src/interface/Meddle.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ void initSpheresAtoms(const Input &,
6262
const Eigen::Matrix3Xd &,
6363
std::vector<Sphere> &);
6464
void print(const PCMInput &);
65-
66-
/*! Gauss' theorem estimate of the total ASC for a set of point charges
67-
* \param[in] charges Vector of point charges
68-
* \param[in] permittivity Solvent permittivity
69-
* \param[in] correction The CPCM correction factor
70-
*/
71-
double GaussEstimate(const Eigen::VectorXd & charges,
72-
double permittivity,
73-
double correction = 0.0);
7465
} // namespace detail
7566

7667
/*! \class Meddle

src/utils/Molecule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,10 @@ Eigen::VectorXd computeMEP(const std::vector<Element> & el,
302302
}
303303
return mep;
304304
}
305+
306+
double GaussEstimate(const Eigen::VectorXd & charges,
307+
double permittivity,
308+
double correction) {
309+
return (-charges.sum() * (permittivity - 1) / (permittivity + correction));
310+
}
305311
} // namespace pcm

src/utils/Molecule.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,13 @@ PCMSolver_EXPORT Eigen::VectorXd computeMEP(const Molecule & mol,
240240
Eigen::VectorXd computeMEP(const std::vector<cavity::Element> & el,
241241
double charge = 1.0,
242242
const Eigen::Vector3d & origin = Eigen::Vector3d::Zero());
243+
244+
/*! Gauss' theorem estimate of the total ASC for a set of point charges
245+
* \param[in] charges Vector of point charges
246+
* \param[in] permittivity Solvent permittivity
247+
* \param[in] correction The CPCM correction factor
248+
*/
249+
PCMSolver_EXPORT double GaussEstimate(const Eigen::VectorXd & charges,
250+
double permittivity,
251+
double correction = 0.0);
243252
} // namespace pcm

tests/TestingMolecules.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ inline Molecule C6H6();
7373
*/
7474
inline Molecule H2O();
7575

76-
/*! Returns the Gauss' theorem estimate of the total ASC
77-
* \param[in] charges Vector of molecular charges
78-
* \param[in] permittivity Solvent permittivity
79-
* \param[in] correction The CPCM correction factor
80-
*/
81-
inline double Gauss_ASC(const Eigen::VectorXd & charges,
82-
double permittivity,
83-
double correction = 0.0);
84-
8576
template <int group> Molecule dummy(double radius, const Eigen::Vector3d & center) {
8677
std::vector<Sphere> spheres;
8778
Sphere sph1(center, radius);
@@ -546,12 +537,6 @@ Molecule H2O() {
546537

547538
return Molecule(nAtoms, charges, masses, geom, atoms, spheres, pGroup);
548539
};
549-
550-
double Gauss_ASC(const Eigen::VectorXd & charges,
551-
double permittivity,
552-
double correction) {
553-
return (-charges.sum() * (permittivity - 1) / (permittivity + correction));
554-
}
555540
} // namespace pcm
556541

557542
#endif // TESTINGMOLECULES_HPP

tests/cpcm/cpcm_gepol-H2O.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ TEST_CASE("Test solver for the C-PCM with H2O molecule and a GePol cavity",
7171
// for CPCM it will be -Q*(epsilon-1)/(epsilon + correction)
7272
Eigen::VectorXd fake_asc = Eigen::VectorXd::Zero(size);
7373
fake_asc = solver.computeCharge(fake_mep);
74-
double totalASC = Gauss_ASC(molecule.charges(), permittivity, correction);
74+
double totalASC = GaussEstimate(molecule.charges(), permittivity, correction);
7575
double totalFakeASC = fake_asc.sum();
7676
CAPTURE(totalASC - totalFakeASC);
7777
REQUIRE(totalASC == Approx(totalFakeASC).epsilon(1.0e-03));

0 commit comments

Comments
 (0)