Validation

EIS data fundamentally relies on the conditions of linearity,

Measurement Model

Testing your data with the measurement model is straightforward:

import matplotlib.pyplot as plt
import numpy as np
import sys
sys.path.append('../')

from eisfit import validation  # noqa E402

data = np.genfromtxt('./data/exampleData.csv', delimiter=',')
f = data[:, 0]
Z = data[:, 1] + 1j*data[:, 2]

mask = np.imag(Z) < 0

model_list, error_list = validation.measurementModel(f, Z, max_k=25)

fig = plt.figure()
plt.plot(Z.real, -Z.imag, 'o')
for model in model_list:
    Z_fit = model.predict(f)
    plt.plot(Z_fit.real, -Z_fit.imag)

fig2, ax2 = plt.subplots()
ax2.plot(range(1, len(error_list)+1), error_list)
ax2.set_yscale('log')
ax2.set_ylabel('Root Mean Squared Error')
ax2.set_xlabel('Number of RC elements')

plt.show()
eisfit.validation.measurementModel(frequencies, impedances, algorithm='SLSQP', max_k=7, R_guess=0.1, C_guess=10)[source]

Runs a measurement model test for validating impedance data

Iteratively add RC circuit elements until the error converges. If error does not converge, it indicates that the data doesn’t meet standards for linearity.

Notes

\[RMSE = R_0 + \sum_{0}^{k} R_i || C_i\]
frequencies: np.ndarray
A list of frequencies to test
impedances: np.ndarray of complex numbers
A list of values to match to
max_k: int
The maximum number of RC elements to fit
initial_guess: np.ndarray
Initial guesses for R and C elements
eisfit.validation.rmse(a, b)[source]

A function which calculates the root mean squared error between two vectors.

Notes

\[RMSE = \sqrt{\frac{1}{n}(a-b)^2}\]