Skip to content

Circuit models

You write a circuit as a text string. The string gives the elements and their connections. It also sets the order of the parameters for the fit functions and the simulation functions.

Elements

Each element is one letter and one number, for example R1 or Q2. The number identifies one element among elements of the same type: R1 and R2 are two resistors. With the angular frequency \(\omega = 2\pi f\), the elements have these impedances:

Letter Element Parameters, in order Impedance Units
R Resistor \(R\) \(R\) \(\Omega\)
C Capacitor \(C\) \(1/(j\omega C)\) F
L Inductor \(L\) \(j\omega L\) H
Q Constant phase element (CPE) \(Q, n\) \(1/[Q(j\omega)^n]\) \(Q\): S s\(^n\), \(n\): none
W Warburg, semi-infinite \(\sigma\) \(\sigma(1-j)/\sqrt{\omega}\) \(\Omega\) s\(^{-1/2}\)
F Warburg, finite length \(F, \tau\) \(F\tanh(\sqrt{j\omega\tau})/\sqrt{j\omega\tau}\) \(F\): \(\Omega\), \(\tau\): s
G Gerischer \(G, \tau\) \(G/\sqrt{1+j\omega\tau}\) \(G\): \(\Omega\), \(\tau\): s
H Gerischer, finite length \(H, \tau, \phi\) \(H/[\sqrt{1+j\omega\tau}\tanh(\phi\sqrt{1+j\omega\tau})]\) \(H\): \(\Omega\), \(\tau\): s, \(\phi\): none

A CPE with \(n = 1\) is a capacitor with \(C = Q\). At low frequency the impedance of F approaches \(F\), that of G approaches \(G\), and that of H approaches \(H/\tanh\phi\).

Connections

Symbol Meaning Example
+ Series R1+C1
| Parallel R1|C1
( ) Group R1+(R2|Q1)

Parentheses make a group from a part of the circuit. A + or | in parentheses applies only to that group. Thus you can put one group in a different group:

Circuit string Meaning
(R1|Q1)+(R2|Q2)+Q3 Two arcs in series (for example bulk and grain boundary), followed by a CPE for the electrode
(R1|Q1|C1)+Q2 Three elements in parallel, followed by a CPE
R0+(Q1|(R1+W1)) Randles circuit: R1 and W1 in series, this branch parallel to Q1, and R0 in series with the whole

Write the string without spaces. Parentheses that do not close and unknown letters cause a ValueError.

Parameter order

Give the parameters in the order of the circuit string, from left to right. An element with two or three parameters uses the next two or three values.

import numpy as np
from EISFitpython import circuit_main as circuits

circuit = "R1+(R2|Q1)+F1"
params = [
    5.0,       # R1
    20.0,      # R2
    1.0e-6,    # Q1: coefficient Q
    0.90,      # Q1: exponent n
    100.0,     # F1: resistance F
    0.01,      # F1: time constant tau
]

f = np.array([1.0, 10.0, 100.0])
Z = circuits.compute_impedance(params, circuit, f)

Pass the frequencies as a NumPy array, in hertz.

For "(R1|Q1)+(R2|Q2)+Q3" the order is:

R1, Q1, n1, R2, Q2, n2, Q3, n3

Functions for simulation and for fitting

compute_impedance returns one complex impedance value for each frequency. The optimizer of SciPy uses only real numbers. For a fit, the model function thus puts the real parts and then the imaginary parts into one vector:

[real(Z[0]), ..., real(Z[N-1]), imag(Z[0]), ..., imag(Z[N-1])]

Two functions create a model function model(f, *params) for a circuit:

  • Z_curve_fit(circuit) returns the real vector above.
  • Z_gen(circuit, return_type) returns the real vector with return_type="concatenated" and the complex impedance with return_type="complex".
f = np.logspace(6, -1, 50)
model = circuits.Z_gen("R1+(R2|Q1)", return_type="complex")
Z = model(f, 5.0, 20.0, 1e-6, 0.9)

You need these functions only if you call the optimizer directly. The fit functions of the package create the model function automatically.