From ba3a5b93a16ff5532a08891e8f8ec2212b0e0daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20M=C3=BCller?= <49639740+MarJMue@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:44:59 +0200 Subject: [PATCH 1/5] fix typos --- .vscode/ltex.dictionary.en-US.txt | 3 +++ README.md | 2 +- docs/dispersions.rst | 4 ++-- docs/index.rst | 6 +++--- docs/plot.rst | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 .vscode/ltex.dictionary.en-US.txt diff --git a/.vscode/ltex.dictionary.en-US.txt b/.vscode/ltex.dictionary.en-US.txt new file mode 100644 index 00000000..9b1509bb --- /dev/null +++ b/.vscode/ltex.dictionary.en-US.txt @@ -0,0 +1,3 @@ +dispersions +dataframes +ellipsometry diff --git a/README.md b/README.md index 1421bd6e..66f6776a 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,4 @@ pip install -e ".[fitting]" - Solver2x2 based on Steve Byrnes' [tmm](https://github.com/sbyrnes321/tmm) - Mikhail Polyanskiy's [refractiveindex.info database](https://github.com/polyanskiy/refractiveindex.info-database) and Pavel Dmitriev's [pyTMM](https://github.com/kitchenknif/PyTMM) for his importer script for the database -[@MarJMue](https://github.com/MarJMue) recieves financial support by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation), grant No. 398143140 (FOR 2824). +[@MarJMue](https://github.com/MarJMue) receives financial support by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation), grant No. 398143140 (FOR 2824). diff --git a/docs/dispersions.rst b/docs/dispersions.rst index 69a32e3e..a73b004b 100644 --- a/docs/dispersions.rst +++ b/docs/dispersions.rst @@ -265,7 +265,7 @@ DispersionSum This object can be used to add an arbitrary number of dispersions. The overloaded `+` operator of the dispersion base class creates an instance of this object with two classes as parameters. -If you want to chain a lot of dispersions it may be more performant to use +If you want to chain a lot of dispersions, it may be more performant to use this class directly. .. autoclass:: elli.dispersions.base_dispersion.DispersionSum @@ -274,6 +274,6 @@ this class directly. InvalidParameters ----------------- -This exception is thrown whenever a dispersions got invalid parameters. +This exception is thrown whenever a dispersion got invalid parameters. .. autoexception:: elli.dispersions.base_dispersion.InvalidParameters diff --git a/docs/index.rst b/docs/index.rst index 2a87af47..c45c3bbb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,8 +14,8 @@ However, pyElli comes with batteries included and already offers a wide range of :doc:`dispersion models` and the material database of Refractiveindex.info. Most of the models presented in the -comprehensive book of Fujiwara and Colllins [1]_ are present and additionally -a lot of other models used by ellipsometry vendor softwares are included. +comprehensive book of Fujiwara and Collins [1]_ are present and additionally +a lot of other models used by ellipsometry vendor software are included. The material database offers the dispersions seen on the `website `_ and can be accessed by using the :class:`elli.db.RII` module. @@ -54,7 +54,7 @@ but can contain arbitrary more :class:`layers` which are o The :class:`VaryingMixtureLayer` class can also account for gradient changes of materials in z-direction of a layer, which is useful for gradient layers or roughness modeling. As the last step the :class:`Structure` is plugged into an :class:`Experiment`, which contains -the experimental conditions, such as light polarizations. +the experimental conditions, such as light polarization. By evaluating the experiment a :class:`Result` class containing the calculated data is returned. The creation of an experiment can be skipped by calling the :meth:`evaluate` method directly on a :class:`Structure` class if you want to use standard experimental settings. diff --git a/docs/plot.rst b/docs/plot.rst index a6db1213..31acd250 100644 --- a/docs/plot.rst +++ b/docs/plot.rst @@ -7,7 +7,7 @@ Interactive fitting PyElli offers several classes and decorators to make fitting easy. The central idea is to construct a class containing the measurement data and an optical model which is fitted to the data with `lmfit `_. -Since pyElli uses lmfit under the hood you may take advantage of it's vast capabilities. +Since pyElli uses lmfit under the hood you may take advantage of its vast capabilities. To make creation of the fitting classes as easy as possible pyElli contains decorators to automatically instantiate the class by providing a function containing the optical model. @@ -56,7 +56,7 @@ be inherited from in additional fitting classes. Parameter class --------------- -The parameter class extending lmfits Parameter class by a history +The parameter class extending lmfit's Parameter class by a history of parameter changes. .. automodule:: elli.fitting.params_hist From 3bc1ee1eae694f94664079465f1a9256e04c9339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20M=C3=BCller?= <49639740+MarJMue@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:45:54 +0200 Subject: [PATCH 2/5] Include pytorch installation in the documentation --- README.md | 6 +++++- docs/installation.rst | 9 ++++++++- docs/solvers.rst | 1 + src/elli/solver4x4.py | 8 ++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 66f6776a..a7e0f4c0 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,11 @@ pip install pyElli[fitting] ``` This installs pyElli with the additional fitting capabilities and interactive widgets. -If don't want to have this functionality just drop the `[fitting]` in the end. +If you don't want to have this functionality just drop the `[fitting]` in the end. + +To increase performance of the 4x4 Solver for anisotropic media, it is recommended to +install PyTorch CPU package manually, as it is too heavy to include in the standard installation. +Installation information can be found at the [PyTorch Website](https://pytorch.org/get-started/locally/). A complete environment for pyElli is also available as a [Docker Container](https://hub.docker.com/r/domna/pyelli). To pull and run it directly just execute diff --git a/docs/installation.rst b/docs/installation.rst index 392a02ff..a063c329 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -10,7 +10,14 @@ To install the package in your current virtual environment execute .. code-block:: shell - pip install pyElli + pip install pyElli[fitting] + +This installs pyElli with the additional fitting capabilities and interactive widgets. +If you don't want to have this functionality just drop the `[fitting]` in the end. + +To increase performance of the 4x4 Solver for anisotropic media, it is recommended to +install PyTorch CPU package manually, as it is too heavy to include in the standard installation. +Installation information can be found at the `PyTorch Website `. A complete environment for pyElli is also available as a `Docker Container `_. diff --git a/docs/solvers.rst b/docs/solvers.rst index 0657bb68..39e734c3 100644 --- a/docs/solvers.rst +++ b/docs/solvers.rst @@ -16,6 +16,7 @@ pyElli provides different implementations to be used in the calculation of the t The :class:`PropagatorEig` is based on solving the eigenvalues of the first order approximation of the matrix exponential. Although, it is very fast it is not very accurate. The :class:`PropagatorExpm` is solving the matrix exponential by the Pade approximation. +It can use SciPy as backend, but for performance-critical tasks, it is recommended to install PyTorch. .. rubric:: References diff --git a/src/elli/solver4x4.py b/src/elli/solver4x4.py index 6c3a10cd..1b4c4f2e 100644 --- a/src/elli/solver4x4.py +++ b/src/elli/solver4x4.py @@ -66,6 +66,14 @@ class PropagatorExpm(Propagator): """Propagator class using the Padé approximation of the matrix exponential.""" def __init__(self, backend: Literal["torch", "scipy", "automatic"] = "automatic"): + """The Propagator can use two different backends: SciPy and PyTorch. + The default installation only provides SciPy. + PyTorch is faster by an factor of 20 and will be used automatically. + If you need to install PyTorch please follow the instructions at https://pytorch.org/get-started/locally/. + + Args: + backend (Literal["torch", "scipy", "automatic"], optional): _description_. Defaults to "automatic". + """ backends = { "torch": lambda mats: torch.linalg.matrix_exp( torch.from_numpy(mats) From c45d8ae91775d375423e9aa51ff339beff781d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20M=C3=BCller?= <49639740+MarJMue@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:49:31 +0200 Subject: [PATCH 3/5] include the speedup factor --- README.md | 2 +- docs/installation.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7e0f4c0..e3ec48c4 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ pip install pyElli[fitting] This installs pyElli with the additional fitting capabilities and interactive widgets. If you don't want to have this functionality just drop the `[fitting]` in the end. -To increase performance of the 4x4 Solver for anisotropic media, it is recommended to +To increase performance of the 4x4 Solver by a factor of 20, it is recommended to install PyTorch CPU package manually, as it is too heavy to include in the standard installation. Installation information can be found at the [PyTorch Website](https://pytorch.org/get-started/locally/). diff --git a/docs/installation.rst b/docs/installation.rst index a063c329..ad5c4ea2 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -15,7 +15,7 @@ To install the package in your current virtual environment execute This installs pyElli with the additional fitting capabilities and interactive widgets. If you don't want to have this functionality just drop the `[fitting]` in the end. -To increase performance of the 4x4 Solver for anisotropic media, it is recommended to +To increase performance of the 4x4 Solver by a factor of 20, it is recommended to install PyTorch CPU package manually, as it is too heavy to include in the standard installation. Installation information can be found at the `PyTorch Website `. From 3e177f7f64764210e0405acd87e2f28cf4ebcb89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20M=C3=BCller?= <49639740+MarJMue@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:54:27 +0200 Subject: [PATCH 4/5] Fix sphinx docs --- docs/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation.rst b/docs/installation.rst index ad5c4ea2..cbbb3faf 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -17,7 +17,7 @@ If you don't want to have this functionality just drop the `[fitting]` in the en To increase performance of the 4x4 Solver by a factor of 20, it is recommended to install PyTorch CPU package manually, as it is too heavy to include in the standard installation. -Installation information can be found at the `PyTorch Website `. +Installation information can be found at the `PyTorch Website `_. A complete environment for pyElli is also available as a `Docker Container `_. From 14f9e6c1092783a0948e9c8c009d58e9669fc415 Mon Sep 17 00:00:00 2001 From: MarJMue <49639740+MarJMue@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:04:54 +0200 Subject: [PATCH 5/5] Include suggestions --- README.md | 5 +++-- docs/installation.rst | 5 +++-- src/elli/solver4x4.py | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e3ec48c4..d5e12558 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,10 @@ pip install pyElli[fitting] This installs pyElli with the additional fitting capabilities and interactive widgets. If you don't want to have this functionality just drop the `[fitting]` in the end. -To increase performance of the 4x4 Solver by a factor of 20, it is recommended to -install PyTorch CPU package manually, as it is too heavy to include in the standard installation. +To increase performance of the 4x4 Solver, it is recommended to +install PyTorch manually, as it is too big to include in the standard installation. Installation information can be found at the [PyTorch Website](https://pytorch.org/get-started/locally/). +The CPU variant is sufficient, if you want to save some space. A complete environment for pyElli is also available as a [Docker Container](https://hub.docker.com/r/domna/pyelli). To pull and run it directly just execute diff --git a/docs/installation.rst b/docs/installation.rst index cbbb3faf..26129fa1 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -15,9 +15,10 @@ To install the package in your current virtual environment execute This installs pyElli with the additional fitting capabilities and interactive widgets. If you don't want to have this functionality just drop the `[fitting]` in the end. -To increase performance of the 4x4 Solver by a factor of 20, it is recommended to -install PyTorch CPU package manually, as it is too heavy to include in the standard installation. +To increase performance of the 4x4 Solver, it is recommended to +install PyTorch manually, as it is too big to include in the standard installation. Installation information can be found at the `PyTorch Website `_. +The CPU variant is sufficient, if you want to save some space. A complete environment for pyElli is also available as a `Docker Container `_. diff --git a/src/elli/solver4x4.py b/src/elli/solver4x4.py index 1b4c4f2e..4f2610de 100644 --- a/src/elli/solver4x4.py +++ b/src/elli/solver4x4.py @@ -68,11 +68,11 @@ class PropagatorExpm(Propagator): def __init__(self, backend: Literal["torch", "scipy", "automatic"] = "automatic"): """The Propagator can use two different backends: SciPy and PyTorch. The default installation only provides SciPy. - PyTorch is faster by an factor of 20 and will be used automatically. - If you need to install PyTorch please follow the instructions at https://pytorch.org/get-started/locally/. + PyTorch is faster and will be used automatically if available. + If you want to install PyTorch please follow the instructions at https://pytorch.org/get-started/locally/. Args: - backend (Literal["torch", "scipy", "automatic"], optional): _description_. Defaults to "automatic". + backend (Literal["torch", "scipy", "automatic"], optional): Setting to change the linear algebra provider. Defaults to "automatic". """ backends = { "torch": lambda mats: torch.linalg.matrix_exp(