Skip to content

Removed triclinic restrictions on slab ewald/pppm.#411

Closed
frobnitzem wants to merge 1 commit into
lammps:masterfrom
frobnitzem:master
Closed

Removed triclinic restrictions on slab ewald/pppm.#411
frobnitzem wants to merge 1 commit into
lammps:masterfrom
frobnitzem:master

Conversation

@frobnitzem

Copy link
Copy Markdown
Collaborator

Since the slab correction applies specifically to the z-direction, it is not influenced by tilt. I have confirmed the correction by calculating it manually for a system with 2 charges (+1 at 0,0,1.5 and -1 at 0.0,-1.5). The files are attached:

ewtest.zip

Four cases are tested -- an orthogonal and a triclinic box with and without the slab correction.
Although changing the box tilt alters the energies and forces, the correction term is identical for both, as it should be.

@stanmoore1

stanmoore1 commented Mar 11, 2017

Copy link
Copy Markdown
Contributor

Unfortunately, it isn't this simple. This PR fails the most basic sanity check. An orthogonal box should give the same energy and force as a triclinic box when all the tilt factors are equal to 0.0, since the triclinic box isn't really tilted. However, if I add this line below to an input script using this PR I get significantly different forces and energies than the orthogonal case:

change_box all triclinic xy final 0.0 xz final 0.0 yz final 0.0

A second good check for triclinic systems is that when there are periodic boundary conditions in x and y, the system energy and force for an orthogonal box will match a triclinic box with tilt factors xy = Ly and xz = Lz, where Ly is the total box length in the y direction and Lz is the total box length in the z direction, i.e.:

change_box all triclinic xy final ${Ly} xz final ${Lz} yz final 0.0

A third good check for kspace slab systems is that this input script and data file (attached below) give the analytic solution of forces in magnitude equal to pi (3.14159...), see the book Understanding Molecular Simulation, Frenkel and Smit, p. 318:

data.two.txt
in.test.txt

@stanmoore1

Copy link
Copy Markdown
Contributor

For the Kspace slab analytic solution, just place two oppositely charged particles in a slab system. They form two infinite sheets of charge due to periodic boundary conditions in the x and y directions. If the charges are far apart enough in the z-direction, the force in the z-direction for the orthogonal case converges to 2*pi*q^2/(Lx*Ly)

@stanmoore1

Copy link
Copy Markdown
Contributor

Sorry, in the above post that should be tilt factor = 0.0, not 1.0. I've edited the post above. If I run the script I attached with a pure orthogonal box, I get an energy = 6.5933251. If I run it with triclinic and all zero tilt factors, I get an energy = 2.6182985. The energies should match in these two cases but don't.

@frobnitzem

frobnitzem commented Mar 12, 2017 via email

Copy link
Copy Markdown
Collaborator Author

@akohlmey

Copy link
Copy Markdown
Member

i looked into this a little bit today. turns out, the slab correction does work correctly with the provided modification, but that is not the origin of the difference. the issue is, that activating the slab correction changes the volume of the cell and that means, that all computations done before applying the slab correction, need to account for that correctly, and that is where things get a bit complicated, since for triclinic cells, all of those computations are done in lamda coordinates.
thus i will close this pull request as "invalid" for now, and we only keep issue #410 as a reminder to look into it, when somebody has the time.

@akohlmey akohlmey closed this Mar 29, 2017
akohlmey added a commit to akohlmey/lammps that referenced this pull request Jun 17, 2026
The force-style YAML tests (kspace-*_tri_slab.yaml) exercise the pair+kspace
force in a triclinic slab box, but they never invoke "compute group/group",
whose own slab correction (KSpace::slabcorr_groups) was separately enabled for
triclinic cells when EW3DC was generalized to non-orthogonal boxes.

This adds unittest/commands/test_kspace_group_group_slab.cpp, a GoogleTest that
builds the two-charged-sheet reproducer from lammps#411 (charges +/-1 in
a box periodic in x,y and non-periodic in z, Lx=1 Ly=2) and checks the
group A <-> group B interaction for ewald and pppm:

  - the orthogonal reference matches the analytic infinite-sheet result,
    z force = 2*pi*q^2/(Lx*Ly) = pi and energy = 2*pi*q^2*d/(Lx*Ly) = 5*pi;
  - the triclinic xy-tilted box reproduces the orthogonal result (Ewald to ~1e-13,
    PPPM within mesh tolerance), confirming the triclinic group/group slab path.

Verified passing on 1, 2, and 4 MPI ranks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants