Exemplo n.º 1
0
 def test_redf(self):
     d = ElectronicRadialDistributionFunction().featurize(
         self.diamond)[0]
     self.assertAlmostEqual(int(1000 * d["distances"][0]), 25)
     self.assertAlmostEqual(int(1000 * d["distribution"][0]), 0)
     self.assertAlmostEqual(int(1000 * d["distances"][len(
         d["distances"]) - 1]), 6175)
     self.assertAlmostEqual(int(1000 * d["distribution"][len(
         d["distances"]) - 1]), 0)
     d = ElectronicRadialDistributionFunction().featurize(
         self.nacl)[0]
     self.assertAlmostEqual(int(1000 * d["distances"][0]), 25)
     self.assertAlmostEqual(int(1000 * d["distribution"][0]), 0)
     self.assertAlmostEqual(int(1000 * d["distances"][56]), 2825)
     self.assertAlmostEqual(int(1000 * d["distribution"][56]), -2108)
     self.assertAlmostEqual(int(1000 * d["distances"][len(
         d["distances"]) - 1]), 9875)
     d = ElectronicRadialDistributionFunction().featurize(
         self.cscl)[0]
     self.assertAlmostEqual(int(1000 * d["distances"][0]), 25)
     self.assertAlmostEqual(int(1000 * d["distribution"][0]), 0)
     self.assertAlmostEqual(int(1000 * d["distances"][72]), 3625)
     self.assertAlmostEqual(int(1000 * d["distribution"][72]), -2194)
     self.assertAlmostEqual(int(1000 * d["distances"][len(
         d["distances"]) - 1]), 7275)
Exemplo n.º 2
0
from matminer.featurizers.structure import ElectronicRadialDistributionFunction
import numpy as np 

cen_structures=np.load('centrosymmetric_insulators.npy',allow_pickle=True)
cen_redf=[]

non_cen_structures=np.load('non_centrosymmetric_insulators.npy',allow_pickle=True) 
non_cen_redf=[]

#create redf representations
redf = ElectronicRadialDistributionFunction()
redf.set_n_jobs(28)

redf.fit(cen_structures)
for item in cen_structures: 
	cen_redf.append(redf.featurize(item))
np.save('centrosymmetric_redf_representation.npy',cen_redf)


redf.fit(non_cen_structures)
for item in non_cen_structures:
	non_cen_redf.append(redf.featurize(item))
np.save('non_centrosymmetric_redf_representation.npy',non_cen_redf)
namecolumns = ['structure']
for i in CIFfiles:
    structlist.append([Structure.from_file(directoryname + i)
                       ])  #Converts CIF to pymatgen structure object
    namelist.append(os.path.splitext(i)[0])  #Collects all the structure names
    structs.append(Structure.from_file(directoryname + i))
#Creates Pandas dataframe with data being a list of structures and the row name being the structure name
dftest = pd.DataFrame(data=structlist, index=namelist, columns=namecolumns)

p = PartialRadialDistributionFunction()
p.fit(np.asarray(structs))

c = CoulombMatrix()
c.fit(np.asarray(structs))

erdf = ElectronicRadialDistributionFunction()
erdf.cutoff = 10  #longest diagonal of lattice...I picked a number semi-arbitrarily

#Featurizes the structures
featurizer = MultipleFeaturizer([
    ElementProperty.from_preset('magpie'),
    OxidationStates(),
    AtomicOrbitals(),
    BandCenter(),
    ElectronegativityDiff(),
    DensityFeatures(),
    RadialDistributionFunction(), p, c, erdf
])

r = (featurizer.featurize_many(dftest, ['structure'])
     )  #Featurizes entire Pandas Dataframe