Forum Navigation
You need to log in to create posts and topics.

OVITO 自动分别导出多个分子的轨迹

亲爱的ovito开发人员

由于我最近的项目需求,我发现ovito可以通过先选取单个分子,然后再导出这个分子的轨迹。请问是否可以利用ovito自动分别导出每个分子的自己的轨迹,而不是我自己先去选中一个分子,再导出。

此致

敬礼!

Hi, I'm posting your question here first for other users that might read this:

Due to my recent project requirements, I have discovered that ovito can be used to export the trajectory of a single molecule by first selecting it and then exporting that molecule. Could you please tell me if it is possible to use ovito to automatically export each molecule's own trajectory separately, instead of me going through and selecting a molecule first and then exporting it myself.

My suggestion would be to use a python script that does something along those lines:

from ovito.io import import_file, export_file
from ovito.modifiers import *
import numpy

# Load input data and create a data pipeline.
pipeline = import_file(<your-trajectory>)

expr_mod = ExpressionSelectionModifier()
pipeline.modifiers.append(expr_mod)
pipeline.modifiers.append(DeleteSelectedModifier())

for molecule_id in set(pipeline.compute().particles["Molecule Identifier"]):
    expr_mod.expression = f"MoleculeIdentifier != {molecule_id}"
    export_file(pipeline, f"molecule_{molecule_id}.dump", "lammps/dump", multiple_frames = True)

Best,

Constanze

 

 

 

新的OVITO微信频道!
New for our users in China: OVITO on WeChat 

Official OVITO WeChat channel operated by Foshan Diesi Technology Co., Ltd.