The hard X-ray performance of pixelated CdTe-based detectors using Monte Carlo and ab initio simulations