Utilitites

impedancefitter.utils.available_file_format()[source]

List available file formats.

Currently available:

XLSX and CSV:

The file is structured like: frequency, real part of impedance, imaginary part of impedance. There may be many different sets of impedance data, i.e. there may be more columns with the real and the imaginary part. Then, the frequencies column must not be repeated. In fact, the number of columns equals the number of impedance data sets plus one (for the frequency).

Note

A single header line is needed in a CSV and XLSX file. It may contain for example frequency, Real Part, Imag Part. Otherwise the read-in function will fail.

CSV_E4980AL:

Read in data that is structured in 5 columns: frequency, real part, imaginary part of the impedance, voltage, current

Note

There is always only one data set in a file.

TXT:

These files contain frequency, real and imaginary part of the impedance (i.e., 3 columns). The TXT files may contain two traces; only one of them is read in. For TXT files you can specify the number of rows to skip. Moreover, the file ending is not strictly enforced here.

impedancefitter.utils.available_models()[source]

return list of available models

impedancefitter.utils.check_parameters(bufdict)[source]

Check parameters for physical correctness.

Parameters

bufdict (dict) – Contains all parameters and their values

impedancefitter.utils.draw_scheme(modelname, show=True, save=False)[source]

Show (and save) SchemDraw drawing.

Parameters
  • modelname (str) – String representation of the equivalent circuit.

  • show (bool, optional) – Show scheme in matplotlib window.

  • save (bool, optional) – Save scheme to file. File is called scheme.svg.

impedancefitter.utils.get_equivalent_circuit_model(modelname, logscale=False)[source]

Get LMFIT CompositeModel.

Parameters
  • modelname (str) – String representation of the equivalent circuit.

  • logscale (bool) – Convert to logscale.

Returns

the final model of the entire circuit

Return type

lmfit.model.CompositeModel or lmfit.model.Model

Notes

The parser is based on Pyparsing. It is sensitive towards extra ( or ) or +. Thus, keep the circuit simple.

impedancefitter.utils.get_labels(params)[source]

return the labels for every parameter in LaTex code.

Parameters

params (list of string) – list with parameters names (possible prefixes included)

Returns

labels – dictionary with parameter names as keys and LaTex code as values.

Return type

dict

impedancefitter.utils.return_diel_properties(omega, Z, c0)[source]

Return relative permittivity and conductivity from impedance spectrum in cavity with known unit capacitance.

Notes

Use that the impedance is

\[Z = (j \omega \varepsilon^\ast c_0)^{-1} ,\]

where \(\varepsilon^\ast\) is the complex permittivity (see for instance [Grant1958] for further explanation).

When the unit capacitance \(c_0\) of the device is known, a direct mapping from impedance to relative complex permittivity is possible:

\[\varepsilon_\mathrm{r}^\ast = (j \omega Z c_0)^{-1} = \frac{\varepsilon^\ast}{\varepsilon_0}\]

The unit capacitance (or air capacitance) of the device is defined as

\[c_0 = \frac{\varepsilon_0 A}{d}\]

for a parallel-plate capacitor with electrode area A and spacing d but can also be measured in a calibration step.

The relative permittivity is the real part of \(\varepsilon_\mathrm{r}^\ast\) and the conductivity is the negative imaginary part times the frequency and the vacuum permittivity.

Parameters
  • omega (numpy.ndarray, double) – frequency array

  • Z (numpy.ndarray, complex) – impedance array

  • c0 (double) – unit capacitance of device

Returns

References

Grant1958

Grant, F. A. (1958). Use of complex conductivity in the representation of dielectric phenomena. Journal of Applied Physics, 29(1), 76–80. https://doi.org/10.1063/1.1722949

impedancefitter.utils.set_parameters(model, parameterdict=None, emcee=False)[source]
Parameters
  • model (lmfit.model.Model) – The LMFIT model used for fitting.

  • parameterdict (dict, optional) – A dictionary containing parameters for model with min, max, vary info for LMFIT. If it is None (default), the parameters are read in from a yaml-file.

  • emcee (bool, optional) – if emcee is used, an additional __lnsigma parameter will be set

Returns

params – LMFIT Parameters object.

Return type

lmfit.parameter.Parameters