Enclosed quantum systems: use of the direct variational method