Start with two gene loci in perfect linkage disequilibrium and let recombination break the haplotypes apart, generation after generation. Change map distance, allele frequencies and population size to see D shrink as (1-r) per generation while genetic drift keeps a random residue of r-squared. A Blender-built chromosome population coloured by allele, with numerical checks of the linkage formulas.