# 2.1.2. qmix.mathfn package

## 2.1.2.1. Submodules

## 2.1.2.2. qmix.mathfn.filters module

This sub-module contains filters for cleaning experimental data.

qmix.mathfn.filters.gauss_conv(x, sigma=10, ext_x=3)

  Smooth data using a Gaussian convolution.

  Parameters:

    - x (ndarray) – noisy data

    - sigma (float) – std. dev. of Gaussian curve, given as number of data points

    - ext_x (float) – Gaussian curve will extend from ext_x * sigma in each direction

  Returns:

    filtered data

  Return type:

    ndarray

## 2.1.2.3. qmix.mathfn.ivcurve_models module

This sub-module contains DC I-V curve models.

These models range from simple (e.g., ‘perfect’ and ‘polynomial’) to complex (e.g., ‘exponential’ and ‘expanded’).

qmix.mathfn.ivcurve_models.expanded(voltage, vgap=0.0028, rn=14.0, rsg=500.0, agap=40000.0, a0=10000.0, ileak=5e-06, vnot=0.00285, inot=1e-05, anot=20000.0, ioff=1e-05)

  My “expanded” I-V curve model.

  This model is based on the exponential I-V curve model, but I have added the ability to include leakage current, the proximity effect, the onset of thermal tunnelling, and the reduced current amplitude often seen above the gap. It is able to recreate experimental data very well, but it is very complex.

  Parameters:

    - voltage (ndarray) – normalized bias voltage

    - vgap (float, optional) – gap voltage, in units [V], default is 2.8e-3

    - rn (float, optional) – normal resistance, in units [ohms], default is 14

    - rsg (float, optional) – sub-gap resistance, in units [ohms], default is 5e2

    - agap (float, optional) – gap linearity coefficient, default is 4e4

    - a0 (float, optional) – linearity coefficient at the origin, default is 1e4

    - ileak (float, optional) – amplitude of leakage current, default is 5e-6

    - vnot (float, optional) – notch location, in units [V], default is 2.85e-3

    - inot (float, optional) – notch current amplitude, in units [A], default is 1e-5

    - anot (float, optional) – linearity of notch, default is 2e4

    - ioff (float, optional) – current offset, default is 1e-5

  Returns:

    normalized current

  Return type:

    ndarray

qmix.mathfn.ivcurve_models.exponential(voltage, vgap=0.0028, rn=14.0, rsg=300.0, agap=40000.0, model='fixed')

  The exponential I-V curve model that is used in some papers from Chalmers.

  From Rashid et al. (2016) [see full references in online docs].

  Note

  - The equation from this paper will result in an I-V curve that has a subgap resistance that is half the value that it is supposed to be.

  - The normal resistance will also be slightly lower than it is supposed to be.

  - I fixed this model. This model can be selected by setting `model='fixed'`. The original model can be selected by setting `model='original'`.

  Parameters:

    - voltage (ndarray) – normalized bias voltage

    - vgap (float, optional) – gap voltage, in units [V], default is 2.8e-3

    - rn (float, optional) – normal resistance, in units [ohms], default is 14

    - rsg (float, optional) – sub-gap resistance, in units [ohms], default is 300

    - agap (float, optional) – gap linearity coefficient (typically around 4e4), default is 4e4

    - model (str, optional) – model to used (either ‘fixed’ or ‘original’), default is “fixed”

  Returns:

    normalized current

  Return type:

    ndarray

qmix.mathfn.ivcurve_models.perfect(voltage)

  Generate a perfect I-V curve.

  This is the ideal I-V curve. The current is equal to 0 when the normalized bias voltage is less than 1, equal to 0.5 when the normalized bias voltage is equal to 1, and equal to the normalized bias voltage otherwise.

  The current and voltage are normalized to Igap and Vgap, respectively, where Igap=Vgap/Rn is the gap current, Vgap is the gap voltage, and Rn is the normal resistance.

  Parameters:

    voltage (ndarray) – normalized bias voltage

  Returns:

    normalized current

  Return type:

    ndarray

qmix.mathfn.ivcurve_models.perfect_kk(voltage, max_kk=100.0)

  Generate Kramers-Kronig transform of the perfect I-V curve.

  This is an analytic solution.

  Parameters:

    - voltage (ndarray) – normalized bias voltage

    - max_kk (float, optional) – if output is NaN, use this max value instead, default is 100

  Returns:

    kk-transform of perfect i-v curve

  Return type:

    ndarray

qmix.mathfn.ivcurve_models.polynomial(voltage, order=50)

  Generate the polynomial I-V curve model.

  From Kennedy (1999) [see full references in online docs].

  Parameters:

    - voltage (ndarray) – normalized bias voltage

    - order (float) – order of polynomial (usually between 30 and 50)

  Returns:

    normalized current

  Return type:

    ndarray

## 2.1.2.4. qmix.mathfn.kktrans module

This sub-module contains functions to generate the Kramers-Kronig transform of DC I-V data.

Used to find the real component of the response function from the DC I-V curve.

qmix.mathfn.kktrans.kk_trans(v, i, n=50)

  Calculate the Kramers-Kronig transform from DC I-V data.

  Note

  Voltage spacing must be constant!

  Parameters:

    - v (ndarray) – normalized voltage (DC I-V curve)

    - i (ndarray) – normalized current (DC I-V curve)

    - n (int) – padding for Hilbert transform

  Returns:

    kk transform

  Return type:

    ndarray

qmix.mathfn.kktrans.kk_trans_trapz(v, i)

  Calculate the Kramers-Kronig transform using a simple trapezoidal summation.

  This function isn’t used anymore, but it is nice to use it to compare against qmix.mathfn.kktrans.kk_trans.

  Note

  Voltage spacing must be constant!

  This function is (much!) slower than the Hilbert transform version (i.e., qmix.mathfn.kktrans.kk_trans). It also has problems with how it is calculated around the singularity.

  Parameters:

    - v (ndarray) – normalized voltage (DC I-V curve)

    - i (ndarray) – normalized current (DC I-V curve)

  Returns:

    kk transform

  Return type:

    ndarray

## 2.1.2.5. qmix.mathfn.misc module

This sub-module contains various mathematical functions that do various things, variously.

qmix.mathfn.misc.slope(x, y)

  Take a simple derivative, dy/dx.

  The derivative is centered and it has the same number of points as the original x/y data.

  Parameters:

    - x (ndarray) – x data

    - y (ndarray) – y data

  Returns:

    derivative

  Return type:

    ndarray

qmix.mathfn.misc.slope_span_n(x, y, n=11, nozeros=True)

  Simple derivative, except the derivative is over a -N/2 to N/2 span.

  This helps with noisy data.

  This function also deletes zero values since the results of this function are usually used to divide other values (i.e., to avoid div. 0 errors).

  Parameters:

    - x (ndarray) – x data

    - y (ndarray) – y data

    - n (int, optional) – span, must be odd, default is 11

    - nozeros (bool, optional) – don’t allow der=0 results, default is True

  Returns:

    derivative

  Return type:

    ndarray

## 2.1.2.6. Module contents

This sub-package contains mathematical functions.

This includes numerical differentiation, I-V curve models, Kramers-Kronig transforms and various filters.