Multiscale modeling of heterogeneous magnetic materials