24小时热门版块排行榜    

查看: 2402  |  回复: 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的回帖
简单回复
2020-09-16 14:37   回复  
cnzs(金币+1): 谢谢参与
1 发自小木虫IOS客户端
psylhh3楼
2020-09-17 17:32   回复  
cnzs(金币+1): 谢谢参与
相关版块跳转 我要订阅楼主 cnzs 的主题更新
提示: 如果您在30分钟内回复过其他散金贴,则可能无法领取此贴金币
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 理学化学调剂 +3 040517FYfy? 2026-03-09 3/150 2026-03-14 03:09 by JourneyLucky
[考研] 材料与化工 一志愿山大 321分 求调剂 +7 每天散步 2026-03-09 8/400 2026-03-14 02:18 by JourneyLucky
[考研] 考研材料与化工,求调剂 +8 戏精丹丹丹 2026-03-09 8/400 2026-03-14 01:14 by JourneyLucky
[考研] 材料与化工(0856)304求B区调剂 +7 邱gl 2026-03-10 10/500 2026-03-14 00:45 by JourneyLucky
[基金申请] 现在如何回避去年的某一个专家,不知道名字 10+3 zk200107 2026-03-12 5/250 2026-03-14 00:38 by zhanghaozhu
[考研] 333求调剂 +3 球球古力 2026-03-11 3/150 2026-03-13 21:27 by JourneyLucky
[考研] 311求调剂 +3 冬十三 2026-03-13 3/150 2026-03-13 20:41 by JourneyLucky
[考研] 301求调剂 +6 Liyouyumairs 2026-03-11 6/300 2026-03-13 20:11 by JourneyLucky
[考研] 材料工程调剂 +4 咪咪空空 2026-03-11 4/200 2026-03-13 19:57 by JourneyLucky
[考研] 290求调剂 +7 ADT 2026-03-12 7/350 2026-03-13 15:17 by JourneyLucky
[论文投稿] 投稿问题 5+4 星光灿烂xt 2026-03-12 6/300 2026-03-13 14:17 by god_tian
[考研] 求调剂 资源与环境 285 +3 未名考生 2026-03-10 3/150 2026-03-13 10:31 by houyaoxu
[考研] 08食品或轻工求调剂,本科发表3篇sci一区top论文,一志愿南师大食品科学与工程 +3 我是一个兵, 2026-03-10 3/150 2026-03-13 10:21 by Yuyi.
[考博] 26读博 +4 Rui135246 2026-03-12 10/500 2026-03-13 07:15 by gaobiao
[考研] 085600 材料与化工 295 求调剂 +10 dream…… 2026-03-10 12/600 2026-03-12 13:46 by dream……
[考研] 0817化学工程319求调剂 +8 lv945 2026-03-08 10/500 2026-03-12 05:26 by wll0811
[考研] 调剂 +5 调剂的考研学生 2026-03-09 5/250 2026-03-10 22:13 by peike
[考研] 调剂 +5 呵唔哦豁 2026-03-10 5/250 2026-03-10 22:00 by 28375m
[考研] 求调剂,一志愿江南大学,食品科学与工程,总分,320 +3 yyyyyukino 2026-03-07 3/150 2026-03-08 23:07 by 清风月
[考研] 材料科学(0805)338 求调剂 +7 xiaokang3286 2026-03-07 7/350 2026-03-08 03:42 by lfhuang
信息提示
请填处理意见