Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run spectral_forced_turbulence due to jnp.linalg.norm error #200

Open
wagenaartje opened this issue Feb 12, 2023 · 3 comments
Open

Comments

@wagenaartje
Copy link

wagenaartje commented Feb 12, 2023

I have copied the code from spectral_forced_turbulence.ipynb, but it gives the following error:

---------------------------------------------------------------------------

UnfilteredStackTrace                      Traceback (most recent call last)

<timed exec> in <module>

[/usr/local/lib/python3.8/dist-packages/jax_cfd/base/initial_conditions.py](https://localhost:8080/#) in filtered_velocity_field(rng_key, grid, maximum_velocity, peak_wavenumber, iterations)
    110   # specified maximum velocity.
--> 111   return funcutils.repeated(project_and_normalize, iterations)(velocity)
    112 

28 frames

UnfilteredStackTrace: TypeError: jnp.linalg.norm requires ndarray or scalar arguments, got <class 'list'> at position 0.

The stack trace below excludes JAX-internal frames.
The preceding is the original exception that occurred, unmodified.

--------------------


The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)

<timed exec> in <module>

[/usr/local/lib/python3.8/dist-packages/jax/_src/numpy/util.py](https://localhost:8080/#) in _check_arraylike(fun_name, *args)
    343                     if not _arraylike(arg))
    344     msg = "{} requires ndarray or scalar arguments, got {} at position {}."
--> 345     raise TypeError(msg.format(fun_name, type(arg), pos))
    346 
    347 

TypeError: jnp.linalg.norm requires ndarray or scalar arguments, got <class 'list'> at position 0.

You can reproduce this with this Google Colab. It is also confusing that the Google Colab provided in the README does not install jax-cfd. What is the intended way of running them?

Edit: it seems that the jax-cfd version on PyPi is outdated. Downloading the source from the repository works.

@gideonite
Copy link
Contributor

Edit: it seems that the jax-cfd version on PyPi is updated. Downloading the source from the repository works.

Does this mean that this is no longer an issue?

I dug into this a little bit and it seems that the problem lies with scaling the initial conditions to have the correct maximum velocity but if the latest code fixes this, then I would suggest closing this issue.

@wagenaartje
Copy link
Author

Yes, the latest code fixes this but I would argue it is still an issue because it is not integrated in the version installed via pip. Especially because it was fixed about 3 months ago already (see commit a9e1c21).

@danielkelshaw
Copy link

Also ran into this issue when installing from PyPi. Had to fix the source code to make this work. Would be nice to be able to pip install a corrected version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants