what are the input variables to get the micro-stress firled

Asked by nobody on 2019-10-16

I asked this question before[1], as I mentioned before YADE on the cluster right now doesn't have the TesselationWrapper module now, but I still want to get the micro-strain field and micro-stress field.

So I need to know what are the input variables to the TesselationWrapper to get these fields.
In reference 1 #7, Jan told me what are the input variables for the micro-strain filed, indeed, this works very well. again, thanks to Jan.

If I want to get the micro-stress field. except for the position and radius data for all the particles. what are the other variables I need to output?

############################
#"b" being a body
TW=TesselationWrapper()
TW.setState()
TW.computeVolumes()
s=bodyStressTensors()
stress = s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id)

According to the code given on the official website above, so I need to output the id and use the bodyStressTensors to get the stress??
####################################
###########################
or from this [2] reference (especially equation 39), I need to output all the contact force and contact point and do the cross product and the get the per particle stress.

####################

thanks in advance

best,
yong

[1]:https://answers.launchpad.net/yade/+question/684747
[2]https://arxiv.org/pdf/1304.4895.pdf

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
2019-10-19
Last reply:
2019-10-20
Robert Caulk (rcaulk) said : #1

>doesn't have the TesselationWrapper module

Let's be clear and concise about the problem at hand, you are unable to to compile yade with CGAL on your cluster.

 >I need to know what are the input variables to the TesselationWrapper to get these fields.

TesselationWrapper is a set of functions that uses CGAL to triangulate your particles and then obtain information from that triangulation. So the input is simply your entire packing of particles (coordinates and their radii to be exact) :-). Let's try to put it simply, your DEM packing is a letter, TesselationWrapper is the mailman, CGAL is the recipient. TesselationWrapper takes your letter and delivers it to CGAL. CGAL reads the letter and writes a response (the triangulation). CGAL sends the response through our trusty mailman, TesselationWrapper. I don't expect this process to have a happy ending if CGAL does not receive the letter.

Now that we are familiar with how the back end works, it is clear that performing the duties of TesselationWrapper without CGAL requires us to find a new recipient (triangulation software), and a new mail man to send our letter (data interface). The way to start that process is, as Jan suggests in [1], create a text file of the coordinates of your particles at each state of interest. Then mail them to a different library using a different mail man.

As you might remember me saying in one of your other posts about this, figuring out how to link CGAL is undoubtedly the only route. Simply selecting a different route in this case already indicates that you will face troubles along that particular route.

[1]https://answers.launchpad.net/yade/+question/684747

Jan Stránský (honzik) said : #2

Hi,

> If I want to get the micro-stress field. except for the position and radius data for all the particles. what are the other variables I need to output?

as you guessed, it is stress tensor of each body :-)

> According to the code given on the official website above, so I need to output the id and use the bodyStressTensors to get the stress??

ID is not needed IMO (but does not hurt anything at the same time). You can output the stresses in one file with x,y,z,r or you can just use a separate file.
Normally corresponding line fits together, ID is the line number.

> or from this [2] reference (especially equation 39), I need to output all the contact force and contact point and do the cross product and the get the per particle stress.

You can do this, but it just what bodyStressTensors computes, so less error prone would be to use the output of bodyStressTensors directly.
It is not cross product, but tensor product [3]

cheers
Jan

[3] https://en.wikipedia.org/wiki/Tensor_product

nobody (nobody01) said : #3

Hi Jan, Robert,

thank you guys give me the suggestions.

right now I can export the position, radius, and the nine components per particle stress. I named these variables as
(x,y,z,r,s11,s22,s33,s44,s55,s66,s77,s88,s99)

as reference [1] mentioned that we can use export.VTKExporter to export the stress.

exportSpheres(ids='all', what={}, comment='comment', numLabel=None, useRef=False)

in this command, we need to set the what ={},

I wrote the code like this :

from yade import ymport, export
import numpy as np
vtk = export.VTKExporter("stress")
i = 0
number_of_txtfiles = 100
while i < number_of_txtfiles:
 O.bodies.append(ymport.text("./num"+str(i)+".txt"))
 TW = TesselationWrapper()
 TW.triangulate()
 TW.computeVolumes()
 TW.setState
 vtk.exportSpheres(ids='all',what=[('stress',"numpy.array([s11,s22,s33],[s44,s55,s66],[s77,s88,s99])")],useRef=False) ##### this line
 i = i +1
###################

