Skip to content

Commit 4730c69

Browse files
committed
Document FQ feature
1 parent c315048 commit 4730c69

File tree

13 files changed

+98
-44
lines changed

13 files changed

+98
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66

7+
- An implementation of the fluctuating charge (FQ) molecular mechanics (MM) model.
78
- A new API initialization function `pcmsolver_new_read_host`. This allows
89
creating an *uninitialized* `pcmsolver_context_t` object: the initialization is
910
deferred to a later point and orchestrated by the host program. The input

doc/snippets/example_input-all.inp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ ChargeDistribution {
4444
Monopoles = [Double]
4545
Dipoles = [Double]
4646
}
47+
MMFQ {
48+
SitesPerFragment = [Integer]
49+
Sites = [Array of Doubles]
50+
NonPolarizable = [Bool]
51+
}

doc/users/input.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,33 @@ No additional spheres will be generated.
485485

486486
* **Type**: array of doubles
487487

488+
MMFQ section keywords
489+
---------------------
490+
491+
Set a classical fluctuating charge force field. This is incompatible with any
492+
options specifying a continuum model. No additional spheres will be generated.
493+
494+
.. glossary::
495+
496+
SitesPerFragment
497+
Number of sites per MM fragment. For water this is 3.
498+
499+
* **Type**: integer
500+
* **Default**: 3
501+
502+
Sites
503+
Array of MM sites for the FQ model
504+
Format is :math:`[\ldots, x_i, y_i, z_i, chi_i, eta_i \ldots]`
505+
506+
* **Type**: array of doubles
507+
508+
NonPolarizable
509+
Whether to make this force field nonpolarizable.
510+
511+
* **Type**: bool
512+
* **Default**: false
513+
514+
488515
.. _available-radii:
489516

490517
Available radii

src/interface/Input.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,7 @@ std::string right_trim(const char * src) {
435435
return right_trim(tmp);
436436
}
437437

438-
std::string trim(std::string s) {
439-
return right_trim(left_trim(s));
440-
}
438+
std::string trim(std::string s) { return right_trim(left_trim(s)); }
441439

442440
std::string trim(const char * src) {
443441
std::string tmp(src);

src/interface/Meddle.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ void Meddle::CTORBody() {
155155
TIMER_ON("Meddle::initCavity");
156156
initCavity();
157157
TIMER_OFF("Meddle::initCavity");
158-
}
159158

160-
TIMER_ON("Meddle::initStaticSolver");
161-
initStaticSolver();
162-
TIMER_OFF("Meddle::initStaticSolver");
159+
TIMER_ON("Meddle::initStaticSolver");
160+
initStaticSolver();
161+
TIMER_OFF("Meddle::initStaticSolver");
163162

164-
if (input_.isDynamic()) {
165-
TIMER_ON("Meddle::initDynamicSolver");
166-
initDynamicSolver();
167-
TIMER_OFF("Meddle::initDynamicSolver");
163+
if (input_.isDynamic()) {
164+
TIMER_ON("Meddle::initDynamicSolver");
165+
initDynamicSolver();
166+
TIMER_OFF("Meddle::initDynamicSolver");
167+
}
168168
}
169169
}
170170

