Skip to content

Commit 307fc28

Browse files
committed
conflict resolution
2 parents 4e0a4a0 + 0110a85 commit 307fc28

12 files changed

Lines changed: 432 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
.deps/
1414
.dirstamp
1515
.libs/
16+
.idea
1617
/config.inc
1718
/doxygen_html
1819
/efpmd/libff/libtinker.a
1920
/efpmd/src/efpmd
2021
/fraglib/params
22+
/bin/efpmd
2123
tags

.idea/libefp.iml

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

efpmd/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,20 @@ Default value: `"."` (current directory)
215215
The `<path>` parameter should not contain spaces or should be in double quotes
216216
otherwise.
217217

218+
### Pairwise energy analysis
219+
220+
##### Enable/Disable pairwise analysis
221+
222+
`enable_pairwise [true|false]`
223+
224+
Default value: `false`
225+
226+
##### Specify ligand
227+
228+
`ligand [integer]`
229+
230+
Default value: `0` (the first fragment in the system)
231+
218232
### Periodic Boundary Conditions (PBC)
219233

220234
##### Enable/Disable PBC

efpmd/src/common.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ void print_energy(struct state *state)
168168
msg("\n\n");
169169
}
170170

171+
171172
void print_gradient(struct state *state)
172173
{
173174
size_t n_frags;
@@ -270,6 +271,98 @@ void print_matrix(size_t rows, size_t cols, const double *mat)
270271
}
271272
}
272273

274+
void print_pair_energy(struct state *state){
275+
276+
if (cfg_get_bool(state->cfg, "enable_pairwise")) {
277+
msg(" ------ PAIRWISE ENERGY ANALYSIS FOLLOWS ------------------\n\n");
278+
size_t n_frags;
279+
check_fail(efp_get_frag_count(state->efp, &n_frags));
280+
double coord[6 * n_frags];
281+
check_fail(efp_get_coordinates(state->efp, coord));
282+
283+
struct efp_energy *energies;
284+
energies = xmalloc(n_frags * sizeof(struct efp_energy));
285+
check_fail(efp_get_pairwise_energy(state->efp, energies));
286+
287+
char ligand[32];
288+
size_t lig_atoms;
289+
290+
size_t ligand_index = cfg_get_int(state->cfg, "ligand");
291+
check_fail(efp_get_frag_name(state->efp, ligand_index, sizeof(ligand),ligand));
292+
check_fail(efp_get_frag_atom_count(state->efp, ligand_index, &lig_atoms));
293+
struct efp_atom latoms[lig_atoms];
294+
check_fail(efp_get_frag_atoms(state->efp, ligand_index, lig_atoms, latoms));
295+
296+
char frag_name[32];
297+
size_t frag_atoms;
298+
double lattice_energy[6];
299+
for (size_t j=0; j<6; j++){
300+
lattice_energy[j]=0.0;
301+
}
302+
for (size_t i=0; i <n_frags; i++){
303+
check_fail(efp_get_frag_name(state->efp, i, sizeof(frag_name),frag_name));
304+
check_fail(efp_get_frag_atom_count(state->efp, i, &frag_atoms));
305+
306+
struct efp_atom atoms[frag_atoms];
307+
check_fail(efp_get_frag_atoms(state->efp, i, frag_atoms, atoms));
308+
309+
msg(" PAIRWISE ENERGY BETWEEN FRAGMENT %zu (%s) AND LIGAND %zu (%s) \n", i, frag_name, ligand_index, ligand);
310+
msg("fragment %s\n", frag_name);
311+
for (size_t a = 0; a < frag_atoms; a++) {
312+
double x = atoms[a].x * BOHR_RADIUS;
313+
double y = atoms[a].y * BOHR_RADIUS;
314+
double z = atoms[a].z * BOHR_RADIUS;
315+
msg(" %-16s %12.6lf %12.6lf %12.6lf\n", atoms[a].label, x, y, z);
316+
}
317+
msg("\n");
318+
319+
msg("fragment %s\n", ligand);
320+
for (size_t a = 0; a < lig_atoms; a++) {
321+
double x = latoms[a].x * BOHR_RADIUS;
322+
double y = latoms[a].y * BOHR_RADIUS;
323+
double z = latoms[a].z * BOHR_RADIUS;
324+
msg(" %-16s %12.6lf %12.6lf %12.6lf\n", latoms[a].label, x, y, z);
325+
}
326+
msg("\n");
327+
328+
msg(" PAIRWISE ENERGY COMPONENTS (ATOMIC UNITS)\n");
329+
msg("%40s %16.10lf\n", "PAIRWISE ELECTROSTATIC ENERGY", energies[i].electrostatic);
330+
msg("%40s %16.10lf\n", "PAIRWISE POLARIZATION ENERGY", energies[i].polarization);
331+
msg("%40s %16.10lf\n", "PAIRWISE DISPERSION ENERGY", energies[i].dispersion);
332+
msg("%40s %16.10lf\n", "PAIRWISE EXCHANGE REPULSION ENERGY",
333+
energies[i].exchange_repulsion);
334+
msg("%40s %16.10lf\n", "PAIRWISE CHARGE PENETRATION ENERGY",
335+
energies[i].charge_penetration);
336+
337+
energies[i].total = energies[i].electrostatic + energies[i].polarization + energies[i].dispersion
338+
+ energies[i].exchange_repulsion + energies[i].charge_penetration;
339+
msg("%40s %16.10lf\n", "PAIRWISE TOTAL ENERGY", energies[i].total);
340+
msg("\n ---------------------------------------------------------\n");
341+
342+
lattice_energy[0] = lattice_energy[0] + energies[i].electrostatic;
343+
lattice_energy[1] = lattice_energy[1] + energies[i].polarization;
344+
lattice_energy[2] = lattice_energy[2] + energies[i].dispersion;
345+
lattice_energy[3] = lattice_energy[3] + energies[i].exchange_repulsion;
346+
lattice_energy[4] = lattice_energy[4] + energies[i].charge_penetration;
347+
lattice_energy[5] = lattice_energy[5] + energies[i].total;
348+
}
349+
free(energies);
350+
351+
msg(" LATTICE ENERGY COMPONENTS (ATOMIC UNITS)\n");
352+
msg("%40s %16.10lf\n", "LATTICE ELECTROSTATIC ENERGY", lattice_energy[0]);
353+
msg("%40s %16.10lf\n", "LATTICE POLARIZATION ENERGY", lattice_energy[1]);
354+
msg("%40s %16.10lf\n", "LATTICE DISPERSION ENERGY", lattice_energy[2]);
355+
msg("%40s %16.10lf\n", "LATTICE EXCHANGE REPULSION ENERGY", lattice_energy[3]);
356+
msg("%40s %16.10lf\n", "LATTICE CHARGE PENETRATION ENERGY", lattice_energy[4]);
357+
msg("%40s %16.10lf\n", "LATTICE TOTAL ENERGY", lattice_energy[5]);
358+
msg("\n\n");
359+
360+
msg(" ------ PAIRWISE ENERGY ANALYSIS COMPLETED --------------\n\n");
361+
}
362+
}
363+
364+
365+
273366
six_t box_from_str(const char *str)
274367
{
275368
six_t box;
@@ -283,3 +376,4 @@ six_t box_from_str(const char *str)
283376
// vec_scale(&box, 1.0 / BOHR_RADIUS);
284377
return box;
285378
}
379+