I know there are some problems with (##### this line). Because the command mentioned that, for the" what " parameter we need to do as this reference[2] said.

 what=dict(particleVelocity='b.state.vel',dist='b.state.pos.norm()', ... )

since I already output the particle information. how can I relate this information to this command (vtk.exportSpheres)
Because in the "what" parameter, I need to set the b attribute.

thanks in advance.

best,
yong

but right now how can I input the nine components in the vtk.exportSpheres command, especially in the

[1]https://yade-dem.org/doc/user.html#microstressandmicrostrain
[2]https://yade-dem.org/doc/yade.export.html?highlight=exportspheres#yade.export.VTKExporter.exportSpheres

nobody (nobody01) said : #4

Hi all,

let me make this more clear, right now I exported some text files. the file contains the position, radius, and the nine per particle stress components.

I'm trying to use the following code to output the micro stress field[1].

###############################################
from yade import ymport, export
vtk = export.VTKExporter("stress")
s=bodyStressTensors()
m = 0
number_of_txtfiles =1634
while m < number_of_txtfiles:
 O.bodies.append(ymport.text("./num"+str(m)+".txt"))
 O.step()
 TW = TesselationWrapper()
 TW.triangulate()
 TW.computeVolumes()
 TW.setState
 for b in O.bodies:
  if isinstance(b.shape,Sphere):
   b.mystress = s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id)
   vtk.exportSpheres(ids='all',what=[('pos','b.state.pos'),('stress','b.mystress')],useRef=False)
 m = m +1
########################################
here is the error.

Welcome to Yade 2018.02b
TCP python prompt on localhost:9000, auth cookie `cuessk'
XMLRPC info provider on http://localhost:21000
Running script calculate-stress.py
Traceback (most recent call last):
  File "/usr/bin/yade", line 182, in runScript
    execfile(script,globals())
  File "calculate-stress.py", line 16, in <module>
    b.mystress = s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id)
IndexError: list index out of range
[[ ^L clears screen, ^U kills line. F12 controller, F11 3d view (use h-key for showing help), F10 both, F9 generator, F8 plot. ]]
#############################
I tried the following attempts:
1) print out some basic particle information

In [1]: len(O.bodies)
Out[1]: 622

In [2]: b.state.pos
Out[2]: Vector3(0.935164196838,0.38080276367,0.869850258236)

In [3]: b.shape.radius
Out[3]: 0.041134821457

this is the same as the first exported text file.

2) I tried to print out the per particle stress. i.e. the stress I got by using bodystresstensor.

In [5]: s
Out[5]: []

In [6]: s[b.id]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/usr/bin/yade in <module>()
----> 1 s[b.id]

IndexError: list index out of range

In [7]:

this means that particle stress didn't import successfully. So I checked the yade.ymport.text function, here is the explanation: it says it will load the coordinate from the file. as for the **kw ((unused keyword arguments) is passed to utils.sphere). I checked the definition of the utils.sphere[3] , it didn't mention particle stress.

#################################
as we all know, we do not have some function like the position (b.state.pos) (this is something like the intrinsic funtion that a particle has, but for the particle stress, we don't have commnad like b.sress or b.state.stress), I think maybe this is the reason why the per particle stress can not import successfully.

besides, I don't know why the list index is out of range.

#########################

thanks,

references
[1]https://yade-dem.org/doc/user.html#microstressandmicrostrain
[2]https://yade-dem.org/doc/yade.ymport.html?highlight=yade%20ymport%20text#yade.ymport.text
[3]https://yade-dem.org/doc/yade.utils.html?highlight=yade%20utils%20sphere#yade.utils.sphere

> besides, I don't know why the list index is out of range.

Hi,
I have a small training to suggest, try to recognize this pattern in your code:

listOfIds=range(len(O.bodies))
O.bodies.append(Body())
print(listOfIds[0])

---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/usr/bin/yadedaily in <module>()
----> 1 print(listOfIds[0])

IndexError: range object index out of range

Bruno

Jan Stránský (honzik) said : #6

> right now I can export the position, radius, and the nine components per particle stress. I named these variables as
(x,y,z,r,s11,s22,s33,s44,s55,s66,s77,s88,s99)
> since I already output the particle information. how can I relate this information to this command (vtk.exportSpheres)

since you already output the particle information, use this output and do not make it more difficult than necessary :-)

VTKExporter is meant to save data in .vtk format (for Paraview). I would not use it for this case (although it is possible). But anyway you would have to read the 9 components and then somehow process them. No benefit compared to using already saved 9 components..

Just to make the answer complete, here is a MWE how to save the stresses with VTKExporter (have a look at the output file).
###
from yade import export
O.bodies.append((
   sphere((0,0,0),1),
   sphere((1,0,0),1),
))
O.step()
stresses = bodyStressTensors()
vtk = export.VTKExporter("stress-test")
for b in O.bodies:
   b.mystress = stresses[b.id]
vtk.exportSpheres(what=[("stress","b.mystress")])
###
here, the name 'stress' is used, but it can be any name (e.g. just 'stress', which does not conflict (a few) names already occupied by C++ (like state, shape, material, isClump etc.)

cheers
Jan

nobody (nobody01) said : #7

Hi Jan,
In your MWE, you use (b.mystress = stresses[b.id] ), this command and then export it.

while here[1]. the micro-stress part mentioned that first we need to get the per-particle stress given by bodyStressTensors.

here in my opinion, what you've done is just to get the per-particle stress.

After that, we need to use this command: stress = s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id). as [1] mentioned we need to re-normalize it in order to obtain the micro-stress.

overall, in my opinion, I think this is (stresses[b.id] ) to get the per-particle stress.
stress = s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id) this is to get the micro-stress.

I don't know my understanding is right or not.

if your opinion is right, which means per-particle stress is the same as the micro-stress filed??

can you help me to understand this more thoroughly?

best,
yong

[1]https://yade-dem.org/doc/user.html#microstressandmicrostrain

nobody (nobody01) said : #8

Hi Bruno,

I put the code you gave me in the terminal.

here are the results:

#############################
In [1]: listOfIds=range(len(O.bodies))

In [2]: O.bodies.append(Body())
Out[2]: 622

In [3]: print(listOfIds[0])
0

In [4]: print(range(len(O.bodies)))
output for this command is [0 all the way to 622]

 In [5]: print(listOfIds)
output for this command is [0 all the way to 621]

In [6]: print(O.bodies.append(Body()))
623

######################
you can see they are not the same, so I am thinking mat be there are somthing wrong with this.

best,
yong

Chareyre (bruno-chareyre-9) said : #9

Hi, i meant to execute it without running your script first.
Bruno

Le ven. 18 oct. 2019 22:08, nobody <email address hidden> a
écrit :

> Question #685223 on Yade changed:
> https://answers.launchpad.net/yade/+question/685223
>
> nobody gave more information on the question:
> Hi Bruno,
>
> I put the code you gave me in the terminal.
>
> here are the results:
>
> #############################
> In [1]: listOfIds=range(len(O.bodies))
>
> In [2]: O.bodies.append(Body())
> Out[2]: 622
>
> In [3]: print(listOfIds[0])
> 0
>
> In [4]: print(range(len(O.bodies)))
> output for this command is [0 all the way to 622]
>
> In [5]: print(listOfIds)
> output for this command is [0 all the way to 621]
>
>
> In [6]: print(O.bodies.append(Body()))
> 623
>
>
> ######################
> you can see they are not the same, so I am thinking mat be there are
> somthing wrong with this.
>
>
> best,
> yong
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>
>

nobody (nobody01) said : #10

Hi Bruno,

I did as you said, the result is the same as you posted, but I didn't fully understand what does this mean and why we need to do this, can you explain a little bit more.

#########################
elcome to Yade 2018.02b
TCP python prompt on localhost:9000, auth cookie `caskdy'
XMLRPC info provider on http://localhost:21000
[[ ^L clears screen, ^U kills line. F12 controller, F11 3d view (use h-key for showing help), F10 both, F9 generator, F8 plot. ]]

