spectralDNS / shenfun

High performance computational platform in Python for the spectral Galerkin method
http://shenfun.readthedocs.org
BSD 2-Clause "Simplified" License
201 stars 42 forks source link

Problem with Chebyshev basis? #19

Closed loiseaujc closed 6 years ago

loiseaujc commented 6 years ago

Hi Mikael,

I have started to implement my Rayleigh-Benard solver and wanted to play a bit with the Poisson and Biharmonic solvers first. To do so, I downloaded the scripts available in the demo folder and I have some weird things going on:

For information, I have installed shenfun using conda.

mikaem commented 6 years ago

Hi That's really weird. The demos are run as part of the test-suit and there are no errors on Travis, Circle-Ci or my own mac. All using conda. Are you running the demo as, e.g.::

python dirichlet_poisson2D 32 chebyshev?

Anything special about your installation? Are you building locally or downloading from the Anaconda channel?

loiseaujc commented 6 years ago

Weird indeed.

I do run the script using the command you mentioned. Regarding shenfun, I installed using:

conda install -c conda-forge -c spectralDNS python=3.6 shenfun

As far as I know, my installation has nothing special. I use conda 4.5.11 and made sure all of my packages are up-to-date.

Edit: I re-installed shenfun using the same command in a dedicated conda-env to make sure the problem was not arising from interferences with other python packages but it did not change a thing. I will give a try by building the package from source later today.

mikaem commented 6 years ago

Did you install in a new conda environment? I assume you have cloned or forked the repository since you have the demos? If you uninstall the conda version (conda uninstall shenfun (this leaves the dependencies installed)) and add

export PYTHONPATH=~/where_shenfun_is_located/:$PYTHONPATH

Then do

python setup.py build_ext --inplace

Now change to demo folder and run the demo again. Also, I realised yesterday the mkl had broken some tests on circle-ci, which is why I now in the latest version of shenfun have nomkl as a dependency. But that may not have migrated to the binaries yet.

loiseaujc commented 6 years ago

I am not 100% sure if its related, but here is the error I get if I run the same script with python 2.7;

/home/jean-christophe/anaconda3/envs/shenfun_test/lib/python2.7/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.

  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "poisson_2D.py", line 51, in <module>
    T = TensorProductSpace(comm, (SD, K1), axes=(0, 1))
  File "/home/jean-christophe/anaconda3/envs/shenfun_test/lib/python2.7/site-packages/shenfun/tensorproductspace.py", line 118, in __init__
    xfftn.plan(pencilB.subshape, axes, dtype, kw)
  File "/home/jean-christophe/anaconda3/envs/shenfun_test/lib/python2.7/site-packages/shenfun/chebyshev/bases.py", line 385, in plan
    self.CT.plan(shape, axis, dtype, options)
  File "/home/jean-christophe/anaconda3/envs/shenfun_test/lib/python2.7/site-packages/shenfun/chebyshev/bases.py", line 140, in plan
    xfftn_fwd = plan_fwd(U, axis=axis, **opts)
  File "build/bdist.linux-x86_64/egg/pyfftw/builders/builders.py", line 549, in dct
  File "build/bdist.linux-x86_64/egg/pyfftw/builders/_utils.py", line 205, in _Xfftn
  File "pyfftw/pyfftw.pyx", line 1252, in pyfftw.pyfftw.FFTW.__cinit__ (/home/mikael/anaconda2/conda-bld/work/pyfftw/pyfftw.c:11613)
RuntimeError: The data has an uncaught error that led to the planner returning NULL. This is a bug.

Once again, if I set the basis to Legendre, the python 2.7 version works perfectly.

loiseaujc commented 6 years ago

Nope, I did not fork. I simply downloaded the demo folder directly from GitHub.

I will do as you suggest and get back to you.

mikaem commented 6 years ago

Exactly, I saw that error message yesterday for the mpi4py-fft code. It is caused by numpy using mkl. I will rebuild shenfun with nomkl and upload a new binary. Will take 20 minutes though.

loiseaujc commented 6 years ago

Oh yes, I do remember such a problem! If I simply add import pyfftw at the very begining of the script, then

python dirichlet_poisson_2D.py 32 chebyshev

works correctly with python 2.7 at least, but not with python 3.6

Will take 20 minutes though.

More than fair enough! :] I will let you know once I updated shenfun if I can run the demo correctly.

mikaem commented 6 years ago

Should be ready now. Build version 7. Just realised, though, that python=2.7 version has not been uploaded to Anaconda cloud for linux after the move to Circle-Ci 2.0 some months ago.

loiseaujc commented 6 years ago

Awesome! It now works like a charm. Thanks a lot.

I will get back to you whenever I am done with my 2D Rayleigh-Benard solver. Once it works (and has been validated), I can eventually send a pull request to add it to the demos if you want.