I am trying to calculate the coulomb energy of one atom (Na+) in a box under 3D periodic boundary(including long-range coulomb), but the “compute pe” command output a obviously wrong answer(negative value). I know it’s because of “Ksapce”, so how can I get a right value under 3D periodic boundary?

The “correct” energy coulomb energy for a single Na+ atom under periodic boundary conditions cannot be computed numerically. But simple consideration will tell you that it has to be “infinity”. You can confirm that by using pair style coul/cut and systematically increasing the cutoff: the coulomb energy will grow as you increase the cutoff.

In fact, any periodic system with a net charge in the unit cell will show that behavior.

Long-range coulomb solvers will ignore that divergent term due to the net charge when computing interactions and thus compute values for an artificially neutralized system and that is what you see. Publications often describe that as “applying a neutralizing jellium”. Hence the warning that long-range solvers in LAMMPS will print when the system is not neutral.