@@ -175,6 +175,7 @@ Meddle::Meddle(const Input & input, const HostWriter & write)
175175
cavity_(nullptr),
176176
K_0_(nullptr),
177177
K_d_(nullptr),
178+
FQ_(nullptr),
178179
hasDynamic_(false),
179180
hasFQ_(false) {
180181
input_.initMolecule();
@@ -188,6 +189,7 @@ Meddle::Meddle(const std::string & inputFileName, const HostWriter & write)
188189
cavity_(nullptr),
189190
K_0_(nullptr),
190191
K_d_(nullptr),
192+
FQ_(nullptr),
191193
hasDynamic_(false),
192194
hasFQ_(false) {
193195
input_.initMolecule();
@@ -206,6 +208,7 @@ Meddle::Meddle(int nr_nuclei,
206208
cavity_(nullptr),
207209
K_0_(nullptr),
208210
K_d_(nullptr),
211+
FQ_(nullptr),
209212
hasDynamic_(false),
210213
hasFQ_(false) {
211214
TIMER_ON("Meddle::initInput");
@@ -227,6 +230,7 @@ Meddle::Meddle(int nr_nuclei,
227230
cavity_(nullptr),
228231
K_0_(nullptr),
229232
K_d_(nullptr),
233+
FQ_(nullptr),
230234
hasDynamic_(false),
231235
hasFQ_(false) {
232236
TIMER_ON("Meddle::initInput");
@@ -247,6 +251,7 @@ Meddle::Meddle(int nr_nuclei,
247251
cavity_(nullptr),
248252
K_0_(nullptr),
249253
K_d_(nullptr),
254+
FQ_(nullptr),
250255
hasDynamic_(false),
251256
hasFQ_(false) {
252257
// This one does a deferred initialization:

src/mmfq/FQOhno.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* PCMSolver, an API for the Polarizable Continuum Model
3-
* Copyright (C) 2017 Roberto Di Remigio, Luca Frediani and collaborators.
3+
* Copyright (C) 2020 Roberto Di Remigio, Luca Frediani and collaborators.
44
*
55
* This file is part of PCMSolver.
66
*
@@ -76,7 +76,8 @@ Eigen::VectorXd FQOhno::computeCharge_impl(const Eigen::VectorXd & potential,
7676

7777
std::ostream & FQOhno::printSolver(std::ostream & os) {
7878
os << "Fluctuating charge solver type: Ohno" << std::endl;
79-
if (nonPolarizable_) os << "Nonpolarizable force field" << std::endl;
79+
if (nonPolarizable_)
80+
os << "Nonpolarizable force field" << std::endl;
8081
os << "Number of fragments = " << mmfq_.nFragments << std::endl;
8182
os << "Number of sites per fragment = " << mmfq_.nSitesPerFragment << std::endl;
8283
os << "Number of sites = " << mmfq_.nFragments * mmfq_.nSitesPerFragment;

src/mmfq/FQOhno.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* PCMSolver, an API for the Polarizable Continuum Model
3-
* Copyright (C) 2017 Roberto Di Remigio, Luca Frediani and collaborators.
3+
* Copyright (C) 2020 Roberto Di Remigio, Luca Frediani and collaborators.
44
*
55
* This file is part of PCMSolver.
66
*

src/utils/MMFQ.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* PCMSolver, an API for the Polarizable Continuum Model
3-
* Copyright (C) 2018 Roberto Di Remigio, Luca Frediani and contributors.
3+
* Copyright (C) 2020 Roberto Di Remigio, Luca Frediani and contributors.
44
*
55
* This file is part of PCMSolver.
66
*

tests/CMakeLists.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ target_compile_definitions(unit_tests
1818
"$<$<NOT:$<BOOL:${HAS_CXX11}>>:CATCH_CONFIG_NO_CPP11>"
1919
)
2020

21-
add_subdirectory(input)
22-
add_subdirectory(numerical_quadrature)
23-
add_subdirectory(gepol)
24-
add_subdirectory(dielectric_profile)
25-
add_subdirectory(green)
21+
add_subdirectory(benchmark)
2622
add_subdirectory(bi_operators)
2723
add_subdirectory(cpcm)
24+
add_subdirectory(dielectric_profile)
25+
add_subdirectory(gepol)
26+
add_subdirectory(green)
2827
add_subdirectory(iefpcm)
28+
add_subdirectory(input)
29+
add_subdirectory(mmfq)
30+
add_subdirectory(numerical_quadrature)
2931
add_subdirectory(utils)
30-
add_subdirectory(benchmark)
3132

3233
target_link_libraries(unit_tests
3334
PRIVATE

tests/green/AnalyticEvaluate.hpp

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -396,23 +396,33 @@ inline Eigen::Array4d analyticSphericalSharp(double eps,
396396
// Value of the function
397397
result(0) = 1.0 / (epsSolv * distance) - G_img;
398398

399-
double d_probe_G_img = sevenPointStencil(
400-
std::bind(
401-
imagePotential, eps, epsSolv, radius, origin, maxL, std::placeholders::_1, std::placeholders::_2),
402-
pp,
403-
sp,
404-
ppNormal,
405-
1.0e-04);
399+
double d_probe_G_img = sevenPointStencil(std::bind(imagePotential,
400+
eps,
401+
epsSolv,
402+
radius,
403+
origin,
404+
maxL,
405+
std::placeholders::_1,
406+
std::placeholders::_2),
407+
pp,
408+
sp,
409+
ppNormal,
410+
1.0e-04);
406411
// Value of the directional derivative wrt probe
407412
result(1) = (sp - pp).dot(ppNormal) / (epsSolv * distance_3) - d_probe_G_img;
408413

409-
double d_source_G_img = sevenPointStencil(
410-
std::bind(
411-
imagePotential, eps, epsSolv, radius, origin, maxL, std::placeholders::_1, std::placeholders::_2),
412-
sp,
413-
pp,
414-
spNormal,
415-
1.0e-04);
414+
double d_source_G_img = sevenPointStencil(std::bind(imagePotential,
415+
eps,
416+
epsSolv,
417+
radius,
418+
origin,
419+
maxL,
420+
std::placeholders::_1,
421+
std::placeholders::_2),
422+
sp,
423+
pp,
424+
spNormal,
425+
1.0e-04);
416426
// Directional derivative wrt source
417427
result(2) = -(sp - pp).dot(spNormal) / (epsSolv * distance_3) - d_source_G_img;
418428
// Value of the Hessian

tests/input/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ file(
1111
COPY
1212
cpcm.inp
1313
diffuse.inp
14-
fq.inp
14+
mmfq.inp
1515
multipoles.inp
1616
restart.inp
1717
sharp.inp

tests/mmfq/mmfq-ohno.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
#include "utils/MathUtils.hpp"
3333

3434
using namespace pcm;
35-
using utils::MMFQ;
3635
using mmfq::FQOhno;
36+
using utils::MMFQ;
3737

3838
TEST_CASE("Test MMFQ for a pair of water fragments and the Ohno kernel",
39-
"[mmfq][ohno]") {
39+
"[mmfq][ohno][mmfq-ohno]") {
4040
MMFQ fragments;
4141
fragments.nFragments = 2;
4242
fragments.nSitesPerFragment = 3;

tests/numerical_quadrature/numerical_quadrature.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ SCENARIO("Numerical quadrature of functions", "[numerical_quadrature]") {
6161
WHEN("The function is a constant") {
6262
THEN("the integrals are the finite element areas") {
6363
for (int i = 0; i < cavity.size(); ++i) {
64-
results(i) = integrateS<32, 16>(std::bind(constant, std::placeholders::_1, std::placeholders::_2),
65-
cavity.elements(i));
64+
results(i) = integrateS<32, 16>(
65+
std::bind(constant, std::placeholders::_1, std::placeholders::_2),
66+
cavity.elements(i));
6667
double diff = results(i) - cavity.elementArea(i);
6768
if (std::abs(diff) > 1.0e-12) {
6869
WARN("Test versus area for single sphere");
@@ -85,7 +86,9 @@ SCENARIO("Numerical quadrature of functions", "[numerical_quadrature]") {
8586
"radius") {
8687
for (int i = 0; i < cavity.size(); ++i) {
8788
results(i) = integrateS<32, 16>(
88-
std::bind(one_over_r, 1.55, std::placeholders::_1, std::placeholders::_2), cavity.elements(i));
89+
std::bind(
90+
one_over_r, 1.55, std::placeholders::_1, std::placeholders::_2),
91+
cavity.elements(i));
8992
double diff = results(i) - (cavity.elementArea(i) / radius);
9093
if (std::abs(diff) > 1.0e-11) {
9194
WARN("Test versus area divided by radius for single sphere");
@@ -116,8 +119,9 @@ SCENARIO("Numerical quadrature of functions", "[numerical_quadrature]") {
116119
WHEN("The function is a constant") {
117120
THEN("the integrals are the finite element areas") {
118121
for (int i = 0; i < cavity.size(); ++i) {
119-
results(i) = integrateS<64, 16>(std::bind(constant, std::placeholders::_1, std::placeholders::_2),
120-
cavity.elements(i));
122+
results(i) = integrateS<64, 16>(
123+
std::bind(constant, std::placeholders::_1, std::placeholders::_2),
124+
cavity.elements(i));
121125
double diff = results(i) - cavity.elementArea(i);
122126
if (std::abs(diff) > 1.0e-11) {
123127
WARN("Test versus area for H2 molecule");
@@ -146,7 +150,9 @@ SCENARIO("Numerical quadrature of functions", "[numerical_quadrature]") {
146150
"radius") {
147151
for (int i = 0; i < cavity.size(); ++i) {
148152
results(i) = integrateS<64, 16>(
149-
std::bind(one_over_r, 1.20, std::placeholders::_1, std::placeholders::_2), cavity.elements(i));
153+
std::bind(
154+
one_over_r, 1.20, std::placeholders::_1, std::placeholders::_2),
155+
cavity.elements(i));
150156
double diff =
151157
results(i) - (cavity.elementArea(i) / molecule.spheres(0).radius);
152158
if (std::abs(diff) > 1.0e-11) {

0 commit comments

Comments
 (0)