Author Topic: Von Mises Stress  (Read 584 times)

Amir Dehghan

  • Newbie
  • *
  • Posts: 11
Von Mises Stress
« on: September 19, 2018, 11:38:36 PM »
Hi every one,
I want to get the Von Mises Stress as the data file and get the following steps:
1. Define the  Von Mises Stress formula in " Compute property"
2. I've also added the Python script for write code
But I encounter an error!
I have attached two screenshots for the above mentioned items.
« Last Edit: September 20, 2018, 07:57:43 AM by Amir Dehghan »

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 121
Re: Von Mises Stress
« Reply #1 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
« Last Edit: September 20, 2018, 08:12:38 AM by Constanze Kalcher »

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 121
Re: Von Mises Stress
« Reply #2 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?

Amir Dehghan

  • Newbie
  • *
  • Posts: 11
Re: Von Mises Stress
« Reply #3 on: September 20, 2018, 08:41:32 AM »
Hi Constanze,

I changed the code as you commented, I encountered an error with another issue.
I attached a screenshot.

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 121
Re: Von Mises Stress
« Reply #4 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

Amir Dehghan

  • Newbie
  • *
  • Posts: 11
Re: Von Mises Stress
« Reply #5 on: September 20, 2018, 10:26:35 AM »
Thanks, its working now.

If I want to have the sum of all arrays (like the command "compute  Stress_zz all reduce sum c_Stress[3]" in Lammps)
What should I do?

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 121
Re: Von Mises Stress
« Reply #6 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
« Last Edit: September 20, 2018, 11:10:47 AM by Constanze Kalcher »

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 121
Re: Von Mises Stress
« Reply #7 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] )

Amir Dehghan

  • Newbie
  • *
  • Posts: 11
Re: Von Mises Stress
« Reply #8 on: September 20, 2018, 11:19:25 AM »
Thanks alot.

When im exporting the Von Mises Stress data, do not display it to .*txt file correctly!
Attached to the data file and a screenshot.

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 121
Re: Von Mises Stress
« Reply #9 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.

Amir Dehghan

  • Newbie
  • *
  • Posts: 11
Re: Von Mises Stress
« Reply #10 on: September 20, 2018, 12:12:59 PM »
Because im using Von Mises Stress formula code in lammp ( compute Stress all stress/atom NULL

variable VMS equal "(sqrt((c_Stress[1]-c_Stress[2])^2+(c_Stress[2]-c_Stress[3])^2+(c_Stress[3]-c_Stress[1])^2+6*(c_Stress[4]^2+c_Stress[5]^2+c_Stress[6]^2)/2))/1000000"
.
.
.
dump 1 all custom 10 dump1.lammpstrj mass id type x y z c_Stress[1] c_Stress[2] c_Stress[3] c_Stress[4] c_Stress[5] c_Stress[6] v_VMS ),

im facing this error: "ERROR: Dump custom variable is not atom-style variable (../dump_custom.cpp:1426)"


Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 121
Re: Von Mises Stress
« Reply #11 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.
« Last Edit: September 20, 2018, 01:26:55 PM by Constanze Kalcher »