Dislocation Velocity

Quote from Ayobami Daramola on December 6, 2020, 9:07 amHi,
Thanks for giving us this platform, I have a challenge and i have tried all my possible best and yet no solution, I try calculating the dislocation velocity of my dump file but i got this following error:
The Python script has exited with an error.
Traceback (most recent call last):
File "path", line 30, in get_dislocation_position
positions = output.particle_properties.position.marray #.copy()
File "/home/local/EMSE2000/ayobami.daramola/Téléchargements/ovito-pro-3.3 (1).4-x86_64/bin/../lib/ovito/plugins/python/ovito/data/stdobj/property.py", line 231, in _Property_marray
self.make_writable()
RuntimeError: Modifying the values of this property is not allowed, because it is currently shared by more than one property container or data collection. Please explicitly request a mutable version of the property by using the '_' notation.
here is the python script i used
from ovito.data import *
import os
os.chdir('/dir/path/')
import dis_mobility as dmmodify = dm.get_dislocation_position
dm.initialize_data(18)"""
from ovito import *
import numpy as np
import os
def get_dislocation_position(frame, input, output):
x_extent = output.cell.matrix[0,0]
positions = output.particle_properties.position.marray #.copy()# Eliminate all periodic images
positions[(positions[:,0] > x_extent),0] = positions[(positions[:,0] > x_extent),0] - x_extent
# Edit positions to put dislocation all on same side
if frame == 0:
global core_spread
core_spread = np.max(positions[:,0]) - np.min(positions[:,0])
if core_spread > 0.5*x_extent:
core_spread = None
elif core_spread:
ref = positions[0,0]
for i,p in enumerate(positions):
if i == 0:
continue
if (p[0] - ref) > core_spread*1.3:
p[0] -= x_extent
ref = np.mean(positions[0:(i+1),0])
dislocation = np.mean(positions,0)[0]
timestep = output.attributes['Timestep']while (pos[frame - 1] - dislocation) > 0.25*x_extent:
dislocation += x_extentwith open('posVStime.txt','a+') as f:
f.write('{}\t{}\n'.format(timestep, dislocation))
I dont know whats wrong here, I am using ovito 3.3 Pro
attached is a proptype of my file thanks in advance. I really love the work here.
Regards
Ayobami
Hi,
Thanks for giving us this platform, I have a challenge and i have tried all my possible best and yet no solution, I try calculating the dislocation velocity of my dump file but i got this following error:
The Python script has exited with an error.
Traceback (most recent call last):
File "path", line 30, in get_dislocation_position
positions = output.particle_properties.position.marray #.copy()
File "/home/local/EMSE2000/ayobami.daramola/Téléchargements/ovito-pro-3.3 (1).4-x86_64/bin/../lib/ovito/plugins/python/ovito/data/stdobj/property.py", line 231, in _Property_marray
self.make_writable()
RuntimeError: Modifying the values of this property is not allowed, because it is currently shared by more than one property container or data collection. Please explicitly request a mutable version of the property by using the '_' notation.
here is the python script i used
from ovito.data import *
import os
os.chdir('/dir/path/')
import dis_mobility as dm
modify = dm.get_dislocation_position
dm.initialize_data(18)
"""
from ovito import *
import numpy as np
import os
def get_dislocation_position(frame, input, output):
x_extent = output.cell.matrix[0,0]
positions = output.particle_properties.position.marray #.copy()
# Eliminate all periodic images
positions[(positions[:,0] > x_extent),0] = positions[(positions[:,0] > x_extent),0] - x_extent
# Edit positions to put dislocation all on same side
if frame == 0:
global core_spread
core_spread = np.max(positions[:,0]) - np.min(positions[:,0])
if core_spread > 0.5*x_extent:
core_spread = None
elif core_spread:
ref = positions[0,0]
for i,p in enumerate(positions):
if i == 0:
continue
if (p[0] - ref) > core_spread*1.3:
p[0] -= x_extent
ref = np.mean(positions[0:(i+1),0])
dislocation = np.mean(positions,0)[0]
timestep = output.attributes['Timestep']
while (pos[frame - 1] - dislocation) > 0.25*x_extent:
dislocation += x_extent
with open('posVStime.txt','a+') as f:
f.write('{}\t{}\n'.format(timestep, dislocation))
I dont know whats wrong here, I am using ovito 3.3 Pro
attached is a proptype of my file thanks in advance. I really love the work here.
Regards
Ayobami
Uploaded files:
Quote from Constanze Kalcher on December 9, 2020, 10:08 amHi Ayobami,
Thanks for the positive feedback, this is much appreciated!
I think the reason why you see this error message is because you are using the old ovitos 2.9 syntax. A couple of things have changed in the python scripting interface, please see the version changes here: https://www.ovito.org/docs/current/python/introduction/version_changes.php.
Please note that you'll need to make both the particles data object and the positions property object mutable in order to be able to modify the positions. This is described in more detail here: https://www.ovito.org/docs/current/python/introduction/data_manipulation.php in subsection "Modifying property values".
Making the small changes shown below to your code example should fix it.
def get_dislocation_position(frame, data): x_extent = data.cell[0,0] #Use underscore notation to make the position property array modifiable positions = data.particles_.positions_ #... timestep = data.attributes['Timestep'] #...Best,
Constanze
Hi Ayobami,
Thanks for the positive feedback, this is much appreciated!
I think the reason why you see this error message is because you are using the old ovitos 2.9 syntax. A couple of things have changed in the python scripting interface, please see the version changes here: https://www.ovito.org/docs/current/python/introduction/version_changes.php.
Please note that you'll need to make both the particles data object and the positions property object mutable in order to be able to modify the positions. This is described in more detail here: https://www.ovito.org/docs/current/python/introduction/data_manipulation.php in subsection "Modifying property values".
Making the small changes shown below to your code example should fix it.
def get_dislocation_position(frame, data): x_extent = data.cell[0,0] #Use underscore notation to make the position property array modifiable positions = data.particles_.positions_ #... timestep = data.attributes['Timestep'] #...
Best,
Constanze