efpmd/src/common.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ enum run_type {
5959
RUN_TYPE_OPT,
6060
RUN_TYPE_MD,
6161
RUN_TYPE_EFIELD,
62-
RUN_TYPE_GTEST
62+
RUN_TYPE_GTEST,
6363
};
64+
//RUN_TYPE_PAIRWISE
6465

6566
enum ensemble_type {
6667
ENSEMBLE_TYPE_NVE,
@@ -113,6 +114,7 @@ void print_fragment(const char *, const double *, const double *);
113114
void print_charge(double, double, double, double);
114115
void print_vector(size_t, const double *);
115116
void print_matrix(size_t, size_t, const double *);
117+
void print_pair_energy(struct state *);
116118

117119
void check_fail(enum efp_result);
118120
void compute_energy(struct state *, bool);
@@ -121,4 +123,5 @@ six_t box_from_str(const char *);
121123
int efp_strcasecmp(const char *, const char *);
122124
int efp_strncasecmp(const char *, const char *, size_t);
123125

126+
124127
#endif /* EFPMD_COMMON_H */

efpmd/src/main.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void sim_opt(struct state *);
3737
void sim_md(struct state *);
3838
void sim_efield(struct state *);
3939
void sim_gtest(struct state *);
40+
// void sim_pairwise(struct state *);
4041

4142
#define USAGE_STRING \
4243
"usage: efpmd [-d | -v | -h | input]\n" \
@@ -62,7 +63,9 @@ static struct cfg *make_cfg(void)
6263
RUN_TYPE_OPT,
6364
RUN_TYPE_MD,
6465
RUN_TYPE_EFIELD,
65-
RUN_TYPE_GTEST });
66+
RUN_TYPE_GTEST});
67+
/* "pairwise\n",
68+
RUN_TYPE_PAIRWISE */
6669

