Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Constanze Kalcher

Pages: 1 2 [3] 4 5
61
Support Forum / Re: Von Mises Stress
« on: September 20, 2018, 11:50:22 AM »
That's what I meant with line 7 in your python script doesn't make much sense. Global attributes are not meant to save arrays.

Why don't you export the atomic von Mises stresses via the file-export formats *.dump"  or ".xyz"? Then you don't need that python script modifier at all.

Maybe you can explain how you want your output file to look like, because I'm having trouble understanding the issue.

62
Support Forum / Re: Von Mises Stress
« on: September 20, 2018, 10:51:50 AM »
If you want to sum up only the z-component of your stress tensor you can do:
Code: [Select]
numpy.sum( input.particles["Stress Tensor"][:,2] )

63
Support Forum / Re: Von Mises Stress
« on: September 20, 2018, 10:44:14 AM »
Code: [Select]
numpy.sum(Von_Mises) sums up all the atomic von Mises stresses.
See https://docs.scipy.org/doc/numpy/reference/generated/numpy.sum.html

64
Support Forum / Re: Von Mises Stress
« on: September 20, 2018, 10:06:40 AM »
Amir,

it's not an error, you trying to print a particle property object and that's what it does.
Try e.g.
Code: [Select]
print(Von_Mises[...])to print all the values in the von_Mises array,
or
Code: [Select]
print(Von_Mises[0])to print the first one.

Just so you know you didn't have to change the name of your particle property "Von Mises Stress",
Code: [Select]
input.particles["Von Mises Stress"]
Blank spaces in strings (enclosed by " ")  are fine. But since you apparently also changed it in the Compute property modifier that of course also works.

In line 7 you're saving the whole particle property object as a global attribute, which works but is probably not what you wanted to do.

-Constanze

65
Support Forum / Re: Von Mises Stress
« on: September 20, 2018, 08:10:09 AM »
Also in line 6 you‘re calling the particle property „Selection“, which I can see from your screenshot doesn’t exist. You can remove that line.
Also what are you trying to achieve with line 7?

66
Support Forum / Re: Von Mises Stress
« on: September 20, 2018, 08:04:49 AM »
Hi Amir,

the error is due to the way you’re trying to define variables.
You can’t use blank spaces, rather use „-„ or „_“.
Change your code to e.g.

Code: [Select]
von_Mises = ...
von_Mises_Stress = ...

-Constanze

67
Support Forum / Re: Exporting data
« on: September 19, 2018, 05:57:44 PM »
But if you simply want to compute the strain from the length-change of your simulation cell, e.g. in z-direction, you could use a python script modifier function like this one:
Code: [Select]
from ovito.data import *
import ovito

l0 = ovito.scene.selected_pipeline.source.compute(0).cell[2][2]

def modify(frame, input, output):
    cell = input.expect(SimulationCell)
    print(cell)
    output.attributes["Strain"] = (cell[2][2] - l0)/l0
   

68
Support Forum / Re: Exporting data
« on: September 19, 2018, 05:42:07 PM »
In case you are just getting familiar with python, here's how you could reference the z component of the per-atom stress and strain tensors.
Code: [Select]
strain_zz = input.particles["Strain Tensor"][:,2]
stress_zz = input.particles["Stress Tensor"][:,2]

To calculate the strain tensor activate the option "Output strain tensors" in the Atomic strain modifier.


69
Support Forum / Re: Particles
« on: September 19, 2018, 01:36:58 PM »
OVITO currently has the following file export functions:

1) Either you can export a selection of particles along with their properties, like e.g. the atomic stresses. If you choose the *.dump or *.xyz format as export file format you can select which particle-properties you want to export, e.g. only the Stress Tensor (see screenshot 1).

2) Global attributes like the total strain and stress (which you probably first need to calculate using a Python script modifier as explained above) can be exported as well. Simply choose "Table of values" as export file format (see screenshot 2).

-Constanze

70
Support Forum / Re: Particles
« on: September 19, 2018, 12:06:26 PM »
Amir,
it's not clear what you mean by "tension in different strains" and "copy" the data. What you where trying to reference in your first screenshot as StressTensor.ZZ is a per-atom information, not the total stress.
If you're trying to calculate the total stress and strain you can do so, e.g. with a python script modifier. This has been explained here:

http://forum.ovito.org/index.php?topic=376.0

Still, the file-export is the way to go to export the time-evolution these quantities.

-Constanze




71
Support Forum / Re: Particles
« on: September 19, 2018, 11:46:23 AM »
Hi Amir,

have you considered using the File Export function?

-Constanze

72
Support Forum / Re: Theta evolution vs. Frame
« on: September 18, 2018, 02:37:47 PM »
Hi Ali,

here is one possible example for an OVITO batch script that uses a python modifier function to calculate the angle between three specified particles at every simulation frame and saves that information as a global attribute. Finally the time evolution of the angle is saved in a textfile "theta.txt".
I'll leave it up to you to finish the part with the particle indices since I didn't know which of these atoms was supposed to be the central atom.

