Electrochemistry¶
The main TechniqueMeasurement class for electrochemistry is the ECMeasurement.
Sublcasses of ECMeasurement include CyclicVoltammagram and CyclicVoltammagramDiff.
Direct-current electrochemsitry measurements (ixdat does not yet offer specific
functionality for impedance data) are characterized by the essential quantities being
working-electrode current (in loop with the counter electrode) and potential (vs the
reference electrode) as a function of time. Either current or potential can be controlled
as the input variable, so the other acts at the response, and it is common to plot
current vs potential, but in all cases both are tracked or controlled as a function of
time. This results in the essential variables t (time), v (potential), and j
(current). The main job of ECMeasurement and subclasses is to give standardized,
convenient, and powerful access to these three variables for data selection, analysis,
and visualization, regardless of which hardware the data was acquired with.
The default plotter, ECPlotter, plots these variables.
The default exporter, ECExporter, exports these variables as well as an incrementer for
selecting data, cycle.
Electrochemistry is the most thoroughly developed technique in ixdat. For in-depth
examples of the functionality in the ECMeasurement class and its subclasses, see
the following Tutorials:
The ec module¶
Source: https://github.com/ixdat/ixdat/tree/user_ready/src/ixdat/techniques/ec.py
left: ECMeasurement.plot_vs_potential() right: ECMeasurement.plot_measurement(). See tutorial
Module for representation and analysis of EC measurements
-
class
ixdat.techniques.ec.ECCalibration(RE_vs_RHE=None, A_el=None)[source]¶ A small container for RHE_vs_RE and A_el
-
class
ixdat.techniques.ec.ECMeasurement(name, *, technique=None, metadata=None, s_ids=None, series_list=None, m_ids=None, component_measurements=None, reader=None, plotter=None, exporter=None, sample=None, lablog=None, tstamp=None, ec_technique=None, t_str='time / [s]', E_str='raw potential / [V]', V_str='$U_{RHE}$ / [V]', RE_vs_RHE=None, R_Ohm=None, raw_potential_names=('Ewe/V', '<Ewe>/V'), I_str='raw current / [mA]', J_str='J / [mA cm$^{-2}$]', A_el=None, raw_current_names=('I/mA', '<I>/mA'), cycle_names=('cycle number', ))[source]¶ Class implementing electrochemistry measurements
TODO: Implement a unit library for current and potential, A_el and RE_vs_RHE TODO: so that e.g. current can be seamlessly normalized to mass OR area.
The main job of this class is making sure that the ValueSeries most essential for visualizing and normal electrochemistry measurements (i.e. excluding impedance spec., RRDE, etc, which would need new classes) are always available in the correct form as the measurement is added with others, reduced to a selection, calibrated and normalized, etc. These most important ValueSeries are:
potential: The working-electrode potential typically in [V]. If ec_meas is an ECMeasurement, then ec_meas[“potential”] always returns a ValueSeries characterized by:
- calibrated and/or corrected, if the measurement has been calibrated with the reference electrode potential (RE_vs_RHE, see calibrate) and/or corrected for ohmic drop (R_Ohm, see correct_ohmic_drop).
- A name that makes clear any calibration and/or correction
- Data which spans the entire timespan of the measurement - i.e. whenever EC data is being recorded, potential is there, even the name of the raw ValueSeries (what the acquisition software calls it) changes. Indeed ec_meas[“potential”].tseries is the measurement’s definitive time variable.
current: The working-electrode current typically in [mA] or [mA/cm^2]. ec_meas[“current”] always returns a ValueSeries characterized by:
- normalized if the measurement has been normalized with the electrode area (A_el, see normalize)
- A name that makes clear whether it is normalized
- Data which spans the entire timespan of the measurement
selector: A counter series distinguishing sections of the measurement program. This is essential for analysis of complex measurements as it allows for corresponding parts of experiments to be isolated and treated identically. selector in ECMeasurement is defined to incriment each time one or more of the following changes:
- loop_number: A parameter saved by some potentiostats (e.g. BioLogic) which allow complex looped electrochemistry programs.
- file_number: The id of the component measurement from which each section of the data (the origin of each ValueSeries concatenated to potential)
- cycle_number: An incrementer within a file saved by a potentiostat.
The names of these ValueSeries, which can also be used to index the measurement, are conveniently available as properties:
- ec_meas.t_str is the name of the definitive time, which corresponds to potential.
- ec_meas.E_str is the name of the raw potential
- ec_meas.V_str is the name to the calibrated and/or corrected potential
- ec_meas.I_str is the name of the raw current
- ec_meas.J_str is the name of the normalized current.
- ec_meas.sel_str is the name of the default selector, i.e. “selector”
Numpy arrays from important DataSeries are also directly accessible via attributes:
- ec_meas.t for ec_meas[“potential”].t
- ec_meas.v for ec_meas[“potential”].data
- ec_meas.j for ec_meas[“current”].data
ECMeasurement comes with an ECPlotter which either plots potential and current against time (ec_meas.plot_measurement()) or plots current against potential (`ec_meas.plot_vs_potential()).
It turns out that keeping track of current, potential, and selector when combining datasets is enough of a job to fill a class. Thus, the more exciting electrochemistry-related functionality should be implemented in inheriting classes such as CyclicVoltammogram.
-
calibrate(RE_vs_RHE=None, A_el=None, R_Ohm=None)[source]¶ Calibrate the EC measurement (all args optional)
Parameters: - RE_vs_RHE (float) – reference electode potential on RHE scale in [V]
- A_el (float) – electrode area in [cm^2]
- R_Ohm (float) – ohmic drop resistance in [Ohm]
-
calibrate_RE(RE_vs_RHE)[source]¶ Calibrate the reference electrode by providing RE_vs_RHE in [V].
Return string: The name of the calibrated potential
-
correct_ohmic_drop(R_Ohm)[source]¶ Correct for ohmic drop by providing R_Ohm in [Ohm].
Return string: The name of the corrected potential
-
current¶ The ValueSeries with the ECMeasurement’s current.
This is result of the following: - Starts with self.raw_current - if the measurement is “normalized” i.e. A_el is not None: divide the current data by A_el, change its name from I_str to J_str, and add /cm^2 to its unit.
-
cycle_number¶ The cycle number ValueSeries, requires building from component measurements
-
exporter¶ The default plotter for ECMeasurement is ECExporter
-
file_number¶ The file number ValueSeries, requires building from component measurements.
-
grab_current(tspan=None, norm=True)[source]¶ Return t [s] and current (if cal else raw_current) [V] vectors cut by tspan
-
grab_potential(tspan=None, cal=True)[source]¶ Return t and potential (if cal else raw_potential) [V] vectors cut by tspan
-
j¶ The current ([mA] or [mA/cm^2]) numpy array of the measurement
-
normalize_current(A_el)[source]¶ Normalize current to electrod surface area by providing A_el in [cm^2].
Return string: The name of the normalized current
-
plotter¶ The default plotter for ECMeasurement is ECPlotter
-
potential¶ The ValueSeries with the ECMeasurement’s potential.
This is result of the following: - Starts with self.raw_potential - if the measurement is “calibrated” i.e. RE_vs_RHE is not None: add RE_vs_RHE to the potential data and change its name from E_str to V_str - if the measurement is “corrected” i.e. R_Ohm is not None: subtract R_Ohm times the raw current from the potential and add ” (corrected)” to its name.
-
raw_current¶ Return a time-shifted ValueSeries for the raw current, built first time.
-
raw_potential¶ Return a time-shifted ValueSeries for the raw potential, built first time.
-
selector¶ The ValuSeries which is used by default to select parts of the measurement.
See the class docstring for details.
-
t¶ The definitive time np array of the measurement, corresponding to potential
-
v¶ The potential [V] numpy array of the measurement
The cv module¶
Source: https://github.com/ixdat/ixdat/tree/user_ready/src/ixdat/techniques/cv.py
output of CyclicVoltammagramDiff.plot(). Tutorial.
-
class
ixdat.techniques.cv.CyclicVoltammogram(*args, **kwargs)[source]¶ Class for cyclic voltammetry measurements.
Onto ECMeasurement, this adds: - a property cycle which is a ValueSeries on the same TimeSeries as potential, which counts cycles. “cycle” becomes the Measurement’s sel_str. Indexing with integer or iterable selects according to cycle. - functions for quantitatively comparing cycles (like a stripping cycle, base cycle) - the default plot() is plot_vs_potential()
-
calc_capacitance(vspan)[source]¶ Return the capacitance in [F], calculated by the first sweeps through vspan
Parameters: vspan (iterable) – The potential range in [V] to use for capacitance
-
cycle¶ the cycle number. The default selector. see redefine_cycle
Type: ValueSeries
-
diff_with(other, v_list=None, cls=None, v_scan_res=0.001, res_points=10)[source]¶ Return a CyclicVotammagramDiff of this CyclicVotammagram with another one
Each anodic and cathodic sweep in other is lined up with a corresponding sweep in self. Each variable given in v_list (defaults to just “current”) is interpolated onto self’s potential and subtracted from self.
Parameters: - other (CyclicVoltammogram) – The cyclic voltammogram to subtract from self.
- v_list (list of str) – The names of the series to calculate a difference between self and other for (defaults to just “current”).
- cls (ECMeasurement subclass) – The class to return an object of. Defaults to CyclicVoltammogramDiff.
- v_scan_res (float) – see CyclicVoltammogram.get_timed_sweeps()
- res_points (int) – see CyclicVoltammogram.get_timed_sweeps()
-
get_timed_sweeps(v_scan_res=0.0005, res_points=10)[source]¶ Return list of [(tspan, type)] for all the potential sweeps in self.
There are three types: “anodic” (positive scan rate), “cathodic” (negative scan rate), and “hold” (zero scan rate)
Parameters: - v_scan_res (float) – The minimum scan rate considered significantly different than zero, in [V/s]. Defaults to 5e-4 V/s (0.5 mV/s). May need be higher for noisy potential, and lower for very low scan rates.
- res_points (int) – The minimum number of points to be considered a sweep. During a sweep, a potential difference of at least v_res should be scanned through every res_points points.
-
integrate(item, tspan=None, vspan=None, ax=None)[source]¶ Return the time integral of item while time in tspan or potential in vspan
item (str): The name of the ValueSeries to integrate tspan (iter of float): A time interval over which to integrate it vspan (iter of float): A potential interval over which to integrate it.
-
redefine_cycle(start_potential=None, redox=None)[source]¶ Build cycle which iterates when passing through start_potential
Parameters: - start_potential (float) – The potential in [V] at which the cycle counter will iterate. If start_potential is not given, the cycle is just the selector inherited from ECMeasurement shifted to start at 0.
- redox (bool) – True (or 1) for anodic, False (or 0) for cathodic. The direction in which the potential is scanning through start_potential to trigger an iteration of cycle.
-
scan_rate¶ The scan rate as a ValueSeries
-
select_sweep(vspan, t_i=None)[source]¶ Return a CyclicVoltammogram for while the potential is sweeping through vspan
Parameters: - vspan (iter of float) – The range of self.potential for which to select data. Vspan defines the direction of the sweep. If vspan[0] < vspan[-1], an oxidative sweep is returned, i.e. one where potential is increasing. If vspan[-1] < vspan[0], a reductive sweep is returned.
- t_i (float) – Optional. Time before which the sweep can’t start.
-