With the aim of establishing a relationship between the electronic structur
e and the site occupancy within the Cu-O chains, we perform total energy ca
lculations for the sub-stoichiometric compound YBa2Cu3O6.5 for various patt
erns of vacancy ordering. Supercells containing up to four formula units ar
e considered. The effective interactions of O(1) atoms are extracted from t
he total energies by means of the cluster expansion technique. The most sta
ble configuration is found to be the experimentally observed ortho-ii struc
ture. This finding is confirmed by Monte-Carlo simulations for a rigid latt
ice using the pair interactions. Thermal disorder effects are studied. The
influence of vacancy ordering on the total and partial densities of states
is discussed.