Interaction of hadrons with electron beam in a modulator is an important part of coherent electron cooling (CeC), a novel cooling method for hadron beams. Being an untested technique, the CeC is undergoing a proof-of-principle test at Brookhaven National Laboratory (BNL). Simulation of this process for a realistic electron beam propagating through a realistic quadrupole beamline constitutes a very challenging problem. We successfully used the code SPACE for these simulations and obtained accurate dependences of the modulation process on the position and velocity of ions. We obtained good numerical convergence of simulations and performed verification tests using theoretical predications available for a uniform infinite plasma with κ − 2 velocity distribution. In this paper, we describe simulation methods and results, and report our findings for the CeC modulator in the BNL experiment.