Whole Powder Pattern Modelling: theory and application