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 ... 5
1
Support Forum / Re: Von Mises Stress
« on: September 20, 2018, 12:29:25 PM »
This doesn't answer my question. How do you want to save the information you calculated?

Besides, if your lammps command worked (I guess it's because the correct variable style should be atom not equal), the quantity VMS would also be a part of your dump file since it's a per-atom quantity. So now that you've calculated that with OVITO, why don't you append that new information as additional column to your .dump files?

However, the sum of all the per-atom values you compute for every snapshot and save as global attribute is something you could export as *.txt file, like you tried above.

2
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.

3
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] )

4
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

5
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

6
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?

7
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

8
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
   

9
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.


10
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

11
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




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

have you considered using the File Export function?

-Constanze

13
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


14
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] )

15
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.

Pages: [1] 2 3 ... 5