Magnetism and Structure in Functional Materials