diff --git a/examples/PACKAGES/alchemy/in.twowater b/examples/PACKAGES/alchemy/in.twowater index 8c19eab215..6e1727de5a 100644 --- a/examples/PACKAGES/alchemy/in.twowater +++ b/examples/PACKAGES/alchemy/in.twowater @@ -86,8 +86,8 @@ fix_modify integrate press pressure # "dump 1 all atom 100 ${name}.lammpstrj" & # "dump_modify 1 sort id" -thermo_style custom step temp press etotal density pe ke f_transform[1] f_transform[4] -thermo_modify colname f_transform[1] lambda colname f_transform[4] EPot_mixed +thermo_style custom step temp press etotal density pe ke f_transform f_transform[3] +thermo_modify colname f_transform lambda colname f_transform[3] EPot_mixed thermo_modify press pressure thermo 100 diff --git a/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.0 b/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.0 index 7717dae784..fc652dded7 100644 --- a/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.0 +++ b/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.0 @@ -167,8 +167,8 @@ fix_modify integrate press pressure # only need to output a dump file from one partition # if "${name} == twowater" then # "dump 1 all atom 100 ${name}.lammpstrj" # "dump_modify 1 sort id" -thermo_style custom step temp press etotal density pe ke f_transform[1] f_transform[4] -thermo_modify colname f_transform[1] lambda colname f_transform[4] EPot_mixed +thermo_style custom step temp press etotal density pe ke f_transform f_transform[3] +thermo_modify colname f_transform lambda colname f_transform[3] EPot_mixed thermo_modify press pressure thermo 100 @@ -377,21 +377,21 @@ Per MPI rank memory allocation (min/avg/max) = 7.535 | 7.535 | 7.535 Mbytes 19800 295.68946 81474.342 2308.3249 1.0240743 2219.3041 89.020804 0.01 1910.5545 19900 306.4947 43488.052 2330.4958 1.0222707 2238.222 92.27385 0.005 1957.4368 20000 313.31679 -25133.284 -1161.6979 1.0163289 -1256.0256 94.327722 0 -1649.7551 -Loop time of 11.8252 on 2 procs for 20000 steps with 102 atoms +Loop time of 11.7903 on 2 procs for 20000 steps with 102 atoms -Performance: 29.226 ns/day, 0.821 hours/ns, 1691.296 timesteps/s, 172.512 katom-step/s +Performance: 29.312 ns/day, 0.819 hours/ns, 1696.311 timesteps/s, 173.024 katom-step/s 99.3% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 6.8298 | 8.6298 | 10.43 | 61.3 | 72.98 -Bond | 0.045072 | 0.045296 | 0.045519 | 0.1 | 0.38 -Neigh | 0.10567 | 0.10572 | 0.10577 | 0.0 | 0.89 -Comm | 0.73714 | 2.5381 | 4.3392 | 113.0 | 21.46 -Output | 0.0032977 | 0.0035468 | 0.003796 | 0.4 | 0.03 -Modify | 0.43872 | 0.44155 | 0.44438 | 0.4 | 3.73 -Other | | 0.06121 | | | 0.52 +Pair | 6.8605 | 8.6071 | 10.354 | 59.5 | 73.00 +Bond | 0.044148 | 0.044761 | 0.045375 | 0.3 | 0.38 +Neigh | 0.10568 | 0.10573 | 0.10578 | 0.0 | 0.90 +Comm | 0.74919 | 2.4939 | 4.2386 | 110.5 | 21.15 +Output | 0.0033838 | 0.0036358 | 0.0038879 | 0.4 | 0.03 +Modify | 0.46825 | 0.47526 | 0.48227 | 1.0 | 4.03 +Other | | 0.05993 | | | 0.51 Nlocal: 51 ave 51 max 51 min Histogram: 2 0 0 0 0 0 0 0 0 0 diff --git a/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.1 b/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.1 index 8fa06d5677..e1d32eb1c7 100644 --- a/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.1 +++ b/examples/PACKAGES/alchemy/log.25Feb23.twowater.g++.4.1 @@ -45,7 +45,7 @@ Read molecule template water: create_atoms 0 single -2.0 0.0 0.0 mol water 453624 Created 3 atoms using lattice units in orthogonal box = (-5 -5 -5) to (5 5 5) - create_atoms CPU = 0.004 seconds + create_atoms CPU = 0.003 seconds create_atoms 0 single 2.0 0.0 0.0 mol water 767353 Created 3 atoms using lattice units in orthogonal box = (-5 -5 -5) to (5 5 5) @@ -191,8 +191,8 @@ fix_modify integrate press pressure # only need to output a dump file from one partition # if "${name} == twowater" then # "dump 1 all atom 100 ${name}.lammpstrj" # "dump_modify 1 sort id" -thermo_style custom step temp press etotal density pe ke f_transform[1] f_transform[4] -thermo_modify colname f_transform[1] lambda colname f_transform[4] EPot_mixed +thermo_style custom step temp press etotal density pe ke f_transform f_transform[3] +thermo_modify colname f_transform lambda colname f_transform[3] EPot_mixed thermo_modify press pressure thermo 100 @@ -402,21 +402,21 @@ Per MPI rank memory allocation (min/avg/max) = 7.535 | 7.535 | 7.535 Mbytes 19800 295.68946 81474.342 1996.4567 1.0240743 1907.4359 89.020804 0.99 1910.5545 19900 306.4947 43488.052 2048.2997 1.0222707 1956.0258 92.27385 0.995 1957.4368 20000 313.31679 -25133.284 -1555.4274 1.0163289 -1649.7551 94.327722 1 -1649.7551 -Loop time of 11.8253 on 2 procs for 20000 steps with 102 atoms +Loop time of 11.7903 on 2 procs for 20000 steps with 102 atoms -Performance: 29.226 ns/day, 0.821 hours/ns, 1691.295 timesteps/s, 172.512 katom-step/s +Performance: 29.312 ns/day, 0.819 hours/ns, 1696.310 timesteps/s, 173.024 katom-step/s 99.3% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 6.8508 | 8.6272 | 10.404 | 60.5 | 72.96 -Bond | 0.045829 | 0.046542 | 0.047256 | 0.3 | 0.39 -Neigh | 0.10781 | 0.10791 | 0.108 | 0.0 | 0.91 -Comm | 0.75178 | 2.5281 | 4.3045 | 111.7 | 21.38 -Output | 0.0032916 | 0.0035722 | 0.0038527 | 0.5 | 0.03 -Modify | 0.44867 | 0.45212 | 0.45556 | 0.5 | 3.82 -Other | | 0.05976 | | | 0.51 +Pair | 6.8748 | 8.631 | 10.387 | 59.8 | 73.20 +Bond | 0.04667 | 0.047105 | 0.04754 | 0.2 | 0.40 +Neigh | 0.10858 | 0.10862 | 0.10866 | 0.0 | 0.92 +Comm | 0.74367 | 2.4997 | 4.2558 | 111.1 | 21.20 +Output | 0.0034405 | 0.0037033 | 0.003966 | 0.4 | 0.03 +Modify | 0.4338 | 0.4388 | 0.4438 | 0.8 | 3.72 +Other | | 0.06136 | | | 0.52 Nlocal: 51 ave 51 max 51 min Histogram: 2 0 0 0 0 0 0 0 0 0 diff --git a/src/REPLICA/fix_alchemy.cpp b/src/REPLICA/fix_alchemy.cpp index ea89b1a016..6a65c0d116 100644 --- a/src/REPLICA/fix_alchemy.cpp +++ b/src/REPLICA/fix_alchemy.cpp @@ -31,33 +31,27 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ -static double get_lambda(const bigint &step, const bigint &begin, const bigint &end, int iworld) -{ - double lambda = step - begin; - if (lambda != 0.0) lambda /= end - begin; - if (iworld == 0) lambda = 1.0 - lambda; - return lambda; -} - -/* ---------------------------------------------------------------------- */ - FixAlchemy::FixAlchemy(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), commbuf(nullptr) { if (narg != 3) error->all(FLERR, "Incorrect number of arguments for fix alchemy"); + if (universe->nworlds != 2) error->all(FLERR, "Must use exactly two partitions"); - lambda = epot[0] = epot[1] = 0.0; + lambda = epot[0] = epot[1] = epot[2] = 0.0; progress = 0; for (int i = 0; i < 6; ++i) pressure[i] = 0.0; no_change_box = 1; + time_depend = 1; + scalar_flag = 1; + extscalar = 0; vector_flag = 1; - size_vector = 10; - extvector = 0; + size_vector = 3; + extvector = 1; ilevel_respa = 0; nmax = 6; + sync_box = 0; // set up rank-to-rank communicator - if (universe->nworlds != 2) error->all(FLERR, "Must use exactly two partitions"); int color = comm->me; int key = universe->iworld; MPI_Comm_split(universe->uworld, color, key, &samerank); @@ -163,12 +157,22 @@ void FixAlchemy::setup(int vflag) void FixAlchemy::post_integrate() { + // synchronize atom positions const int nall = atom->nlocal + atom->nghost; MPI_Bcast(&atom->x[0][0], 3 * nall, MPI_DOUBLE, 0, samerank); // synchronize box dimensions, if needed if (sync_box) synchronize_box(domain, samerank); } + +/* ---------------------------------------------------------------------- */ + +static double get_lambda(const bigint &step, const bigint &begin, const bigint &end, int iworld) +{ + double lambda = step - begin; + if (lambda != 0.0) lambda /= end - begin; + if (iworld == 0) lambda = 1.0 - lambda; + return lambda; } /* ---------------------------------------------------------------------- */ @@ -215,11 +219,16 @@ void FixAlchemy::post_force(int /*vflag*/) /* ---------------------------------------------------------------------- */ +double FixAlchemy::compute_scalar() +{ + return lambda; +} + +/* ---------------------------------------------------------------------- */ + double FixAlchemy::compute_vector(int n) { - if (n == 0) return lambda; - if ((n > 0) && (n < 4)) return epot[n - 1]; - return pressure[n - 4]; + return epot[n]; } /* ---------------------------------------------------------------------- */ diff --git a/src/REPLICA/fix_alchemy.h b/src/REPLICA/fix_alchemy.h index ea342fa0ea..86c58a7b78 100644 --- a/src/REPLICA/fix_alchemy.h +++ b/src/REPLICA/fix_alchemy.h @@ -34,6 +34,7 @@ class FixAlchemy : public Fix { void setup(int) override; void post_integrate() override; void post_force(int) override; + double compute_scalar() override; double compute_vector(int) override; void *extract(const char *, int &) override;