Quantum mechanical simulations of water and ammonia molecules and their clusters