Modeling of liquid water and ionic solutions by first-principles simulations