日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python库读取cif文件_Pymatgen读/写各种文件,pymatgen,读写

發布時間:2023/12/10 python 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python库读取cif文件_Pymatgen读/写各种文件,pymatgen,读写 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

pymatgen讀/寫各種文件

pymatgen是材料大數據計算的必備程序包了,其也作為API與materials project對接,可以批量下載自己想要的材料結構、性質,它也提供了大量VASP計算后的數據處理、計算,堪稱材料基因組學的神器!

pymatgen提供了讀取CIF、json、POSCAR、CONTCAR等文件的程序,可以批量讀取、轉化、另存。不過,作為初學者,里面很多功能是很難理解的,特別是對python語言不熟的同學。

1. pymatgen讀取json文件,轉化為Structure對象,并保存為CIF文件

from pymatgen import Structure, Lattice, MPRester, Molecule

import json

from pymatgen.io.cif import CifWriter

# 如果只有一個結構

#data_file = open("../db-1.json", "r")

#all_structures = data_file.readlines()

#structure = json.loads(all_structure)["structure"]

structure = Structure.from_dict(structure)

c = CifWriter(structure)

c.write_file("1.cif")

# 如果是一個結構數據庫,讀取后保存為cif文件

data_file = open("db.json", "r")

all_structures = data_file.readlines()

i = 0

for structure in all_structures:

structure = json.loads(structure)["structure"]

structure = Structure.from_dict(structure)

i = i + 1

c = CifWriter(structure)

c.

總結

以上是生活随笔為你收集整理的python库读取cif文件_Pymatgen读/写各种文件,pymatgen,读写的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。