Magnetism and structure in functional alloys