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

Fix warnings #70

Merged
merged 7 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 23.1.0
rev: 24.1.1
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2023 Logan Bishop-Van Horn
Copyright (c) 2022-2024 Logan Bishop-Van Horn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion docs/about/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ License

MIT License

Copyright (c) 2022-2023 Logan Bishop-Van Horn
Copyright (c) 2022-2024 Logan Bishop-Van Horn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
38 changes: 38 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,44 @@ means that essentially all portions of the simulation *except* the sparse linear
``cupy`` by setting ``tdgl.SolverOptions.sparse_solver = "cupy"``, however emperically it seems that this is slower than
performing the sparse linear solve on the CPU.

.. important::

Using ``cupy`` with an NVIDIA GPU requires the `NVIDIA CUDA Toolkit <https://developer.nvidia.com/cuda-toolkit>`_. You can check whether the CUDA toolkit is
installed and on the system path by running

.. code-block:: bash

nvcc --version

from the command line. The version of ``cupy`` you install must be compatible with the version of the CUDA Toolkit you have installed.

You can install the CUDA Toolkit either directly from the `NVIDIA website <https://developer.nvidia.com/cuda-toolkit>`_
or from the `NVIDIA conda channel <https://anaconda.org/nvidia>`_. To install the CUDA Toolkit using ``conda``, activate the ``conda`` environment
for ``tdgl`` and run

.. code-block:: bash

conda install cuda -c nvidia

If you have installed the CUDA Toolkit but ``nvcc --version`` still fails, you may need to update the ``PATH`` and ``LD_LIBRARY_PATH``
environment variables to point to your CUDA installation.

.. code-block:: bash

# If you installed CUDA Toolkit directly from the NVIDIA website,
# resulting in CUDA being installed in /usr/local/cuda:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

# If you installed CUDA using conda, activate the appropriate conda environment and run:
export PATH=${CONDA_PREFIX}/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=${CONDA_PREFIX}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

The exact path to your CUDA installation may vary depending on operating system and configuration. You may want to add the appropriate
``PATH`` and ``LD_LIBRARY_PATH`` modifications to your ``~/.bashrc`` file.

For more detailed installation instructions, see the `NVIDIA documentation <https://docs.nvidia.com/cuda/cuda-quick-start-guide/index.html>`_.

