  In experiments searching for a nonzero electric dipole moment of trapped
particles, frequency shifts correlated with an applied electric field can be
interpreted as a false signal. One such effect, referred to as the geometric
phase effect, is known to occur in a magnetic field that is nonperfectly
homogeneous. The increase in sensitivity of experiments demands improved
theoretical description of this effect. In the case of fast particles, like
atoms at room temperature and low pressure, the validity of established
theories was limited to a cylindrical confinement cell in a uniform gradient
with cylindrical symmetry. We develop a more general theory valid for an
arbitrary shape of the magnetic field as well as for arbitrary geometry of the
confinement cell. Our improved theory is especially relevant for experiments
measuring the neutron electric dipole moment with an atomic comagnetometer. In
this context, we have reproduced and extended earlier numerical studies of the
geometric phase effect induced by localized magnetic impurities.
