EISFitpython.circuit_main¶
This module calculates the impedance of a circuit. It also creates model
functions for scipy.optimize.curve_fit.
For the circuit syntax, the element equations and the parameter order, see Circuit models.
compute_impedance¶
Calculates the impedance of a circuit at the given frequencies.
| Parameter | Type | Description |
|---|---|---|
p |
sequence of float | Element parameters in the order of the circuit string. |
circuit_str |
str |
Circuit string, for example "R1+(R2|Q1)". |
freqs |
NumPy array | Frequencies in hertz. The values must be positive. |
Returns a complex NumPy array with one value for each frequency. An incorrect
circuit string causes a ValueError.
import numpy as np
Z = circuits.compute_impedance(
[5.0, 20.0, 1e-6, 0.9],
"R1+(R2|Q1)",
np.array([1.0, 10.0, 100.0]),
)
Z_curve_fit¶
Creates a model function model(f, *params) for a fit with SciPy. The model
function calculates the impedance of the circuit. It returns a real vector with
2 * len(f) values: first all real parts, then all imaginary parts.
| Parameter | Type | Description |
|---|---|---|
circuit_str |
str |
Circuit string for the model function. |
Z_gen¶
Creates a model function model(f, *params) for a fit or for a simulation.
| Parameter | Type | Default | Description |
|---|---|---|---|
circuit_string |
str |
necessary | Circuit string for the model function. |
return_type |
str |
"concatenated" |
"concatenated": real vector for a fit. "complex": complex impedance. |
A different value of return_type causes a ValueError.