Forum Navigation
You need to log in to create posts and topics.

Dislocation density python script

Hello everybody,

I am very new to Ovito and I am trying to analyze dislocation density on my structure using the Python script found on this website: https://www.ovito.org/docs/current/python/modules/ovito_modifiers.php

The script is:

from ovito.io import import_file, export_file
from ovito.modifiers import DislocationAnalysisModifier
from ovito.data import DislocationNetwork

pipeline = import_file("input/simulation.dump")

# Extract dislocation lines from a crystal with diamond structure:
modifier = DislocationAnalysisModifier()
modifier.input_crystal_structure = DislocationAnalysisModifier.Lattice.CubicDiamond
pipeline.modifiers.append(modifier)
data = pipeline.compute()

total_line_length = data.attributes['DislocationAnalysis.total_line_length']
cell_volume = data.attributes['DislocationAnalysis.cell_volume']
print("Dislocation density: %f" % (total_line_length / cell_volume))

# Print list of dislocation lines:
print("Found %i dislocation segments" % len(data.dislocations.segments))
for segment in data.dislocations.segments:
    print("Segment %i: length=%f, Burgers vector=%s" % (segment.id, segment.length, segment.true_burgers_vector))
    print(segment.points)

# Export dislocation lines to a CA file:
export_file(pipeline, "output/dislocations.ca", "ca")

# Or export dislocations to a ParaView VTK file:
export_file(pipeline, "output/dislocations.vtk", "vtk/disloc")


This is a script for 3.0.0 dev808 version, but I am running a 2.9.0. When I download the newest edition I cannot use python script as it is only for Pro users. 
Therefore, my question is whether there is a version on which you think this might work and where can I find it. Also, if you think there might be a simple fix for this code let me know, I would appreciate it since I am pretty new to this software.

I will attach a screenshot with the error I get (it basically does not read my file I think), so maybe that can help. I tried changing the name of the file and position of .dump, but that did not work.

My best,
Ognjen

 

Uploaded files:
  • You need to login to have access to uploads.

Hello Ognjen,

welcome to the OVITO community! I can confirm that if you want to use the python scripting capability of OVITO, it will require you (or your supervisor) to use a licensed version of OVITO Pro (http://www.ovito.org/shop). We did not take this decision lightly, and all the reasons for this transition are explained here in our frequently asked questions, https://www.ovito.org/about/ovito-pro.
I think you can understand that we are no longer able to invest our energy and time into offering free scientific support for the 2.9 release. This will harm the future development of OVITO and - on the long run - the research community as a whole.

That being said, the script you are trying to use is a stand-alone batch script and not meant to be used in the graphical user interface of OVITO (GUI). You can learn more about the different ways of using OVITO's python scripting interface here, https://www.ovito.org/docs/current/python/introduction/running.php.

The good news is, that you don't need to use the python scripting interface to calculate the dislocation density. You can use the DislocationAnalyisModifier available in OVITO Basic, which will store the total line length of all dislocations in a global attribute called DislocationAnalysis.total_line_length. Global attributes can be conveniently exported using OVITO's export file-function "Table of values". So you can simply export the line length along with the cell volume and you are all set.

-Constanze

Hi Constanze,

Thank you for the help, I will check out these tools.

Ognjen