24小时热门版块排行榜    

Znn3bq.jpeg
汕头大学海洋科学接受调剂
查看: 5217  |  回复: 12
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

gtssongchi

木虫 (小有名气)

[求助] ovito中打开python脚本错误 已有3人参与

大家好,用ovito计算voronoi多面体时,按照手册采用的python脚本计算。手册上脚本如下
# Import OVITO modules.
from ovito.io import *
from ovito.modifiers import *

# Import NumPy module.
import numpy

# Load a simulation snapshot of a Cu-Zr metallic glass.
node = import_file("../data/CuZr_metallic_glass.dump.gz"

# Set atomic radii (required for polydisperse Voronoi tessellation).
atypes = node.source.particle_properties.particle_type.type_list
atypes[0].radius = 1.35        # Cu atomic radius (atom type 1 in input file)
atypes[1].radius = 1.55        # Zr atomic radius (atom type 2 in input file)

# Set up the Voronoi analysis modifier.
voro = VoronoiAnalysisModifier(
    compute_indices = True,
    use_radii = True,
    edge_count = 6, # Length after which Voronoi index vectors are truncated
    edge_threshold = 0.1
)
node.modifiers.append(voro)
                     
# Let OVITO compute the results.
node.compute()

# Make sure we did not lose information due to truncated Voronoi index vectors.
if voro.max_face_order > voro.edge_count:
    print("Warning: Maximum face order in Voronoi tessellation is {0}, "
          "but computed Voronoi indices are truncated after {1} entries. "
          "You should consider increasing the 'edge_count' parameter to {0}."
          .format(voro.max_face_order, voro.edge_count))
    # Note that it would be possible to automatically increase the 'edge_count'
    # parameter to 'max_face_order' here and recompute the Voronoi tessellation:
    #   voro.edge_count = voro.max_face_order
    #   node.compute()

# Access computed Voronoi indices as NumPy array.
# This is an (N)x(edge_count) array.
voro_indices = node.output.particle_properties['Voronoi Index'].array

# 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)))

我只是将其中的文件路径改变了。在运行时却提示如下错误:
Traceback (most recent call last):
  File "/home/csong/ovito.py", line 2, in <module>
    from ovito.io import *
ImportError: No module named 'ovito.io'; 'ovito' is not a package
ERROR: Failed to initialize Python interpreter.

请问这是什么原因呢?
回复此楼

» 猜你喜欢

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

刘子不晕车

禁虫 (初入文坛)

本帖内容被屏蔽

7楼2019-12-30 00:23:50
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 13 个回答

abinitio

版主 (著名写手)

【答案】应助回帖

感谢参与,应助指数 +1
ovito 是那个版本?我感觉3.0.0 -dev的pythonscript好象有问题
2楼2017-11-15 15:58:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gtssongchi

木虫 (小有名气)

引用回帖:
2楼: Originally posted by abinitio at 2017-11-15 15:58:03
ovito 是那个版本?我感觉3.0.0 -dev的pythonscript好象有问题

老师您好,ovito是2.9.0的版本
3楼2017-11-15 19:16:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

伊有涯

新虫 (小有名气)

【答案】应助回帖

ovito怎么用python进行计算啊?怎么弄的啊?
喜欢天空,百看不厌。当然不看也可以。
4楼2018-07-05 19:37:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 本科西工大 324求调剂 +5 wysyjs25 2026-04-10 5/250 2026-04-13 23:08 by pies112
[考研] 一志愿哈工大 085600 277 12材科基求调剂 5+5 chenny174 2026-04-10 36/1800 2026-04-13 22:17 by zhq0425
[考研] 一志愿2110,化学学硕310分,本科重点双非求调剂 +20 努力奋斗112 2026-04-08 20/1000 2026-04-13 14:24 by 张zhihao
[考研] 一志愿双非085400电子信息344 求调剂,对材料和化学方向也感兴趣 +12 无情的小羊 2026-04-09 13/650 2026-04-13 14:17 by 张zhihao
[考研] 297工科,求调剂? +13 河南农业大学-能 2026-04-12 13/650 2026-04-13 14:12 by dingyanbo1
[考研] 一志愿鲁东大学071000生物学学硕初试分数276求调剂 +8 慕绝cc 2026-04-09 8/400 2026-04-13 14:08 by 张zhihao
[考研] 291求调剂 +8 关忆北. 2026-04-11 8/400 2026-04-12 09:32 by 逆水乘风
[教师之家] 请问地理、遥感方面,可以做哪些横向项目啊,纵向完不成考核啊 +3 锦衣卫寒战 2026-04-07 5/250 2026-04-11 20:51 by 豫椒
[考研] 303求调剂 +14 SereinQ 2026-04-10 15/750 2026-04-11 20:43 by 蓝云思雨
[考研] 284求调剂 +11 archer.. 2026-04-09 12/600 2026-04-11 20:23 by 蓝云思雨
[考研] 求调剂 +11 翩翩一书生 2026-04-09 11/550 2026-04-11 19:57 by 逆水乘风
[考研] 工科273调剂 +6 X1999 2026-04-09 7/350 2026-04-11 10:23 by zhq0425
[考研] 085506-求调剂-285分 +3 雷欧飞踢 2026-04-08 3/150 2026-04-11 08:37 by zhq0425
[考研] 中科院总分315求调剂 +8 lallalh 2026-04-09 8/400 2026-04-10 19:30 by dick_runner
[考研] 284求调剂 +9 让我上岸吧阿西 2026-04-09 11/550 2026-04-10 19:18 by 靖jing
[考研] 0858求调剂 5+5 Gky09300550, 2026-04-10 8/400 2026-04-10 19:13 by chemisry
[考研] 初试261 +3 Asht少 2026-04-10 6/300 2026-04-10 16:38 by Asht少
[考研] 266求调剂 +29 阳阳哇塞 2026-04-07 29/1450 2026-04-10 16:20 by 高维春
[考研] 求机械专硕297第二批调剂 +5 拾柒12。 2026-04-08 5/250 2026-04-09 16:43 by 允当适度
[考研] 材料307分求大佬组收留 +17 Hll胡 2026-04-07 17/850 2026-04-09 10:53 by liuhuiying09
信息提示
请填处理意见