very thick SrTiO$_3$ substrates, this pure surface state should be avoided when simulating the SrTiO$_3$ substrate and thick SrTiO$_3$ capping layers. However, for thin SrTiO$_3$ capping layers, the presence of this O-$p$ state on the TiO$_2$-terminated surface will lower the critical separation, which has recently been discussed [@Pentcheva-2009].

![\[fig:interface\] Schematics of [the supercells]{} and energy diagrams for different types of interfaces. **a)** The $np$-type interface. **b)** The $n$-type interface. **c)** The $p$-type interface. **d)** The new quantum well systems.](fullconfig.ps){width="13cm"}

We observe that an insulating-to-metallic transition occurs in our simulations when the [LaAlO$_3$ ]{}film reaches a critical thickness, the value of which depends on the system geometry. The phase transition can be explained in terms of an energy diagram shown in Fig. \[fig:interface\]. For the $np$-type and $n$-type interfaces, due to the polar structure of LaAlO$_3$, the electric field through the LaAlO$_3$ film lifts up the valence band edge of the LaAlO$_3$ and reduces the energy gap. The energy gap of the $np$-type interface is the energy difference between the Ti-$d$ states of the SrTiO$_3$ substrate and the O-$p$ states of the SrTiO$_3$ capping layer, while the energy gap of the $n$-type interface is given by the energy difference between the 