Bug report in function VTKExporter.exportInteractions()

Asked by Hongyang Cheng

Dear all,

I've been playing with VTKExporter lately and found that there might be a sentence "i = O.interaction[ii,jj]" missing in the func exportInteractions [1] for the looping which outputs Vector3 data.

[1] https://yade-dem.org/doc/_modules/yade/export.html#VTKExporter.exportInteractions

It appears that all the Vector3 data (i.phys.normalForce) exported with this function are the same (same as in the first interaction).

The following is part of the script where I think the problem might be:
---------------------------------------------------------------
# Line 34
     for i in O.interactions:
         if i.isReal: break
....

---------------------------------------------------------------
This loop returns i as the first interaction. It probably is the reason that I got same value for all i.phys.normalForce.

---------------------------------------------------------------
# Line 45
         elif isinstance(test,Vector3):
            outFile.write("\nVECTORS %s double\n"%(name))
            for ii,jj in intrs:
               (should we add "i = O.interaction[ii,jj])" here?)
               v = eval(command)
               outFile.write("%g %g %g\n"%(v[0],v[1],v[2]))

In addition to that, does someone know where to find this python script in the source code files? If I am right about this bug, I think I have to modify the code file and install Yade again.

I have a question about VTKExporter. It is irrelevant to above.

When we call VTKExporter class functions, exportInteractions(params) for instance, is it possible to derive some data from O.interactions's attributes like defining the param what as "what=[('contactPhi','degrees(acos(i.geom.normal[2]))')]"? Every time I do that periodically in PyRunner. It reports "name "degrees" ( or acos) is not defined bla bla bla (math module didn't work?). Could someone help me out? :-)

Regards,

alex

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Hongyang Cheng
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello Alex,

>
> I've been playing with VTKExporter lately and found that there might be a
> sentence "i = O.interaction[ii,jj]" missing in the func exportInteractions
> [1] for the looping which outputs Vector3 data.
>
> [1]
> https://yade-dem.org/doc/_modules/yade/export.html#VTKExporter.exportInteractions
>
> It appears that all the Vector3 data (i.phys.normalForce) exported with
> this function are the same (same as in the first interaction).
>
> The following is part of the script where I think the problem might be:
> ---------------------------------------------------------------
> # Line 34
> for i in O.interactions:
> if i.isReal: break
> ....
>

This piece of code is only to chood one interaction instance for testing
the exported variable type (float, Vector3, Matrix3).

>
> ---------------------------------------------------------------
> This loop returns i as the first interaction. It probably is the reason
> that I got same value for all i.phys.normalForce.
>
> ---------------------------------------------------------------
> # Line 45
> elif isinstance(test,Vector3):
> outFile.write("\nVECTORS %s double\n"%(name))
> for ii,jj in intrs:
> (should we add "i = O.interaction[ii,jj])" here?)
> v = eval(command)
> outFile.write("%g %g %g\n"%(v[0],v[1],v[2]))
>
> In addition to that, does someone know where to find this python script in
> the source code files? If I am right about this bug, I think I have to
> modify the code file and install Yade again.
>

It is definitely a bug, thanks for reporting and also the correction :-)
For reporting bugs, next time you can use bug report directly (at launchapd
just next to "ask question").

The file is yade/py/export.py . yade is the source directory, depending
how you installed yade. If you install it from sources, you can change
anything and intall it (running "make install") and it should reflect the
changes.

I have made the changes in the current git version, so if you are using git
version, you can "git pull"

>
> I have a question about VTKExporter. It is irrelevant to above.
>
> When we call VTKExporter class functions, exportInteractions(params) for
> instance, is it possible to derive some data from O.interactions's
> attributes like defining the param what as
> "what=[('contactPhi','degrees(acos(i.geom.normal[2]))')]"? Every time I do
> that periodically in PyRunner. It reports "name "degrees" ( or acos) is not
> defined bla bla bla (math module didn't work?). Could someone help me out?
> :-)
>

The problem is that the piece of code is run in the export.py file, where
those functions are not imported. Try (untested):

from yade import export
export.degrees = degrees # the same for acos or whatever else
and run the example again

HTH
Jan

Revision history for this message
Hongyang Cheng (alex-cheng) said :
#2

Hi Jan,

Thanks. I am installing yade from the newest source directory now.

export.degrees helped. Guess I gotta learn more about python.

Alex