Material ScienceAlgorithm accurately predicts how electromagnetic waves and magnetic materials interact