How to use TW.triangulate() to calculate strain between two states by importing samples

Asked by Leonard

Hi,

I'd like to ask that how to use TW.triangulate() to calculate strain between two states by importing the two samples at the corresponding states.

The approach of calculating micro-strain between state 0 and state 1 is mentioned at [1], the main steps are as below:
###
O.load("test.yade") ## import sample
TW.setState(0) #store current positions internaly for later use as the "0" state
O.run(100,True) #make particles move a little (let's hope they will!)
TW.setState(1) #store current positions internaly in the "1" (deformed) state
TW.defToVtk("strain.vtk")
###
The above code works well during a simulation.

However, I have carried out a series of triaxial compression tests and I saved samples at different axial strain levels (e.g. at strain 0%, 10%, 20%). I wonder if I can use TW.triangulate() to calculate the micro-strain between strain10% and strain20% (or any of the two strain states). If it is possible, it will save a lot of time as I don't need to re-run all the tests again.

something like (pseudocode):

###
O.load("sample_strain0.yade")
TW.setState(0) #store current positions internaly for later use as the "0" state
O.load("sample_strain1.yade")
TW.setState(1) #store current positions internaly in the "1" (deformed) state
TW.defToVtk("strain.vtk")
###

Thanks!

Leonard

[1]https://yade-dev.gitlab.io/trunk/user.html#micro-strain

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Karol Brzezinski (kbrzezinski) said (last edit ):
#1

Hi Leonard,

How about saving packings at different states in external txt files, and computing strains between pairs of files? [1]

Best wishes,
Karol

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

Revision history for this message
Leonard (z2521899293) said :
#2

Hi Karol,

Haha, thanks for addressing this question again.

Just two things to be confirmed to make sure I correctly understood:

1. In the two txt files, each line (which is the x, y, z, radius of a sphere) should be the same sphere. e.g. If sphere id 10 is at the 10th line in txt1, it should also be at the 10th line in txt2.

2.When I input the two txt files into defToVtkFromPositions(), I use the 2 lines of code as below:

TW=TesselationWrapper()
TW.defToVtkFromPositions("txt1.txt","txt2.txt","def.vtk")

without TW.triangulate() which has been used in example [1]. I'd like to confirm that when we use defToVtkFromPositions(), there is no need to involve TW.triangulate().

Please correct me if I am wrong.

One question is that, when I execute TW.defToVtkFromPositions(), it returns a Macro strain and it is always:

0 0 0
0 0 0
0 0 0
in all of my states against initial state in a triaxial compression test. Even I can observe strain_deviator difference in paraview at different states. May I ask what is Macro strain and why it is a zero matrix in my case.

Thanks

Best wishes
Leonard

[1]https://yade-dev.gitlab.io/trunk/user.html#micro-strain

Revision history for this message
Karol Brzezinski (kbrzezinski) said :
#3

Hi Leonard,

Regarding your questions:

1. Yes - the order of spheres in files must be identical.

2. You still need to triangulate and compute volumes. Sorry, if it was not clear previously linked topic. Please see the example provided here [2]. Two approaches are compared on one example, but the code should be self-explanatory.

Cheers,
Karol

[2] https://answers.launchpad.net/yade/+question/696150

Revision history for this message
Leonard (z2521899293) said :
#4

Hi Karol,

Thanks very much for your reply and the nice reference example.

>>You still need to triangulate and compute volumes

Maybe it would be better to clarify my doubt: I think TW.triangulate() and TW.computeVolumes() are only needed in the approach of using TW.setState(0) TW.setState(1). While in the approach of using TW.defToVtkFromPositions( 'sp0.txt','sp1.txt' , 'strain_from_files.vtk'), TW.triangulate() and TW.computeVolumes() are not needed.

Taking your example, now we don't compare the two approaches, but we compare the approach of using TW.defToVtkFromPositions with/ without triangulate and compute volumes:

####
centers = []
for x in range(3):
 for y in range(3):
  for z in range(3):
   centers.append((x,y,z))

O.bodies.append([
 sphere(center=center,radius=1,) for center in centers
])

sp = SpherePack()
sp.fromSimulation()

TW=TesselationWrapper()
# TW.triangulate() ## without triangulate
# TW.computeVolumes() ## without compute volumes

sp.save('sp0.txt')

shiftBodies(list(range(18,27,1)),(0,0,0.5)) # move one layer of spheres without engines (I am just being lazy)

sp.fromSimulation()
sp.save('sp1.txt')
TW.defToVtkFromPositions( 'sp0.txt','sp1.txt' , 'strain_from_files2.vtk')
####
The above example uses TW.defToVtkFromPositions without triangulate and compute volumes, and the vtk file visualised in paraview seems to be the same as TW.defToVtkFromPositions with triangulate and compute volumes.

Thereby, I think it is not needed to triangulate and compute volumes when use TW.defToVtkFromPositions(). Please correct me if I misunderstood.

Thanks

Best regards,
Leonard

Revision history for this message
Karol Brzezinski (kbrzezinski) said :
#5

Sorry, but I am 'computerless' right now, and I cannot check it to confirm.
Can you please take the above example, comment out the triangulation part and see if you get the same results?

Cheers,
Karol

Revision history for this message
Leonard (z2521899293) said :
#6

Hi Karol,

Many thanks for your reply.

Here are the output with triangulation part (i.e. not comment out)
#############
Triangulated Grains : 33
sym_grad_u_total_g (wrong averaged strain):
0 0 0.125
0 0 0
0.125 0 0

Total volume = 8, grad_u =
0 0 0
0 0 0
0.25 0 0

sym_grad_u (true average strain):
0 0 0.125
0 0 0
0.125 0 0

Macro strain :
0 0 0
0 0 0
0 0 0
########

Here below are the output without triangulation part (i.e. comment out):

#######
Triangulated Grains : 33
sym_grad_u_total_g (wrong averaged strain):
0 0 0.125
0 0 0
0.125 0 0

Total volume = 8, grad_u =
0 0 0
0 0 0
0.25 0 0

sym_grad_u (true average strain):
0 0 0.125
0 0 0
0.125 0 0

Macro strain :
0 0 0
0 0 0
0 0 0
#############

In addition, the two vtk files are visulised in paraview and they look the same.

Thanks

Leonard

Revision history for this message
Launchpad Janitor (janitor) said :
#7

This question was expired because it remained in the 'Open' state without activity for the last 15 days.