When switching between real and complex builds of DOLFINx through Docker, which is running “source /usr/local/bin/dolfinx-complex-mode”, there was any response.
You can check if your PYTHONPATH has been updated
echo $PYTHONPATH
or check the ScalarType of PETSc; from petsc4py import PETSc; print(PETSc.ScalarType)
Thank you very much for your response. When I run echo $PYTHONPATH in the terminal, the result is
usr/local/dolfinx-complex/lib/python3.10/dist-packages:/usr/local/dolfinx-rea1/lib/python3.10/dist-packages:/usr/local/lib:. But I don’t know if I have succeeded.
And when I run from petsc4py import PETSc; print(PETSc.ScalarType), the result is still <class ‘numpy.float64’>.
What is your $PETSC_ARCH
and $PETSC_DIR
after calling the source command?
You can see here that the complex mode of dolfinx is first in the list.
Thank you. I forgot to switch kernel before.
Hi KellenLLLL,
I’m having the same issue as you. What do you mean by “switch kernel”?
I have also run (in my Docker container) source dolfinx-complex-mode
, and I get the same results as you when running echo $PETSC_ARCH
and echo $PETSC_DIR
. So it seems that source dolfinx-complex-mode
is working. However, when I run (in Python) from petsc4py import PETSc; print(PETSc.ScalarType)
I still get <class ‘numpy.float64’>.
Maybe if I also “switch the kernel” my issue will be fixed…?
What docker container are you running?
Are you using jupyterlab for running Python?
If so, you need to press the kernel option in the menu-bar, and change to the dolfinx complex kernel:
https://jupyterlab.readthedocs.io/en/stable/user/running.html
Hi Dokken,
Thanks for your reply.
I’m running the dolfinx/dolfinx:stable docker container.
I’m running python through VS Code, and have set up the ‘Dev Containers’ VS Code extension to configure VS Code to run through the docker container.
Does VS Code have a similar kernel option to jupyterlab that I need to switch?
You can do this use the vscode devcontainer.json
(Container environment variables)
as shown below:
Thanks so much for your help Dokken, the devcontainer tip was a massive help!
For any future readers who have the same problem as me:
- In your project folder, create a folder called ‘.devcontainer’.
- Create a text file and fill it in as specified by Dokken above. Save as ‘devcontainer.json’ and save in the ‘.devcontainer’ folder you just created.
- Make sure you are not currently in a remote connection (if you are, click the green remote connection tab in the lower left corner of VS Code to exit).
- Hit ctrl+shift+p (or f1) to bring up the command palette.
- Type ‘Dev Containers: Open Folder in Container …’ and run it.
- Open the project folder that contains the .devcontainer/devcontainer.json that you just created.
This seems to spin up a new container built from the dolfinx/dolfinx:stable image, so you may have to reinstall a couple of things (like VS Code Python extension), but it works!
Earlier I had been using the ‘Dev Containers: Attach to Running Container’ command, and then connecting to a dolfinx/dolfinx:stable container that I already had running. This was working for running Fenicsx, but wasn’t working for using ‘source dolfinx-complex-mode’, not sure why.