Understanding the photomagnetic behavior in copper octacyanomolybdates