Author Topic: using user-defined particle property  (Read 370 times)

skavou1

  • Newbie
  • *
  • Posts: 5
using user-defined particle property
« on: January 31, 2018, 07:06:56 PM »
Hello Dr.Stukowski,
In myLAMMPS input file, I calculated the kinetic energy/atom and dump in if cfg files :
        compute    c2 all ke/atom
        dump       d2 all cfg 20000 one.dump.*.cfg mass type xs ys zs c_c2

But when Importing those files in Ovito, in python scripting it gives error

        k= input.particle_properties.c_c2.array
       AttributeError: DataCollection does not contain the particle property 'c_c2'.

Would you please help me solve this issue.

Regards,
Sepideh

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 476
Re: using user-defined particle property
« Reply #1 on: January 31, 2018, 10:39:15 PM »
Dear Sepideh,

Hmm, I would expect this to work and I don't have an explanation for the error at the moment. But I have to admit that I never tested the CFG format reader with this particular type of CFG file written by LAMMPS.

Can you please attach one of your CFG files as well as the OVITO Python script? I will check what is going on. If the CFG file is too big, please post at least the header part of the file (including the "auxiliary" lines).

Thanks.

-Alexander

skavou1

  • Newbie
  • *
  • Posts: 5
Re: using user-defined particle property
« Reply #2 on: February 06, 2018, 09:28:22 PM »
Hello Dr.Stukowski,
I solved the issue. it needs to be added in this form:
k = input.particle_properties['c_c2'].array

Regards,
Sepideh

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 476
Re: using user-defined particle property
« Reply #3 on: February 07, 2018, 12:26:37 PM »
Yeah, you are right. That's something I overlooked in your code.

In the old OVITO version (2.9.0), standard particle properties could be accessed as if they were Python attributes, but user-defined properties required the particle_properties['...'] notation (key-based dictionary access). In the upcoming OVITO version (3.0.0), the key-based dictionary access must be used for all properties. So particle_properties['c_c2'] is the right way to go in any case.