← Back to team overview

yade-users team mailing list archive

Re: [Question #680317]: different result after scenetostring

 

Question #680317 on Yade changed:
https://answers.launchpad.net/yade/+question/680317

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Joe,
nice finding.
The reason is that O.sceneToString only saves "python" variables, defined in YADE_CLASS_...macros.
CpmPhys has some read-only variables defined outside this macro [1] that are not saved and are reset by O.stringToScene.
You can try:
###
print max(i.phys.epsT.norm() for i in O.interactions)
print max(i.phys.sigmaT.norm() for i in O.interactions)
scene = O.sceneToString() ####!!!!!
O.stringToScene(scene) ####!!!!!
print max(i.phys.epsT.norm() for i in O.interactions)
print max(i.phys.sigmaT.norm() for i in O.interactions)

v2 = (trsf2-O.cell.trsf)/(500*O.dt)
O.cell.velGrad = v2
O.run(500,True)

print(O.cell.trsf)
print(utils.getStress())
print max(i.phys.shearForce.norm() for i in O.interactions) #####!!!!!
###
if O.sceneToString() and O.stringToScene(scene) is used or not, the shear strain and shear forces and therefore stress are different.

A solution would be to change the source code and put all these variables to YADE_BASE...
To preserve the read-onlyness, probably Attr::readonly flag (similar to e.g. [2]) should be used.
So basically replacing
Real omega = 0
...
.def_readonly("omega",&CpmPhys::omega,"...")
to
((Real,omega,0,Attr::readonly,"..."))

cheers
Jan

[1] https://gitlab.com/yade-dev/trunk/blob/master/pkg/dem/ConcretePM.hpp#L145
[2] https://gitlab.com/yade-dev/trunk/blob/master/core/Scene.hpp#L78

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.