Seems we need to double-check that tutorial a bit. Thanks for reading and trying it, and for reporting the issues.
To work around the issue (a more general solution will be provided later), insert 2 lines after the "nlread" line:
n_up = n_u[:,:,:]
n_dn = n_d[:,:,:]
After that, you should be able to use
r = (n_up - n_dn)/(n_up + n_dn + 1e_19)
(I added a small infinitesimal for safety, to avoid division by zero.)
Same solution applies to both scripts.
However, it will not be possible to save the computed polarization grid in an NCFile, so the "nlsave" line must be removed; you will have to be content with the picture in the manual, for now :)
Ok, here's how to do the isosurface in 10.8.
(n_u,n_d) = nlread('density.nc', ElectronDensity)
n_up = n_u[:,:,:].inUnitsOf(n_u.unit())
n_dn = n_d[:,:,:].inUnitsOf(n_d.unit())
n = (n_up - n_dn)/(n_up + n_dn + 1e-19)
# Overwrite values in n_u with the difference density
import NLEngine
n_u._GridValues__grid3d = NLEngine.RealGrid3D(n_u._GridValues__grid3d.gridDescriptor(), \
NLEngine.doubleSequenceToRealVector(n.flatten()))
# Save it!
nlsave('diff.nc', n_u, object_id="Spin Polarization Density")
This will not be part of the official tutorial, we will temporarily remove it for 10.8, but it will be possible to do it in 11.2 - just like the current tutorial states.