Code: [Select]
from ovito.io import *
from ovito.modifiers import *
from ovito.data import *
import numpy as np

#User defined modifier funtion to calculate the angle between particles 3493, 1805 and 1813                                                                                                                                                                                                             
def compute_theta(frame, input, output):
   
    #Get particle indices from Particle Identifiers           
    particle_identifiers = input.particles["Particle Identifier"]                                                                                                                                                                   
    central_particle_index = np.where(particle_identifiers == 3493)[0][0]
    neighbor_1_index = ...
    neighbor_2_index = ...

    #Calculate the distance vectors                                                                                                                                                                 
    positions = input.particles['Position']
    dist_1 =  positions[neighbor_1_index] - positions[central_particle_index]
    dist_2 =  positions[neighbor_2_index] - positions[central_particle_index]

    #Get the angle                                                                                                                                                                                                                 
    cos_theta = np.dot(dist_1,dist_2)/np.linalg.norm(dist_1)/np.linalg.norm(dist_2)
    theta = np.arccos(cos_theta)

    #Save as global attribute                                                                                                                                                                                                     
    output.attributes['theta'] = np.degrees(theta)

# Load the simulation dataset to be analyzed.                                                                                                                                                                                     
pipeline = import_file("simulation.dump")
pipeline.modifiers.append(PythonScriptModifier(function = compute_theta))

# Export calculated theta values to a text file and let OVITO's data pipeline do the rest:                                                                                                                                           
export_file(pipeline, "theta.txt", format = "txt", columns = ["Timestep", "theta"], multiple_frames = True)

Let me know if that works for you and if you have questions.

Edit: Also note that I was assuming you're using OVITO3.

-Constanze


73
The OVITO 3 equivalent of the above Python script modifier would be :
Code: [Select]
from ovito.data import *
import numpy as np

def modify(frame, input, output):
    shear_strain = input.particles["Shear Strain"]
    selection = input.particles["Selection"]
    output.attributes["Average shear strain"] = np.mean( shear_strain[selection == 1] )

74
Let's say you want to calculate the average value of a particle property for only a subset of atoms, for example the shear strain.
First you may want to use one of the Selection modifiers, e.g., Expression select, Select particle type, Slice or Manual selection to select the atoms of interest.

Then, insert a Python script modifier that calculates the mean value of the per-atom shear strain of your selection and saves it as a global attribute.
Code: [Select]
from ovito.data import *
import numpy as np

def modify(frame, input, output):
    shear_strain = input.particle_properties["Shear Strain"].array
    selection = input.particle_properties["Selection"].array
    output.attributes["Average shear strain"] = np.mean( shear_strain[selection == 1] )

Global attributes can be exported as Calculation Results Text File output file format.

75
Support Forum / Re: Calculating the velocity of a, or group of atoms.
« on: September 14, 2018, 02:14:40 PM »
Hello,

the Compute Property Modifier only lets you reference the Particle Properties at the current frame, which appear in the Variables panel.
These particle properties are either part of your input data or the result of a modifier calculation you performed.

Have you considered using the Displacement vectors modifier to calculate the atomic displacements in reference to your initial frame? Then you will have access to these values in the Compute Property Modifier as "Displacement.X", etc.

-Constanze

76
Support Forum / Re: Shifting the System Along an Axis
« on: September 12, 2018, 07:06:03 AM »
Hi,

ok great! You can of course do it in OVITO 3.0, it's just that the Affine Transformation modifier looks slightly different there. You will find an "Operate on" panel at the bottom, where you need to select Particles and unselect Simulation cell.
Sorry for the confusion.

-Constanze

77
Support Forum / Re: Shifting the System Along an Axis
« on: September 10, 2018, 07:24:39 PM »
Hi jatin1990,

