InteractionLocator.macroAroundPt module

Asked by Rinaldi Giuseppe

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:

yade._eudoxos.InteractionLocator.macroArountPt

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)

/usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
----> 1
      2
      3
      4
      5

/usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
    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?

Thanks in advance,

Giuseppe

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Rinaldi Giuseppe
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#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:
> https://answers.launchpad.net/yade/+question/185098
>
> 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:
>
> yade._eudoxos.InteractionLocator.macroArountPt
>
> 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)
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
> ----> 1
> 2
> 3
> 4
> 5
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
> 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?
>
> Thanks in advance,
>
> Giuseppe
>
>

Revision history for this message
Jérôme Duriez (jduriez) said :
#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 ?

Revision history for this message
Jérôme Duriez (jduriez) said :
#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.

Before more advised answers, you could maybe give a look on the web about "underscore python modules" (second answer of http://stackoverflow.com/questions/1301346/the-meaning-of-a-single-and-a-double-underscore-before-an-object-name-in-python ?)

Revision history for this message
Emanuele Catalano (catalano) said :
#4

Hello Giuseppe,
one solution is to add the line

from yade import _eudoxos

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

def saveData():
    from yade import _eudoxos
    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

Revision history for this message
Rinaldi Giuseppe (ciosrin) said :
#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 :

Yade [1]: ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

/usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
----> 1
      2
      3
      4
      5

/usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
    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

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#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

Revision history for this message
Jan Stránský (honzik) said :
#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:
> https://answers.launchpad.net/yade/+question/185098
>
> Status: Answered => Open
>
> 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 :
>
>
>
> Yade [1]:
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
> ----> 1
> 2
> 3
> 4
> 5
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
> 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
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Rinaldi Giuseppe (ciosrin) said :
#8

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

Yade [1]: ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

/usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
----> 1
      2
      3
      4
      5

/usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
    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)

Revision history for this message
Jan Stránský (honzik) said :
#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:
> https://answers.launchpad.net/yade/+question/185098
>
> Rinaldi Giuseppe posted a new comment:
> now also if I use eudoxos without underscore I get the following:
>
>
> Yade [1]: ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
> ----> 1
> 2
> 3
> 4
> 5
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
> 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)
>

Revision history for this message
Rinaldi Giuseppe (ciosrin) said :
#10

Hi Strànsky ,

if I do so I get the following:

Yade [1]: ---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)

/usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
----> 1
      2
      3
      4
      5

/usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
    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!

Revision history for this message
Jan Stránský (honzik) said :
#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:
> https://answers.launchpad.net/yade/+question/185098
>
> Status: Answered => Open
>
> Rinaldi Giuseppe is still having a problem:
> Hi Strànsky ,
>
> if I do so I get the following:
>
> Yade [1]: ---------------------------------------------------------------------------
> RuntimeError Traceback (most recent call last)
>
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
> ----> 1
> 2
> 3
> 4
> 5
>
> /usr/lib/yade-daily/py/yade/__init__.pyc in saveData()
> 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!
>

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#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.

Revision history for this message
Rinaldi Giuseppe (ciosrin) said :
#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

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

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

Revision history for this message
Rinaldi Giuseppe (ciosrin) said :
#15

I see.

many thanks!

Giuseppe