Run from a saved Yade model

Asked by Hien N.G. NGUYEN

Hello Yade devs and users,
I have a question about loading a saved model and change the engine behavior.:

I followed the example in https://github.com/yade/trunk/blob/master/examples/triax-tutorial/script-session1.py
At line 160: O.save('compactedState'+key+'.yade.gz') I use O.save('mymodel.xml.gz') and then I have the file mymodel.xml.gz in that folder, I stopped there and turn off yade.
Next time, to continue my simulation I run this script to continue, as a normal triaxial test:

from yade import pack, utils
O.load('mymodel.xml.gz')
triax=TriaxialStressController()
while 1:
  triax.stressMask=5
  triax.goal2=-0.01
  triax.goal1=100000
  triax.goal3=100000
  O.run(100,True)
  print 'p=', triax.meanStress
  if triax.strain[1] < 80000:
    break

but I see that when I run that script, in the terminal, the output of triax.meanStress is 0.0, and the TriaxialStressController is still continuing to use stressMask=7 with goal=100000 (I used Inspect tool from graphic interface) as saved from previous simulation. It seems that my code didn't affect the model at all.
I tried both
yade-stable myscript.py and yade-stable then execfile('myscript.py')

Can you explain this for me, thank you!

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jérôme Duriez
Solved:
Last query:
Last reply:
Revision history for this message
Jérôme Duriez (jduriez) said :
#1

Hello,

It's not really related with save/load in fact.

In the example script you are using, triax is a python variable corresponding to an instance (I hope not mistaking about the words) of a TriaxialStressController engine. This variable / instance of engine was then introduced in the list of the Engines of the simulation (l.107)

But, in the code you gave us, triax corresponds to a *new* instance of a TriaxialStressController engine, that has *nothing* to do with the simulation ! (since it does not belong to engines list) That's why it does not affect the model...

The solution is to modify the right Engine belonging to O.engines (probably by triax = O.engines[4] ?)

Revision history for this message
Hien N.G. NGUYEN (rin) said :
#2

Sweet, a clear explanation.
I can call meanStress by O.engines[4].meanStress and assign by
O.engines[4].stressMask... now.
But then by using O.engines[4] how to call the stress on the 6 walls.
It was like triax.stress(triax.wall_top_id)[1] and print
triax.stress(triax.wall_top_id)[1] supposes to have 100000 but I received
0.0 again.

On Wed, Oct 16, 2013 at 11:21 AM, jduriez <
<email address hidden>> wrote:

> Your question #237426 on Yade changed:
> https://answers.launchpad.net/yade/+question/237426
>
> Status: Open => Answered
>
> jduriez proposed the following answer:
> Hello,
>
> It's not really related with save/load in fact.
>
> In the example script you are using, triax is a python variable
> corresponding to an instance (I hope not mistaking about the words) of a
> TriaxialStressController engine. This variable / instance of engine was
> then introduced in the list of the Engines of the simulation (l.107)
>
> But, in the code you gave us, triax corresponds to a *new* instance of a
> TriaxialStressController engine, that has *nothing* to do with the
> simulation ! (since it does not belong to engines list) That's why it
> does not affect the model...
>
> The solution is to modify the right Engine belonging to O.engines
> (probably by triax = O.engines[4] ?)
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/yade/+question/237426/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/yade/+question/237426
>
> You received this question notification because you asked the question.
>

--

Nguyễn Nho Gia Hiển
Gia Hien NGUYEN NHO

*· *University of Technology, Ho Chi Minh City, Viet Nam
Civil Engineer

Revision history for this message
Best Jérôme Duriez (jduriez) said :
#3

I suspect (I'm not an expert in triaxial engines) that the stresses were not computed again since you loaded (I see this variable, especially : https://www.yade-dem.org/doc/yade.wrapper.html#yade.wrapper.TriaxialStressController.computeStressStrainInterval, not well documented, it's true ;-) )
Try to run few steps, and check again

Revision history for this message
Hien N.G. NGUYEN (rin) said :
#4

You are right, I've figured it out by running about 100 steps with the old configuration of the engine then recall triax.stress(triax.wall_top_id)[1] again and there it is.

Revision history for this message
Hien N.G. NGUYEN (rin) said :
#5

Thanks jduriez, that solved my question.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#6

Well done Jerome. :)