The new accelerate facility HIAF is under constructing in IMP (Institute of Modern Physics), Chinese Academy of Sciences. It consists of a linac, a booster of BRing and a spectrometer ring of SRing and some terminals for experiments. The electron cooling technology is applied in the SRing, which is composed of solenoids and racetrack coils. In this paper, the magnetic field of the electron cooler is simulated and article trajectories are displayed. Because of the long evacuated tube for cooling section, different type of drift solenoids are optimized to connect the two 3.5m solenoids to ensure the field fluctuation within 20Gauss.