jitr 0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ # This workflow will publish releases to https://pypi.org/project/jitr
2
+
3
+ name: PyPI publish
4
+
5
+ on:
6
+ release:
7
+ types: [published]
8
+
9
+ jobs:
10
+ pypi-publish:
11
+ name: Build and upload release to PyPI
12
+ runs-on: ubuntu-latest
13
+ environment:
14
+ name: pypi
15
+ url: https://pypi.org/project/jitr/
16
+ permissions:
17
+ id-token: write
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v4
22
+ with:
23
+ python-version: "3.x"
24
+ - name: Install pypa/build
25
+ run: >-
26
+ python3 -m
27
+ pip install
28
+ build
29
+ --user
30
+ - name: Build a binary wheel and a source tarball
31
+ run: >-
32
+ python3 -m
33
+ build
34
+ --sdist
35
+ --wheel
36
+ --outdir dist/
37
+ .
38
+ - name: Publish distribution 📦 to PyPI
39
+ uses: pypa/gh-action-pypi-publish@release/v1
40
+ with:
41
+ password: ${{ secrets.PYPI_ACCESS_TOKEN }}
@@ -0,0 +1,65 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: Python package
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "main" ]
11
+
12
+ jobs:
13
+ build:
14
+
15
+ permissions:
16
+ # Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
17
+ contents: write
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ python-version: ["3.9"]
25
+
26
+ steps:
27
+ - uses: actions/checkout@v3
28
+ with:
29
+ token: ${{ secrets.PAT }}
30
+ ref: ${{ github.head_ref }}
31
+
32
+ - name: black
33
+ uses: lgeiger/black-action@v1.0.1
34
+ with:
35
+ args: .
36
+
37
+ - name: Check for modified files
38
+ id: git-check
39
+ run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
40
+
41
+ - name: Push changes
42
+ if: steps.git-check.outputs.modified == 'true'
43
+ uses: stefanzweifel/git-auto-commit-action@v4
44
+
45
+ - name: Set up Python ${{ matrix.python-version }}
46
+ uses: actions/setup-python@v3
47
+ with:
48
+ python-version: ${{ matrix.python-version }}
49
+
50
+ - name: Install package and dependencies
51
+ run: |
52
+ python -m pip install --upgrade pip
53
+ python -m pip install flake8 pytest
54
+ pip install .
55
+
56
+ - name: Lint with flake8
57
+ run: |
58
+ # stop the build if there are Python syntax errors or undefined names
59
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
60
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
61
+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
62
+
63
+ - name: Test with pytest
64
+ run: |
65
+ pytest
jitr-0.3/.gitignore ADDED
@@ -0,0 +1,164 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
161
+
162
+
163
+ ## scm versioning
164
+ __version__.py
jitr-0.3/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Kyle Beyer
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jitr-0.3/PKG-INFO ADDED
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.1
2
+ Name: jitr
3
+ Version: 0.3
4
+ Summary: Calculable R-matrix solver for quantum scattering using just-in-time compilation for performance.
5
+ Author-email: Kyle Beyer <beykyle@umich.edu>
6
+ License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2023, Kyle Beyer
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice, this
14
+ list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the copyright holder nor the names of its
21
+ contributors may be used to endorse or promote products derived from
22
+ this software without specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Requires-Python: >=3.9
39
+ Description-Content-Type: text/markdown
40
+ License-File: LICENSE
41
+ Requires-Dist: numpy
42
+ Requires-Dist: scipy
43
+ Requires-Dist: mpmath
44
+ Requires-Dist: matplotlib
45
+
46
+ [![Python package](https://github.com/beykyle/jitr/actions/workflows/python-package.yml/badge.svg)](https://github.com/beykyle/jitr/actions/workflows/python-package.yml)
47
+ # Just-In-Time R-matrix (JITR)
48
+ ## Quick start
49
+ ```
50
+ pip install jitr
51
+ ```
52
+
53
+ ## Description
54
+ Solves the radial Bloch-Shrödinger equation in the continuum using the calculable R-Matrix method on a Lagrange-Legendre mesh, using just-in-time (JIT) compilation from [`numba`](https://numba.pydata.org/). The theory generally follows:
55
+ - Descouvemont, P. (2016). An R-matrix package for coupled-channel problems in nuclear physics. Computer physics communications, 200, 199-219,
56
+ - Baye, D. (2015). The Lagrange-mesh method. Physics reports, 565, 1-107,
57
+
58
+ with the primary difference being that this code uses the energy-scaled version of the Bloch-Shrödinger equation, with dimensionless domain, $s = kr$, where $r$ is the radial coordinate and $k$ is the channel wavenumber.
59
+
60
+ Capable of:
61
+ - non-local interactions
62
+ - coupled-channels
63
+
64
+
65
+ ## Simple example
66
+
67
+
jitr-0.3/README.md ADDED
@@ -0,0 +1,22 @@
1
+ [![Python package](https://github.com/beykyle/jitr/actions/workflows/python-package.yml/badge.svg)](https://github.com/beykyle/jitr/actions/workflows/python-package.yml)
2
+ # Just-In-Time R-matrix (JITR)
3
+ ## Quick start
4
+ ```
5
+ pip install jitr
6
+ ```
7
+
8
+ ## Description
9
+ Solves the radial Bloch-Shrödinger equation in the continuum using the calculable R-Matrix method on a Lagrange-Legendre mesh, using just-in-time (JIT) compilation from [`numba`](https://numba.pydata.org/). The theory generally follows:
10
+ - Descouvemont, P. (2016). An R-matrix package for coupled-channel problems in nuclear physics. Computer physics communications, 200, 199-219,
11
+ - Baye, D. (2015). The Lagrange-mesh method. Physics reports, 565, 1-107,
12
+
13
+ with the primary difference being that this code uses the energy-scaled version of the Bloch-Shrödinger equation, with dimensionless domain, $s = kr$, where $r$ is the radial coordinate and $k$ is the channel wavenumber.
14
+
15
+ Capable of:
16
+ - non-local interactions
17
+ - coupled-channels
18
+
19
+
20
+ ## Simple example
21
+
22
+
jitr-0.3/assets/cc.png ADDED
Binary file
@@ -0,0 +1,119 @@
1
+ import numpy as np
2
+ from matplotlib import pyplot as plt
3
+
4
+ from jitr import (
5
+ ProjectileTargetSystem,
6
+ RadialSEChannel,
7
+ LagrangeRMatrix,
8
+ woods_saxon_potential,
9
+ coulomb_potential,
10
+ surface_peaked_gaussian_potential,
11
+ complex_det,
12
+ delta,
13
+ smatrix,
14
+ schrodinger_eqn_ivp_order1,
15
+ )
16
+
17
+
18
+ def coupled_channels_example(visualize=False):
19
+ """
20
+ 3 level system example with local diagonal and transition potentials and neutral
21
+ particles. Potentials are real, so S-matrix is unitary and symmetric
22
+ """
23
+ mass = 939 # reduced mass of scattering system MeV / c^2
24
+
25
+ # Potential parameters
26
+ V = 60 # real potential strength
27
+ W = 0 # imag potential strength
28
+ R = 4 # Woods-Saxon potential radius
29
+ a = 0.5 # Woods-Saxon potential diffuseness
30
+ params = (V, W, R, a)
31
+
32
+ nodes_within_radius = 10
33
+
34
+ system = ProjectileTargetSystem(
35
+ incident_energy=50,
36
+ reduced_mass=939,
37
+ channel_radius=5 * (2 * np.pi),
38
+ num_channels=3,
39
+ level_energies=[0, 12, 20],
40
+ )
41
+
42
+ l = 0
43
+
44
+ matrix = np.empty((3, 3), dtype=object)
45
+
46
+ # diagonal potentials are just Woods-Saxons
47
+ for i in range(system.num_channels):
48
+ matrix[i, i] = RadialSEChannel(
49
+ l=l,
50
+ system=system,
51
+ interaction=lambda r: woods_saxon_potential(r, params),
52
+ threshold_energy=system.level_energies[i],
53
+ )
54
+
55
+ # transition potentials have depths damped by a factor compared to diagonal terms
56
+ # and use surface peaked Gaussian form factors rather than Woods-Saxons
57
+ transition_dampening_factor = 1
58
+ Vt = V / transition_dampening_factor
59
+ Wt = W / transition_dampening_factor
60
+
61
+ # off diagonal potential terms
62
+ for i in range(system.num_channels):
63
+ for j in range(system.num_channels):
64
+ if i != j:
65
+ matrix[i, j] = RadialSEChannel(
66
+ l=l,
67
+ system=system,
68
+ interaction=lambda r: surface_peaked_gaussian_potential(
69
+ r, (Vt, Wt, R, a)
70
+ ),
71
+ threshold_energy=system.level_energies[i],
72
+ )
73
+
74
+ solver_lm = LagrangeRMatrix(40, system, matrix)
75
+
76
+ H = solver_lm.bloch_se_matrix()
77
+
78
+ if visualize:
79
+ for i in range(3):
80
+ for j in range(3):
81
+ plt.imshow(np.real(solver_lm.single_channel_bloch_se_matrix(i, j)))
82
+ plt.xlabel("n")
83
+ plt.ylabel("m")
84
+ plt.colorbar()
85
+ plt.title(f"({i}, {j})")
86
+ plt.show()
87
+
88
+ # get R and S-matrix, and both internal and external soln
89
+ R, S, uint = solver_lm.solve_wavefunction()
90
+
91
+ # S must be unitary
92
+ assert np.isclose(complex_det(S), 1.0)
93
+ # S is symmetric iff the correct factors of momentum are applied
94
+ # assert np.allclose(S, S.T)
95
+
96
+ r_values = np.linspace(0.05, 40, 500)
97
+ s_values = np.linspace(0.05, system.channel_radius, 500)
98
+
99
+ lines = []
100
+ for i in range(system.num_channels):
101
+ u_values = uint[i].uint()(s_values)
102
+ (p1,) = plt.plot(s_values, np.real(u_values), label=r"$n=%d$" % i)
103
+ (p2,) = plt.plot(s_values, np.imag(u_values), ":", color=p1.get_color())
104
+ lines.append([p1, p2])
105
+
106
+ legend1 = plt.legend(
107
+ lines[0], [r"$\mathfrak{Re}\, u_n(s) $", r"$\mathfrak{Im}\, u_n(s)$"], loc=3
108
+ )
109
+ plt.legend([l[0] for l in lines], [l[0].get_label() for l in lines], loc=1)
110
+ plt.gca().add_artist(legend1)
111
+
112
+ plt.xlabel(r"$s_n = k_n r$")
113
+ plt.ylabel(r"$u (s) $ [a.u.]")
114
+ plt.tight_layout()
115
+ plt.show()
116
+
117
+
118
+ if __name__ == "__main__":
119
+ coupled_channels_example()