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

How to change dimensionality of dataset in Python script

Hello!

I'm writing a script that takes in a .xyz formatted file but I want it to compute properties in 2D. In the GUI, there's an option under the simulation cell to change the dimensionality to 2D but I couldn't figure out how to do this in a script. Is this possible? If so, how would it be done?

Thanks for your help!

Hi,

the SimulationCell Data object has a flag is2D which you should set to True, see https://www.ovito.org/docs/current/python/modules/ovito_data.php?highlight=is2d#ovito.data.SimulationCell.is2D.

pipeline = import_file(<your-file>)

def my_modifier(frame, data):
    data.cell_.is2D = True

pipeline.modifiers.append(my_modifier)
#Add more modifiers
#pipeline.modifiers.append()
result = pipeline.compute()

Let me know if you have further questions,

- Constanze

This helps a lot. Thank you!