Skip to content

Batch and Arrhenius analysis

A batch fit applies one circuit to a list of files, one spectrum after the other. From the fitted parameters, the package calculates conductivities, activation energies and effective capacitances.

The examples on this page use the seven spectra in EIS_Data/Example-3-4. The temperatures are 140 °C to 200 °C. Run the examples from the repository root.

Fit the spectra in sequence

import numpy as np
from EISFitpython import data_extraction as data
from EISFitpython import EIS_Batchfit as batch

files = data.get_eis_files("EIS_Data", "Example-3-4")
temperature_c = np.array([140, 150, 160, 170, 180, 190, 200])

circuit = "(R1|Q1)+(R2|Q2)+Q3"
initial = [1.8e6, 1.3e-11, 0.9, 8.2e6, 1.3e-9, 0.9, 5.7e-7, 0.6]
UB, LB = [], []
weight_mtd, method = "M", "lm"

fit_params, fit_errors = batch.Batch_fit(
    files, initial, circuit, temperature_c, UB, LB, weight_mtd, method
)

fit_params and fit_errors have one row for each file and one column for each circuit parameter. For this circuit, column 0 is R1, column 1 is Q1 and column 2 is n1.

Obey these three rules:

  • Give one temperature for each file, in degrees Celsius.
  • Put the files in the order of the temperature. The fitted parameters of one file are the start values for the next file. Thus the order of the files can change the result.
  • To limit the frequency range, set min_value and max_value. You must set the two values together.

With return_cov=True, Batch_fit returns a third array. This array contains the covariance matrix of each fit.

Plot all spectra in one figure

ax = batch.Nyq_stack_plot(files, temperature_c)

Nyq_stack_plot draws all spectra in one Nyquist plot with one common impedance unit. It writes Nyq_stackplot.svg. Give the temperatures in degrees Celsius. The legend shows them in kelvin.

Conductivity and activation energy

Get the resistances from the fit result and give them to plot_arrhenius:

R_bulk, R_bulk_err = fit_params[:, 0], fit_errors[:, 0]
R_gb, R_gb_err = fit_params[:, 3], fit_errors[:, 3]

conductivity, conductivity_error = batch.plot_arrhenius(
    R_values=[R_bulk, R_gb],
    R_err=[R_bulk_err, R_gb_err],
    temp=temperature_c,
    diameter=0.8,
    thickness=0.21,
    labels=["Bulk", "Grain boundary"],
)

diameter and thickness are the dimensions of the pellet in centimeters. The function calculates the conductivity in S/cm from the resistance \(R\), the thickness \(l\) and the electrode area \(A\):

\[ \sigma = \frac{1}{R}\frac{l}{A},\qquad A = \pi\left(\frac{d}{2}\right)^2. \]

The function adds 273.15 to each temperature to get kelvin. Then it fits a straight line to \(\ln(\sigma T)\) as a function of \(1000/T\).

For each component, the report gives:

  • the activation energy and its standard error,
  • the pre-exponential factor and its standard error,
  • the conductivity at room temperature (298.15 K) and its standard error,
  • a table of the conductivity at each temperature.

The error of each conductivity value has two parts. The first part is the error of the resistance. The second part is a fixed error of the geometry: 0.001 cm for the thickness and 0.01 cm² for the area.

Effective capacitance

A constant phase element has no capacitance in farads. For a resistor in parallel with a CPE, C_eff calculates an effective capacitance from the three fitted parameters:

\[ C_\mathrm{eff} = \left(QR^{1-n}\right)^{1/n}. \]

The value identifies the source of an arc. A bulk response is typically in the picofarad range. A grain-boundary response has a larger capacitance.

The error of the capacitance

The fit gives a strong correlation between \(R\), \(Q\) and \(n\) of one arc. If the fit gives a larger \(Q\), it gives a smaller \(n\). The two changes cancel in the capacitance. Thus the error of the capacitance depends on the method that you use for this correlation.

Select one of three methods with the argument error:

error Method Necessary input
"bootstrap" The package fits many synthetic spectra and calculates the capacitance for each fit. The error is the standard deviation of these values boot: the results of Batch_bootstrap
"covariance" Error propagation with the covariance matrix of the fit cov: the covariance matrices from Batch_fit(..., return_cov=True)
"standard" Error propagation with the standard errors only. This method assumes independent parameters None

The bootstrap method and the covariance method give almost equal results. The standard method ignores the correlation and gives a much larger error for a fitted CPE. For the bulk arc at 200 °C in this example, the three methods give 4.6 %, 3.7 % and 101 %.

boot = batch.Batch_bootstrap(
    files, fit_params, circuit, UB, LB, weight_mtd, method, n_boot=1000, seed=0
)

capacitance_results = batch.C_eff(
    R_arrays=[R_bulk, R_gb],
    R_err_arrays=[R_bulk_err, R_gb_err],
    Q_arrays=[fit_params[:, 1], fit_params[:, 4]],
    Q_err_arrays=[fit_errors[:, 1], fit_errors[:, 4]],
    n_arrays=[fit_params[:, 2], fit_params[:, 5]],
    n_err_arrays=[fit_errors[:, 2], fit_errors[:, 5]],
    T=temperature_c,
    labels=["Bulk", "Grain boundary"],
    error="bootstrap",
    boot=[
        (boot[:, :, 0], boot[:, :, 1], boot[:, :, 2]),   # bulk: R1, Q1, n1
        (boot[:, :, 3], boot[:, :, 4], boot[:, :, 5]),   # grain boundary: R2, Q2, n2
    ],
)

Give Batch_bootstrap the same circuit, bounds, weighting and method as Batch_fit. With 1000 fits for each spectrum, the bootstrap takes approximately 30 seconds for this example. The same seed always gives the same result.

C_eff returns one pair (C, C_err) for each component. It writes Effective_Capacitance_Values.txt. With the bootstrap method, the report also gives the range that contains 95 % of the fits.

Example_scripts/Example3 contains this analysis as a complete script. One variable in the script selects the method.