temp_3c_sect = CellTemperatureData.process(file_temp_3c, dis_3c_sect.ti,
                                           dis_3c_sect.tf)

# Plot original data
# ----------------------------------------------------------------------------

# original current data
fig, (ax1, ax2, ax3) = plt.subplots(1,
                                    3,
                                    figsize=(10, 4.8),
                                    sharey=True,
                                    tight_layout=True)
ax1.plot(dis_1c.time, dis_1c.current)
ax2.plot(dis_2c.time, dis_2c.current)
ax3.plot(dis_3c.time, dis_3c.current)
config_ax(ax1, xylabels=('', 'Current [A]'))
config_ax(ax2, xylabels=('Time [s]', ''))
config_ax(ax3)

# original voltage data
fig, (ax1, ax2, ax3) = plt.subplots(1,
                                    3,
                                    figsize=(10, 4.8),
                                    sharey=True,
                                    tight_layout=True)
ax1.plot(dis_1c.time, dis_1c.voltage, color='C3')
ax2.plot(dis_2c.time, dis_2c.voltage, color='C3')
ax3.plot(dis_3c.time, dis_3c.voltage, color='C3')
config_ax(ax1, xylabels=('', 'Voltage [V]'))
config_ax(ax2, xylabels=('Time [s]', ''))
config_ax(ax3)
"""
View plots of the battery module HPPC data.
"""

import matplotlib.pyplot as plt

from ecm import ModuleData
from utils import config_ax

# Battery module HPPC data
# ----------------------------------------------------------------------------

file_hppc = 'data/module1-electchar-65ah-45deg.csv'
data = ModuleData(file_hppc)

# Plot
# ----------------------------------------------------------------------------

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, data.voltage, color='C3')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'))

plt.show()
Exemplo n.º 3
0
    ecm.current = i_cells2[k]
    soc = ecm.soc()
    ocv = ecm.ocv(soc, vz_pts=(v_pts, z_pts))
    vt = ecm.vt(soc, ocv, rctau)
    v_cells[k] = vt

    icell = i_cells2[k]
    _, temp_cell = tm.calc_q_temp(i=icell, ocv=ocv, time=data_dis.time, ti=297, vt=vt)
    temp_cells[k] = temp_cell

# Plot
# ----------------------------------------------------------------------------

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data_dis.time, data_dis.current, marker='.')
config_ax(ax, xylabels=('Time [s]', 'Current [A]'))

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data_dis.time, data_dis.voltage, color='C3', marker='.', label='data')
ax.plot(data_dis.time, vt_dis, label='ecm')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
for k in range(n_cells):
    ax.plot(data_dis.time, i_cells2[k], label=f'cell {k+1}')
config_ax(ax, xylabels=('Time [s]', 'Current [A]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
for k in range(n_cells):
    ax.plot(data_dis.time, v_cells[k], label=f'cell {k+1}')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='best')
Exemplo n.º 4
0
from ecm import CellHppcData
from ecm import EquivCircModel
from utils import config_ax

# Battery cell HPPC data and equivalent circuit model
# ----------------------------------------------------------------------------

file_hppc = 'data/cell-low-current-hppc-25c-2.csv'
data = CellHppcData.process(file_hppc)

ecm = EquivCircModel(data, params)
soc = ecm.soc()
ocv = ecm.ocv(soc)
coeffs = ecm.curve_fit_coeff(ecm.func_ttc, 5)
rctau = ecm.rctau_ttc(coeffs)
vt = ecm.vt(soc, ocv, rctau)

# Plot HPPC data and equivalent circuit model
# ----------------------------------------------------------------------------

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, data.voltage, 'C3', label='data')
ax.plot(data.time, vt, 'k--', label='ecm')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, abs(data.voltage - vt))
config_ax(ax, xylabels=('Time [s]', 'Absolute voltage difference [V]'))

plt.show()
# indices representing start (id2) and end (id4) of curve in each SOC section
_, _, id2, _, id4 = data.get_idrc()

for i in range(len(id2)):
    start = id2[i]
    end = id4[i]
    t_curve = data.time[start:end]
    v_curve = data.voltage[start:end]
    t_scale = t_curve - t_curve[0]

    vfit1 = ecm.func_otc(t_scale, *coeffs_otc[i])
    vfit2 = ecm.func_ttc(t_scale, *coeffs_ttc[i])

    fig, ax = plt.subplots()
    ax.plot(t_curve, v_curve, 'C3', marker='.', label='data')
    ax.plot(t_curve, vfit1, label='otc')
    ax.plot(t_curve, vfit2, label='ttc')
    config_ax(ax,
              xylabels=('Time [s]', 'Voltage [V]'),
              title=f'SOC section {i}',
              loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, data.voltage, 'C3', label='data')
ax.plot(data.time[id2], data.voltage[id2], 'x', label='id2')
ax.plot(data.time[id4], data.voltage[id4], 'x', label='id4')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='best')

plt.show()
# Print state of charge (SOC) and open circuit voltage (OCV) points
# ----------------------------------------------------------------------------

print('--- State of charge (SOC) and open circuit voltage (OCV) ---')
print(f"{'SOC [-]':10} {'OCV [V]':10}")
for idx, z in enumerate(z_pts):
    print(f'{z:<10.4f} {v_pts[idx]:<10.4f}')

# Plot SOC and OCV from equivalent circuit model
# ----------------------------------------------------------------------------

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, data.voltage, 'C3', label='data')
ax.plot(t_pts, v_pts, 'x', label='ocv pts')
ax.plot(data.time, ocv, '--', label='ocv')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='best')

fig, ax1 = plt.subplots(tight_layout=True)
ax1.plot(data.time, data.current, 'C9', label='data')
ax1.plot(t_pts, i_pts, 'x', label='ocv pts')
ax1.legend(loc='lower left')
ax1.set_xlabel('Time [s]')
ax1.set_ylabel('Current [A]', color='C0')
ax1.tick_params('y', colors='C0')
ax1.set_frame_on(False)
ax2 = ax1.twinx()
ax2.plot(data.time, soc, 'm', label='soc')
ax2.plot(t_pts, z_pts, 'xC6', label='soc pts')
ax2.legend(loc='best')
ax2.set_ylabel('SOC [-]', color='m')
ax2.tick_params('y', colors='m')