Hamiltonian model of capture into mean motion resonance