Dear Ovito devs,
I am right now trying to make a Python script to concatenate averaging compute
outputs from LAMMPS from a dump file and the computation of properties to save some time.
Say I have a compute named ABC that outputs a per-atom vector in a dump file. The dump file columns will then be titled c_ABC[1] c_ABC[2]
etc. When using the TimeAveragingModifier
modifier, I can compute the per-atom averages by using
TimAveMod = TimeAveragingModifier(
operate_on=["property:particles/c_abc[1]", "property:particles/c_abc[2]"]
)
Now say I want to operate on the output of TimAveMod
and compute properties. The manual states that the fields will have Average
appended to their name. Yet when doing:
ComProMod= ComputePropertyModifier(
output_property="fubar",
expressions=["c_abc1Average"]
)
Which is the name I get when exporting the file in the lammps dump format, but I get a RuntimeError
from Data pipeline failure, as the Modifier does find the token c_abc1average
. I tried several different writing like c_abc1average
or c_abc1_average
but none worked. Which is the correct one? The property is listed in the particles as 'c_abc[1] Average'
but it is obviously not the name internally used.
Which is then the correct token to use for the parser to find it?
Hi Germain,
If the time-averaged particle property has the real name c_abc[1] Average
, like you say, then the corresponding mangled property name to be used in the context of a Compute Property modifier is c_abc_1_Average
.
The muParser component internally used by this modifier only supports variable identifiers made of alphanumeric characters and underscores, unfortunately. That’s why the modifier replaces all other characters in a property name with underscores to derive a valid mangled name, which can be referenced in the math expression.
Pro tip: You can use the GUI of OVITO to find out what the mangled name for a property is. First, insert a Compute Property modifier that creates a new dummy property with the desired name, e.g.:

Then insert another Compute Property modifier into the pipeline and open the list of available expression variables. Here it shows the mangled name:
1 Like
Yes makes sense. I noticed the replacement of characters with underscores but was unaware of the proper set of authorized characters since I didn’t know if the parser was in-build or not… The replacement of [ ] makes sense now.
The script works like a breeze now.
Obviously, the documentation was insufficient in this area. I have therefore expanded the Python docs of the ComputePropertyModifier a bit: ovito.modifiers — OVITO Python Reference 3.8.1 documentation
1 Like