problem of the command "O.cell.velGrad"

Asked by


Firstly, A RVE (goal stress-strain stress(0,0)=0,strain(1,1)=-0.008,stress(0,1)=0, strain(2,:)=0) is calibrated using the following commands:

#!/usr/bin/python # This is file
import string
from yade import plot,qt
from yade.pack import *
from yade import pack



def plotAddData():
 with open('stressStrain.txt','a') as f:
  f.write(str(p3d.strain[0])+' '+str(p3d.strain[1])+ ' ' + str(p3d.strain[5])+' '+str(p3d.stress[0])+' '+str(p3d.stress[1])+ ' ' + str(p3d.stress[5]))


       nSteps=10000, # how many time steps the simulation will last
       # after reaching nSteps do doneHook action
       doneHook='print "Simulation with Peri3dController finished."; O.pause()',

p3d.stressMask=0b100001 # prescribed sx,ey,sz,syz,ezx,sxy; e..strain; s..stress
p3d.goal=(0,-0.008,0,0,0,0) #xx, yy, zz, yz, zx, xy
bo1s.aabbEnlargeFactor=ig2ss.interactionDetectionFactor=1.; O.wait()

As you can see, the strain and stress at each step are written in the file "stressStrain.txt".

Now I want to use the strain in the "stressStrain.txt" to calculate the stress again using the following commands:


#!/usr/bin/python # This is file
import string

from yade.pack import *
from yade import pack
import numpy as np # initial the math of matrix compute (needed in ns)

# initial the global , variables
arrcc =[0]*3 # last step strain(commit)
arrtt =[0]*3 # last step strain(trail)
scc=[0]*3 # last step stress
orst=1 # initialize the orginal save document(trial)
check=[0]*1 # I need to calculate the first step when ag=0

# load the identical package
O.load('./model.gz') # only load the package, because the O.cell.velGrad is not compatible with the peri3dcontroller eigine
#O.periodic=True ### note!!! add

# see the example of peri3dcontroller, 1.5 is used to speed up the computation


bo1s.aabbEnlargeFactor=ig2ss.interactionDetectionFactor=1. # O.step and change 1.5 back to 1. , because the concrete model is developed in the 1. environment

def response(msg):
 # change the form of message
 aa = msg.split(',')
 global arrcc
 global arrtt
 global scc
 global orst

     arr=[0]*3 # change form, the current strain

 if orst == 2:
 orst == 2

     for i in range(0,3):
         arr[i] = string.atof(aa[i])
 ag = [0]*3 # current - last ie. the changed strain
 ag[0] = arr[0] - arrcc[0]
 ag[1] = arr[1] - arrcc[1]
  ag[2] = (arr[2] - arrcc[2]) # incremental strain

 arrcc[0]=arr[0] # update strain

 dstrain = utils.Matrix3(ag[0],ag[2],0,ag[2],ag[1],0,0,0,0) # the goal strain xx xy xz, yx yy yz, zx zy zz

 stressxx=stressValue[0,0] # the return stress xx
 stressyy=stressValue[1,1] # the return stress yy
 stressxy=(stressValue[0,1]+stressValue[1,0])/2 # the return stress xy = (xy + yx)/2
 print stressxx,stressyy,stressxy

 O.saveTmp('temp') # different gauss point has different number(first first ...)

with open('stressStrain.txt','r') as f:
for i in lines:
 msg = str(strain[0])+","+str(strain[1])+","+str(strain[2])


I thought the stress calculated are the same ones in the "stressStrain.txt" (or acceptable small errors ), however, they are not, and the results are seriously affected by the time step O.dt.
I think using the command "O.cell.velGrad=dstrain/(ns*O.dt) "can reach the strain I want.
Can you please tell me how to solve the problem? my goal is: when I give a strain, the RVE returns a correct stress (i.e., the one in the stressStrain.txt )

I would greatly appreciate it if you can help me!
Thank you!

Question information

English Edit question
Yade Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Bruno Chareyre (bruno-chareyre) said :


> thought the stress calculated are the same ones in the "stressStrain.txt"
> print stressxx,stressyy,stressxy
> msg = str(strain[0])+","+str(strain[1])+","+str(strain[2])

Is the question about strain or about stress?

Revision history for this message ( said :


The question is, in the first file, when I calibrated the parameters of the RVE, I can get the strain and stress at each step. For example, the strain is [0,1e-5,0] at first step, the corresponding stress is [0 1e3 0];

Then I use the strain to calculate the stress using the method in the second file:

dstrain = utils.Matrix3(0,0,0,0,1e-5,0,0,0,0)

and the stress I get from this way is not [0 1e3 0], but another one.

So I am confused, that the RVE I calibrated, which is applied to the same strain, the stress is different?

Thank you for your help!

Revision history for this message
Jan Stránský (honzik) said :


I have tried your code, but it is running too long. Could you please modify it to run faster for easy testing?

> the results are seriously affected by the time step O.dt
> O.cell.velGrad=dstrain/(ns*O.dt)

how they could not be affected, if O.dt defines velGrad?
Not only absolute strain, but also strain rate influences the results. After all, it is a dynamic simulation...
Use the same O.dt for both simulations if you want to get same results.

> I think using the command "O.cell.velGrad=dstrain/(ns*O.dt) "can reach the strain I want.

Apart from just strain, export also O.cell.trsf from the first simulation.
Than, in the second simulation, compare saved O.cell.trsf with actual O.cell.trsf.
My guess is that they do differ. If yes, than the strain is not the same.

> that the RVE I calibrated, which is applied to the same strain

see above, depends on what "strain" is. O.cell.trsf (deformation gradient) is more unique measure.


Can you help with this problem?

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

To post a message you must log in.