run FEMxDEM examples

Asked by jamespaul on 2019-03-13

Hi,

I want to run a FEMxDEM code,

Learning from 'examples/FEMxDEM/biaxialSmooth.py',i entered the following 6 commands in the terminal:

1 sudo apt install python-escript
2 cd /usr/share/doc/yade/examples
3 export PYTHONPATH="/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM"
4 export LD_LIBRARY_PATH=/usr/lib/python-escript/lib
5 ln -s /usr/share/doc/yade/examples/FEMxDEM/prepareRVE.py

error:ln: invalid option -- '/'
Try 'ln --help' for more information.

6 ln -s/usr/share/doc/yade/examples/FEMxDEM/prepareRVE.py /usr/share/doc/yade/examples/FEMxDEM/biaxialSmooth.py

error:ln: invalid option -- '/'
Try 'ln --help' for more information.

>I think the 5th step is wrong,because i haven't 'ln yade-versionNo yadeimport.py'.How do I generate this file and connect with biaxialSmooth.py? Via prepareRVE.py?

>The version of YADE should be at least rev3682 in which Bruno added the stringToScene function.
My Yade version: 2018.02b.Is rev3682 a version of yadedaily?

Thanks in advance,

James

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Janek Kozicki
Solved:
2019-03-20
Last query:
2019-03-20
Last reply:
2019-03-19
Janek Kozicki (cosurgi) said : #1

Hi,

I did spend some time trying to get FEMxDEM examples to work. I am
not 100% satisfied, perhaps if you are determined enough we can both
improve the documentation for this in https://yade-dev.gitlab.io/trunk/FEMxDEM.html

However perhaps we will need some help from FEMxDEM original author,
hence I am sending this email also to Ning Guo. Bruno mentioned that Ning has
successors in HK, I am not sure who are they, but maybe they can help
too, if Ning is not available. We just need to find them ;)

Regarding your present error:

https://gitlab.com/yade-dev/trunk/blob/master/examples/FEMxDEM/biaxialSmooth.py#L10

your command 5. is too short, the first argument is the position of
your yade executable. I have written it as '/path/to/yade'

If you are not sure where is your yade executabe, you can type command:

  which yade

And then use it in place of '/path/to/yade' in command:

ln -s /path/to/yade ../../py/FEMxDEM/yadeimport.py

It is because yade must be imported inside a FEMxDEM python script.
So this command creates a symbolic link 'ln -s' pointing to original
yade exectuable, and this symlink is called yadeimport.py and is
placed inside py/FEMxDEM directory (not the examples dir!) So that
the FEMxDEM scripts can find it.

Regarding yade version, I would suggest the recently released 2019.01a
version. But it is very likely that 2018.02b will work too.

best regards
Janek

PS: I will be able to have a closer look on weekend at that.

jamespaul said: (by the date of Wed, 13 Mar 2019 07:03:26 -0000)

> Question #679154 on Yade changed:
> https://answers.launchpad.net/yade/+question/679154
>
> Summary changed to:
> run FEMxDEM examples
>
> Description changed to:
> Hi,
>
> I want to run a FEMxDEM code,
>
> Learning from 'examples/FEMxDEM/biaxialSmooth.py',i entered the
> following 6 commands in the terminal:
>
> 1 sudo apt install python-escript
> 2 cd /usr/share/doc/yade/examples
> 3 export PYTHONPATH="/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM"
> 4 export LD_LIBRARY_PATH=/usr/lib/python-escript/lib
> 5 ln -s /usr/share/doc/yade/examples/FEMxDEM/prepareRVE.py
>
> error:ln: invalid option -- '/'
> Try 'ln --help' for more information.
>
> 6 ln -s/usr/share/doc/yade/examples/FEMxDEM/prepareRVE.py
> /usr/share/doc/yade/examples/FEMxDEM/biaxialSmooth.py
>
> error:ln: invalid option -- '/'
> Try 'ln --help' for more information.
>
> >I think the 5th step is wrong,because i haven't 'ln yade-versionNo
> yadeimport.py'.How do I generate this file and connect with
> biaxialSmooth.py? Via prepareRVE.py?
>
> >The version of YADE should be at least rev3682 in which Bruno added the stringToScene function.
> My Yade version: 2018.02b.Is rev3682 a version of yadedaily?
>
> Thanks in advance,
>
> James
>
> --
> You received this question notification because your team yade-users 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

--
Janek Kozicki http://janek.kozicki.pl/ |

Janek Kozicki (cosurgi) said : #2

Ah, the path ../../py/FEMxDEM/yadeimport.py is relative to yade source tree. It refers to this directory https://gitlab.com/yade-dev/trunk/tree/master/py/FEMxDEM and in this directory the symlink yadeimport.py must appear.

If you use yade installed as a packege, then you will have to find this directory. Command "dpkg -L yade" might help you a bit with this.

Perhaps we should just add this symlink to the installed/packaged version of yade?

jamespaul (jamespauljames) said : #3

