def xyz_rdf(name): os.chdir( '/home/jinho93/oxides/cluster/zno/cp2k/1.aimd/3.16A/30/3.fix/2.again') mole = IMolecule.from_file('tail.xyz') # mole = IMolecule.from_str(out, fmt='xyz') s = mole.get_boxed_structure(1.6027345000000000E+01, 1.6671211000000000E+01, 6.0678892000000005E+01) structures = [s] ind = [] ref = [] print(name) for i, sp in enumerate(s.sites): print(sp.z) up = .7 down = .66 if sp.species_string == name and up > sp.c > down: ind.append(i) elif sp.species_string == 'O' and up + 0.05 > sp.c > down - 0.05: ref.append(i) r = RadialDistributionFunction(structures, ind, reference_indices=ref, ngrid=301, sigma=.1) print(r.peak_r[0]) r.get_rdf_plot(plt=plt, ylim=[-0.005, max(r.rdf)], label=f'{name}-ref') r.export_rdf('rdf.dat') plt.show()
def xdat_rdf_speices(name): import matplotlib.pyplot as plt from pymatgen_diffusion.aimd.van_hove import RadialDistributionFunction s = Xdatcar('XDATCAR').structures[-1:] ind = [] ref = [] for i, sp in enumerate(s[0].species): if sp.name == name: ind.append(i) elif sp.name == 'O': ref.append(i) r = RadialDistributionFunction(s, ind, reference_indices=ref, ngrid=501, sigma=.1) print(r.peak_r[0]) r.get_rdf_plot(plt=plt, ylim=[-0.005, max(r.rdf)], label=f'{name}-ref') r.export_rdf('/home/jinho93/rdf.dat') plt.show()
import os import numpy as np from pymatgen.io.vasp import Xdatcar from pymatgen_diffusion.aimd.van_hove import RadialDistributionFunction, plt from pymatgen import Structure if __name__ == '__main__': structure = Structure.from_file('POSCAR') num = 4 fig = plt.figure(0) output = np.zeros((201, num)) output[:, 0] = np.linspace(0.0, 10, 201) for c in range(num - 1): oxy = [] for i, j in enumerate(structure.sites): if j.species_string == "O" and c / num < j.c < (c + 1) / num: oxy.append(i) zn = [] for i, j in enumerate(structure.sites): if j.species_string == "Zn": zn.append(i) ax = fig.add_subplot(221 + c) rdf = RadialDistributionFunction([structure], oxy, zn, ngrid=201) rdf.get_rdf_plot(ylim=(0, max(rdf.rdf))) output[:, c + 1] = rdf.rdf np.savetxt('output.dat', output) plt.show()