24小时热门版块排行榜    

查看: 2400  |  回复: 3
【有奖交流】积极回复本帖子,参与交流,就有机会分得作者 cnzs 的 7 个金币 ,回帖就立即获得 1 个金币,每人有 1 次机会
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

cnzs

铁虫 (初入文坛)


[交流] VASP数据使用ovito官网脚本分析voronio

1.能不能用ovito处理AIMD的XDATCAR文件?
2.如果可以为什么我用官网提供的Python脚本只能得出第一个离子步的数据?
3.有没有大佬可以帮忙改进一下Python脚本?
# Import OVITO modules.
from ovito.io import *
from ovito.modifiers import *
from ovito.pipeline import *

# Import NumPy module.
import numpy

# Load a simulation snapshot of a Cu-Zr metallic glass.
pipeline = import_file("D:/ovito/400/XDATCAR",multiple_frames = True)

# Set atomic radii (required for polydisperse Voronoi tessellation).
atom_types = pipeline.source.data.particles['Particle Type'].types
atom_types[0].radius = 1.28  #  atomic radius (atom type 1 in input file)
atom_types[1].radius = 1.55  #  atomic radius (atom type 2 in input file)


# Set up the Voronoi analysis modifier.
voro = VoronoiAnalysisModifier(
    compute_indices = True,
    use_radii = True,
    edge_threshold = 0.1
)
pipeline.modifiers.append(voro)

# Let OVITO compute the results.
data = pipeline.compute()

# Access computed Voronoi indices.
# This is an (N) x (M) array, where M is the maximum face order.
voro_indices = data.particles['Voronoi Index']

# This helper function takes a two-dimensional array and computes a frequency
# histogram of the data rows using some NumPy magic.
# It returns two arrays (of equal length):
#    1. The list of unique data rows from the input array
#    2. The number of occurences of each unique row
# Both arrays are sorted in descending order such that the most frequent rows
# are listed first.
def row_histogram(a):
    ca = numpy.ascontiguousarray(a).view([('', a.dtype)] * a.shape[1])
    unique, indices, inverse = numpy.unique(ca, return_index=True, return_inverse=True)
    counts = numpy.bincount(inverse)
    sort_indices = numpy.argsort(counts)[::-1]
    return (a[indices[sort_indices]], counts[sort_indices])

# Compute frequency histogram.
unique_indices, counts = row_histogram(voro_indices)

# Print the ten most frequent histogram entries.
for i in range(10):
    print("%s\t%i\t(%.1f %%)" % (tuple(unique_indices),
                                 counts,
                                 100.0*float(counts)/len(voro_indices)))


result:
(0, 0, 0, 2, 8, 4, 0, 0)           11        (5.5 %)
(0, 0, 0, 3, 6, 4, 0, 0)                7        (3.5 %)
(0, 0, 0, 0, 12, 0, 0, 0)        6        (3.0 %)
(0, 0, 0, 1, 10, 3, 0, 0)        5        (2.5 %)
(0, 0, 0, 2, 8, 1, 0, 0)                5        (2.5 %)
(0, 0, 0, 4, 6, 4, 0, 0)              5        (2.5 %)
(0, 0, 0, 2, 8, 5, 0, 0)          5        (2.5 %)
(0, 0, 0, 1, 10, 2, 0, 0)        5        (2.5 %)
(0, 0, 0, 2, 8, 0, 0, 0)         4        (2.0 %)
(0, 0, 0, 4, 4, 6, 0, 0)         3        (1.5 %)
回复此楼

» 猜你喜欢

» 抢金币啦!回帖就可以得到:

查看全部散金贴

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

小火柴123

新虫 (正式写手)



cnzs(金币+1): 谢谢参与
请问楼主解决了吗?
4楼2022-06-22 14:07:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 4 个回答
简单回复
2020-09-16 14:37   回复  
cnzs(金币+1): 谢谢参与
1 发自小木虫IOS客户端
提示: 如果您在30分钟内回复过其他散金贴,则可能无法领取此贴金币
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 307求调剂 +7 超级伊昂大王 2026-03-10 7/350 2026-03-14 00:49 by JourneyLucky
[考研] 材料与化工(0856)304求B区调剂 +7 邱gl 2026-03-10 10/500 2026-03-14 00:45 by JourneyLucky
[考研] 泣血叩求调剂恩,愿以丹心报师恩 +6 Iuruoh 2026-03-11 6/300 2026-03-13 22:06 by JourneyLucky
[考研] 学硕285求调剂 +13 Wisjxn 2026-03-12 45/2250 2026-03-13 21:13 by a不易
[硕博家园] 深圳大学硕士招生(2026秋,传感器方向,仅录取第一志愿) +4 xujiaoszu 2026-03-11 7/350 2026-03-13 17:28 by xujiaoszu
[考研] 【0856】化学工程(085602)313 分,本科学科评估A类院校化学工程与工艺,诚求调剂 +7 小刘快快上岸 2026-03-11 7/350 2026-03-13 16:06 by ruiyingmiao
[考研] 工科材料085601 279求调剂 +8 困于星晨 2026-03-12 10/500 2026-03-13 15:42 by ms629
[考研] 274求调剂 +3 S.H1 2026-03-12 3/150 2026-03-13 15:15 by JourneyLucky
[考研] 267一志愿南京工业大学0817化工求调剂 +4 SUICHILD 2026-03-12 4/200 2026-03-13 14:14 by JourneyLucky
[考研] 304求调剂(085602一志愿985) +12 化工人999 2026-03-09 12/600 2026-03-13 12:02 by JourneyLucky
[考研] 270求调剂 085600材料与化工专硕 +3 YXCT 2026-03-11 3/150 2026-03-13 10:13 by houyaoxu
[考研] 求调剂 +5 yfihxh 2026-03-09 5/250 2026-03-11 18:35 by 18137688336
[考研] 0856材料与化工353分求调剂 +11 NIFFFfff 2026-03-09 11/550 2026-03-10 18:36 by suyuanhai
[考研] 收调剂 +7 调剂的考研学生 2026-03-10 7/350 2026-03-10 17:57 by 麦茶汤圆
[考研] 0817学硕华东区求调剂 +3 30660438 2026-03-08 3/150 2026-03-10 16:55 by Pegasus0429
[硕博家园] 木虫好像不热闹了,是不是? +4 偏振片 2026-03-10 4/200 2026-03-10 09:51 by longwave
[考研] 家人们 调剂不迷路 看这里 +8 likeihood 2026-03-09 13/650 2026-03-10 08:09 by likeihood
[考研] 070300化学求调剂 +5 扑风铃的猫 2026-03-08 10/500 2026-03-09 13:58 by macy2011
[考研] 085701环境工程专业,初试305,均过国家A区线 +7 卡卡来了@ 2026-03-07 8/400 2026-03-08 06:40 by 刘兵
[考研] 第一志愿上海大学,专业化学工程与技术,总分288,求调剂 +3 1829197082 2026-03-07 3/150 2026-03-07 19:14 by houyaoxu
信息提示
请填处理意见