13 Commits

Author SHA1 Message Date
f3c1bdf292 Docs commit?
Some checks failed
gitea-physics/pysuperconductor/pipeline/head There was a failure building this commit
2021-01-04 16:05:38 -06:00
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
11 changed files with 224 additions and 11 deletions

6
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 {
@@ -53,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'
}
}
}
@@ -63,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'

20
docs/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

52
docs/conf.py Normal file
View File

@@ -0,0 +1,52 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'pysuperconductor'
copyright = '2021, Deepak Mallubhotla'
author = 'Deepak Mallubhotla'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

20
docs/index.rst Normal file
View File

@@ -0,0 +1,20 @@
.. pysuperconductor documentation master file, created by
sphinx-quickstart on Mon Jan 4 16:01:14 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pysuperconductor's documentation!
============================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

35
docs/make.bat Normal file
View File

@@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

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>"]

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,9 +1,16 @@
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: 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)
@@ -32,11 +39,16 @@ def gap_integral(
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,
@@ -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
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
# )