Numerical modelling of the motion of a dense electron bunch in an inhomogeneous structure