Molecular equilibria and condensation in a solar nebula and cool stellar atmospheres