24小时热门版块排行榜    

查看: 5686  |  回复: 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的回帖

pl927

禁虫 (小有名气)

本帖内容被屏蔽

10楼2020-01-03 15:54:03
已阅   回复此楼   关注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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 uKOSCocCb6Fm 2026-11-12 8/400 2026-11-15 02:26 by xSrQNSSjcgoX
[考研] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +5 YHiw1gou1Eda 2026-11-10 8/400 2026-11-14 22:51 by Equinoxhua
[考研] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +4 YHiw1gou1Eda 2026-11-10 7/350 2026-11-14 22:44 by Equinoxhua
[硕博家园] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 XJXMuRjD7cK7 2026-11-13 3/150 2026-11-14 12:51 by KXypaGgBBlw7
[基金申请] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 XJXMuRjD7cK7 2026-11-13 3/150 2026-11-13 23:37 by 6PrO1XyZ5URF
[考研] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +8 zSbvVX9JFl9J 2026-11-09 9/450 2026-11-13 11:11 by Equinoxhua
[基金申请] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +6 C6CRn66RYYXS 2026-11-10 7/350 2026-11-13 10:55 by Equinoxhua
[考博] 27博士申请 +5 白白白ly 2026-11-09 5/250 2026-11-13 05:01 by wlf1982
[教师之家] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +6 C6CRn66RYYXS 2026-11-10 6/300 2026-11-13 04:21 by Equinoxhua
[考博] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +4 cdqGD6ftHmbl 2026-11-11 5/250 2026-11-12 12:28 by ECLTXnJnRSXf
[考博] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 Z7qfCsdIiD1T 2026-11-10 5/250 2026-11-12 11:25 by HajghKOMynmz
[教师之家] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +4 Z7qfCsdIiD1T 2026-11-10 9/450 2026-11-12 11:22 by HajghKOMynmz
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 Z7qfCsdIiD1T 2026-11-10 6/300 2026-11-12 11:22 by HajghKOMynmz
[考研] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +4 Z7qfCsdIiD1T 2026-11-10 4/200 2026-11-12 11:22 by HajghKOMynmz
[硕博家园] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +5 G2rhSvqvhNzl 2026-11-10 6/300 2026-11-12 10:30 by HajghKOMynmz
[公派出国] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +7 FChKX8meu1ds 2026-11-09 9/450 2026-11-12 10:03 by HajghKOMynmz
[考博] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +5 FChKX8meu1ds 2026-11-09 8/400 2026-11-12 09:46 by HajghKOMynmz
[教师之家] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +3 TgvkbZZl9tqB 2026-11-11 3/150 2026-11-12 08:26 by HajghKOMynmz
[基金申请] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +3 TgvkbZZl9tqB 2026-11-11 5/250 2026-11-12 08:15 by HajghKOMynmz
[公派出国] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +5 zSbvVX9JFl9J 2026-11-09 8/400 2026-11-12 04:57 by 9fOTqj074tIg
信息提示
请填处理意见