Computer modelling techniques have been employed to qualitatively and quantitatively investigate the uptake and distribution of carbonate groups in the hydroxyapatite lattice. Two substitutional defects are considered: the type-A defect, where the carbonate group is located in the hydroxy channel, and the type-B defect, where the carbonate group is located at the position of a phosphate group. A combined type A-B defect is also considered and different charge compensations have been taken into account. The lowest energy configuration of the A-type carbonate has the O-C-O axis aligned with the channel in the c-direction of the apatite lattice and the third oxygen atom lying in the a/b plane. The orientation of the carbonate of the B-type defect is strongly affected by the composition of the apatite material, varying from a position (almost) flat in the a/b plane to being orientated with its plane in the b/c plane. However, Ca-O interactions are always maximised and charge compensating ions are located near the carbonate ion. When we make a direct comparison of the energies per substitutional carbonate group, the results of the different defect simulations show that the type-A defect where two hydroxy groups are replaced by one carbonate group is energetically preferred (DeltaH = -404 kJ mol(-1)), followed by the combined A-B defect, where both a phosphate and a hydroxy group are replaced by two carbonate groups (DeltaH = -259 kJ mol(-1)). The type-B defect, where we have replaced a phosphate group by both a carbonate group and another hydroxy group in the same location is energetically neutral (DeltaH = -1 kJ mol(-1)), but when the replacement of the phosphate group by a carbonate is charge compensated by the substitution of a sodium or potassium ion for a calcium ion, the resulting type-B defect is energetically favourable (DeltaH(Na) = -71 kJ mol(-1),DeltaH(K) = -6 kJ mol(-1)) and its formation is also promoted by A-type defects present in the lattice. Our simulations suggest that it is energetically possible for all substitutions to occur, which are calculated as ion-exchange reactions from aqueous solution. Carbonate defects are widely found in biological hydroxy-apatite and our simulations, showing that incorporation of carbonate from solution into the hydroxyapatite lattice is thermodynamically feasible, hence agree with experiment.