Add new atom property using a script?

Hi there,

I would like to add a new atom property within a script. For instance, I want to take the result of a calculation and add it onto the structure as an atom property so I can visualize it and simplify some data flow.
I see there is a command for 'SetProperty("Property", "Value"), but how do I create a new property? 

Thanks for your help,

Pat

Answers 8
FH
FH 2020-06-29 Best Answer

Hi Pat, 
You cannot create a new property on the fly if it has not been previously defined in the data model. however, as Reinier mentioned, you can 'recycle' a lot of the existing properties for your own purposes. String properties can be stored in the name, and there are a lot of numerical properties at your disposal. Please check the scripting documentation for what is available, and make sure that you are using something that is not used in the calculations you are using. 
If you are doing classical simulations, I can suggest storing numerical data in things like Spin, HubbardUd, HubbardUf, HubbardUp etc. If you are doing DFT calculations, you also have the atomic charge available to you. 
All the best, 
Felix

RA
RA 2020-06-28

Hi Pat,


I don't think it is possible to create new properties on-the-fly. Where did you find this SetProperty command?


You could of course assign the value to the Name property of an Atom, which you can then visualize using labels. Or use a Perl hash to associate a property value with an atom.


Regards,
Reinier

PS
PS 2020-06-29

Hi Reinier,  

Thanks for your response.  I found the SetProperty command on the forum, and it works pretty well.  As you suggested, I could use one of the current properties, such as Name. 
However, I did notice that the CASTEP NMR analysis tool will create new properties for the atom (e.g. NMRShielding).  I figure there must be a command that will allow me to do this?  

If there is a library of commands somewhere, that will be very helpful to me.

Best regards, 
Pat

PS
PS 2020-06-29

Thank you for the answer, I will take advantage of this as you suggested.  Could you please direct me to the scripting documentation?

FH
FH 2020-06-30

You can use context help to get to the relevant sections: 
Open a new scripting document, type a keyword that you are interested in (e.g. HubbardUd or another property you are thinking of recycling), move your cursor into the middle of that word, then press F1. The scripting API documentation should open pretty much on the page(s) you are interested in.

PS
PS 2020-06-30

Thank you for the information.  Unfortunately, each time I try to access the documentation (either through the help menu or using the F1 command as you suggested) my firewall blocks it.  Is there another way of accessing it?

FH
FH 2020-07-01

Assuming that you have a standard installation on the C-drive of your computer, you should be able to reach the documentation on your HD by pasting the following into your browser: file:///C:/Program%20Files%20(x86)/BIOVIA/Materials%20Studio%2020.1/share/doc/MaterialsStudio.htm
The number in bold refers to the version, e.g. if you have the 2020 release it should be 20, it should be 19 for the previous release etc. Alternatively, you could also navigate to the same location in the file explorer open MaterialsStudio.htm by hand. 

PS
PS 2020-07-01

Thanks Felix for all of your help!  I have now found the documentation.