Author Topic: How can we get a bond angle distribution in ovito?  (Read 1195 times)

sbista

  • Newbie
  • *
  • Posts: 2
How can we get a bond angle distribution in ovito?
« on: February 16, 2018, 05:32:37 AM »
Hi,
I would like to know if we could write a python script to get a bond angle distribution for a selected particle types in ovito. I am interested in creating a histogram of bond angle distribution between certain particle types in my simulations.
Thanks

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 577
Re: How can we get a bond angle distribution in ovito?
« Reply #1 on: February 16, 2018, 04:17:41 PM »
Hi there,

Here is a script I wrote some time ago for Ovito 2.9.0 to calculate the bond-angle distribution for a system (for demonstration purposes). It may serve you as a starting point to develop a solution for your specific problem. Disclaimer: I never used the script for real-word analyses and I never verified that it is working correctly. So use with caution.

-Alex

SC

  • Newbie
  • *
  • Posts: 7
Re: How can we get a bond angle distribution in ovito?
« Reply #2 on: October 24, 2018, 03:58:20 PM »
Dear Dr. Stukowski,

I used your script to calculate bond angle distribution. I get the following:

Bond angle cosine histogram:
[4423220       0       0       0      93    6950  147557  998011 2604010
 2946143 1606165  457026   73560    6972     416      13       0       0
      17     612   12790  140796  844062 2757451 4967918 5003619 2852902
  945803  261040  284857  629331 1145734 1616595 1763957 1499768  995794
  515809  211497   68083   17656    3582     580     560    4518   30945
  162271  646447 1931808 4161468 6223576 6294421 4273684 1978276  647640
  153969   27062    3385     308      14       3       0       0       0
       0       0       0       0       0       0       8     689   22868
  343535 2270218 6146446 6336389 2299107  264943    8670      72       0
       0       0       0       0       0       5     979   55577 1012293
 4272345 3194279  309097    2341       0       0       0       0       0
       0]
Invalid Python script. It does not define the function modify().

However, I am not sure how this can be interpreted. Would you please give some explanation about this?

Bets wishes,

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 206
Re: How can we get a bond angle distribution in ovito?
« Reply #3 on: October 24, 2018, 04:50:13 PM »
Dear SC,

concerning the error message: did you just copy that code in a python script modifier in the GUI of OVITO? Note that this is a bash-script which is meant to be executed from the command line like this:
Code: [Select]
ovitos <name-of-script.py>
See the documentation about running scripts.

-Constanze
« Last Edit: October 24, 2018, 04:51:50 PM by Constanze Kalcher »

SC

  • Newbie
  • *
  • Posts: 7
Re: How can we get a bond angle distribution in ovito?
« Reply #4 on: February 17, 2019, 04:47:45 PM »
Dear Constanze,

Thanks for your reply.

Do you mean that I should run it in "ovitos" program? or Windows commend line?

I tried both but was not successful.

Best,

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 577
Re: How can we get a bond angle distribution in ovito?
« Reply #5 on: February 17, 2019, 06:46:02 PM »
Hi SC,

Constanze went on vacation, so let me answer your question.

Yes, "ovitos" is a command line application for executing Python scripts that do run outside of the graphical Ovito user interface. It is typically used when automating analysis and rendering tasks which do not require user intervention.

On Windows, you can find "ovitos.exe" in the installation directory of Ovito. You should run it from the Windows command line prompt as specified by Constanze in order to see the console output your Python script produces.

-Alex

SC

  • Newbie
  • *
  • Posts: 7
Re: How can we get a bond angle distribution in ovito?
« Reply #6 on: February 17, 2019, 07:14:37 PM »
Dear Alex,

Thank you so much for your reply.

I have attached a file showing the results of the analysis. However, i am not sure how to interpret the results. I would like to get a graph like that of g(r) which can be obtained in GUI.

Best,

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 577
Re: How can we get a bond angle distribution in ovito?
« Reply #7 on: February 19, 2019, 07:21:42 PM »
The script builds up a histogram of bond angles over the [-1,+1] value range of cos(theta). This histogram is stored in a Numpy array in the variable "angle_cosine_histogram". You can use the numpy.savetxt() function to write the numeric data to a text file in the current directory. For example, add the following line to the end of the script:

Code: [Select]
np.savetxt("distribution.txt", angle_cosine_histogram, delimiter=',')

You can then use your favorite plotting tool (e.g. Microsoft Excel, Gnuplot, etc.) to import this text file and create a graph from the numeric data. There is currently no direct way of exporting the visual plots you can find within the graphical version of Ovito as images.

stl4

  • Newbie
  • *
  • Posts: 3
Re: How can we get a bond angle distribution in ovito?
« Reply #8 on: March 11, 2019, 11:15:20 PM »
Hello,

I have a question regarding the script you had provided. If I am interested in calculating the distribution of bonding angles between Si-O-Si as well as O-Si-O.
1)Would I need to alter the following portion "create_bonds_mod.set_pairwise_cutoff('Si', 'O', 1.7)" to calculate the O-Si-O and Si-O-Si distribution? I assume that the previous line calculates both the O-Si-O and Si-O-Si angle since my histogram appears in the attached image.

2)If both angles are calculated, how can I separate those two angles since the lower end of Si-O-Si occurs at the upper end of O-Si-O?

Thank you for your assistance