Python problems in Yade 2021.01a

Asked by mohsen

In the name of god

Hi every one.

I encountered a problem in my compiled YADE 2021.01a. i wrote a simple code to be run but i received an strange error:
##################################
In [1]: b=[1,2,3];c=[b,b,b,]
In [2]: for kk in c:
   ...: a=[x/max(kk) for x in kk]

---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~/YadeGit/master2021Hertz/install/bin/yade-2021.01a in <module>
      1 for kk in c:
----> 2 a=[x/max(kk) for x in kk]
      3

~/YadeGit/master2021Hertz/install/bin/yade-2021.01a in <listcomp>(.0)
      1 for kk in c:
----> 2 a=[x/max(kk) for x in kk]
      3

NameError: name 'kk' is not defined
##########################################
I checked the code for both python 2 and 3 and there was no problem.

Any help?

Question information

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

Nice catch.
I confirming the issue with yadedaily, too.
Cheers
Jan

Revision history for this message
Jan Stránský (honzik) said :
#2

It is a known issue that Yade terminal has some problems with scopes, maybe this is related to that.

If you put the code in a script and run the script, it should works OK (works OK in my yadedaily).

Cheers
Jan

Revision history for this message
mohsen (agha-mohsena) said :
#3

Thanks Jan

about running scripts i should say that for me there is not change and in all cases the error exists.

I think the problems are more than just converting the scripts using 2to3. i have some scripts that are working in 2018b YADE version but showing error in 2021. At this time i do not know whether stick to 2021 or come back 2018?

Regards

Revision history for this message
Anton Gladky (gladky-anton) said :
#4

Definitely update your scripts to 3rd python version and switch to a newer Yade. We are not supporting older Yade version, so there is no chance to fix an error in those versions, if they are detected.

Revision history for this message
Anton Gladky (gladky-anton) said :
#5

Please file a bug here [1] with a minimal working example, so we will have a change to fix it before the next release.

[1] https://gitlab.com/yade-dev/trunk/-/issues

Revision history for this message
Jan Stránský (honzik) said :
#6

> i have some scripts ... but showing error in 2021

What are the script?
What are the errors?

Cheers
Jan

Revision history for this message
mohsen (agha-mohsena) said :
#7

Ye Jan
This is an error for an script using cpm material for bonded agglomerates. this script work properly in Yade 2018. do you have any idea?
#######
Welcome to Yade 20211203-6160~581d3d8~focal1
Using python version: 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0]
TCP python prompt on localhost:9000, auth cookie `cukdse'
XMLRPC info provider on http://localhost:21000
Running script TRRepSandCalRealDimConsDtNewShTandSTireCalStepCAlmMod2To3.py
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<double, -1, 1, 0, -1, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<double, 6, 1, 0, 6, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<int, 6, 1, 0, 6, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<double, 3, 1, 0, 3, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<int, 3, 1, 0, 3, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<double, 2, 1, 0, 2, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<int, 2, 1, 0, 2, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<double, 3, 3, 0, 3, 3> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<double, 6, 6, 0, 6, 6> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<double, -1, -1, 0, -1, -1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<std::complex<double>, 2, 1, 0, 2, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<std::complex<double>, 3, 1, 0, 3, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<std::complex<double>, 6, 1, 0, 6, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<std::complex<double>, -1, 1, 0, -1, 1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<std::complex<double>, 3, 3, 0, 3, 3> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<std::complex<double>, 6, 6, 0, 6, 6> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Matrix<std::complex<double>, -1, -1, 0, -1, -1> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::Quaternion<double, 0> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::AlignedBox<double, 3> already registered; second conversion method ignored.
<frozen importlib._bootstrap>:219: RuntimeWarning: to-Python converter for Eigen::AlignedBox<double, 2> already registered; second conversion method ignored.
python3.8: /builds/yade-dev/trunk/deb/yadedaily/pkg/dem/ConcretePM.cpp:447: virtual bool yade::Law2_ScGeom_CpmPhys_Cpm::go(boost::shared_ptr<yade::IGeom>&, boost::shared_ptr<yade::IPhys>&, yade::Interaction*): Assertion `!math::isnan(sigmaT[1])' failed.
Aborted (core dumped)
####

Revision history for this message
Jan Stránský (honzik) said :
#8

> an script

please provide a link or the script

> <frozen importlib._bootstrap>:219: RuntimeWarning: ...

this is just a warning

> python3.8: /builds/yade-dev/trunk/deb/yadedaily/pkg/dem/ConcretePM.cpp:447: virtual bool yade::Law2_ScGeom_CpmPhys_Cpm::go(boost::shared_ptr<yade::IGeom>&, boost::shared_ptr<yade::IPhys>&, yade::Interaction*): Assertion `!math::isnan(sigmaT[1])' failed.

this is an error, but without the script it is impossible to tell what is the problem..
Or, the problem is that sigmaT if CPMPhys is NaN, but it ismpossible to tell why (without the script).

Cheers
Jan

Revision history for this message
mohsen (agha-mohsena) said :
#9

Hi Jan

My script is long and hard to make a MWE! but what it might help is that the ConcretePM.cpp file for Yade 2021 is quit different from ConcretePM.cpp file for YADE 2018 as i compare them. as you suggested previously, by decrease of time step the simulation can continue more steps but again it interrupted with the same error (Aborted (core dumped)).
I tried to present a MWE.
Regards

Revision history for this message
Jan Stránský (honzik) said :
#10

I have installed 2021.01a (although on Ubuntu 18.04)

> about running scripts i should say that for me there is not change and in all cases the error exists.

to be sure, could you please post here the exact script you are using?
For me, this script
###
b=[1,2,3];c=[b,b,b,]
for kk in c:
    a=[x/max(kk) for x in kk]
###
works without any error. Run as
yade-2021.01a script.py
It gives the error you reported if used in "fresh| Yade console started as "yade-2021.01a".

(interestingly) If I run any (even empty) script first, then also using just the console gives no error.

> I tried to present a MWE.

yes, for the "console error" the code you provided was a perfect MWE, thanks

> but what it might help is that the ConcretePM.cpp file for Yade 2021 is quit different from ConcretePM.cpp file for YADE 2018 as i compare them. as you suggested previously, by decrease of time step the simulation can continue more steps but again it interrupted with the same error (Aborted (core dumped)).

this probably is a different issue than python 2 / 3 (although there might be situations leading to differences, like if there is integer division in python 2 or python 3). Impossible to tell without a MWE, or at least the script used, if not minimal :-)
So probably you should open a new question concerning the CPM part of your problem.

Cheers
Jan

Revision history for this message
Jan Stránský (honzik) said :
#11

> the ConcretePM.cpp file for Yade 2021 is quit different from ConcretePM.cpp file for YADE 2018

I used
git diff -w origin/2018.02:pkg/dem/ConcretePM.cpp origin/2021.01:pkg/dem/ConcretePM.cpp
to compare the versions. -w option ii ignoring all whitespaces

Most of the changes are formatting changes, not influencing the resulting code.
Concerning the error, the std::isnan was changed to math::isnan. I have no idea if it could be a problem or not.

Maybe it would be worth to check the results between 2018 and 2021 on a simple simulations.

In this case, maybe it might be wort staying with the older version (accepting all the nagatives it has).

Cheers
Jan

Can you help with this problem?

Provide an answer of your own, or ask mohsen for more information if necessary.

To post a message you must log in.