can't update velGrad value in a periodic cell

Asked by Sacha Duverger on 2019-10-21

Hello,

I'm having trouble resetting to zero some of O.cell.velGrad coefficients in a periodic cell. I assign new values through O.cell.nextVelGrad as yade's documention specifies it, but when the value I want to assign is zero velGrad doesn't change.
Besides O.cell.velGradChanged always stays False. If I understood the documentation correctly it should be turned to True as soon as I set a value in O.cell.nextVelGrad.

Is there something I'm missing?

Thanks in advance,

I'm using Yade 2018.02b, here is my MWE and output:

O.periodic = True
O.bodies.append(sphere((1,1,1),1))
O.cell.setBox(2,2,2)

print O.cell.velGrad, O.cell.velGradChanged

for i in range(3): O.cell.nextVelGrad[i,i] = -1
O.step()
print O.cell.velGrad, O.cell.velGradChanged

for i in range(3): O.cell.nextVelGrad[i,i] = -2
O.step()
print O.cell.velGrad, O.cell.velGradChanged

for i in range(3): O.cell.nextVelGrad[i,i] = 0
O.step()
print O.cell.velGrad, O.cell.velGradChanged

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

Output:

Matrix3(0,0,0, 0,0,0, 0,0,0) False
Matrix3(-1,0,0, 0,-1,0, 0,0,-1) False
Matrix3(-2,0,0, 0,-2,0, 0,0,-2) False
Matrix3(-2,0,0, 0,-2,0, 0,0,-2) False

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-10-22
Last query:
2019-10-22
Last reply:
2019-10-21
Best Jan Stránský (honzik) said : #1

Hello,

> I assign new values through O.cell.nextVelGrad as yade's documention specifies it

it is always good to be more specific (like a link to a paragraph in documentation). I assume you mean [1].

First of all, nextVelGrad is read-only [2]. Usually it has some reason. The documentation [1] says, that if you set velGrad, internally it is stored in nextVelGrad, but it is not meant to set nextVelGrad directly.

You can hack it by assignment of individual components, but definitely it is not recommended.

> Besides O.cell.velGradChanged always stays False.

according to source code [3], velGradChanged=true is set, if velGrad is set (also see above)
Moreover, it is reset to false at O.step() [4], so print it before O.step().

###
O.cell.velGrad = Matrix3(-1,0,0, 0,-1,0, 0,0,-1)
print O.cell.velGrad, O.cell.velGradChanged
O.step()
print O.cell.velGrad, O.cell.velGradChanged
###

cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Cell.velGrad
[2] https://gitlab.com/yade-dev/trunk/blob/master/core/Cell.hpp#L162
[3] https://gitlab.com/yade-dev/trunk/blob/master/core/Cell.hpp#L106
[4] https://gitlab.com/yade-dev/trunk/blob/master/pkg/dem/NewtonIntegrator.cpp#L100

Sacha Duverger (schmxprr) said : #2

Thanks Jan Stránský, that solved my question.