Computational design of magnetic metal-organic complexes and coordination polymers with spin-switchable functionalities