Numerical and theoretical modeling of the sheath upstream of ion optics: sheath structure transition and its effect on the beam divergence. (8th July 2021)