Python GUI for impedance spectroscopy analysis

A graphical user interface (GUI) for a widely used instrument, namely the Keysight 4294A impedance analyzer, was developed in Python language. This GUI allows control of instrument, acquisition and processing of impedance spectra from dielectric materials and electric circuits. Examples of analysis of electric circuits and porous alumina are provided to illustrate some of the possible applications.


I. INTRODUCTION
Impedance spectroscopy (IS) is an experimental technique applicable to a broad range of investigations on the dielectric response of materials or, more generally, on the electric behavior of the system under analysis [1]. In this technique, the system under study (for instance, a sample of a dielectric material or an electric circuit) is subject to a time-varying electric potential, and the resulting current magnitude and phase are measured, yielding the system's impedance (both magnitude and phase). This process is then repeated sweeping the electric potential oscillation frequency, thus allowing determining the system's impedance phase and magnitude as a function of frequency.
Nowadays this technique is usually employed using impedance analyzers capable of sweep frequencies over several orders of magnitude within seconds. This way, both slow and fast system's response can be observed by looking at the low and high frequency ends of the impedance spectrum, respectively. Though impedance spectroscopy is a relatively easy, fast and powerful technique, the interpretation of the results is seldom straightforward. In fact, the interpretation of the impedance spectrum of a dielectric material rely on the proposal of an equivalent circuit, the number and nature of its elements varying according to the particular experimental conditions, and sample's composition and microstructure. Besides that, equipment control, and acquisition and manipulation of IS data often require programming skills, which creates an additional barrier to the widespread use of IS by the scientific community. Accordingly, in this work we present a Graphic User Interface (GUI) created with the Python programming language and designed for IS analysis with a Keysight 4294A precision impedance analyzer [2]. This GUI was developed having in mind studies in material sciences, but it can be easily adapted to the most diverse applications and used is different operational systems once its dependencies are installed. The frequency response of simple LRC circuits and, also, the dielectric permittivity of porous alumina samples, were measured using the GUI described in this work to illustrate some possible applications.

A. Theoretical Background
In materials science, IS is mainly used to measure the dielectric permittivity, which is dependent on the polarizability of the charged species in the sample [1]. In fact, the response of a material (in terms of electric current magnitude and phase) to an applied oscillating electric potential, can provide significant information on charge mobility and, thus, for instance, on the microscopic mechanisms responsible for ionic conduction or dielectric relaxation. Furthermore, the electric charges present in a material have their mobility affected by most structural transitions and kinetic processes. Therefore, changes in dielectric permittivity may be used to detect phase transitions and to track the progress of kinetic processes such as, for instance, the cure of thermosetting resins. Take, for instance, the glass transition in amorphous materials. If an amorphous or semi-crystalline solid material is cooled below its so-called glass transition temperature, the atomic mobility is reduced, with a measurable effect on the dielectric permittivity of the sample. The dielectric permittivity is also dependent on the frequency of the applied electric field. In fact, upon increasing the electric field oscillation frequency, the finite velocities characteristic of different polarization processes limit the response of a dielectric material to the applied electric potential. Dielectric relaxation, as this phenomenon is called, is thus frequency-dependent, and changes in the structure/microstructure of a sample can be easily followed up by closely monitoring, for instance, the effect of thermodynamic fields (e.g., temperature and/or pressure) on its impedance spectrum [3].
In IS analysis, the system being investigated is subjected to an oscillatory electric potential and the resulting current (both magnitude and phase) across the system is measured. The ratio between the amplitudes of the applied electric potential and the resulting electric current thus the magnitude of the impedance |Z| of the system, while the lag between the peaks of electric current and the applied potential gives the impedance phase, φ. These quantities are absent of any previous assumption about the system and are valid for any case. When analyzing a solid dielectric material, the sample usually consists of a dielectric slab between the plates of a parallel plate capacitor. A equivalent circuit is then assigned to the system and the corresponding mathematical model thus allows other quantities to be calculated. For solid samples in such arrangement, very frequently inductive effects are negligible and the system can be modeled by an electric circuit consisting of a capacitor and a resistor in parallel. For this commonly occurring circuit, the impedance Z of the sample is given by where Z R is the impedance of the resistor, which is equal to its electric resistance R, and Z C is the impedance of the capacitor, given by (jωC) −1 , where j is the imaginary unit, ω = 2πf is the angular frequency, and C is the capacitance [4, p. 46]. For a parallel plate capacitor, the capacitance is given by where is the absolute electric permittivity of the dielectric material, r is the sample's relative dielectric permittivity, 0 is the electric constant ( 0 = 8.854 187 817 × 10 −12 F m −1 [5]), A is the area of the capacitor plates, and d is the distance between the plates of the capacitor. From the above expressions, the real (Z ) and imaginary (Z ) parts of the complex impedance (1) are given by Likewise, the real ( ) and imaginary ( ) parts of the sample's complex dielectric permittivity (for a sample modeled after an equivalent parallel RC circuit) can be written in terms of the measured quantities |Z| and φ as In more complex situations, care should be taken in proposing an equivalent circuit to model the observed behavior [6], [7]. While the data of impedance and phase can be used to derive other physical quantities for any equivalent circuit, capacitance, resistance and permittivity given by the IS GUI here described should only be used on the assumption that the parallel RC equivalent circuit is valid.
It is common practice to represent electric impedance data by means of a Cole-Cole plot, in which the imaginary part of the electric impedance is plotted against the real component. For a RC parallel circuit, a semi-circle centered at R / 2 on the Re[Z] axis is expected, as depicted schematically in Fig. 1. For series association of two (or more) RC parallel circuits, two (or more) semi-circles are expected in a Cole-Cole plot.

