Optimizing the magnetic properties of hard and soft materials for producing exchange spring permanent magnets