From 6b6f8087d3deaa7bcd3e8019d107d27cd90a885b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 11 Mar 2023 17:45:38 -0500 Subject: [PATCH] output potential energy with fix efield with equal style variables --- src/fix_efield.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fix_efield.cpp b/src/fix_efield.cpp index 99482f8459..9d54ccb848 100644 --- a/src/fix_efield.cpp +++ b/src/fix_efield.cpp @@ -273,12 +273,12 @@ void FixEfield::post_force(int vflag) double **x = atom->x; double fx, fy, fz; - double v[6]; + double v[6], unwrap[3]; + ; // constant efield if (varflag == CONSTANT) { - double unwrap[3]; // charge interactions // force = qE, potential energy = F dot x in unwrapped coords @@ -385,7 +385,12 @@ void FixEfield::post_force(int vflag) } f[i][2] += fz; fsum[3] += fz; - if (estyle == ATOM) fsum[0] += efield[0][3]; + if (estyle == ATOM) { + fsum[0] += efield[0][3]; + } else { + domain->unmap(x[i], image[i], unwrap); + fsum[0] -= fx * unwrap[0] + fy * unwrap[1] + fz * unwrap[2]; + } } }