you could use the Affine Transformation modifier in conjunction with the Wrap at periodic boundaries modifier. (This is in case you're using OVITO 2.9).

You can translate the atoms only with the Affine Transformation modifier: Choose Transform particle positions and unselect Transform simulation cell. The Wrap at periodic boundaries modifier will then map those atoms back into the simulation cell that you moved out of your cell.

Does that work for you?
-Constanze

78
Dear Shuai,

I suggest you to have a look at this section in the manual about running scripts.
In short, if you're using the GUI, simply use a Python script modifier and copy-paste the code example.

-Constanze

79
Support Forum / Re: CNA and bond-angle analysis criterion
« on: September 05, 2018, 03:05:33 PM »
I assumed you are using the latest version of OVITO 3, where the python API has been updated, as explained here:
http://ovito.org/manual_testing/python/introduction/version_changes.html.

If you'd rather use OVITO 2.9, you need to adapt line 5 like this:
Code: [Select]
output.attributes["my_fcc_count"] = np.count_nonzero(input.particle_properties["Selection"])

The Data inspector panel is only available in OVITO 3, however, in OVITO2.9 the global attribute "my_fcc_count" will be visible under Attributes to Export when you choose the file format "Calculation Results File" in the Export File function.

-Constanze

80
Support Forum / Re: CNA and bond-angle analysis criterion
« on: September 05, 2018, 01:43:56 PM »
Hi Theo,

alright, in that case you could add a Python Script modifier after the Expand Selection modifier. The following modifier function counts the number of selected atoms (=fcc atoms + 12 nearest neighbors of each fcc atom) and adds a global attribute "my_fcc_count" to your data collection.
Code: [Select]
from ovito.data import *
import numpy as np

def modify(frame, input, output):
    output.attributes["my_fcc_count"] = np.count_nonzero(input.particles["Selection"])

Global attributes appear in the Attributes Section in the Data Inspector and  can be exported using the Export File - Table of Values Option. Does that work for you?

-Constanze

81
Support Forum / Re: CNA and bond-angle analysis criterion
« on: September 05, 2018, 12:05:00 PM »
Dear Theo,

could you please give us a little bit more context what you are trying to do. It is not yet clear to us what question you are trying to answer. What is your setup? Do you have more than these two surface atoms? And what would  a "softer" criterium be in your case, e.g. only being a neighbor to 8 fcc atoms?

I'm happy to help with the python script then.

-Constanze

82
Support Forum / Re: LAMMPS input file with atomic mass information?
« on: September 03, 2018, 12:50:50 PM »
Alternatively,
if you only have the two particle types 1 and 6 in your system using the Compute Property Modifier as suggested by Alex will work as well:

Code: [Select]
pipeline.modifiers.append(ComputePropertyModifier(output_property = 'Mass', expressions = ['(ParticleType == 1) ? 1.008 : 12.011'] ))
pipeline.compute()

83
Support Forum / Re: LAMMPS input file with atomic mass information?
« on: September 03, 2018, 11:21:44 AM »
Hi RU,

here is an example how you would do it in the scripting interface of OVITO 3 with a Python script modifier that uses the user-defined function "assign_mass". Note, that you need to invoke pipeline.compute() to make the particle property "mass" part of your pipeline.

Code: [Select]
from ovito.data import *
from ovito.modifiers import PythonScriptModifier

# Load some input data:
pipeline = import_file("input/simulation.data")

def assign_mass(frame, input, output):
    p_types = input.particles['Particle Type']
    mass = output.particles.create_property('Mass')
    with mass:
        mass[(p_types == 1)] = 1.008
        mass[(p_types == 6)] = 12.011

pipeline.modifiers.append(PythonScriptModifier(function = assign_mass))

# Evaluate data pipeline. This will result in a call to assign_mass() from above.
data = pipeline.compute()

-Constanze

84
Support Forum / Re: Define a new properties
« on: August 27, 2018, 06:06:32 PM »
Dear Ali,

write-access to particle properties was done differently in OVITO 2.9.

In that case, instead of using a with statement in your "lines 81-82" you need to access your particle property "xyz_prime" like this

Code: [Select]
xyz_prime.marray[particle_index] = 1
xyz_prime.changed()

as described in more detail in this Section in the Manual.
Does this solve your problem?

-Constanze

85
Support Forum / Re: Save the distance between two particles
« on: August 27, 2018, 01:53:44 PM »
Hi ramonjgt,

you could use a Python script modifier to calculate the distance between the two particles, e.g. between particle 1 and 2
Code: [Select]
from ovito.data import *
import numpy as np
def modify(frame, input, output):
    distance = np.linalg.norm( input.particles["Position"][1]-input.particles["Position"][2] )
    print (distance)
    output.attributes["Distance"] = distance

and save that information as a global attribute.
Then this information is available in the Text label overlay function as [Distance].

-Constanze

86
Dear Ali,

are you using the GUI of OVITO or is your code snippet part of a larger batch script?
Also can you explain a little bit more on what bonds we are looking at here and how you generate them. It is not yet clear to me which atoms you would like to color code.   A bond angle is defined by three atoms, so which of these three should it be?

-Constanze

87
Support Forum / Re: total strain
« on: August 15, 2018, 05:36:34 PM »
Hi Bahman,

so I assume you have a non-periodic cell where you can't just calculate the total strain from the length change?
Then you could have a look at this topic http://forum.ovito.org/index.php?topic=330.0 ,
where an example is given how to calculate the average value of any particle property using a  Python script modifier. This should answer your question.

Cheers,
Constanze

88
Support Forum / Re: How to coloring particles by its properties
« on: August 09, 2018, 02:30:36 PM »
Hi,
I removed the attached file in Alexander's post.
Best,
Constanze

89
Support Forum / Re: visualization of vectors by arrows
« on: August 07, 2018, 03:29:11 PM »
Hi Ilya,

could you send us a screenshot or even better upload the .ovito state file so we can understand what you're doing.

Best,
Constanze

90
In that case, just change the line where you calculate the Voronoi polyhedra.
Code: [Select]
voro_indices = input.particles['Voronoi Index']
to this:
Code: [Select]
voro_indices = input.particles['Voronoi Index'][ input.particles['Particle Type'] == 1 ]

-Constanze

Pages: 1 2 [3] 4 5