← Back to team overview

yade-dev team mailing list archive

TriaxialStateRecorder vs. python

 

Hello,

I was trying to use python plot.plot() instead of TriaxialStateRecorder.
I had problems with reading wall stresses. They are accessed from
TriaxialStateRecorder with following lines:

<< lexical_cast<string> ( triaxialStressController->stress[triaxialStressController->wall_right][0] ) << " "
<< lexical_cast<string> ( triaxialStressController->stress[triaxialStressController->wall_top][1] ) << " "
<< lexical_cast<string> ( triaxialStressController->stress[triaxialStressController->wall_front][2] ) << " "

But in python a similar thing didn't work. The TriaxialStressController.stress[6]
is not exposed to python. And python actually cannot parse this type.
So I made some changes in TriaxialStressController.[ch]pp so that the
attached script will work. Python cannot also parse type Real[3], so
I replaced it with Vector3r, for strain.

Bruno, can you have a look at what I have changed? Is that OK? I hope
that this change is backward compatible.

please try attached script, after doing `bzr up`
-- 
Janek Kozicki                               http://janek.kozicki.pl/  |
#!/usr/local/bin/yade-trunk -x
# -*- coding: utf-8 -*-
# -*- encoding=utf-8 -*-

TriaxialTest(numberOfGrains=200).load()
O.engines += [PeriodicPythonRunner(iterPeriod=10,command='plot1()')]


triaxialStressController=O.engines[5]

def sigma_1():
	return triaxialStressController.wall_stress[1]

def epsilon_1():
	return triaxialStressController.strain[1]


from yade import qt
qt.View()
qt.Controller()


# plot some results
from math import *
from yade import plot
plot.plots={'epsilon_1':'sigma_1'}
def plot1():
	plot.addData(sigma_1=sigma_1(),
		     epsilon_1=epsilon_1())
O.run(10000,True)
plot.plot()


Follow ups