adding resid to state mapping for solver