# InteractionLocator.macroAroundPt module

Asked by Rinaldi Giuseppe on 2012-01-18

HI all,

I'm a postgraduate student and I'm writing my master thesis at the Warwick University.
I'm studying the sand behaviour in Simple-shear test by changing the strain rate.

In order to evaluate the stress in different points of the periodic cell I want to use the module:

So I wrote: " from yade import eudoxos" at the beginning of the script.

and then:

.....

def saveData():

strain=strainTensor() # strain tensor
stress=stressTensor() # stress tensor
# -------------------------------------------------------------------------
# STRESS TENSOR, normal and tangential component
sigN,sigT=utils.normalShearStressTensors(compressionPositive=True)
sigN,sigT=sigN.diagonal(),sigT.diagonal();
# -------------------------------------------------------------------------
# STRESS TENSOR - NORMAL PART - strong and weak component
stressStrong,stressWeak=utils.normalShearStressTensors(compressionPositive=True,splitNormalTensor=True)
stressStrong,stressWeak=stressStrong.diagonal(),stressWeak.diagonal()
# -------------------------------------------------------------------------
# FABRIC TENSOR, strong and weak component
fabStrong,fabWeak=utils.fabricTensor(splitTensor=True,revertSign=True)
fabStrong,fabWeak=fabStrong.diagonal(),fabWeak.diagonal()
# -------------------------------------------------------------------------
# FABRIC TENSOR, total
fabTot=utils.fabricTensor(splitTensor=False)[0] # get the matrix (the function returns a tuple)
fabTot=fabTot.diagonal()
# -------------------------------------------------------------------------

pointstress=_eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
......

But I get the following:

NameError Traceback (most recent call last)

----> 1
2
3
4
5

128 # -------------------------------------------------------------------------

129
--> 130 pointstress=_eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
131
132 # ENERGY TERMS

NameError: global name '_eudoxos' is not defined

Any ideas why it doesn't work?

Giuseppe

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Rinaldi Giuseppe
Solved:
2012-01-19
Last query:
2012-01-19
2012-01-19
 Jan Stránský (honzik) said on 2012-01-18: #1

Hi Rinaldi,

as I see it, the script does not work, because (as error says) _eudoxos
is not defined. Try to use eudoxos instead (without underscore).
Hopefully you will be successfull.

If you have any other problem, do not hesitate to ask on this forum
Good luck
Jan

Rinaldi Giuseppe píše v St 18. 01. 2012 v 13:55 +0000:
> New question #185098 on Yade:
>
> HI all,
>
> I'm a postgraduate student and I'm writing my master thesis at the Warwick University.
> I'm studying the sand behaviour in Simple-shear test by changing the strain rate.
>
> In order to evaluate the stress in different points of the periodic cell I want to use the module:
>
>
> So I wrote: " from yade import eudoxos" at the beginning of the script.
>
> and then:
>
> .....
>
> def saveData():
>
> strain=strainTensor() # strain tensor
> stress=stressTensor() # stress tensor
> # -------------------------------------------------------------------------
> # STRESS TENSOR, normal and tangential component
> sigN,sigT=utils.normalShearStressTensors(compressionPositive=True)
> sigN,sigT=sigN.diagonal(),sigT.diagonal();
> # -------------------------------------------------------------------------
> # STRESS TENSOR - NORMAL PART - strong and weak component
> stressStrong,stressWeak=utils.normalShearStressTensors(compressionPositive=True,splitNormalTensor=True)
> stressStrong,stressWeak=stressStrong.diagonal(),stressWeak.diagonal()
> # -------------------------------------------------------------------------
> # FABRIC TENSOR, strong and weak component
> fabStrong,fabWeak=utils.fabricTensor(splitTensor=True,revertSign=True)
> fabStrong,fabWeak=fabStrong.diagonal(),fabWeak.diagonal()
> # -------------------------------------------------------------------------
> # FABRIC TENSOR, total
> fabTot=utils.fabricTensor(splitTensor=False)[0] # get the matrix (the function returns a tuple)
> fabTot=fabTot.diagonal()
> # -------------------------------------------------------------------------
>
> pointstress=_eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
> ......
>
> But I get the following:
>
> NameError Traceback (most recent call last)
>
> ----> 1
> 2
> 3
> 4
> 5
>
> 128 # -------------------------------------------------------------------------
>
> 129
> --> 130 pointstress=_eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
> 131
> 132 # ENERGY TERMS
>
>
> NameError: global name '_eudoxos' is not defined
>
> Any ideas why it doesn't work?
>
>
> Giuseppe
>
>

 Jérôme Duriez (jduriez) said on 2012-01-18: #2

