Compare commits
12 Commits
7744f040f6
...
free_energ
| Author | SHA1 | Date | |
|---|---|---|---|
|
a86bcac604
|
|||
|
7843e462de
|
|||
|
0715e1858a
|
|||
|
0ff6118211
|
|||
| 7a5658c8ea | |||
| 33b58a2afb | |||
| 458eff1905 | |||
| bba1643c76 | |||
| 54917655cd | |||
|
3cda66441e
|
|||
|
346caf3ea0
|
|||
|
5bb3a2163f
|
6
Jenkinsfile
vendored
6
Jenkinsfile
vendored
@@ -15,7 +15,7 @@ pipeline {
|
|||||||
environment {
|
environment {
|
||||||
POETRY_HOME="/opt/poetry"
|
POETRY_HOME="/opt/poetry"
|
||||||
POETRY_VERSION="1.1.4"
|
POETRY_VERSION="1.1.4"
|
||||||
//PYPI=credentials("DOES_NOT_EXIST")
|
PYPI=credentials("pypi-pysuperconductor")
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@@ -53,7 +53,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
echo 'Deploying...'
|
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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ pipeline {
|
|||||||
junit 'pytest.xml'
|
junit 'pytest.xml'
|
||||||
cobertura coberturaReportFile: 'coverage.xml'
|
cobertura coberturaReportFile: 'coverage.xml'
|
||||||
mail (bcc: '',
|
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 {
|
success {
|
||||||
echo 'This will run only if successful'
|
echo 'This will run only if successful'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pysuperconductor"
|
name = "pysuperconductor"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Deepak <dmallubhotla+github@gmail.com>"]
|
authors = ["Deepak <dmallubhotla+github@gmail.com>"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
"""pysuperconductor
|
||||||
|
|
||||||
|
This package implements some superconductor calculations, to facilitate noise
|
||||||
|
calculations in proximity to superconductors.
|
||||||
|
"""
|
||||||
import logging
|
import logging
|
||||||
from pysuperconductor.meta import __version__
|
from pysuperconductor.meta import __version__
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
import numpy # type: ignore
|
import numpy # type: ignore
|
||||||
import scipy.integrate as integrate # type: ignore
|
import scipy.integrate as integrate # type: ignore
|
||||||
import scipy.optimize # type: ignore
|
import scipy.optimize # type: ignore
|
||||||
|
import scipy.special # type: ignore
|
||||||
|
import logging
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
|
|
||||||
def energy(freq: float, delta: float) -> float:
|
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)
|
return numpy.sqrt(freq ** 2 + delta ** 2)
|
||||||
|
|
||||||
|
|
||||||
@@ -32,11 +39,16 @@ def gap_integral(
|
|||||||
return integrate.quad(integrand, 0, debye_frequency)[0]
|
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)
|
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
|
nv_inv = 1 / nv
|
||||||
sol = scipy.optimize.root(
|
sol = scipy.optimize.root(
|
||||||
lambda d: gap_integral(temp, d, mu_star, debye_frequency) - nv_inv,
|
lambda d: gap_integral(temp, d, mu_star, debye_frequency) - nv_inv,
|
||||||
@@ -46,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
|
# 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)
|
big_e = energy(xi, delta)
|
||||||
left = 1 / (1 + numpy.exp((big_e - mu_star) / temp))
|
left = scipy.special.expit((mu_star - big_e) / temp)
|
||||||
right = 1 / (1 + numpy.exp(big_e / temp))
|
right = scipy.special.expit(- big_e / temp)
|
||||||
return left - right
|
return left - right
|
||||||
|
|
||||||
|
|
||||||
# as above, this is brevity n * Delta_0
|
# as above, this is brevity n * Delta_0
|
||||||
def n_integral(temp, delta, mu_star):
|
def n_integral(temp: float, delta: float, mu_star: float) -> float:
|
||||||
def integrand(xi):
|
def integrand(xi: float) -> float:
|
||||||
return n_integrand_function(xi, temp, delta, mu_star)
|
return n_integrand_function(xi, temp, delta, mu_star)
|
||||||
intermediate = 20 * numpy.sqrt(delta ** 2 + mu_star ** 2)
|
intermediate = 20 * numpy.sqrt(delta ** 2 + mu_star ** 2)
|
||||||
lower = integrate.quad(integrand, 0, intermediate)[0]
|
lower = integrate.quad(integrand, 0, intermediate)[0]
|
||||||
upper = integrate.quad(integrand, intermediate, numpy.inf)[0]
|
upper = integrate.quad(integrand, intermediate, numpy.inf)[0]
|
||||||
return lower + upper
|
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
|
||||||
|
|||||||
9
pysuperconductor/sc_free_energy.py
Normal file
9
pysuperconductor/sc_free_energy.py
Normal 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
|
||||||
@@ -67,3 +67,15 @@ def test_n_integral():
|
|||||||
verbose=True
|
verbose=True
|
||||||
)
|
)
|
||||||
assert not record
|
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
|
||||||
|
|||||||
22
tests/test_sc_free_energy.py
Normal file
22
tests/test_sc_free_energy.py
Normal 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
|
||||||
|
# )
|
||||||
Reference in New Issue
Block a user