An ab initio model to study oxygen ordering in the high temperature su
perconductor YBa2Cu3Oz is presented. The phase diagram computed with t
his model contains several ordered structures and is in excellent agre
ement with the known experimental information. At high temperature, an
orthorhombic structure transforms by a second order reaction into a t
etragonal structure. At low temperature, a branching algorithm generat
es an infinity of ordered structures all consisting of long O-Cu-O cha
ins. By looking at the kinetic evolution of quenched samples in a Mont
e Carlo simulation it was possible to clarify how annealing of the mat
erial can influence its superconducting transition temperature.