Combined first-principles and model Hamiltonian study of the perovskite series RMnO3 (R = La,Pr,Nd,Sm,Eu, and Gd)