Thanks Janek for your detailed teaching,but I still have some questions that I didn’t understand.

>we can both improve the documentation
Since I will spend a lot of time studying coupling, I am willing to cooperate with you if I have the ability.

>which yade
/usr/bin/yade

I installed yade using sudo apt-get install yade.

>this symlink is called yadeimport.py and is placed inside py/FEMxDEM directory
I typed dpkg -L yade and locate yadeimport.py but still can't find yadeimport.py.

>about 6 commands
1 sudo apt install python-escript #it must be right

2 cd /usr/share/doc/yade/examples/FEMxDEM #I think the path is right? Enter examples,not library or interface.

3 export PYTHONPATH="/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM" #I'm not sure.I use locate FEMxDEM to find the path,somewhat different from your third step.

4 export LD_LIBRARY_PATH=/usr/lib/python-escript/lib #it must be right.

5 ln -s /usr/bin/yade #the second argment is the path of yadeimport.py,I don't know how to get.

6 ln -s /usr/bin/yade ./biaxialSmooth.py #it must be right.

Feng

jamespaul (jamespauljames) said : #4

>run `mv biaxialSmooth.yade.gz 0.yade.gz`

When I run preparerve. py, I get 0. yade. gz. So how can I relate it to biaxialSmooth. py? I don't see the function that imports preparerve.py in biaxialSmooth.

whr (huanran-wu) said : #5

Hi,

I think the successors of Ning in HK Bruno mentioned is me. I am using an earlier version and not familiar with the lastest trunk version. But I'm willing to offer help or improve the documentation if you cannot reach Ning.

To the lastest question:
>run `mv biaxialSmooth.yade.gz 0.yade.gz`
is to generate the initial RVE packing. You don't need to run this command since the packing is already saved as "0.yade.gz".
The packing is related to biaxialSmooth.py through 'simDEM.py' in which the initial packing '0.yade.gz' is loaded.

Huanran

Janek Kozicki (cosurgi) said : #6

Hi, did you manage to create this yadeimport.py symlink pointing to /usr/bin/yade like explained in https://yade-dev.gitlab.io/trunk/user.html#importing-yade-in-other-python-applications ?

the only difficulty is that you have to create this file in the same directory where other FEMxDEM files ( mpipool.py msFEM2D.py msFEM3D.py msFEMup.py saveGauss.py simDEM.py ) are present.

It would be great, if after you manage to get it to run, you will be able to improve the https://yade-dev.gitlab.io/trunk/FEMxDEM.html manual. It is in file doc/sphinx/FEMxDEM.rst

jamespaul (jamespauljames) said : #7

Thanks Janek,

I changed my command as follows

1 sudo apt install python-escript
2 cd /usr/share/doc/yade/examples/FEMxDEM
3 export PYTHONPATH="/usr/lib/python-escript:/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM"
4 export LD_LIBRARY_PATH=/usr/lib/python-escript/lib
5 ln -s /usr/bin/yade /usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py
6 /usr/bin/yade ./biaxialSmooth.py

It works ,but the error is reported

Running script ./biaxialSmooth.py
Traceback (most recent call last):
  File "/usr/bin/yade", line 182, in runScript
    execfile(script,globals())
  File "./biaxialSmooth.py", line 22, in <module>
    prob = MultiScale(domain=mydomain,ng=numg,np=nump,random=False,rtol=1e-2,usePert=False,pert=-2.e-5,verbose=True)
  File "/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/msFEM2D.py", line 67, in __init__
    self.__pde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
ValueError: Cannot use DIRECT solver method, the running escript was not compiled with a direct solver enabled

I think my input is correct,but the function here has some problem.
https://github.com/yade/trunk/blob/master/py/FEMxDEM/msFEM2D.py#L68

I am curious why the 68th line hasn't an output.

Thanks in advance.

Janek Kozicki (cosurgi) said : #8

Ah! I recognize this error. If I am correct you are using yade 2018.02b, while I have fixed this problem only a month ago.

Please look inside your file /usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/msFEM2D.py, is it different?

If yes, then maybe it will be enough if you take the latest version of this file from the link you have found: https://github.com/yade/trunk/blob/master/py/FEMxDEM/msFEM2D.py

It is possible that you will have to do the same with other files too.

jamespaul (jamespauljames) said : #10

Thank you for reminding.

I have copied all the scripts from
"https://github.com/yade/trunk/tree/master/examples/FEMxDEM"and"https://github.com/yade/trunk/tree/master/py/FEMxDEM"

and delete the *.pyc files.

It works ,but the error is reported:

Running script ./biaxialSmooth.py
=======================================================================
For better performance compile python-escript with direct solver method
=======================================================================
Press Enter to continue...

I pressed Enter,but still no response and only forced quit could close the terminal.

whr (huanran-wu) said : #11

This error is on 'escript' side.

It can be solved following the instruction on
https://answers.launchpad.net/escript-finley/+question/294604
 (copied as below)

##########################
You will need to find the options file you are using to compile. For example (as Meng Qing Xiang suggested above)

