15 Commits

Author SHA1 Message Date
a86bcac604 Adds docs
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2021-01-04 16:00:28 -06:00
7843e462de Adding new sc free energy file
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2021-01-04 15:04:42 -06:00
0715e1858a Created version 0.1.1
All checks were successful
gitea-physics/pysuperconductor/pipeline/tag This commit looks good
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-12-13 16:02:01 -06:00
0ff6118211 Adds pypi credentials
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-12-13 16:01:10 -06:00
7a5658c8ea moves jenkinsfile hash sign
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 19:14:42 -06:00
33b58a2afb adds number sign to jenkinsfile email subject
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 19:13:51 -06:00
458eff1905 slight improvements to email
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 19:12:15 -06:00
bba1643c76 uses scipy expit to handle overflow smarter
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 19:05:18 -06:00
54917655cd Removes warnings from overflow and from scipy bug
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 18:45:44 -06:00
3cda66441e adds full functionality test for find_n_gap
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 13:57:37 -06:00
346caf3ea0 adds more type hinting
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 12:52:50 -06:00
5bb3a2163f adds more type hinting 2020-11-24 12:51:03 -06:00
7744f040f6 adds target for mypy
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
2020-11-24 12:47:08 -06:00
cb5a681117 adds mypy to test command and adds fixes for flake issues
Some checks failed
gitea-physics/pysuperconductor/pipeline/head There was a failure building this commit
2020-11-24 12:45:04 -06:00
83a58a5a54 adds mypy type checking
Some checks failed
gitea-physics/pysuperconductor/pipeline/head There was a failure building this commit
2020-11-24 12:39:01 -06:00
9 changed files with 219 additions and 19 deletions

11
Jenkinsfile vendored
View File

