11#!/usr/bin/env python3
22# -*- coding: utf-8 -*-
33""":py:class:`lmfit.Model` model classes and functions for various superconductivity related models."""
4+
45# pylint: disable=invalid-name
56# This module can be used with Stoner v.0.9.0 asa standalone module
67__all__ = [
3940 float64 = _dummy ()
4041
4142
43+ @jit (float64 [:](float64 [:], float64 , float64 ), nopython = True , parallel = True , nogil = True )
44+ def _normalized_gaussian (x , mu = 0 , sigma = 1 ):
45+ """Normalised gaussian function."""
46+ return (1 / (sigma * np .sqrt (2 * np .pi ))) * np .exp (- ((x - mu ) ** 2 ) / (2 * sigma ** 2 ))
47+
48+
4249@jit (float64 [:](float64 [:], float64 , float64 , float64 , float64 ), nopython = True , parallel = True , nogil = True )
4350def _strijkers_core (V , omega , delta , P , Z ):
4451 """Implement strijkers Model for point-contact Andreev Reflection Spectroscopy.
@@ -62,8 +69,7 @@ def _strijkers_core(V, omega, delta, P, Z):
6269
6370 mv = np .max (np .abs (V )) # Limit for evaluating the integrals
6471 E = np .linspace (- 2 * mv , 2 * mv , V .size * 20 ) # Energy range in meV - we use a mesh 20x denser than data points
65- gauss = np .exp (- (E ** 2 / (2 * omega ** 2 )))
66- gauss /= gauss .sum () # Normalised gaussian for the convolution
72+ gauss = _normalized_gaussian (E , 0 , omega )
6773
6874 # Conductance calculation
6975 # For ease of calculation, epsilon = E/(sqrt(E^2 - delta^2))
@@ -74,12 +80,13 @@ def _strijkers_core(V, omega, delta, P, Z):
7480 # Ap is always zero as the polarised current has 0 prob for an Andreev
7581 # event
7682
77- Au1 = (delta ** 2 ) / ((E ** 2 ) + (((delta ** 2 ) - (E ** 2 )) * (1 + 2 * (Z ** 2 )) ** 2 ))
78- Au2 = (((np .abs (E ) / (np .sqrt ((E ** 2 ) - (delta ** 2 )))) ** 2 ) - 1 ) / (
79- ((np .abs (E ) / (np .sqrt ((E ** 2 ) - (delta ** 2 )))) + (1 + 2 * (Z ** 2 ))) ** 2
83+ Au = (
84+ (delta ** 2 ) / ((E ** 2 ) + (((delta ** 2 ) - (E ** 2 )) * (1 + 2 * (Z ** 2 )) ** 2 )),
85+ (((np .abs (E ) / (np .sqrt ((E ** 2 ) - (delta ** 2 )))) ** 2 ) - 1 )
86+ / (((np .abs (E ) / (np .sqrt ((E ** 2 ) - (delta ** 2 )))) + (1 + 2 * (Z ** 2 ))) ** 2 ),
8087 )
8188 Bu2 = (4 * (Z ** 2 ) * (1 + (Z ** 2 ))) / (((np .abs (E ) / (np .sqrt ((E ** 2 ) - (delta ** 2 )))) + (1 + 2 * (Z ** 2 ))) ** 2 )
82- Bp2 = Bu2 / (1 - Au2 )
89+ Bp2 = Bu2 / (1 - Au [ 1 ] )
8390
8491 unpolarised_prefactor = (1 - P ) * (1 + (Z ** 2 ))
8592 polarised_prefactor = 1 * (P ) * (1 + (Z ** 2 ))
@@ -89,21 +96,18 @@ def _strijkers_core(V, omega, delta, P, Z):
8996 + polarised_prefactor
9097 + + np .where (
9198 np .abs (E ) <= delta ,
92- unpolarised_prefactor * (2 * Au1 - 1 ) - np .ones_like (E ) * polarised_prefactor ,
93- unpolarised_prefactor * (Au2 - Bu2 ) - Bp2 * polarised_prefactor ,
99+ unpolarised_prefactor * (2 * Au [ 0 ] - 1 ) - np .ones_like (E ) * polarised_prefactor ,
100+ unpolarised_prefactor * (Au [ 1 ] - Bu2 ) - Bp2 * polarised_prefactor ,
94101 )
95102 )
96103
97104 # Convolve and chop out the central section
98- cond = np .convolve (G , gauss )
99- cond = cond [(E .size // 2 ) : 3 * (E .size // 2 )]
105+ cond = np .convolve (G , gauss )[(E .size // 2 ) : 3 * (E .size // 2 )]
100106 # Linear interpolation back onto the V data point
101107 matches = np .searchsorted (E , V )
102- condl = cond [matches - 1 ]
103- condh = cond [matches ]
104- El = E [matches - 1 ]
105- Er = E [matches ]
106- cond = (condh - condl ) / (Er - El ) * (V - El ) + condl
108+ cond = (cond [matches ] - cond [matches - 1 ]) / (E [matches ] - E [matches - 1 ]) * (V - E [matches - 1 ]) + cond [
109+ matches - 1
110+ ]
107111 return cond
108112
109113
@@ -314,7 +318,7 @@ def integrad(mu, m):
314318 def prefactor (m ):
315319 return delta ** 2 / (delta ** 2 + w_m (m ) ** 2 )
316320
317- def term (m ):
321+ def term (m ): # pylint: disable=unused-variable
318322 return prefactor (m ) * quad (integrad , - 1 , 1 , (m ,)) # pylint: disable=W0612
319323
320324
0 commit comments