Pppm parameters (gewald, mesh) with slab

I have a question on correctly choosing the parameters for the pppm method when running with boundary ppf and kspace_modify slab.

Currently, I use:

boundary p p f
kspace_style pppm/electrode 1.0e-6
kspace_modify slab 3.0

and let LAMMPS decide on gewald and the mesh. However, I am astonished about the choice that Lammps makes. What I get is the following:

G vector (1/distance) = 0.33944558
grid = 45 48 270
stencil order = 5

However, my system has a size of about 28 29 106 and consists of two metal slabs on top and bottom and water in between. Since I use kspace_modify slab 3.0, I would have expected a grid that is more or less proportional to 28 29 3*106 as the particle density (at least in the water, which makes up the largest part of the cell, is the same in x, y and z). I would therefore expect something like 45, 48, 512.

I looked into the code to try to figure out what Lammps actually does to set the parameters, but it did not really want to become clear to me what lammps does exactly.

So my question boils down to: Are the automatic estimates for the grid reliable when using kspace_modify slab, or is the estimated grid parameter in z artificially low, because the average particle density is artificially reduced in z?

Thank you for your help!

Kspace error is not directly proportional to box length, but rather a non-linear function. See https://aip.scitation.org/doi/10.1063/1.477415, Eq. 38. This is coded up in LAMMPS here: https://github.com/lammps/lammps/blob/e902b7a8f1e7dfc315200405c6bc703fef743a69/src/KSPACE/pppm.cpp#L1262-L1264, where prd is the box length.

Dear Stan,
Thank you for your answer. I can now indeed see that LAMMPS (correctly) uses zprd_slab = zprd*slab_volfactor for the z-dimension when computing the grid. I also read through the paper (Thanks for pointing me there!). That made me wonder, however, how justified it is to choose different grid spacings in x,y and z, as the paper derives the expressions for a cubic box. It did not become 100% clear to me whether a larger grid spacing in z could not influence the error of the force in x and vice versa. Did anybody ever derive the error in the force for a non-cubic box?
Thank you again for your help!

It should work fine for non-cubic boxes. I have tested for triclinic with difference skew factors. If you want to test for yourself, you can use a highly refined Ewald sum as the “ground truth” and compare that to what you get with PPPM.