The alternative solution, I think, would be that you need to import "_eudoxos" with underscore, instead of "eudoxos" without underscore.

What if you type "from yade import _eudoxos" at the beginning of the script ?

 Jérôme Duriez (jduriez) said on 2012-01-18: #3

In fact (it's clear now that I do not know python very well...), I think you should consider http://docs.python.org/tutorial/modules.html and the only sentence where there is "underscore" word.

 Emanuele Catalano (catalano) said on 2012-01-18: #4

Hello Giuseppe,
one solution is to add the line

inside the function saveData() and not (or not only) outside.

def saveData():
etc etc
pointstress=_eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])

This should solve your problem, don't know if finer solutions exist.

Emanuele

 Rinaldi Giuseppe (ciosrin) said on 2012-01-18: #5

first of all thank you for your quick response!

if I use eudoxos without underscore I get the following:

Running script simpleShear.py
Traceback (most recent call last):
File "/usr/bin/yade-daily", line 183, in runScript
execfile(script,globals())
File "simpleShear.py", line 142
pointstress=eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
^
IndentationError: unexpected indent
[[ ^L clears screen, ^U kills line. F12 controller, F11 3d view, F10 both, F9 generator, F8 plot. ]]

if add the line from yade import _eudoxos (as Emanuele Catalano suggests) I get :

TypeError Traceback (most recent call last)

----> 1
2
3
4
5

142
143
--> 144 pointstress=_eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1]),
145
146

TypeError: unbound method Boost.Python.function object must be called with InteractionLocator instance as first argument (got tuple instance instead)

Any ideas

 Bruno Chareyre (bruno-chareyre) said on 2012-01-18: #6

This problem is plrobably not related to the eudoxos module:

pointstress=eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
^
IndentationError: unexpected indent

 Jan Stránský (honzik) said on 2012-01-18: #7

Hi Rinaldi,

The problem is (as error message indicates) in indentation in your script.
Read some text about python indentation and try to correct it on the line
that causes the error. If you still get IndentationError, please send the
script in attachement so as we can help with the error localization and
correction :-)

Jan
Dne 18.1.2012 17:24 "Rinaldi Giuseppe" <email address hidden>
napsal(a):

> Question #185098 on Yade changed:
>
>
> Rinaldi Giuseppe is still having a problem:
> first of all thank you for your quick response!
>
> if I use eudoxos without underscore I get the following:
>
> Running script simpleShear.py
> Traceback (most recent call last):
> File "/usr/bin/yade-daily", line 183, in runScript
> execfile(script,globals())
> File "simpleShear.py", line 142
>
> pointstress=eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
> ^
> IndentationError: unexpected indent
> [[ ^L clears screen, ^U kills line. F12 controller, F11 3d view, F10 both,
> F9 generator, F8 plot. ]]
>
>
>
> if add the line from yade import _eudoxos (as Emanuele Catalano suggests)
> I get :
>
>
>
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
>
> ----> 1
> 2
> 3
> 4
> 5
>
> 142
> 143
> --> 144
> pointstress=_eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1]),
> 145
> 146
>
> TypeError: unbound method Boost.Python.function object must be called
> with InteractionLocator instance as first argument (got tuple instance
>
> Any ideas
>
> --
> You received this question notification because you are a member of
>
> _______________________________________________
> Post to : <email address hidden>
>

 Rinaldi Giuseppe (ciosrin) said on 2012-01-18: #8

now also if I use eudoxos without underscore I get the following:

TypeError Traceback (most recent call last)

----> 1
2
3
4
5

143
144
--> 145 pointstress=eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
146
147

TypeError: unbound method Boost.Python.function object must be called with InteractionLocator instance as first argument (got tuple instance instead)

 Jan Stránský (honzik) said on 2012-01-19: #9

Hi Rinaldi,

the problem could be that you have no instance (existing object) of
InteractionLocator. Instead of line 145 try following:

locator = eudoxos.InteractionLocator()
pointstress =
locator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])

