Skip to content

Commit af4387d

Browse files
author
Roberto Di Remigio
committed
Copy reference files to tests directories
1 parent 2b56ddf commit af4387d

24 files changed

+167
-1049
lines changed

cmake/custom/autogenerated.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ install(FILES ${PROJECT_BINARY_DIR}/include/Config.hpp DESTINATION include)
1717

1818

1919
# Configure the input parsing script
20-
configure_file(${PROJECT_SOURCE_DIR}/tools/pcmsolver.py.in ${PROJECT_BINARY_DIR}/bin/pcmsolver.py @ONLY)
20+
configure_file(${PROJECT_SOURCE_DIR}/tools/pcmsolver.py.in ${PROJECT_BINARY_DIR}/bin/tmp-pcmsolver-py @ONLY)
21+
add_custom_command(
22+
OUTPUT
23+
${PROJECT_BINARY_DIR}/bin/pcmsolver.py
24+
COMMAND
25+
cmake -E copy ${PROJECT_BINARY_DIR}/bin/tmp-pcmsolver-py ${PROJECT_BINARY_DIR}/bin/pcmsolver.py
26+
VERBATIM
27+
)
28+
add_custom_target(generate-pcmsolver-py ALL DEPENDS ${PROJECT_BINARY_DIR}/bin/pcmsolver.py)
2129
install(FILES ${PROJECT_BINARY_DIR}/bin/pcmsolver.py DESTINATION bin)
30+
2231
# Install GetKw Python bindings
2332
file(COPY ${PROJECT_SOURCE_DIR}/tools/getkw.py
2433
${PROJECT_SOURCE_DIR}/tools/pyparsing.py

src/interface/Input.cpp

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void Input::reader(const std::string & filename)
108108
const Section & medium = input_.getSect("MEDIUM");
109109
// Get the name of the solvent
110110
std::string name = medium.getStr("SOLVENT");
111-
if (name == "EXPLICIT" || name == "E") {
111+
if (name == "EXPLICIT") {
112112
hasSolvent_ = false;
113113
// Get the probe radius
114114
probeRadius_ = medium.getDbl("PROBERADIUS");
@@ -256,64 +256,66 @@ void Input::semanticCheck()
256256

257257
void Input::initMolecule()
258258
{
259-
// Gather information necessary to build molecule_
260-
// 1. number of atomic centers
261-
int nuclei = int(geometry_.size() / 4);
262-
// 2. position and charges of atomic centers
263-
Eigen::Matrix3Xd centers = Eigen::Matrix3Xd::Zero(3, nuclei);
264-
Eigen::VectorXd charges = Eigen::VectorXd::Zero(nuclei);
265-
int j = 0;
266-
for (int i = 0; i < nuclei; ++i) {
267-
centers.col(i) << geometry_[j], geometry_[j+1], geometry_[j+2];
268-
charges(i) = geometry_[j+3];
269-
j += 4;
259+
// Gather information necessary to build molecule_
260+
// 1. number of atomic centers
261+
int nuclei = int(geometry_.size() / 4);
262+
// 2. position and charges of atomic centers
263+
Eigen::Matrix3Xd centers = Eigen::Matrix3Xd::Zero(3, nuclei);
264+
Eigen::VectorXd charges = Eigen::VectorXd::Zero(nuclei);
265+
int j = 0;
266+
for (int i = 0; i < nuclei; ++i) {
267+
centers.col(i) << geometry_[j], geometry_[j+1], geometry_[j+2];
268+
charges(i) = geometry_[j+3];
269+
j += 4;
270+
}
271+
// 3. list of atoms and list of spheres
272+
double factor = angstromToBohr();
273+
std::vector<Atom> radiiSet, atoms;
274+
if ( radiiSet_ == "UFF" ) {
275+
radiiSet = initUFF();
276+
} else {
277+
radiiSet = initBondi();
278+
}
279+
for (int i = 0; i < charges.size(); ++i) {
280+
int index = int(charges(i)) - 1;
281+
atoms.push_back(radiiSet[index]);
282+
}
283+
// Based on the creation mode (Implicit or Atoms)
284+
// the spheres list might need postprocessing
285+
if ( mode_ == "IMPLICIT" || mode_ == "ATOMS") {
286+
for (int i = 0; i < charges.size(); ++i) {
287+
int index = int(charges(i)) - 1;
288+
double radius = radiiSet[index].radius * factor;
289+
if (scaling_) radius *= radiiSet[index].radiusScaling;
290+
spheres_.push_back(Sphere(centers.col(i), radius));
270291
}
271-
// 3. list of atoms and list of spheres
272-
double factor = angstromToBohr();
273-
std::vector<Atom> radiiSet, atoms;
274-
atoms.reserve(nuclei);
275-
if ( radiiSet_ == "UFF" ) {
276-
radiiSet = initUFF();
277-
} else {
278-
radiiSet = initBondi();
279-
}
280-
// Based on the creation mode (Implicit or Atoms)
281-
// the spheres list might need postprocessing
282-
if ( mode_ == "IMPLICIT" ) {
283-
for (int i = 0; i < charges.size(); ++i) {
284-
int index = int(charges(i)) - 1;
285-
atoms.push_back(radiiSet[index]);
286-
double radius = radiiSet[index].radius * factor;
287-
if (scaling_) radius *= radiiSet[index].radiusScaling;
288-
spheres_.push_back(Sphere(centers.col(i), radius));
289-
}
290-
if (mode_ == "ATOMS") {
291-
// Loop over the atomsInput array to get which atoms will have a user-given radius
292-
for (size_t i = 0; i < atoms_.size(); ++i) {
293-
int index = atoms_[i] - 1; // -1 to go from human readable to machine readable
294-
// Put the new Sphere in place of the implicit-generated one
295-
spheres_[index] = Sphere(centers.col(index), radii_[i]);
296-
}
297-
}
298-
}
299-
300-
// 4. masses
301-
Eigen::VectorXd masses = Eigen::VectorXd::Zero(nuclei);
302-
for (int i = 0; i < masses.size(); ++i) {
303-
masses(i) = atoms[i].mass;
304-
}
305-
// 5. molecular point group
306-
// FIXME currently hardcoded to C1
307-
308-
// OK, now get molecule_
309-
molecule_ = Molecule(nuclei, charges, masses, centers, atoms, spheres_);
310-
// Check that all atoms have a radius attached
311-
std::vector<Atom>::const_iterator res =
312-
std::find_if(atoms.begin(), atoms.end(), invalid);
313-
if (res != atoms.end()) {
314-
std::cout << molecule_ << std::endl;
315-
PCMSOLVER_ERROR("Some atoms do not have a radius attached. Please specify a radius for all atoms!", BOOST_CURRENT_FUNCTION);
292+
if (mode_ == "ATOMS") {
293+
// Loop over the atomsInput array to get which atoms will have a user-given radius
294+
for (size_t i = 0; i < atoms_.size(); ++i) {
295+
int index = atoms_[i] - 1; // -1 to go from human readable to machine readable
296+
// Put the new Sphere in place of the implicit-generated one
297+
spheres_[index] = Sphere(centers.col(index), radii_[i]);
298+
}
316299
}
300+
}
301+
302+
// 4. masses
303+
Eigen::VectorXd masses = Eigen::VectorXd::Zero(nuclei);
304+
for (int i = 0; i < masses.size(); ++i) {
305+
masses(i) = atoms[i].mass;
306+
}
307+
// 5. molecular point group
308+
// FIXME currently hardcoded to C1
309+
310+
// OK, now get molecule_
311+
molecule_ = Molecule(nuclei, charges, masses, centers, atoms, spheres_);
312+
// Check that all atoms have a radius attached
313+
std::vector<Atom>::const_iterator res =
314+
std::find_if(atoms.begin(), atoms.end(), invalid);
315+
if (res != atoms.end()) {
316+
std::cout << molecule_ << std::endl;
317+
PCMSOLVER_ERROR("Some atoms do not have a radius attached. Please specify a radius for all atoms!", BOOST_CURRENT_FUNCTION);
318+
}
317319
}
318320

319321
cavityData Input::cavityParams()

tests/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ add_subdirectory(C_host)
3434
if(ENABLE_FORTRAN_API)
3535
add_subdirectory(Fortran_host)
3636
endif()
37-
add_subdirectory(standalone)
37+
if(BUILD_STANDALONE)
38+
add_subdirectory(standalone)
39+
endif()

tests/bi_operators/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/bi_operators/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ if(BUILD_CUSTOM_BOOST)
33
add_dependencies(bi_operators-tests custom_boost)
44
endif()
55

6+
# Copy reference files to ${PROJECT_BINARY_DIR}/tests/bi_operators (aka ${CMAKE_CURRENT_BINARY_DIR})
7+
list(APPEND reference_files tanhsphericaldiffuse_D_collocation.npy uniformdielectric_D_purisima.npy vacuum_D_purisima.npy
8+
tanhsphericaldiffuse_S_collocation.npy uniformdielectric_S_collocation.npy vacuum_S_collocation.npy
9+
uniformdielectric_D_collocation.npy vacuum_D_collocation.npy)
10+
file(COPY ${reference_files} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
611
# bi_operators_purisima.cpp test
7-
configure_file(bi_operators_purisima.cpp.in ${CMAKE_CURRENT_LIST_DIR}/bi_operators_purisima.cpp @ONLY)
812
add_Catch_test(bi_operators_purisima "bi_operators;bi_operators_purisima")
913

1014
# bi_operators_numerical.cpp test
11-
configure_file(bi_operators_numerical.cpp.in ${CMAKE_CURRENT_LIST_DIR}/bi_operators_numerical.cpp @ONLY)
1215
add_Catch_test(bi_operators_numerical "bi_operators;bi_operators_numerical")
1316

1417
# bi_operators_collocation.cpp test
15-
configure_file(bi_operators_collocation.cpp.in ${CMAKE_CURRENT_LIST_DIR}/bi_operators_collocation.cpp @ONLY)
1618
add_Catch_test(bi_operators_collocation "bi_operators;bi_operators_collocation")
1719

1820
# This executable updates the .npy files containing the reference values

tests/bi_operators/bi_operators_collocation.cpp.in renamed to tests/bi_operators/bi_operators_collocation.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ SCENARIO("A collocation integrator with approximate diagonal elements", "[bi_ope
6464
THEN("the matrix elements of S are")
6565
{
6666
results = gf.singleLayer(cavity.elements());
67-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/vacuum_S_collocation.npy");
67+
reference = cnpy::custom::npy_load<double>("vacuum_S_collocation.npy");
6868
for (size_t i = 0; i < cavity.size(); ++i) {
6969
for (size_t j = 0; j < cavity.size(); ++j) {
7070
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -74,7 +74,7 @@ SCENARIO("A collocation integrator with approximate diagonal elements", "[bi_ope
7474
AND_THEN("the matrix elements of D are")
7575
{
7676
results = gf.doubleLayer(cavity.elements());
77-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/vacuum_D_collocation.npy");
77+
reference = cnpy::custom::npy_load<double>("vacuum_D_collocation.npy");
7878
for (size_t i = 0; i < cavity.size(); ++i) {
7979
for (size_t j = 0; j < cavity.size(); ++j) {
8080
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -93,7 +93,7 @@ SCENARIO("A collocation integrator with approximate diagonal elements", "[bi_ope
9393
THEN("the matrix elements of S are")
9494
{
9595
results = gf.singleLayer(cavity.elements());
96-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/uniformdielectric_S_collocation.npy");
96+
reference = cnpy::custom::npy_load<double>("uniformdielectric_S_collocation.npy");
9797
for (size_t i = 0; i < cavity.size(); ++i) {
9898
for (size_t j = 0; j < cavity.size(); ++j) {
9999
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -103,7 +103,7 @@ SCENARIO("A collocation integrator with approximate diagonal elements", "[bi_ope
103103
AND_THEN("the matrix elements of D are")
104104
{
105105
results = gf.doubleLayer(cavity.elements());
106-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/uniformdielectric_D_collocation.npy");
106+
reference = cnpy::custom::npy_load<double>("uniformdielectric_D_collocation.npy");
107107
for (size_t i = 0; i < cavity.size(); ++i) {
108108
for (size_t j = 0; j < cavity.size(); ++j) {
109109
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -124,7 +124,7 @@ SCENARIO("A collocation integrator with approximate diagonal elements", "[bi_ope
124124
THEN("the matrix elements of S are")
125125
{
126126
results = gf.singleLayer(cavity.elements());
127-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/tanhsphericaldiffuse_S_collocation.npy");
127+
reference = cnpy::custom::npy_load<double>("tanhsphericaldiffuse_S_collocation.npy");
128128
for (size_t i = 0; i < cavity.size(); ++i) {
129129
for (size_t j = 0; j < cavity.size(); ++j) {
130130
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -134,7 +134,7 @@ SCENARIO("A collocation integrator with approximate diagonal elements", "[bi_ope
134134
AND_THEN("the matrix elements of D are")
135135
{
136136
results = gf.doubleLayer(cavity.elements());
137-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/tanhsphericaldiffuse_D_collocation.npy");
137+
reference = cnpy::custom::npy_load<double>("tanhsphericaldiffuse_D_collocation.npy");
138138
for (size_t i = 0; i < cavity.size(); ++i) {
139139
for (size_t j = 0; j < cavity.size(); ++j) {
140140
REQUIRE(reference(i, j) == Approx(results(i, j)));

tests/bi_operators/bi_operators_numerical.cpp.in renamed to tests/bi_operators/bi_operators_numerical.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
6565
results = gf.singleLayer(cavity.elements());
6666
// Numerical integrator not really working now...
6767
/*
68-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/vacuum_S_numerical.npy");
68+
reference = cnpy::custom::npy_load<double>("vacuum_S_numerical.npy");
6969
for (size_t i = 0; i < cavity.size(); ++i) {
7070
for (size_t j = 0; j < cavity.size(); ++j) {
7171
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -78,7 +78,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
7878
Eigen::MatrixXd results = gf.doubleLayer(cavity.elements());
7979
// Numerical integrator not really working now...
8080
/*
81-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/vacuum_D_numerical.npy");
81+
reference = cnpy::custom::npy_load<double>("vacuum_D_numerical.npy");
8282
for (size_t i = 0; i < cavity.size(); ++i) {
8383
for (size_t j = 0; j < cavity.size(); ++j) {
8484
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -102,7 +102,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
102102
results = gf.singleLayer(cavity.elements());
103103
// Numerical integrator not really working now...
104104
/*
105-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/uniformdielectric_S_numerical.npy");
105+
reference = cnpy::custom::npy_load<double>("uniformdielectric_S_numerical.npy");
106106
for (size_t i = 0; i < cavity.size(); ++i) {
107107
for (size_t j = 0; j < cavity.size(); ++j) {
108108
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -115,7 +115,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
115115
Eigen::MatrixXd results = gf.doubleLayer(cavity.elements());
116116
// Numerical integrator not really working now...
117117
/*
118-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/uniformdielectric_D_numerical.npy");
118+
reference = cnpy::custom::npy_load<double>("uniformdielectric_D_numerical.npy");
119119
for (size_t i = 0; i < cavity.size(); ++i) {
120120
for (size_t j = 0; j < cavity.size(); ++j) {
121121
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -138,7 +138,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
138138
results = gf.singleLayer(cavity.elements());
139139
// Numerical integrator not really working now...
140140
/*
141-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/ionicliquid_S_numerical.npy");
141+
reference = cnpy::custom::npy_load<double>("ionicliquid_S_numerical.npy");
142142
for (size_t i = 0; i < cavity.size(); ++i) {
143143
for (size_t j = 0; j < cavity.size(); ++j) {
144144
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -151,7 +151,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
151151
results = gf.doubleLayer(cavity.elements());
152152
// Numerical integrator not really working now...
153153
/*
154-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/ionicliquid_D_numerical.npy");
154+
reference = cnpy::custom::npy_load<double>("ionicliquid_D_numerical.npy");
155155
for (size_t i = 0; i < cavity.size(); ++i) {
156156
for (size_t j = 0; j < cavity.size(); ++j) {
157157
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -174,7 +174,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
174174
results = gf.singleLayer(cavity.elements());
175175
// Numerical integrator not really working now...
176176
/*
177-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/anisotropicliquid_S_numerical.npy");
177+
reference = cnpy::custom::npy_load<double>("anisotropicliquid_S_numerical.npy");
178178
for (size_t i = 0; i < cavity.size(); ++i) {
179179
for (size_t j = 0; j < cavity.size(); ++j) {
180180
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -187,7 +187,7 @@ SCENARIO("A collocation integrator with numerical integrator of the diagonal ele
187187
results = gf.doubleLayer(cavity.elements());
188188
// Numerical integrator not really working now...
189189
/*
190-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/anisotropicliquid_D_numerical.npy");
190+
reference = cnpy::custom::npy_load<double>("anisotropicliquid_D_numerical.npy");
191191
for (size_t i = 0; i < cavity.size(); ++i) {
192192
for (size_t j = 0; j < cavity.size(); ++j) {
193193
REQUIRE(reference(i, j) == Approx(results(i, j)));

tests/bi_operators/bi_operators_purisima.cpp.in renamed to tests/bi_operators/bi_operators_purisima.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ SCENARIO("A collocation integrator with diagonal elements according to Purisima
6464
THEN("the matrix elements of S are")
6565
{
6666
results = gf.singleLayer(cavity.elements());
67-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/vacuum_S_collocation.npy");
67+
reference = cnpy::custom::npy_load<double>("vacuum_S_collocation.npy");
6868
for (size_t i = 0; i < cavity.size(); ++i) {
6969
for (size_t j = 0; j < cavity.size(); ++j) {
7070
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -74,7 +74,7 @@ SCENARIO("A collocation integrator with diagonal elements according to Purisima
7474
AND_THEN("the matrix elements of D are")
7575
{
7676
results = gf.doubleLayer(cavity.elements());
77-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/vacuum_D_purisima.npy");
77+
reference = cnpy::custom::npy_load<double>("vacuum_D_purisima.npy");
7878
for (size_t i = 0; i < cavity.size(); ++i) {
7979
for (size_t j = 0; j < cavity.size(); ++j) {
8080
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -93,7 +93,7 @@ SCENARIO("A collocation integrator with diagonal elements according to Purisima
9393
THEN("the matrix elements of S are")
9494
{
9595
results = gf.singleLayer(cavity.elements());
96-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/uniformdielectric_S_collocation.npy");
96+
reference = cnpy::custom::npy_load<double>("uniformdielectric_S_collocation.npy");
9797
for (size_t i = 0; i < cavity.size(); ++i) {
9898
for (size_t j = 0; j < cavity.size(); ++j) {
9999
REQUIRE(reference(i, j) == Approx(results(i, j)));
@@ -103,7 +103,7 @@ SCENARIO("A collocation integrator with diagonal elements according to Purisima
103103
AND_THEN("the matrix elements of D are")
104104
{
105105
results = gf.doubleLayer(cavity.elements());
106-
reference = cnpy::custom::npy_load<double>("@CMAKE_CURRENT_LIST_DIR@/uniformdielectric_D_purisima.npy");
106+
reference = cnpy::custom::npy_load<double>("uniformdielectric_D_purisima.npy");
107107
for (size_t i = 0; i < cavity.size(); ++i) {
108108
for (size_t j = 0; j < cavity.size(); ++j) {
109109
REQUIRE(reference(i, j) == Approx(results(i, j)));

tests/input/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)