In [1]: listOfIds = range(len(O.bodies))

In [2]: O.bodies.append(Body())
Out[2]: 0

In [3]: print(listOfIds[0])
-------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/usr/bin/yade in <module>()
----> 1 print(listOfIds[0])

IndexError: list index out of range

yong

Chareyre (bruno-chareyre-9) said : #11

Ok good.
Now as suggested earlier try to understand why it fails, then see if you
don't have something similar in your script (the error is the same).
Bruno

Le dim. 20 oct. 2019 00:47, nobody <email address hidden> a
écrit :

> Question #685223 on Yade changed:
> https://answers.launchpad.net/yade/+question/685223
>
> Status: Answered => Open
>
> nobody is still having a problem:
> Hi Bruno,
>
> I did as you said, the result is the same as you posted, but I didn't
> fully understand what does this mean and why we need to do this, can you
> explain a little bit more.
>
>
> #########################
> elcome to Yade 2018.02b
> TCP python prompt on localhost:9000, auth cookie `caskdy'
> XMLRPC info provider on http://localhost:21000
> [[ ^L clears screen, ^U kills line. F12 controller, F11 3d view (use h-key
> for showing help), F10 both, F9 generator, F8 plot. ]]
>
> In [1]: listOfIds = range(len(O.bodies))
>
> In [2]: O.bodies.append(Body())
> Out[2]: 0
>
> In [3]: print(listOfIds[0])
> -------------------------------------------------------------------------
> IndexError Traceback (most recent call last)
> /usr/bin/yade in <module>()
> ----> 1 print(listOfIds[0])
>
> IndexError: list index out of range
>
> yong
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>
>

Jan Stránský (honzik) said : #12

Hi,

> here in my opinion, what you've done is just to get the per-particle stress.

exactly, in my MWE I just exported stress computed by bodyStressTensors(), answering "how can I relate this information to this command (vtk.exportSpheres)"

cheers
Jan

Can you help with this problem?

Provide an answer of your own, or ask nobody for more information if necessary.

To post a message you must log in.