I do understand about the options for PPPM and appreciate how you can
control things with those options for PPPM. However, I'd like to first get
Ewald going as I want to compare to Ewald in another code. I can play with
the cutoff and this would allow me to change the # of vectors and whatever
g_ewald corresponds to. However the cutoff for the electrostatics would
also change the short range Coulomb term would it not?
Yes.
So, then my question becomes, how do the lammps parameters g_ewald and the
vectors that are outputted correspond to kappa and kmax (as written in any
standard solid state physics book as the manual states).
Does kappa in the Ewald equations (as written in any standard solid state
physics book) = g_ewald in ewald.cpp?
Yes. I'd have to look at the same equations you're looking at to be sure. If you look at eqns 4, 5, and 6 of JCP 109, pg 7679, LAMMPS's g_ewald corresponds to the alpha parameter there. I've seen this Ewald parameter written as alpha or kappa typically in the literature.
Then does kmax (as written in any standard solid state physics book) = the
1d vector as printed in the vector line in the output?
Yes. Again, assuming that equations you're looking at are the same as those I'm looking at, kmax is the value you should be using. Looking at Ewald::eik_dot_r(), you'll see that LAMMPS uses kmax as the summation limit in each dimension.
My real question is that I don't understand what g_ewald means in LAMMPS and
what the vectors outputted mean (i.e., what they correspond to in the Ewald
equations).
You'll want to use g_ewald (the Ewald parameter that divides real and reciprocal space) and kmax (the reciprocal space vector length in each dimension) for comparison with other codes.
Like I said, with a cutoff of 14.0 angstroms (VDW and Electrostatics) I'm
getting 0.3 error between the two codes and with a cutoff of 25\.0
angstroms \(half the box I'm using\) I'm getting 0\.02 difference. However,
I really just want to (1) make sure that the other code is correct and (2)
want to use the same parameters so I can compare results to make sure I am
correctly comparing data between the two.
Note that there is a boundary condition energy term that might be different between the two codes. (See eqn 7 of JCP 109, pg 7679.) If your system is not net neutral, you'll have to make sure that these extra terms are the same in both codes. LAMMPS uses the following energy correction for systems that are not net neutral:
-0.5*PI*qsum*qsum / (g_ewald*g_ewald*volume)
I'd like to compare both codes with the same kappa, kmax, and cutoff. Then
I think I should be getting exactly the same result for the total energy
(within the precision of conversion factors, etc.)
The user usually specifies the cutoff and the precision, from these numbers, LAMMPS computes (kappa = g_ewald) using this simple heuristic:
g_ewald = (1.35 - 0.15*log(precision))/cutoff;
Alternatively, you can set g_ewald from the input deck using the kspace_modify command.
Then kmax is computed like this:
// determine kmax
// function of current box size, precision, G_ewald (short-range cutoff)
int nkxmx = static_cast<int> ((g_ewald*xprd/PI) * sqrt(-log(precision)));
int nkymx = static_cast<int> ((g_ewald*yprd/PI) * sqrt(-log(precision)));
int nkzmx = static_cast<int> ((g_ewald*zprd_slab/PI) * sqrt(-log(precision)));
int kmax_old = kmax;
kmax = MAX(nkxmx,nkymx);
kmax = MAX(kmax,nkzmx);
As you've noted, LAMMPS prints kmax to the screen for you:
fprintf(screen," vectors: actual 1d max = %d %d %d\n",kcount,kmax,kmax3d);
(It's the second number printed in that line.)
That gives you kappa, kmax, and cutoff, so you should be able to get exact agreement between two codes if these parameters are the same.
Paul