Compare commits

..

8 Commits

Author SHA1 Message Date
6a45d1123e chore(deps): update dependency black to v23
All checks were successful
gitea-physics/pdme/pipeline/pr-master This commit looks good
2023-04-10 01:33:37 +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 88 additions and 10 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.
### [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)

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 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)
![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.

View File

@ -69,6 +69,47 @@ def fast_vs_for_dipoleses(
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:
"""
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.

19
poetry.lock generated
View File

@ -52,7 +52,7 @@ python-versions = "*"
[[package]]
name = "black"
version = "23.1.0"
version = "23.3.0"
description = "The uncompromising code formatter."
category = "dev"
optional = false
@ -94,7 +94,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "coverage"
version = "7.1.0"
version = "7.2.3"
description = "Code coverage measurement for Python"
category = "dev"
optional = false
@ -417,14 +417,19 @@ testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtuale
[[package]]
name = "scipy"
version = "1.8.0"
description = "SciPy: Scientific Library for Python"
version = "1.10.0"
description = "Fundamental algorithms for scientific computing in Python"
category = "main"
optional = false
python-versions = ">=3.8,<3.11"
python-versions = "<3.12,>=3.8"
[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]]
name = "six"
@ -496,7 +501,7 @@ python-versions = "*"
[metadata]
lock-version = "1.1"
python-versions = "^3.8,<3.10"
content-hash = "19a6af95086758eb503d273fa5366bf73cc0060ef5a395a41c51fcdf7372b5dd"
content-hash = "be6bfa73e6db07338369f817a2d0c86f1072b313d23d470feb5ca49cfd5aa8ad"
[metadata.files]
appnope = []

View File

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

View File

@ -107,3 +107,28 @@ def test_between():
expected = numpy.array([False, False, True])
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.",
)