I tried to get information about atomic particles in reference config mode using WignerSeitzAnalysisModifier with the following Python code. But the results are the information in displaced config mode.
config = ReferenceConfigurationModifier
config.reference = FileSource()
wsa_modifier = WignerSeitzAnalysisModifier(
data = pipeline.compute()
particle_identifiers = data.particles[‘Particle Identifier’]
particle_types = data.particles.particle_types.array
positions = data.particles.positions.array
occupancy = data.particles[‘Occupancy’]
And when I set output_displaced to True to read the information, according to the documentation there are additional attributes such as site type, but when I extract this attribute via Python it says that there is no such attribute. The code and error is in following.
site_type = data.particles[‘Site Type’]
KeyError: “Property ‘Site Type’ does not exist in container.”
My Python version is 3.10 and the ovito package version is 3.9.2. I hope someone can address my query, thank you very much!
It’s challenging to pinpoint the issue from your code snippets without more context.
Here are a couple of comments that might help you:
Please note that the first three lines are probably not achieving what you intended. Loading an external file source as a reference configuration for the WignerSeitzAnalysis Modifier should be done like this:
wsa_modifier.reference = FileSource() wsa_modifier.reference.load(...)
In your case, however, the WignerSeitzModifier uses the default reference configuration source, which is the upstream pipeline, and a constant reference configuration - frame 0.
output_displaced = True corresponds to what is labeled Output mode Atoms (displaced config) in the OVITO desktop application and
output_displaced = False corresponds to the Sites (reference config) mode.
The particle property
Site Type is generated only in Atoms mode.
My hunch is that when you call
pipeline.compute() here, you are actually analyzing frame 0 and comparing it to frame 0 (as explained in comment 1). Since the particles in the current configuration and reference configuration are the same, output mode Sites and Atoms obviously will not give you different particle configurations.
I highly recommend leveraging OVITO Pro’s Python code generator feature, which simplifies the process of creating automation scripts based on your GUI pipeline. It not only saves you time but also reduces the risk of any misunderstandings like this.
Thank you very much for your answer kalcher, after modifying it according to the comment 1, the code runs exactly right and that is indeed the reason. Thanks again!