Compare commits

..

8 Commits

Author SHA1 Message Date
995ef5e07c chore(deps): update dependency pytest-cov to v4
All checks were successful
gitea-physics/pdme/pipeline/pr-master This commit looks good
2023-04-10 01:34:03 +00:00
23e3b95bb6
chore: adds maintained to readme for 2023
All checks were successful
gitea-physics/pdme/pipeline/head This commit looks good
2023-04-09 17:33:07 -05:00
a326e80e00
chore(release): 0.8.8
All checks were successful
gitea-physics/pdme/pipeline/head This commit looks good
gitea-physics/pdme/pipeline/tag This commit looks good
2023-04-09 16:35:10 -05:00
56f660ff25 Merge pull request 'feat: adds fast calc that allows for variable temp' (#28) from feature/temp_sensitive into master
All checks were successful
gitea-physics/pdme/pipeline/head This commit looks good
Reviewed-on: #28
2023-04-09 21:32:10 +00:00
a5fd9c2304
style: whoops blank line
All checks were successful
gitea-physics/pdme/pipeline/pr-master This commit looks good
2023-04-09 16:30:40 -05:00
0dbe874ac4 Merge pull request 'chore(deps): update dependency scipy to ~1.10' (#21) from renovate/scipy-1.x into master
All checks were successful
gitea-physics/pdme/pipeline/head This commit looks good
Reviewed-on: #21
2023-04-09 21:26:46 +00:00
36454d5044
feat: adds fast calc that allows for variable temp
Some checks failed
gitea-physics/pdme/pipeline/head There was a failure building this commit
gitea-physics/pdme/pipeline/pr-master There was a failure building this commit
2023-04-09 16:26:08 -05:00
156019fdac chore(deps): update dependency scipy to ~1.10
All checks were successful
gitea-physics/pdme/pipeline/pr-master This commit looks good
2023-01-04 01:31:57 +00:00
6 changed files with 90 additions and 12 deletions

View File

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.8.8](https://gitea.deepak.science:2222/physics/pdme/compare/0.8.7...0.8.8) (2023-04-09)
### Features
* adds fast calc that allows for variable temp ([36454d5](https://gitea.deepak.science:2222/physics/pdme/commit/36454d5044d93b6b178e016b84dd59a5ebaf15e2))
### [0.8.7](https://gitea.deepak.science:2222/physics/pdme/compare/0.8.6...0.8.7) (2022-09-17) ### [0.8.7](https://gitea.deepak.science:2222/physics/pdme/compare/0.8.6...0.8.7) (2022-09-17)

View File

@ -5,7 +5,7 @@
[![Jenkins](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fpdme%2Fjob%2Fmaster&style=flat-square)](https://jenkins.deepak.science/job/gitea-physics/job/pdme/job/master/) [![Jenkins](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fpdme%2Fjob%2Fmaster&style=flat-square)](https://jenkins.deepak.science/job/gitea-physics/job/pdme/job/master/)
![Jenkins tests](https://img.shields.io/jenkins/tests?compact_message&jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fpdme%2Fjob%2Fmaster%2F&style=flat-square) ![Jenkins tests](https://img.shields.io/jenkins/tests?compact_message&jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fpdme%2Fjob%2Fmaster%2F&style=flat-square)
![Jenkins Coverage](https://img.shields.io/jenkins/coverage/cobertura?jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fpdme%2Fjob%2Fmaster%2F&style=flat-square) ![Jenkins Coverage](https://img.shields.io/jenkins/coverage/cobertura?jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fpdme%2Fjob%2Fmaster%2F&style=flat-square)
![Maintenance](https://img.shields.io/maintenance/yes/2022?style=flat-square) ![Maintenance](https://img.shields.io/maintenance/yes/2023?style=flat-square)
This repo has library code for evaluating dipole models. This repo has library code for evaluating dipole models.

View File

@ -69,6 +69,47 @@ def fast_vs_for_dipoleses(
return numpy.einsum("...j->...", ases * bses) return numpy.einsum("...j->...", ases * bses)
def fast_vs_for_asymmetric_dipoleses(
dot_inputs: numpy.ndarray, dipoleses: numpy.ndarray, temp: numpy.ndarray
) -> numpy.ndarray:
"""
No error correction here baby.
Expects dot_inputs to be numpy array of [rx, ry, rz, f] entries, so a n by 4 where n is number of measurement points.
Dipoleses are expected to be array of arrays of arrays:
list of sets of dipoles which are part of a single arrangement to be added together.
Within each dipole, the expected format is [px, py, pz, sx, sy, sz, e1, e2, w]
The passed in w is expected to be half the actual. This is bad, but here for historical reasons to be changed later.
"""
raw_ps = dipoleses[:, :, 0:3]
ss = dipoleses[:, :, 3:6]
e1s = dipoleses[:, :, 6]
e2s = dipoleses[:, :, 7]
raw_ws = dipoleses[:, :, 8]
rs = dot_inputs[:, 0:3]
fs = dot_inputs[:, 3]
diffses = rs[:, None] - ss[:, None, :]
w1s = numpy.exp(-e1s / temp) * raw_ws
w2s = numpy.exp(-e2s / temp) * raw_ws
mag_prefactor = 4 * ((w1s * w2s) / ((w1s + w2s) ** 2))
ws = w1s + w2s
# some annoying broadcast thing here?
ps = (raw_ps.T * mag_prefactor.T).T
norms = numpy.linalg.norm(diffses, axis=3) ** 3
ases = (numpy.einsum("abcd,acd->abc", diffses, ps) / norms) ** 2
bses = (1 / numpy.pi) * (ws[:, None, :] / (fs[:, None] ** 2 + ws[:, None, :] ** 2))
return numpy.einsum("...j->...", ases * bses)
def between(a: numpy.ndarray, low: numpy.ndarray, high: numpy.ndarray) -> numpy.ndarray: def between(a: numpy.ndarray, low: numpy.ndarray, high: numpy.ndarray) -> numpy.ndarray:
""" """
Intended specifically for the case where a is a list of arrays, and each array must be between the single array low and high, but without error checking. Intended specifically for the case where a is a list of arrays, and each array must be between the single array low and high, but without error checking.

23
poetry.lock generated
View File

@ -93,7 +93,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]] [[package]]
name = "coverage" name = "coverage"
version = "6.4.4" version = "7.2.3"
description = "Code coverage measurement for Python" description = "Code coverage measurement for Python"
category = "dev" category = "dev"
optional = false optional = false
@ -316,8 +316,8 @@ optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
[package.extras] [package.extras]
testing = ["pytest-benchmark", "pytest"] dev = ["pre-commit", "tox"]
dev = ["tox", "pre-commit"] testing = ["pytest", "pytest-benchmark"]
[[package]] [[package]]
name = "prompt-toolkit" name = "prompt-toolkit"
@ -430,14 +430,19 @@ testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtuale
[[package]] [[package]]
name = "scipy" name = "scipy"
version = "1.8.0" version = "1.10.0"
description = "SciPy: Scientific Library for Python" description = "Fundamental algorithms for scientific computing in Python"
category = "main" category = "main"
optional = false optional = false
python-versions = ">=3.8,<3.11" python-versions = "<3.12,>=3.8"
[package.dependencies] [package.dependencies]
numpy = ">=1.17.3,<1.25.0" numpy = ">=1.19.5,<1.27.0"
[package.extras]
test = ["pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "asv", "mpmath", "gmpy2", "threadpoolctl", "scikit-umfpack", "pooch"]
doc = ["sphinx (!=4.1.0)", "pydata-sphinx-theme (==0.9.0)", "sphinx-design (>=0.2.0)", "matplotlib (>2)", "numpydoc"]
dev = ["mypy", "typing-extensions", "pycodestyle", "flake8", "rich-click", "click", "doit (>=0.36.0)", "pydevtool"]
[[package]] [[package]]
name = "six" name = "six"
@ -461,7 +466,7 @@ executing = "*"
pure-eval = "*" pure-eval = "*"
[package.extras] [package.extras]
tests = ["cython", "littleutils", "pygments", "typeguard", "pytest"] tests = ["pytest", "typeguard", "pygments", "littleutils", "cython"]
[[package]] [[package]]
name = "toml" name = "toml"
@ -509,7 +514,7 @@ python-versions = "*"
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.8,<3.10" python-versions = "^3.8,<3.10"
content-hash = "64f2993cf53f0eb309ca4ce27a20a9b4afdd3c6674b43e0e61349e06eabb7f2a" content-hash = "6be63839fba38d5e4fe8a6e32d7a748a74d5984180261233a0c5ae06c8c42005"
[metadata.files] [metadata.files]
appnope = [] appnope = []

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "pdme" name = "pdme"
version = "0.8.7" version = "0.8.8"
description = "Python dipole model evaluator" description = "Python dipole model evaluator"
authors = ["Deepak <dmallubhotla+github@gmail.com>"] authors = ["Deepak <dmallubhotla+github@gmail.com>"]
license = "GPL-3.0-only" license = "GPL-3.0-only"
@ -9,7 +9,7 @@ readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8,<3.10" python = "^3.8,<3.10"
numpy = "^1.22.3" numpy = "^1.22.3"
scipy = "~1.8" scipy = "~1.10"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = ">=6" pytest = ">=6"

View File

@ -107,3 +107,28 @@ def test_between():
expected = numpy.array([False, False, True]) expected = numpy.array([False, False, True])
numpy.testing.assert_array_equal(actual, expected, err_msg="Between calc wrong") numpy.testing.assert_array_equal(actual, expected, err_msg="Between calc wrong")
def test_fast_v_calc_asymmetric_multidipoles_but_symmetric():
# expected format is [px, py, pz, sx, sy, sz, e1, e2, w]
d1 = [1, 2, 3, 4, 5, 6, 1, 1, 7 / 2]
d2 = [2, 5, 3, 4, -5, -6, 2, 2, 2 / 2]
dipoles = numpy.array([[d1, d2]])
dot_inputs = numpy.array([[-1, -1, -1, 11], [2, 3, 1, 5.5]])
# expected_ij is for dot i, dipole j
expected_11 = 0.00001421963287022476
expected_12 = 0.00001107180225755457
expected_21 = 0.000345021108583681380388722
expected_22 = 0.0000377061050587914705139781
expected = numpy.array([[expected_11 + expected_12, expected_21 + expected_22]])
numpy.testing.assert_allclose(
pdme.util.fast_v_calc.fast_vs_for_asymmetric_dipoleses(
dot_inputs, dipoles, 1e10
),
expected,
err_msg="Voltages at dot aren't as expected for multidipole calc.",
)