LDIM determines the maximum number of reference-energies and l-quantum numbers (i.e. pairs) for the non-local projection operators, and LMDIM the maximum number of reference-energies and lm-quantum numbers (i.e. triplets).
For conventional norm conserving pseudopotentials the number of reference-energies per l-quantum number is one. The local pseudopotential is usually the d-pseudopotential. Therefore, non-local projection operators for s and p are included in the pseudopotential file POTCAR and LDIM should be 2 and LMDIM 4=1+3 (i.e. 1s and 3p projector). The OUTCAR file contains information about the necessary setting. At the startup of VASP the pseudopotential are read in and information about the progress is written out:
POTCAR: Ge: VAN Valenz: 4.000 local pseudopotential read in atomic valenz-charges read in non local Contribution for L= 0 read in real space projection operators read in non local Contribution for L= 2 read in real space projection operators read in number of l-projection operators is LMAX = 2 (set LDIM) number of lm-projection operators is LMMAX = 6 (set LMDIM) number of augmentation charges -1 (set LDIM2)The values shown for LMAX (LMMAX) can be used for LDIM (LMDIM).
The explicit formula for LDIM2 should not be changed and is correct, unless the program is linked with us2.f instead of us.f. In principle The module us2.f performs the same tasks as us.f but allows a better optimization of the augmentation charges. Nevertheless the pseudopotential generation program does not support this improved optimization at the moment, therefore, there is no reason to use us2.f.
The same holds for LMYDIM, as long as you use the module us.f simply set LMYDIM to 9=1+3+5.