II. SOFTWARE A. Description and Structure
The software scripts are written in standard Python programming language. The entire program is contained in two python files that must be on the same folder. It was chosen to break the script in two files in order to make software modification easier. The two files, namely script.py and interface.py, are responsible for the routines and the graphical interface, respectively. The former implements the classes and methods, which means that they can be imported Fig. 1: Schematic Cole-Cole plot for a parallel RC circuit. and used independently in other python scripts in a modular fashion. The interface file contains all the visual objects used to present the graphical user interface, which uses instances of QtCore and QtGui from the PyQt4 python package [8] to construct the visual objects on screen. When ran using Python, the script file imports the python interface from the interface.py file and binds the buttons from the interface to methods in the script. Therefore, if some modification in the software is desired, it should be made in both files.
Modifications on the interface can be done directly on the .py file, though using Qt Designer [9] is recomended. The interface was constructed to a .ui file, which is bundled with the software files, and later converted to a .py file for the bindings with the routines. The conversion can be easily done using the pyuic4 command, included with the PyQt4 package.
The modification of the script file is straightforward as is classical python language. The development of the script was made and tested in a Jupyter notebook [10], [11] and later copied to a python file. The routines for the equipment control uses the PyVisa package [12] to send HP Instrument BASIC commands to the equipment drive that is required to be installed on the computer, which in turn send the signals through a GPIB interface cable to the Keysight 4294A impedance analyzer. A summary of the software structure is presented in figure 2.

B. Functionalities
The graphical user interface called ImpedSpec was developed aiming to communicate with, control, collect, and process data from a Keysight 4294A precision impedance analyzer. Before an actual measurement is performed, the interface allows to set the compensation conditions, which later will be taken into account to correct for the instrument contribution to the overall electric impedance in a process handled by the equipment. Two types of compensations can be done, open and short compensation. The open compensation is done by measuring the response of the open circuit, without any sample. The short compensation is done by measuring the closed circuit, also without any sample. These two measurements are later on used to correct for the instrument contribution to the measured resistance and capacitance of the sample.
The interface allows several parameters be defined by the user. The frequency sweep can be configured for up to 600 points linearly or logarithmically distributed between arbitrary start and end frequencies, which are limited only by the range allowed by the impedance analyzer, namely from 40 Hz to 110 MHz, in the case of the Keysight 4294A. It is also possible to define a bandwidth factor from 1 to 5, the maximum amplitude of the electric potential applied to the sample (up to ± 42 V) and also to set up to 256 measurements per point, in which case the arithmetic mean is returned. A screenshot of the ImpedSpec screen after an actual measurement is shown in Fig. 3. Besides the measuring conditions, the user can inform the thickness and diameter of the sample for the calculation of the real and imaginary parts of the sample's electric permittivity. The impedance magnitude and phase, which are independent of the sample dimensions, can also be exhibited and saved to file. The interface assumes the sample is in the form of a thin disc, which allows a more uniform surface charge density on the electrodes. If this is not the case, an equivalent diameter can be informed, i.e., a diameter that results in a circular area equal to that of the actual sample. Besides the impedance magnitude and phase, Cole-Cole and resistance versus capacitance plots can be represented without any information regarding sample's physical dimensions.

