Experimental and theoretical study of the behavior of hydrogen in rare earths