24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 2430  |  回复: 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分钟内回复过其他散金贴,则可能无法领取此贴金币
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 298求调剂 +6 种圣赐 2026-03-29 6/300 2026-04-03 14:20 by dxiaoxin
[考研] 270求调剂 +4 海苔花生饼 2026-03-28 4/200 2026-04-03 12:15 by xingguangj
[考研] 材料调剂 +4 吴棂颖! 2026-04-03 4/200 2026-04-03 11:06 by wangjy2002
[考研] 一志愿华中农业071010,总分320求调剂 +6 困困困困坤坤 2026-04-02 6/300 2026-04-02 21:28 by dongzh2009
[考研] 264分,求任意工科调剂 +4 zzlqwq 2026-03-29 5/250 2026-04-02 17:17 by 何曾几何
[考研] 301求调剂 +4 细胞相关蛋白 2026-04-02 8/400 2026-04-02 16:30 by 271179835
[考研] 337求调剂 +11 《树》 2026-03-29 11/550 2026-04-02 10:20 by 不吃魚的貓
[考研] 08生物与医药专硕初试346找调剂 +6 dianeeee 2026-04-01 7/350 2026-04-02 08:23 by guoweigw
[考研] 291求调剂 +20 Y-cap 2026-03-29 25/1250 2026-04-01 23:49 by 欣喜777
[考研] 材料调剂 +14 一样YWY 2026-04-01 14/700 2026-04-01 21:07 by lijunpoly
[考研] 070300一志愿211,312分求调剂院校 +14 小黄鸭宝 2026-03-30 14/700 2026-04-01 20:19 by 赖春艳
[考研] 353求调剂 +4 拉钩不许变 2026-04-01 4/200 2026-04-01 18:10 by 记事本2026
[考研] 291求调剂 +3 迷蒙木木 2026-04-01 4/200 2026-04-01 11:07 by 逆水乘风
[考研] 一志愿华南师范361分,化学求调剂 +4 Nicole88888 2026-04-01 4/200 2026-04-01 10:08 by 唐沐儿
[考研] 土木304求调剂 +5 顶级擦擦 2026-03-31 5/250 2026-04-01 08:15 by fdcxdystjk¥
[考研] 复试调剂 +7 双马尾痞老板2 2026-03-31 7/350 2026-03-31 19:49 by Dyhoer
[考研] 生物考研337分求调剂 +4 cgxin 2026-03-30 6/300 2026-03-31 14:18 by 记事本2026
[考研] 一志愿浙江大学工科动力工程370,数一121,专业课135,现在能去哪里 +3 080700调剂 2026-03-30 4/200 2026-03-31 12:00 by KLMY666
[考研] 086000生物与医药调剂 +5 Feisty。 2026-03-28 9/450 2026-03-29 12:02 by longlotian
[考研] 2026年华南师范大学欢迎化学,化工,生物,生医工等专业优秀学子加入! +3 llss0711 2026-03-28 6/300 2026-03-29 10:26 by llss0711
信息提示
请填处理意见