scons/templates/trusty_options.py

Find the line which says:

umfpack =

And make sure that it says

umfpack = True

If you can't find the line at all, you can add it to the file.

Note that switching this on means that you will need to have umfpack installed.
On Debian/Ubuntu systems, I think this will be in the libsuitesparse-dev package.
##############################

jamespaul (jamespauljames) said : #12

Thanks whr,

If I use 'sudo apt install python-escript' to install escript,I can't locate the trusty_options.py.

Should I use Debian/Ubuntu Binary Installation or Installing from Source to install it?And if use these methods ,the path should be changed.

whr (huanran-wu) said : #13

I suggest you try to install from the source code at following link:
https://launchpad.net/escript-finley

There is a installation guide 'install.pdf' on the site.

And yes. I think you need to modify the corresponding path to locate escript after installation.

Best Janek Kozicki (cosurgi) said : #14

Hi, to avoid confusion I have hidden my previous post about deleting *.pyc files. Turns out that it was a misconfiguration on my side, and python always uses *.py file if it is more recent than *.pyc file, as indicated in the python manual [1]. Thanks to Jan for spotting my mistake.

Regarding the calculations, this is what I get after I press enter:

Running script biaxialSmooth.py
=======================================================================
For better performance compile python-escript with direct solver method
=======================================================================
Press Enter to continue...
Not converged after 0 iteration(s)! Relative error: 1.000000e+00
Not converged after 1 iteration(s)! Relative error: 7.789837e-02
Not converged after 2 iteration(s)! Relative error: 2.820422e-02
Convergence reached after 3 iteration(s)! Relative error: 8.350168e-03
Not converged after 0 iteration(s)! Relative error: 1.000000e+00
Not converged after 1 iteration(s)! Relative error: 2.794717e-02
Convergence reached after 2 iteration(s)! Relative error: 8.239768e-03

So I assume that the calculations are going smoothly, at least for me. But they are not fast. Try pressing enter and going for lunch ;) I had to wait at least 2 minutes before I saw the first output line about calculation progress.

However this is the farthest I have went in trying FEMxDEM examples. I see that it calculates something, and that's it. I don't know if the calculations are correct, where is the result or what to do with this result ;)

So if during your FEMxDEM adventure you advance further I suppose that adding some notes about how you got there into the documentation might be useful for others.

Thank you for the alternative instructions:

1 sudo apt install python-escript
2 cd /usr/share/doc/yade/examples/FEMxDEM
3 export PYTHONPATH="/usr/lib/python-escript:/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM"
4 export LD_LIBRARY_PATH=/usr/lib/python-escript/lib
5 ln -s /usr/bin/yade /usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py
6 /usr/bin/yade ./biaxialSmooth.py

I will add them to the examples into comment section.

[1] https://docs.python.org/2/tutorial/modules.html?highlight=pyc#compiled-python-files

jamespaul (jamespauljames) said : #15

Thanks Janek Kozicki, that solved my question.

jamespaul (jamespauljames) said : #16

Thanks Huanran too,

I used your method and it works now.

jamespaul (jamespauljames) said : #17

Sorry to border Huanran here,

After running biaxialSmooth.py, it generates packing folder and full of .gz files.I guess this is the information for each gaussian point.I can load them in the yade script, or I can unzip it and generate binary files.But I don't know how to analyze the data here.

Thanks in advance,

James

whr (huanran-wu) said : #18

I think you mean *.yade.gz. They are the RVE packing at the RVE packings at the final state. They should be able to be loaded with yade. Try to open yade (same version as in your multiscale script) at the ./packing folder and "O.load('*.yade.gz')".

The information for gauss points are saved at ./gauss. The contours are saved as .vtu at ./vtk.

Hope this will help.

Huanran

jamespaul (jamespauljames) said : #19

Thanks Huanran,

>They are the RVE packing at the RVE packings at the final state.

In the ./packing folder,there are 512 packing_xxx_100.yade.gz.

512 is the number of gauss point(8*16*4).So I think each file saves a gauss point information.I opened them with yade and found that the images were the same.So how do I analyze these data?

>Do you know how to get the coordinate value of the gauss point?

I used saveDataCSV("./result/disp_%d.csv"%t,disp=disp,shear=shear,e=vR,dispx=disp.getFunctionSpace().getX(),shearx=shear.getFunctionSpace().getX())

But the result of dispx and shearx are the same.

Thanks,
James

whr (huanran-wu) said : #20

The packings are just DEM packings. You can analyze them as you analyze a DEM simulation.

I'm not clear about the second one. How are dispx and shearx defined?

jamespaul (jamespauljames) said : #21

Just the name I gave to this column of data in the CSV file.I exported disp.getFunctionSpace().getX() and shear.getFunctionSpace().getX()) and found they are the same.It's weird.

whr (huanran-wu) said : #22

Based on my understanding, both of them are defined on the function space. So they should be the same.

You can try to ask on the escript forum.

jamespaul (jamespauljames) said : #23

Thanks Huanran