def from_abinit_ixc(cls, ixc): """Build the object from Abinit ixc (integer)""" if ixc >= 0: return cls(**cls.abinitixc_to_libxc[ixc]) else: # libxc notation employed in Abinit: a six-digit number in the form XXXCCC or CCCXXX #ixc = str(ixc) #assert len(ixc[1:]) == 6 #first, last = ixc[1:4], ixc[4:] ixc = abs(ixc) first = ixc // 1000 last = ixc - first * 1000 x, c = LibxcFunc(int(first)), LibxcFunc(int(last)) if not x.is_x_kind: x, c = c, x # Swap assert x.is_x_kind and c.is_c_kind return cls(x=x, c=c)
def from_abinit_ixc(cls, ixc): """Build the object from Abinit ixc (integer)""" ixc = int(ixc) if ixc == 0: return None if ixc > 0: return cls(**cls.abinitixc_to_libxc[ixc]) # libxc notation employed in Abinit: a six-digit number in the form XXXCCC or CCCXXX ixc = abs(ixc) first = ixc // 1000 last = ixc - first * 1000 x, c = LibxcFunc(int(first)), LibxcFunc(int(last)) if not x.is_x_kind: x, c = c, x # Swap assert x.is_x_kind and c.is_c_kind return cls(x=x, c=c)
def test_libxcfunc_api(self): """Testing libxcfunc_api.""" # LDA correlation: Hedin & Lundqvist xc = LibxcFunc.LDA_C_HL print(xc) assert not xc.is_x_kind and xc.is_c_kind and not xc.is_xc_kind assert xc.is_lda_family and not xc.is_gga_family print(xc.info_dict) assert xc.family in LibxcFunc.all_families() assert xc.kind in LibxcFunc.all_kinds() # Test if object can be serialized with Pickle. self.serialize_with_pickle(xc, test_eq=True) # Test if object supports MSONable self.assertMSONable(xc, test_if_subclass=False)