Due to overheads related to transferring data between the CPU and GPU, it is expected that ``cupy`` will provide
a significant speedup only for models with relatively large meshes and/or models that include `screening <notebooks/screening.ipynb>`_.
Please open a `GitHub issue <https://github.com/loganbvh/py-tdgl/issues>`_ if you have any problems using ``tdgl`` with ``cupy``.
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/logo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Constructing Voronoi polygons: 100%|██████████████████████████████████████████████████████████████████████████| 4084/4084 [00:00<00:00, 22134.30it/s]\n"
"Constructing Voronoi polygons: 100%|█████| 4084/4084 [00:00<00:00, 21530.56it/s]\n"
]
},
{
Expand Down Expand Up @@ -276,7 +276,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Simulating: 100%|███████████████████████████████████████████████████████████████████████████████████████████████▉| 800/800 [01:55<00:00, 6.94tau/s ]\n"
"Simulating: 100%|██████████████████████████▉| 800/800 [01:59<00:00, 6.70tau/s ]\n"
]
}
],
Expand Down Expand Up @@ -8699,7 +8699,7 @@
{
"data": {
"text/html": [
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>tdgl</td><td>0.8.0; git revision 909069a [2023-10-28]</td></tr><tr><td>Numpy</td><td>1.24.3</td></tr><tr><td>SciPy</td><td>1.10.1</td></tr><tr><td>matplotlib</td><td>3.7.1</td></tr><tr><td>cupy</td><td>None</td></tr><tr><td>numba</td><td>0.57.1</td></tr><tr><td>IPython</td><td>8.14.0</td></tr><tr><td>Python</td><td>3.10.11 | packaged by conda-forge | (main, May 10 2023, 19:01:19) [Clang 14.0.6 ]</td></tr><tr><td>OS</td><td>posix [darwin]</td></tr><tr><td>Number of CPUs</td><td>Physical: 10, Logical: 10</td></tr><tr><td>BLAS Info</td><td>OPENBLAS</td></tr><tr><td colspan='2'>Sun Oct 29 16:04:55 2023 PDT</td></tr></table>"
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>tdgl</td><td>0.8.1; git revision 268e366 [2024-01-30]</td></tr><tr><td>Numpy</td><td>1.24.3</td></tr><tr><td>SciPy</td><td>1.10.1</td></tr><tr><td>matplotlib</td><td>3.7.1</td></tr><tr><td>cupy</td><td>None</td></tr><tr><td>numba</td><td>0.57.1</td></tr><tr><td>IPython</td><td>8.14.0</td></tr><tr><td>Python</td><td>3.10.11 | packaged by conda-forge | (main, May 10 2023, 19:01:19) [Clang 14.0.6 ]</td></tr><tr><td>OS</td><td>posix [darwin]</td></tr><tr><td>Number of CPUs</td><td>Physical: 10, Logical: 10</td></tr><tr><td>BLAS Info</td><td>OPENBLAS</td></tr><tr><td colspan='2'>Tue Jan 30 14:03:06 2024 PST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/mesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Constructing Voronoi polygons: 100%|████████████████████████████████████████████████████████████████████████████| 525/525 [00:00<00:00, 20666.06it/s]\n"
"Constructing Voronoi polygons: 100%|███████| 525/525 [00:00<00:00, 21148.77it/s]\n"
]
}
],
Expand Down
8 changes: 4 additions & 4 deletions docs/notebooks/polygons.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Constructing Voronoi polygons: 100%|████████████████████████████████████████████████████████████████████████████| 459/459 [00:00<00:00, 16604.01it/s]\n",
"Constructing Voronoi polygons: 100%|████████████████████████████████████████████████████████████████████████████| 459/459 [00:00<00:00, 16565.72it/s]\n",
"Constructing Voronoi polygons: 100%|████████████████████████████████████████████████████████████████████████████| 459/459 [00:00<00:00, 16859.64it/s]\n"
"Constructing Voronoi polygons: 100%|███████| 459/459 [00:00<00:00, 16564.44it/s]\n",
"Constructing Voronoi polygons: 100%|███████| 459/459 [00:00<00:00, 16243.28it/s]\n",
"Constructing Voronoi polygons: 100%|███████| 459/459 [00:00<00:00, 17103.94it/s]\n"
]
},
{
Expand Down Expand Up @@ -520,7 +520,7 @@
{
"data": {
"text/html": [
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>tdgl</td><td>0.8.0; git revision 909069a [2023-10-28]</td></tr><tr><td>Numpy</td><td>1.24.3</td></tr><tr><td>SciPy</td><td>1.10.1</td></tr><tr><td>matplotlib</td><td>3.7.1</td></tr><tr><td>cupy</td><td>None</td></tr><tr><td>numba</td><td>0.57.1</td></tr><tr><td>IPython</td><td>8.14.0</td></tr><tr><td>Python</td><td>3.10.11 | packaged by conda-forge | (main, May 10 2023, 19:01:19) [Clang 14.0.6 ]</td></tr><tr><td>OS</td><td>posix [darwin]</td></tr><tr><td>Number of CPUs</td><td>Physical: 10, Logical: 10</td></tr><tr><td>BLAS Info</td><td>OPENBLAS</td></tr><tr><td colspan='2'>Sun Oct 29 16:04:25 2023 PDT</td></tr></table>"
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>tdgl</td><td>0.8.1; git revision 268e366 [2024-01-30]</td></tr><tr><td>Numpy</td><td>1.24.3</td></tr><tr><td>SciPy</td><td>1.10.1</td></tr><tr><td>matplotlib</td><td>3.7.1</td></tr><tr><td>cupy</td><td>None</td></tr><tr><td>numba</td><td>0.57.1</td></tr><tr><td>IPython</td><td>8.14.0</td></tr><tr><td>Python</td><td>3.10.11 | packaged by conda-forge | (main, May 10 2023, 19:01:19) [Clang 14.0.6 ]</td></tr><tr><td>OS</td><td>posix [darwin]</td></tr><tr><td>Number of CPUs</td><td>Physical: 10, Logical: 10</td></tr><tr><td>BLAS Info</td><td>OPENBLAS</td></tr><tr><td colspan='2'>Tue Jan 30 13:57:41 2024 PST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/py-mesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Constructing Voronoi polygons: 100%|██████████████████████████████████████████████████████████████████████████| 4185/4185 [00:00<00:00, 21368.72it/s]\n"
"Constructing Voronoi polygons: 100%|█████| 4185/4185 [00:00<00:00, 21925.67it/s]\n"
]
},
{
Expand Down Expand Up @@ -364,7 +364,7 @@
{
"data": {
"text/html": [
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>tdgl</td><td>0.8.0; git revision 909069a [2023-10-28]</td></tr><tr><td>Numpy</td><td>1.24.3</td></tr><tr><td>SciPy</td><td>1.10.1</td></tr><tr><td>matplotlib</td><td>3.7.1</td></tr><tr><td>cupy</td><td>None</td></tr><tr><td>numba</td><td>0.57.1</td></tr><tr><td>IPython</td><td>8.14.0</td></tr><tr><td>Python</td><td>3.10.11 | packaged by conda-forge | (main, May 10 2023, 19:01:19) [Clang 14.0.6 ]</td></tr><tr><td>OS</td><td>posix [darwin]</td></tr><tr><td>Number of CPUs</td><td>Physical: 10, Logical: 10</td></tr><tr><td>BLAS Info</td><td>OPENBLAS</td></tr><tr><td colspan='2'>Sun Oct 29 16:04:13 2023 PDT</td></tr></table>"
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>tdgl</td><td>0.8.1; git revision 268e366 [2024-01-30]</td></tr><tr><td>Numpy</td><td>1.24.3</td></tr><tr><td>SciPy</td><td>1.10.1</td></tr><tr><td>matplotlib</td><td>3.7.1</td></tr><tr><td>cupy</td><td>None</td></tr><tr><td>numba</td><td>0.57.1</td></tr><tr><td>IPython</td><td>8.14.0</td></tr><tr><td>Python</td><td>3.10.11 | packaged by conda-forge | (main, May 10 2023, 19:01:19) [Clang 14.0.6 ]</td></tr><tr><td>OS</td><td>posix [darwin]</td></tr><tr><td>Number of CPUs</td><td>Physical: 10, Logical: 10</td></tr><tr><td>BLAS Info</td><td>OPENBLAS</td></tr><tr><td colspan='2'>Tue Jan 30 13:57:24 2024 PST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down
23 changes: 15 additions & 8 deletions docs/notebooks/quickstart.ipynb

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/notebooks/screening.ipynb

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions tdgl/device/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ def kappa(self) -> float:
@property
def Bc2(self) -> pint.Quantity:
"""Upper critical field, :math:`B_{c2}=\\Phi_0/(2\\pi\\xi^2)`."""
return (
ureg("Phi_0") / (2 * np.pi * self.coherence_length**2)
).to_base_units()
return (ureg("Phi_0") / (2 * np.pi * self.coherence_length**2)).to_base_units()

@property
def A0(self) -> pint.Quantity:
Expand Down
5 changes: 3 additions & 2 deletions tdgl/finite_volume/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

try:
import cupy # type: ignore
from cupyx.scipy.sparse import csc_matrix, csr_matrix # type: ignore
from cupyx.scipy.sparse.linalg import factorized # type: ignore
except ImportError:
cupy = None
else:
from cupyx.scipy.sparse import csc_matrix, csr_matrix # type: ignore
from cupyx.scipy.sparse.linalg import factorized # type: ignore

Check warning on line 13 in tdgl/finite_volume/operators.py

View check run for this annotation

Codecov / codecov/patch

tdgl/finite_volume/operators.py#L12-L13

Added lines #L12 - L13 were not covered by tests

from ..solver.options import SparseSolver
from .mesh import Mesh
Expand Down
2 changes: 1 addition & 1 deletion tdgl/solution/plot_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def plot_currents(
Jx, Jy = Jgrid
J = np.sqrt(Jx**2 + Jy**2)
xy = np.array([xgrid.ravel(), ygrid.ravel()]).T
ix = np.where(~solution.device.contains_points(xy)[0])
ix = np.where(~solution.device.contains_points(xy))[0]
ix = np.unravel_index(ix, J.shape)
Jx[ix] = np.nan
Jy[ix] = np.nan
Expand Down
2 changes: 1 addition & 1 deletion tdgl/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version_info__ = (0, 8, 0)
__version_info__ = (0, 8, 1)
__version__ = ".".join(map(str, __version_info__))


Expand Down
9 changes: 6 additions & 3 deletions tdgl/visualization/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ def auto_grid(
def non_gui_backend():
"""A contextmanager that temporarily uses a non-GUI backend for matplotlib."""
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", category=UserWarning, message="Matplotlib is currently using agg"
)
ignore_messages = [
"Matplotlib is currently using agg",
"FigureCanvasAgg is non-interactive",
]
for msg in ignore_messages:
warnings.filterwarnings("ignore", category=UserWarning, message=msg)
try:
old_backend = mpl.get_backend()
mpl.use("Agg")
Expand Down
Loading