Fully coupled photochemistry of the deuterated ionosphere of Mars and its effects on escape of H and D