Hi Chris,
a few comments on your input:
1. WHOLEMOLECULES ENTITY0=1-4857
If you just need it to compute the following:
protein: COM ATOMS=1-4857
then you can remove it. WHOLEMOLECULES is not required (plumed does it on the fly since v2.2 when you compute the COM).
2. COM with 5000 atoms
This will slow down your simulation. Replace it with something like 1-4857:20 or better pick a set of meaningful atoms (I suggest all calpha, you can do it with a script).
3. dz: COMBINE ARG=distz.z PERIODIC=neghalfboxz,halfboxz
Domain should be defined in terms of constants. The quick trick is to set it by hand to the its typical value (e.g. -5,+5 if z dimension is ~10nm). However, this will introduce discontinuities on the distance when the sodium is at a distance close to +5 or -5. If you are 100% sure this will never happen (e.g. since you are using a wall to limit the exploration of the ion) you can ignore this warning and proceed. Otherwise the only solution is to use SCALED_COMPONENTS.
4. dz: MATHEVAL ARG=dist.c,cell.cz FUNC=x*y PERIODIC=NO
This is correct if you want to compute the value of dz to monitor it. However, if you apply a force on it (e.g. with walls or metad) you will still be in trouble. You are forcing plumed to assume that dz is not periodic, but actually it has a periodicity of neghalfboxz,halfboxz, and non-constant periodicities are not supported.
If you want to use the z position as an argument to a bias, you should use directly dist.c, which has period -0.5,+0.5.
If you don't like working with unitless variables (e.g. in METAD you want to set SIGMA in nanometers) you can (approximately) convert it to nm with COMBINE:
dz: COMBINE ARG=dist.c COEFFICIENTS=XXX PERIODIC=-YYY,YYY
where XXX is a precomputed typical value of cell.cz and YYY half of it. In an NPT simulation the actual value is going to fluctuate by max 1%. Notice that no discontinuity will be introduced in this way. The only artefact is that you will think distance is say 0.5 nm and it will be 0.505. Not a big problem.
Hope this helps.
Giovanni