计算化学公社

标题: 如何可以根据静电能创造空位,用pymatgen [打印本页]

作者
Author:
ZizhenZhou    时间: 2021-7-14 13:40
标题: 如何可以根据静电能创造空位,用pymatgen
如题请教各位大神, 小弟想在Li1.2Ni0.2Mn0.6O2的结构中删除10%,20% 的Li元素。
之前曾经用pymatgen搞过元素按比例替换并且可以按照静电能排序,于是想用相同的理念搞一些空位出来,可以pymatgen用的真的不熟练很痛苦,特此求教。能有同样作用的其他办法也希望大神不吝赐教。

作者
Author:
乘风万里    时间: 2021-7-16 15:41
本帖最后由 乘风万里 于 2021-7-16 16:39 编辑
  1. import random
  2. from pymatgen import Structure

  3. path = 'xxxx'
  4. struct = Structure.from_file(path + 'mp-771112.cif')
  5. remove_rate = 0.2

  6. print(struct)

  7. li_index = []
  8. for i,j in enumerate(struct.sites):
  9.     if j.species_string == 'Li':
  10.         li_index.append(i)

  11. remove_index = random.sample(li_index, int(len(li_index)*remove_rate + 0.5))
  12. struct.remove_sites(remove_index)
  13. print(struct)

  14. struct.to(filename=path+'edited.cif')
复制代码



我从materials project 下了 Li2Mn3NiO8 晶胞 (mp-771112),写了点code。这个原胞里有8个Li,20%浓度删除2个Li(近似值)。
需要更低或者精确的浓度的话直接用pymatgen Structure 类的 make_supercell method 扩胞,选好扩胞的矢量(3x3 scaling matrix)就能按精确的浓度删除Li。
都是小脚本,没啥难度。



作者
Author:
ZizhenZhou    时间: 2021-7-18 08:04
大神方便留个邮箱或者微信号吗
作者
Author:
乘风万里    时间: 2021-7-23 11:01
ZizhenZhou 发表于 2021-7-18 08:04
大神方便留个邮箱或者微信号吗

有问题请发帖或者站内私信。
作者
Author:
robert    时间: 2021-7-26 22:02
最近也在学习pymatgen,请教您之前做的,用pymatgen搞过元素按比例替换并且可以按照静电能排序,这个是怎么实现的啊,特别是静电能这一块,希望赐教~
作者
Author:
ZizhenZhou    时间: 2021-7-27 20:43
robert 发表于 2021-7-26 22:02
最近也在学习pymatgen,请教您之前做的,用pymatgen搞过元素按比例替换并且可以按照静电能排序,这个是怎么 ...

from pymatgen.analysis.adsorption import *
from pymatgen.core.surface import Slab, SlabGenerator, generate_all_slabs, Structure, Lattice, ReconstructionGenerator
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from pymatgen.core.structure import Structure
from pymatgen.ext.matproj import MPRester
from matplotlib import pyplot as plt
from pymatgen.io.vasp.inputs import Poscar
from pymatgen.io.cif import CifParser, CifWriter
from pymatgen.transformations.standard_transformations import SubstitutionTransformation, OrderDisorderedStructureTransformation, SupercellTransformation
import os
from pymatgen.analysis.defects.core import Defect
#mp_id = "mp-551830"
#struct = mpr.get_structure_by_material_id(mp_id)
filename = './CONTCAR.cif'
parser = CifParser(filename)
init_structure = parser.get_structures(primitive =False)[0]


# add oxidation states to the structure
data = {"Li":+1, "Mn":+3, "O":-2}
init_structure.add_oxidation_state_by_element(data)

# substitute to get the partial occupancied structure
species_map = {"Mn3+":{"Li1+":0.185, "Ni2+":0.185, "Mn4+":0.63}}
substitutuin = SubstitutionTransformation(species_map)
structure = substitutuin.apply_transformation(init_structure)


sc = SupercellTransformation().from_scaling_factors(4,4,1)
structure = sc.apply_transformation(structure)
#structure.make_supercell([[3,0,0],
#                          [0,3,0],
#                          [0,0,1]])

print(structure)
order = OrderDisorderedStructureTransformation()
standard_structures = order.apply_transformation(structure,return_ranked_list=10000)
print('done')

i = 1
for s in standard_structures:
    cif = CifWriter(s['structure'])
    cif.write_file('./2/structure_{:0>3d}.cif'.format(i))
    i+=1
    print(i)



这是我用的代码,希望能办上忙
作者
Author:
robert    时间: 2021-7-29 12:28
本帖最后由 robert 于 2021-7-29 12:30 编辑
ZizhenZhou 发表于 2021-7-27 20:43
from pymatgen.analysis.adsorption import *
from pymatgen.core.surface import Slab, SlabGenerator, ...

十分感谢!我研究一下,跑跑试试。老哥可以加个联系方式吗~
作者
Author:
ZizhenZhou    时间: 2021-8-3 14:58
跟随楼上大神,站内说吧
作者
Author:
royluo    时间: 2022-1-19 14:16
ZizhenZhou 发表于 2021-7-27 20:43
from pymatgen.analysis.adsorption import *
from pymatgen.core.surface import Slab, SlabGenerator, ...

您好,按照您这个代码生成的结构好像没有独立对称性,会产生很多在对称性上重复的结构.....请问这个要在pymatgen里面加哪个模块来筛选对称独立的结构呢,谢谢!




欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3