-
Notifications
You must be signed in to change notification settings - Fork 2
/
04_dynamic_oxygen_evolution.py
175 lines (150 loc) · 4.64 KB
/
04_dynamic_oxygen_evolution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 8
@author: Kevin Krempl
"""
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
from scipy.stats import linregress
from scipy.integrate import cumtrapz
from ixdat.techniques.deconvolution import Kernel, DecoMeasurement
# Import measurement data
data = DecoMeasurement.read("RawData/Measurement3.pkl", reader="EC_MS")
# Calibration of O2 (M32)
tspansO2 = [[8100, 8130], [8200, 8230], [8500, 8550]]
t_bg = [7260, 7280]
signal = []
current = []
for tspan in tspansO2:
_, sig_values = data.grab_signal("M32", tspan=tspan, t_bg=t_bg)
signal.append(np.mean(sig_values))
_, curr_values = data.grab_current(tspan=tspan)
current.append(np.mean(curr_values))
fit = linregress(signal, np.absolute(current))
calib_O2 = fit[0] # Calibration constant in mA/A (partial current/signal current)
data.calibration = {"M32": calib_O2}
# RHE calibration of RE and surface area normalization of current
data.calibrate(RE_vs_RHE=0.05, A_el=0.196)
# Define model parameters and deconvolute the oxygen signal
params = {
"diff_const": 2.1e-9,
"work_dist": 160e-6,
"volflow_cap": 1.9e-10,
"vol_gas": 1e-10,
"henry_vola": 33,
}
model_kernel = Kernel(parameters=params)
tspan = [10600, 10800]
t_bg = [10800, 10900]
t_partcurr, v_partcurr = data.grab_partial_current(
"M32", model_kernel, tspan=tspan, t_bg=t_bg, snr=10
)
v_partcurr = v_partcurr / 0.196 # Normalize to 0.196 electrode surface area
t_curr, v_curr = data.grab_current(tspan=tspan)
t_curr = t_curr - t_partcurr[0]
t_pot, v_pot = data.grab_potential(tspan=tspan)
t_pot = t_pot - t_partcurr[0]
t_sig, v_sig = data.grab_cal_signal("M32", tspan=tspan, t_bg=t_bg)
t_sig = t_sig - t_partcurr[0]
v_sig = v_sig / 0.196
t_partcurr = t_partcurr - t_partcurr[0]
# Calculate oxide rate and thickness
v_curr_inter = np.interp(t_partcurr, t_curr, v_curr)
v_partcurr_oxide = v_curr_inter - v_partcurr
v_charge_oxide = cumtrapz(v_partcurr_oxide, t_partcurr, initial=0)
v_oxide_thickness = (
v_charge_oxide / (4 * 96485) * 227 / 1000 / 11.25 * 1e8
) # M_PtO2 = 227 g/mol, roh_PtO2 = 11.25 g/cm^3
v_oxide_thickness = v_oxide_thickness - v_oxide_thickness[0]
# Plot and format
fig = plt.figure(figsize=(7.5, 3.5))
gs = fig.add_gridspec(2, 8)
ax1 = fig.add_subplot(gs[0, :-4])
ax1.set_xticklabels([])
ax1.set_ylabel(r"$J_i$ / [mA cm$^{-2}$]")
ax1.set_ylim(-0.01, 0.5)
ax1.plot(t_partcurr, v_partcurr_oxide, color="purple", label="PtO$_2$")
ax1.plot(t_sig, v_sig, color="lightgreen")
ax1.plot(t_partcurr, v_partcurr, color="green", label=r"O$_2$")
plt.tight_layout()
ax1.annotate(
r"O$_2$",
xy=(25, 0.2),
xytext=(40, 0.3),
arrowprops=dict(arrowstyle="->", lw=0.5),
)
ax1.annotate(
r"O$_2$ measured",
xy=(43, 0.1),
xytext=(65, 0.2),
arrowprops=dict(arrowstyle="->", lw=0.5),
)
ax1.annotate(
r"PtO$_2$",
xy=(70, 0.01),
xytext=(90, 0.1),
arrowprops=dict(arrowstyle="->", lw=0.5),
)
# ax1.annotate(
# r"\textbf{a)}", xy=(0.02, 0.95), xytext=(0.02, 0.95), xycoords="figure fraction"
# ) # can be buggy
ax2 = ax1.twinx()
ax2.set_ylabel(r"PtO$_2$ thickness / [A]")
ax2.set_ylim(-0.2, 10)
ax2.plot(
t_partcurr,
v_oxide_thickness,
color="purple",
linestyle="dotted",
label="$d_{PtO_2}$",
)
ax2.annotate(
"",
xy=(140, 8),
xytext=(160, 8),
arrowprops=dict(arrowstyle="<-", lw=0.5, color="purple"),
)
ax3 = fig.add_subplot(gs[1, :-4])
ax3.set_ylim(-0.01, 0.5)
ax3.set_ylabel(r"$J_{tot}$ / [mA cm$^{-2}$]")
ax3.set_xlabel("time / [s]")
ax3.plot(t_curr, v_curr, color="black")
ax3.annotate(
"", xy=(30, 0.2), xytext=(10, 0.2), arrowprops=dict(arrowstyle="<-", lw=0.5)
)
ax4 = ax3.twinx()
ax4.set_ylabel(r"$U_{RHE}$ / [V]")
ax4.plot(t_pot, v_pot, color="red")
ax4.annotate(
"",
xy=(155, 1.55),
xytext=(175, 1.55),
arrowprops=dict(arrowstyle="<-", color="red", lw=0.5),
)
axOx = fig.add_subplot(gs[:, -3:])
axOx.set_ylim(0.01, 0.6)
axOx.set_xlim(0, 10)
axOx.set_xlabel(r"PtO$_2$ thickness / [A]")
axOx.set_ylabel(r"$J_{O_2}$ / [mA cm$^{-2}$]")
axOx.semilogy(
v_oxide_thickness,
v_partcurr[-670:],
linestyle="None",
fillstyle="none",
marker="s",
color="red",
)
# Create linear fit to the semilog plot
coef = np.polyfit(v_oxide_thickness[-550:-150], np.log10(v_partcurr[-550:-150]), 1)
poly1d_fn = np.poly1d(coef)
axOx.plot(
v_oxide_thickness[-570:-150], 10 ** (poly1d_fn(v_oxide_thickness[-570:-150])), "--k"
)
plt.tight_layout()
# ax1.annotate(
# r"\textbf{b)}", xy=(0.62, 0.95), xytext=(0.62, 0.95), xycoords="figure fraction"
# ) # can be buggy
# fig.savefig("Plots/OER_transients.eps", dpi=1000, format="eps")
fig.savefig("Plots/OER_transients.png")