@@ -15,7 +15,7 @@ pipeline {
environment {
POETRY_HOME="/opt/poetry"
POETRY_VERSION="1.1.4"
//PYPI=credentials("DOES_NOT_EXIST")
PYPI=credentials("pypi-pysuperconductor")
}
stages {
@@ -40,6 +40,11 @@ pipeline {
sh '${POETRY_HOME}/bin/poetry run flake8'
}
}
stage('mypy') {
steps {
sh '${POETRY_HOME}/bin/poetry run mypy pysuperconductor'
}
}
}
}
stage('Deploy') {
@@ -48,7 +53,7 @@ pipeline {
}
steps {
echo 'Deploying...'
// sh '${POETRY_HOME}/bin/poetry publish -u ${PYPI_USR} -p ${PYPI_PSW} --build'
sh '${POETRY_HOME}/bin/poetry publish -u ${PYPI_USR} -p ${PYPI_PSW} --build'
}
}
}
@@ -58,7 +63,7 @@ pipeline {
junit 'pytest.xml'
cobertura coberturaReportFile: 'coverage.xml'
mail (bcc: '',
body: "Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> Build URL: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: 'jenkins@jenkins.deepak.science', mimeType: 'text/html', replyTo: 'dmallubhotla+jenkins@gmail.com', subject: "CI ${currentBuild.currentResult}: Project name -> ${env.JOB_NAME}", to: "dmallubhotla+ci@gmail.com")
body: "Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> Build URL: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: 'jenkins@jenkins.deepak.science', mimeType: 'text/html', replyTo: 'dmallubhotla+jenkins@gmail.com', subject: "${env.JOB_NAME} #${env.BUILD_NUMBER}: Build ${currentBuild.currentResult}", to: "dmallubhotla+ci@gmail.com")
}
success {
echo 'This will run only if successful'

1
do.sh
View File

@@ -12,6 +12,7 @@ build() {
test() {
echo "I am ${FUNCNAME[0]}ing"
poetry run flake8
poetry run mypy pysuperconductor
poetry run pytest
}

99
poetry.lock generated
View File

@@ -68,6 +68,30 @@ category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "mypy"
version = "0.790"
description = "Optional static typing for Python"
category = "dev"
optional = false
python-versions = ">=3.5"
[package.dependencies]
mypy-extensions = ">=0.4.3,<0.5.0"
typed-ast = ">=1.4.0,<1.5.0"
typing-extensions = ">=3.7.4"
[package.extras]
dmypy = ["psutil (>=4.0)"]
[[package]]
name = "mypy-extensions"
version = "0.4.3"
description = "Experimental type system extensions for programs checked with the mypy typechecker."
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "numpy"
version = "1.19.3"
@@ -195,10 +219,26 @@ category = "dev"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "typed-ast"
version = "1.4.1"
description = "a fork of Python 2 and 3 ast modules with type comment support"
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "typing-extensions"
version = "3.7.4.3"
description = "Backported and Experimental Type Hints for Python 3.5+"
category = "dev"
optional = false
python-versions = "*"
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "89c70392b9eb2d235f8b88293fee1b8e0d47153894cc12810a0b1884e2646e5e"
content-hash = "0a44a1d796f0619dcc526b6bd681fd179a6c888e4d75826de435fee2e7332a25"
[metadata.files]
atomicwrites = [
@@ -261,6 +301,26 @@ mccabe = [
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
]
mypy = [
{file = "mypy-0.790-cp35-cp35m-macosx_10_6_x86_64.whl", hash = "sha256:bd03b3cf666bff8d710d633d1c56ab7facbdc204d567715cb3b9f85c6e94f669"},
{file = "mypy-0.790-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:2170492030f6faa537647d29945786d297e4862765f0b4ac5930ff62e300d802"},
{file = "mypy-0.790-cp35-cp35m-win_amd64.whl", hash = "sha256:e86bdace26c5fe9cf8cb735e7cedfe7850ad92b327ac5d797c656717d2ca66de"},
{file = "mypy-0.790-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:e97e9c13d67fbe524be17e4d8025d51a7dca38f90de2e462243ab8ed8a9178d1"},
{file = "mypy-0.790-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0d34d6b122597d48a36d6c59e35341f410d4abfa771d96d04ae2c468dd201abc"},
{file = "mypy-0.790-cp36-cp36m-win_amd64.whl", hash = "sha256:72060bf64f290fb629bd4a67c707a66fd88ca26e413a91384b18db3876e57ed7"},
{file = "mypy-0.790-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:eea260feb1830a627fb526d22fbb426b750d9f5a47b624e8d5e7e004359b219c"},
{file = "mypy-0.790-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c614194e01c85bb2e551c421397e49afb2872c88b5830e3554f0519f9fb1c178"},
{file = "mypy-0.790-cp37-cp37m-win_amd64.whl", hash = "sha256:0a0d102247c16ce93c97066443d11e2d36e6cc2a32d8ccc1f705268970479324"},
{file = "mypy-0.790-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cf4e7bf7f1214826cf7333627cb2547c0db7e3078723227820d0a2490f117a01"},
{file = "mypy-0.790-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:af4e9ff1834e565f1baa74ccf7ae2564ae38c8df2a85b057af1dbbc958eb6666"},
{file = "mypy-0.790-cp38-cp38-win_amd64.whl", hash = "sha256:da56dedcd7cd502ccd3c5dddc656cb36113dd793ad466e894574125945653cea"},
{file = "mypy-0.790-py3-none-any.whl", hash = "sha256:2842d4fbd1b12ab422346376aad03ff5d0805b706102e475e962370f874a5122"},
{file = "mypy-0.790.tar.gz", hash = "sha256:2b21ba45ad9ef2e2eb88ce4aeadd0112d0f5026418324176fd494a6824b74975"},
]
mypy-extensions = [
{file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
]
numpy = [
{file = "numpy-1.19.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:942d2cdcb362739908c26ce8dd88db6e139d3fa829dd7452dd9ff02cba6b58b2"},
{file = "numpy-1.19.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:efd656893171bbf1331beca4ec9f2e74358fc732a2084f664fd149cc4b3441d2"},
@@ -364,3 +424,40 @@ toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
]
typed-ast = [
{file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3"},
{file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb"},
{file = "typed_ast-1.4.1-cp35-cp35m-win32.whl", hash = "sha256:0c2c07682d61a629b68433afb159376e24e5b2fd4641d35424e462169c0a7919"},
{file = "typed_ast-1.4.1-cp35-cp35m-win_amd64.whl", hash = "sha256:4083861b0aa07990b619bd7ddc365eb7fa4b817e99cf5f8d9cf21a42780f6e01"},
{file = "typed_ast-1.4.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75"},
{file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652"},
{file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7"},
{file = "typed_ast-1.4.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:fcf135e17cc74dbfbc05894ebca928ffeb23d9790b3167a674921db19082401f"},
{file = "typed_ast-1.4.1-cp36-cp36m-win32.whl", hash = "sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1"},
{file = "typed_ast-1.4.1-cp36-cp36m-win_amd64.whl", hash = "sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa"},
{file = "typed_ast-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614"},
{file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41"},
{file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b"},
{file = "typed_ast-1.4.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:f208eb7aff048f6bea9586e61af041ddf7f9ade7caed625742af423f6bae3298"},
{file = "typed_ast-1.4.1-cp37-cp37m-win32.whl", hash = "sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe"},
{file = "typed_ast-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355"},
{file = "typed_ast-1.4.1-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6"},
{file = "typed_ast-1.4.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907"},
{file = "typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d"},
{file = "typed_ast-1.4.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:7e4c9d7658aaa1fc80018593abdf8598bf91325af6af5cce4ce7c73bc45ea53d"},
{file = "typed_ast-1.4.1-cp38-cp38-win32.whl", hash = "sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c"},
{file = "typed_ast-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4"},
{file = "typed_ast-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34"},
{file = "typed_ast-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:92c325624e304ebf0e025d1224b77dd4e6393f18aab8d829b5b7e04afe9b7a2c"},
{file = "typed_ast-1.4.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:d648b8e3bf2fe648745c8ffcee3db3ff903d0817a01a12dd6a6ea7a8f4889072"},
{file = "typed_ast-1.4.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:fac11badff8313e23717f3dada86a15389d0708275bddf766cca67a84ead3e91"},
{file = "typed_ast-1.4.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:0d8110d78a5736e16e26213114a38ca35cb15b6515d535413b090bd50951556d"},
{file = "typed_ast-1.4.1-cp39-cp39-win32.whl", hash = "sha256:b52ccf7cfe4ce2a1064b18594381bccf4179c2ecf7f513134ec2f993dd4ab395"},
{file = "typed_ast-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:3742b32cf1c6ef124d57f95be609c473d7ec4c14d0090e5a5e05a15269fb4d0c"},
{file = "typed_ast-1.4.1.tar.gz", hash = "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b"},
]
typing-extensions = [
{file = "typing_extensions-3.7.4.3-py2-none-any.whl", hash = "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"},
{file = "typing_extensions-3.7.4.3-py3-none-any.whl", hash = "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918"},
{file = "typing_extensions-3.7.4.3.tar.gz", hash = "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c"},
]

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "pysuperconductor"
version = "0.1.0"
version = "0.1.1"
description = ""
authors = ["Deepak <dmallubhotla+github@gmail.com>"]
@@ -13,6 +13,7 @@ numpy = "1.19.3"
pytest = ">=6"
flake8 = "^3.8.4"
pytest-cov = "^2.10.1"
mypy = "^0.790"
[tool.pytest.ini_options]
junit_family = "xunit1"

View File

@@ -1,3 +1,8 @@
"""pysuperconductor
This package implements some superconductor calculations, to facilitate noise
calculations in proximity to superconductors.
"""
import logging
from pysuperconductor.meta import __version__

View File

@@ -1,32 +1,54 @@
import numpy
import scipy.integrate as integrate
import scipy.optimize
import numpy # type: ignore
import scipy.integrate as integrate # type: ignore
import scipy.optimize # type: ignore
import scipy.special # type: ignore
import logging
import warnings
from typing import Tuple
def energy(freq, delta):
def energy(freq: float, delta: float) -> float:
"""Takes in a "raw" quasiparticle energy and a gap, and returns the
quasiparticle's energy in the SC state."""
return numpy.sqrt(freq ** 2 + delta ** 2)
def gap_integrand_function(xi, temp, delta, mu_star):
def gap_integrand_function(
xi: float,
temp: float,
delta: float,
mu_star: float
) -> float:
big_e = energy(xi, delta)
if temp == 0:
return (1 / (2 * big_e)) * (2 * numpy.heaviside(big_e - mu_star, .5) - 1)
return numpy.tanh((big_e - mu_star) / (2 * temp)) / (2 * big_e)
def gap_integral(temp, delta, mu_star, debye_frequency):
def integrand(xi):
def gap_integral(
temp: float,
delta: float,
mu_star: float,
debye_frequency: float
) -> float:
def integrand(xi: float) -> float:
# the 2 here is to account for the symmetry in the integration range
# to cut the integral to zero to omega_debyeh
return 2 * gap_integrand_function(xi, temp, delta, mu_star)
return integrate.quad(integrand, 0, debye_frequency)[0]
def equilibrium_gap(temp, debye_frequency, nv):
def equilibrium_gap(temp: float, debye_frequency: float, nv: float) -> float:
return find_gap(temp, 0, debye_frequency, nv)
def find_gap(temp, mu_star, debye_frequency, nv):
def find_gap(
temp: float,
mu_star: float,
debye_frequency: float,
nv: float
) -> float:
nv_inv = 1 / nv
sol = scipy.optimize.root(
lambda d: gap_integral(temp, d, mu_star, debye_frequency) - nv_inv,
@@ -36,18 +58,44 @@ def find_gap(temp, mu_star, debye_frequency, nv):
# this is n * Delta_0, calling it n in this file for brevity
def n_integrand_function(xi, temp, delta, mu_star):
def n_integrand_function(
xi: float, temp: float, delta: float, mu_star: float
) -> float:
big_e = energy(xi, delta)
left = 1 / (1 + numpy.exp((big_e - mu_star) / temp))
right = 1 / (1 + numpy.exp(big_e / temp))
left = scipy.special.expit((mu_star - big_e) / temp)
right = scipy.special.expit(- big_e / temp)
return left - right
# as above, this is brevity n * Delta_0
def n_integral(temp, delta, mu_star):
def integrand(xi):
def n_integral(temp: float, delta: float, mu_star: float) -> float:
def integrand(xi: float) -> float:
return n_integrand_function(xi, temp, delta, mu_star)
intermediate = 20 * numpy.sqrt(delta ** 2 + mu_star ** 2)
lower = integrate.quad(integrand, 0, intermediate)[0]
upper = integrate.quad(integrand, intermediate, numpy.inf)[0]
return lower + upper
def find_gap_for_n(
temp: float,
n_bare: float,
debye_frequency: float,
nv: float
) -> Tuple[float, float]:
n = n_bare * find_gap(0, 0, debye_frequency, nv)
nv_inv = 1 / nv
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message="Creating an ndarray from ragged nested"
)
sol = scipy.optimize.root(
lambda x: [
gap_integral(temp, x[0], x[1], debye_frequency) - nv_inv,
n_integral(temp, x[0], x[1]) - n
],
x0=[debye_frequency / (numpy.sinh(nv_inv)), 0]
)
logging.debug(sol)
return sol.x

View File

@@ -0,0 +1,9 @@
def sc_free_energy(
delta: float,
temp: float,
mustar: float,
debye_freq: float,
n_0: float,
v_interaction_0: float
) -> float:
return 9999.35

View File

@@ -67,3 +67,15 @@ def test_n_integral():
verbose=True
)
assert not record
def test_find_n_gap():
actual = None
with pytest.warns(None) as record:
actual = pysuperconductor.os_gap_calc.find_gap_for_n(.3, .1, 100, .2)
numpy.testing.assert_almost_equal(
actual[0], 1.0296692197710933,
decimal=7, err_msg="did not find correct delta",
verbose=True
)
assert not record

View File

@@ -0,0 +1,22 @@
import pysuperconductor.sc_free_energy
import numpy
import pytest
def test_sc_free_energy():
with pytest.warns(None) as record:
actual = pysuperconductor.sc_free_energy.sc_free_energy(
0.907816, .5, .247777, 100, 1, .2)
assert not record
numpy.testing.assert_almost_equal(
actual, 9999.35,
decimal=7, err_msg='superconducting free energy was off', verbose=True
)
with pytest.warns(None) as record:
actual = pysuperconductor.sc_free_energy.sc_free_energy(
0.907816, .5, .247777, 50, 1, .2)
assert not record
# numpy.testing.assert_almost_equal(
# actual, 2498.910078644398,
# decimal=7, err_msg='superconducting free energy was off', verbose=True
# )