C. Sample preparation
The sample's impedance (both magnitude and phase) can be measured without any input regarding the physical dimensions (cross-section area and thickness) of the sample. The electric permittivity, on the other hand, is calculated from impedance magnitude and phase, by assuming an equivalent circuit and by knowing the sample's cross-section area and thickness. The current version of the software always assumes a RC equivalent circuit and a sample as a dielectric in a parallel plate capacitor. Accordingly, for the experimental determination of the electric permittivity, the sample to be analyzed can be conveniently placed between two parallel metallic plates or electrodes as to form a parallel plate capacitor. The area of the electrodes and the distance between them are then used in the computation of the real and imaginary components of the dielectric permittivity (for instance, according to eqs. (5) and (6) above).

III. ILLUSTRATIVE EXAMPLES
To illustrate the use of ImpedSpec, the software was used in the analysis of simple RLC circuits. As an application in materials science, the software was used to analyze the behavior of the dielectric constant for alumina with different porosities.

A. Electric impedance of simple circuits
For testing purposes, commercially available capacitors, resistors, and inductors were arranged in different electric circuits, which were then measured with a Keysight 4294A precision impedance analyzer, using ImpedSpec. The results, expressed in the form of Cole-Cole plots, are summarized in Fig. 4. The Cole-Cole plot for a RC parallel circuit, Fig.  4(a), is a semicircle of radius R/2. Inductors shift the current phase oppositely to capacitors and, therefore, the imaginary component of the impedance of LRC circuits exhibits both positive and negative branches, as seen in figure 4(b). Figure  4(c) shows the two arcs expected for two RC parallel circuits in series. Finally, Fig. 4(d) shows the Cole-Cole plot for a RC parallel circuit in series with a capacitor.

B. Dielectric permittivity of porous alumina
To exemplify the application of the ImpedSpec to the measurement of electric properties of materials, the dielectric permittivity of porous alumina samples (α-Al 2 O 3 , A-1000SG, 99.8% purity -Almatis Inc. Leetsdale, PA) was measured as a function of frequency. Silver ink electrodes were painted on the flat surfaces of each sample and thin copper wires were attached to connect the samples to the impedance analyzer. A schematic representation of the experimental assembly is shown in Fig. 5.
The real part of the relative dielectric permittivity ( r ) of three porous alumina samples (5%, 15%, and 35% porosity) is presented in Fig. 6, for frequencies (f = ω/2π) in the range from 40 Hz to 10 8 Hz as calculated by the program, as calculated assuming a parallel RC equivalent circuit. For the 5% porosity alumina sample, the measured real part of the relative dielectric permittivity, around 10.5, is almost frequency-independent, and is in very good agreement with the literature (see, for instance, Ref. [13, p. 83]). As the porosity increases, the high-frequency real part of the relative dielectric permittivity decreases, as expected [14], [15]. The dielectric permittivity, however, does not exhibit a well defined trend with porosity at the low frequency end of the spectrum, increasing from the 5% porosity sample to that of 35% and, finally, 15% porosity. This is most probably due to different moisture content in the 15% and 35% porosity samples, as it is known that water molecules chemically or physically bound to the pore's inner surface has a great effect on the apparent dielectric permittivity, particularly at low frequencies, due to polarization of the water-ceramic interface [16].

IV. IMPACT
ImpedSpec focuses in scientists that struggle in maintaining a steady workflow due to the lack of a readily available and easy to use graphical user interface in impedance spectroscopy. This group is larger than one might expect due to some events in the scientific instruments industry. The 4294A, produced by Agilent, is a reference equipment and is still very popular among users of impedance analyzers. This instrument was discontinued when Keysight Technologies bought Agilent and was replaced by the E4990A. The newer equipment use a different programming language, making all the new software for control and data acquisition incompatible with the 4294A. This left a gap in the software development for the Agilent equipment, which has no user interface available so far. Our work is concerned with helping all the numerous scientists left with a discontinued equipment that lacks a user-friendly interface. The same programming language (HP Instrument BASIC) is common to other impedance analyzers produced by Agilent in the same period. By changing the code substituting the HP Instrument BASIC commands by other equipment communication language, our interface can be readily modified to be used with other impedance analyzers besides the 4294A. Having the collected data readily available in the computer right after an analysis is not just very convenient, but also a requirement for maintaining a good workflow in the scientific progress.

V. CONCLUSION
The graphical user interface ImpedSpec allows the control of experiments and data acquisition for impedance spectroscopy analysis of electric circuits and dielectric materials. Notwithstanding that this GUI has been explicitly developed having in mind a Keysight 4294A impedance analyzer, ImpedSpec can be adapted for use with other IS instruments by any user with basic programming skills, given that the scripts are open source and thus can be readily modified according to specific needs. The software files are available on github.com/giovanirech/impedspec