6770
cfg_add_enum(cfg, "coord", EFP_COORD_TYPE_XYZABC,
6871
"xyzabc\n"
@@ -139,6 +142,10 @@ static struct cfg *make_cfg(void)
139142
cfg_add_double(cfg, "thermostat_tau", 1.0e3);
140143
cfg_add_double(cfg, "barostat_tau", 1.0e4);
141144

145+
cfg_add_int(cfg, "ligand", 0);
146+
cfg_add_bool(cfg, "enable_pairwise", false);
147+
148+
142149
return cfg;
143150
}
144151

@@ -160,6 +167,8 @@ static sim_fn_t get_sim_fn(enum run_type run_type)
160167
case RUN_TYPE_GTEST:
161168
return sim_gtest;
162169
}
170+
// case RUN_TYPE_PAIRWISE:
171+
// return sim_ pairwise;
163172
assert(0);
164173
}
165174

@@ -247,7 +256,9 @@ static struct efp *create_efp(const struct cfg *cfg, const struct sys *sys)
247256
.pol_driver = cfg_get_enum(cfg, "pol_driver"),
248257
.enable_pbc = cfg_get_bool(cfg, "enable_pbc"),
249258
.enable_cutoff = cfg_get_bool(cfg, "enable_cutoff"),
250-
.swf_cutoff = cfg_get_double(cfg, "swf_cutoff")
259+
.swf_cutoff = cfg_get_double(cfg, "swf_cutoff"),
260+
.enable_pairwise = cfg_get_bool(cfg, "enable_pairwise"),
261+
.ligand = cfg_get_int(cfg, "ligand")
251262
};
252263

253264
enum efp_coord_type coord_type = cfg_get_enum(cfg, "coord");
@@ -310,6 +321,7 @@ static void state_init(struct state *state, const struct cfg *cfg, const struct
310321
state->grad = xcalloc(sys->n_frags * 6 + sys->n_charges * 3, sizeof(double));
311322
state->ff = NULL;
312323

324+
313325
if (cfg_get_bool(cfg, "enable_ff")) {
314326
if ((state->ff = ff_create()) == NULL)
315327
error("cannot create ff object");

efpmd/src/sp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void sim_sp(struct state *state)
3434

3535
print_geometry(state->efp);
3636
compute_energy(state, false);
37+
print_pair_energy(state);
3738
print_energy(state);
3839

3940
msg("SINGLE POINT ENERGY JOB COMPLETED SUCCESSFULLY\n");
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 50;
7+
objects = {
8+
9+
/* Begin PBXGroup section */
10+
D98CC31F240F6D7100E8763E = {
11+
isa = PBXGroup;
12+
children = (
13+
);
14+
sourceTree = "<group>";
15+
};
16+
/* End PBXGroup section */
17+
18+
/* Begin PBXProject section */
19+
D98CC320240F6D7100E8763E /* Project object */ = {
20+
isa = PBXProject;
21+
attributes = {
22+
LastUpgradeCheck = 1130;
23+
};
24+
buildConfigurationList = D98CC323240F6D7100E8763E /* Build configuration list for PBXProject "libefp" */;
25+
compatibilityVersion = "Xcode 9.3";
26+
developmentRegion = en;
27+
hasScannedForEncodings = 0;
28+
knownRegions = (
29+
en,
30+
Base,
31+
);
32+
mainGroup = D98CC31F240F6D7100E8763E;
33+
projectDirPath = "";
34+
projectRoot = "";
35+
targets = (
36+
);
37+
};
38+
/* End PBXProject section */
39+
40+
/* Begin XCBuildConfiguration section */
41+
D98CC324240F6D7100E8763E /* Debug */ = {
42+
isa = XCBuildConfiguration;
43+
buildSettings = {
44+
};
45+
name = Debug;
46+
};
47+
D98CC325240F6D7100E8763E /* Release */ = {
48+
isa = XCBuildConfiguration;
49+
buildSettings = {
50+
};
51+
name = Release;
52+
};
53+
/* End XCBuildConfiguration section */
54+
55+
/* Begin XCConfigurationList section */
56+
D98CC323240F6D7100E8763E /* Build configuration list for PBXProject "libefp" */ = {
57+
isa = XCConfigurationList;
58+
buildConfigurations = (
59+
D98CC324240F6D7100E8763E /* Debug */,
60+
D98CC325240F6D7100E8763E /* Release */,
61+
);
62+
defaultConfigurationIsVisible = 0;
63+
defaultConfigurationName = Release;
64+
};
65+
/* End XCConfigurationList section */
66+
};
67+
rootObject = D98CC320240F6D7100E8763E /* Project object */;
68+
}

0 commit comments

Comments
 (0)