Skip to content

Commit 8e446b1

Browse files
committed
First version of weighted Poisson
1 parent 87fc9d7 commit 8e446b1

File tree

3 files changed

+844
-284
lines changed

3 files changed

+844
-284
lines changed

colvartools/poisson_integrator.cpp

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <iostream>
22
#include <fstream>
3+
#include <sys/stat.h>
34

45
#include "colvargrid.h"
56
#include "colvarproxy.h"
@@ -16,7 +17,30 @@ int main (int argc, char *argv[]) {
1617
colvarmodule *colvars = new colvarmodule(proxy);
1718

1819
std::string gradfile (argv[1]);
19-
std::shared_ptr<colvar_grid_gradient> grad_ptr = std::make_shared<colvar_grid_gradient>(gradfile);
20+
std::shared_ptr<colvar_grid_count> count_ptr;
21+
22+
std::string countfile;
23+
24+
// Look for matching count file
25+
size_t pos = gradfile.rfind(std::string(".czar.grad"));
26+
if (pos != std::string::npos) {
27+
countfile = gradfile.substr(0,pos) + ".zcount";
28+
} else {
29+
pos = gradfile.rfind(std::string(".grad"));
30+
if (pos != std::string::npos) {
31+
countfile = gradfile.substr(0,pos) + ".count";
32+
}
33+
}
34+
if (countfile.size()) {
35+
struct stat buffer;
36+
if (stat(countfile.c_str(), &buffer) == 0) {
37+
std::cout << "Found associated count file " << countfile << ", reading...\n";
38+
count_ptr.reset(new colvar_grid_count(countfile));
39+
}
40+
}
41+
42+
std::cout << "Reading gradient file " << gradfile << std::endl;
43+
std::shared_ptr<colvar_grid_gradient> grad_ptr = std::make_shared<colvar_grid_gradient>(gradfile, count_ptr);
2044

2145
int itmax = 1000;
2246
cvm::real err;
@@ -27,8 +51,11 @@ int main (int argc, char *argv[]) {
2751
potential.integrate(itmax, tol, err);
2852
potential.set_zero_minimum();
2953

30-
potential.write_multicol(std::string(gradfile + ".int"),
31-
"integrated potential");
54+
std::cout << "Writing integrated potential file " << gradfile + ".int" << std::endl;
55+
potential.write_multicol(std::string(gradfile + ".int"), "integrated potential");
56+
57+
std::cout << "Writing internal gradient to file " << gradfile + ".out" << std::endl;
58+
grad_ptr->write_multicol(std::string(gradfile + ".out"), "integrated potential");
3259

3360
delete colvars;
3461
return 0;

0 commit comments

Comments
 (0)