Jan

Rinaldi Giuseppe píše v St 18. 01. 2012 v 17:15 +0000:
> Question #185098 on Yade changed:
>
> Rinaldi Giuseppe posted a new comment:
> now also if I use eudoxos without underscore I get the following:
>
>
> TypeError Traceback (most recent call last)
>
> ----> 1
> 2
> 3
> 4
> 5
>
> 143
> 144
> --> 145 pointstress=eudoxos.InteractionLocator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
> 146
> 147
>
> TypeError: unbound method Boost.Python.function object must be called
> with InteractionLocator instance as first argument (got tuple instance
>

 Rinaldi Giuseppe (ciosrin) said on 2012-01-19: #10

Hi Strànsky ,

if I do so I get the following:

RuntimeError Traceback (most recent call last)

----> 1
2
3
4
5

142 damping=contactLaw.normDampDissip # viscous damping
143
--> 144 locator = eudoxos.InteractionLocator()
145 pointstress = locator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
146

RuntimeError: Zero interactions when constructing InteractionLocator!

 Jan Stránský (honzik) said on 2012-01-19: #11

The problem is, that at the time of InteractionLocator construction, you
have no interactions present in the simulation. Try to place the command
to the time, where you have some. Also attach your script, so we can
advise a correct location to place the line.

Jan

Rinaldi Giuseppe píše v Čt 19. 01. 2012 v 11:25 +0000:
> Question #185098 on Yade changed:
>
>
> Rinaldi Giuseppe is still having a problem:
> Hi Strànsky ,
>
> if I do so I get the following:
>
> RuntimeError Traceback (most recent call last)
>
>
> ----> 1
> 2
> 3
> 4
> 5
>
> 142 damping=contactLaw.normDampDissip # viscous damping
> 143
> --> 144 locator = eudoxos.InteractionLocator()
> 145 pointstress = locator.macroAroundPt((0.00001,0.00001,0.00001),0.00001,[-1])
> 146
>
> RuntimeError: Zero interactions when constructing InteractionLocator!
>

 Bruno Chareyre (bruno-chareyre) said on 2012-01-19: #12

Rinaldi, you are maybe wasting your time trying to solve this problem.
macroAroundPoint is restricted to Dem3DofGeom and CpmPhys classes, which I doubt you are using for simulating sand.
The eudoxos module was developped by Vaclav Smilauer for specific needs during his PhD, it not something well suited in general.

Maybe consider other ways to get stress.
I would recommend https://yade-dem.org/doc/yade.utils.html#yade.utils.bodyStressTensors, which is based on rational solid mechanics and works for all types of interactions.
If you want local averages, you can always average on many particles.

 Rinaldi Giuseppe (ciosrin) said on 2012-01-19: #13

hi Bruno Chareyre ,

I'm using Ip2_FrictMat_FrictMat_MindlinPhys and Law2_S cGeom_MindlinPhys _Mindlin.

So can't I use the module in my script?

Thanks,

Giuseppe

 Bruno Chareyre (bruno-chareyre) said on 2012-01-19: #14

As said above, no.
It would make no sense anyway, since it uses a "contact surface" concept not consistent with Mindlin's contact.

 Rinaldi Giuseppe (ciosrin) said on 2012-01-19: #15

I see.

many thanks!

Giuseppe