Esempio n. 1
0
print(f'\nq_module = {ecm_module.q_module} Ah')
print(f'soc_module max = {max(soc_module):.4f}')
print(f'soc_module min = {min(soc_module):.4f}')

print('\nitem\tvpts\tzpts')
for i, (v, z) in enumerate(zip(vpts_module, zpts_module)):
    print(f'{i}\t{vpts_module[i]:.4f}\t{zpts_module[i]:.4f}')

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

fig, ax = plt.subplots(tight_layout=True)
ax.plot(ecm_module.time, soc_module, 'm', label='module')
ax.plot(ecm_cell.time, soc_cell, 'k--', label='cell')
config_ax(ax, xylabels=('Time [s]', 'State of charge [-]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(soc_module, ocv_module, 'C1', label='module')
ax.plot(zpts_module, vpts_module, 'C1o', label='module pts')
ax.plot(soc_cell, ocv_cell, 'k--', label='cell')
config_ax(ax,
          xylabels=('State of charge [-]', 'Open circuit voltage [V]'),
          loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(ecm_module.time, ocv_module, 'C1', label='module')
ax.plot(ecm_cell.time, ocv_cell, 'k--', label='cell')
config_ax(ax, xylabels=('Time [s]', 'Open circuit voltage [V]'), loc='best')

plt.show()
data_hppc = CellHppcData(file)
ids = data_hppc.get_indices_s()
idq = data_hppc.get_indices_q()
idp = data_hppc.get_indices_pulse()
idd = data_hppc.get_indices_discharge()

# Plot all data from HPPC battery cell test
# ----------------------------------------------------------------------------

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

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

fig, ax = plt.subplots()
ax.plot(data_all.time, data_all.voltage, 'C3')
ax.arrow(15474, 4.06, 0, -0.14, head_width=1000, head_length=0.05, zorder=20)
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'))
axins = inset_axes(ax, 2, 2, loc='lower left', borderpad=4)
axins.plot(data_all.time, data_all.voltage, 'C3')
axins.set_xlim(15420, 15540)
axins.set_ylim(4.08, 4.21)
plt.xticks(visible=False)
plt.yticks(visible=False)
Esempio n. 3
0
temps = ecm.calc_temperature(295.15, ocv, vt)

# vt = vt * 3
vt = vt * 2.985

# Print
# ----------------------------------------------------------------------------

print('q =', ecm.q_module)

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

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, soc, 'C6')
config_ax(ax, xylabels=('Time [s]', 'State of charge [-]'))

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]'))

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]'))

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, data.temp_a1 + 273.15)
ax.plot(data.time, data.temp_a2 + 273.15)
ax.plot(data.time, data.temp_a3 + 273.15)
ax.plot(data.time, temps)
Esempio n. 4
0
ti_3c = temp_3c.tc4.iloc[0] + 273.15

tm_3c = ThermalModel(params)
q_3c, tk_3c = tm_3c.calc_q_temp(i=dis_3c.current, ocv=ocv_3c, time=dis_3c.time, ti=ti_3c, vt=vt_3c)

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

fig, ax = plt.subplots()
ax.plot(dis_1c.time, dis_1c.voltage, marker='.', label='1c')
ax.plot(dis_2c.time, dis_2c.voltage, marker='.', label='2c')
ax.plot(dis_3c.time, dis_3c.voltage, marker='.', label='3c')
ax.plot(dis_1c.time, vt_1c, label='vt_1c')
ax.plot(dis_2c.time, vt_2c, label='vt_2c')
ax.plot(dis_3c.time, vt_3c, label='vt_3c')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='upper right')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(temp_1c.time, temp_1c.tavg + 273.15, marker='.', markevery=20, label='1c')
ax.plot(temp_2c.time, temp_2c.tavg + 273.15, marker='.', markevery=20, label='2c')
ax.plot(temp_3c.time, temp_3c.tavg + 273.15, marker='.', markevery=20, label='3c')
ax.fill_between(temp_1c.time, temp_1c.tmax + 273.15, temp_1c.tmin + 273.15, alpha=0.3)
ax.fill_between(temp_2c.time, temp_2c.tmax + 273.15, temp_2c.tmin + 273.15, alpha=0.3)
ax.fill_between(temp_3c.time, temp_3c.tmax + 273.15, temp_3c.tmin + 273.15, alpha=0.3)
ax.plot(dis_1c.time, tk_1c, label='tk_1c')
ax.plot(dis_2c.time, tk_2c, label='tk_2c')
ax.plot(dis_3c.time, tk_3c, label='tk_3c')
config_ax(ax, xylabels=('Time [s]', 'Temperature [K]'), loc='upper right')

plt.show()
Esempio n. 5
0
# Plot curve fit
# ----------------------------------------------------------------------------

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

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(tight_layout=True)
    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()
ecm_module = ModuleEcm(data_hppc_mod, params)
vt_module = get_vt_module_pack(data_us06, ecm_module)

# Print
# ----------------------------------------------------------------------------

r2_cell = r2fit(data_us06.voltage, vt_cell)
r2_module = r2fit(data_us06.voltage, vt_module)

print(f'R² cell    {r2_cell:.2f}')
print(f'R² module  {r2_module:.2f}')

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

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data_us06.time, data_us06.voltage, color='C3', label='pack data')
ax.plot(data_us06.time, vt_cell, color='k', label='cell ecm')
ax.plot(data_us06.time, vt_module, color='m', label='module ecm')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data_us06.time, abs(data_us06.voltage - vt_cell), label='cell ecm')
ax.plot(data_us06.time, abs(data_us06.voltage - vt_module), label='module ecm')
config_ax(ax,
          xylabels=('Time [s]', 'Absolute voltage difference [V]'),
          loc='best')

plt.show()
# Print
# ----------------------------------------------------------------------------

# currents for each cell in a module should sum to total discharge current
print(f'i_pack = {i_pack[-1]:.2f}')
print(f'i_sum0 = {i_cells[-1][0].sum():.2f}')
print(f'i_sum1 = {i_cells[-1][1].sum():.2f}')

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

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, (ax1, ax2) = plt.subplots(1, 2, tight_layout=True)
ax1.plot(data_dis.time, i_pack, label='data')
config_ax(ax1, xylabels=('Time [s]', 'Current [A]'), loc='best')
for k in range(n_cells):
    ax2.plot(data_dis.time, i_cells2[k], label=f'cell {k+1}')
config_ax(ax2, xylabels=('Time [s]', ''), 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')

fig, ax = plt.subplots(tight_layout=True)
for k in range(n_cells):
dis_2c_sect = CellDischargeData.process_discharge_only(file_dis_2c)
dis_3c_sect = CellDischargeData.process_discharge_only(file_dis_3c)

temp_1c_sect = CellTemperatureData.process(file_temp_1c, dis_1c_sect.ti, dis_1c_sect.tf)
temp_2c_sect = CellTemperatureData.process(file_temp_2c, dis_2c_sect.ti, dis_2c_sect.tf)
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)

# original temperature data
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(10, 4.8), sharey=True, tight_layout=True)
ax1.plot(temp_1c.time, temp_1c.tc1)
# Battery modules US06 data
# ----------------------------------------------------------------------------

# original data
file_us06 = '../data/module123-ir-65ah-us06.csv'
data = PackUs06Data(file_us06, all_data=True)

# processed data for 600s of US06 drive cycle
data_proc = PackUs06Data(file_us06)

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

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

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

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data.time, data.temp_a1, label='temp_a1')
ax.plot(data.time, data.temp_a2, label='temp_a2')
ax.plot(data.time, data.temp_a3, label='temp_a3')
config_ax(ax, xylabels=('Time [s]', 'Temperature [°C]'))

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data_proc.time, data_proc.voltage, color='C3')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'))
Esempio n. 10
0
ecm_cell.time = data_module.time
ecm_cell.q_cell = params.q_module / 2

soc_cell = ecm_cell.soc()
ocv_cell = ecm_cell.ocv(soc_cell, vz_pts=(vpts_module, zpts_module))
# coeffs_cell = ecm_cell.curve_fit_coeff(ecm_cell.func_ttc, 5)
# rctau_cell = ecm_cell.rctau_ttc(coeffs_module)
vt_cell = ecm_cell.vt(soc_cell, ocv_cell, rctau_module)

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

fig, ax = plt.subplots(tight_layout=True)
ax.plot(ecm_module.time, soc_module, 'm', label='module')
ax.plot(ecm_cell.time, soc_cell, 'k--', label='cell')
config_ax(ax, xylabels=('Time [s]', 'State of charge [-]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(soc_module, ocv_module, 'C1', label='module')
ax.plot(zpts_module, vpts_module, 'C1o', label='module pts')
# ax.plot(soc_cell, ocv_cell * 2, 'k--', label='cell')
# ax.plot(zpts_cell, vpts_cell * 2, 'kx', label='cell pts')
config_ax(ax, xylabels=('State of charge [-]', 'Open circuit voltage [V]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(ecm_module.time, vt_module, 'C3', label='module')
ax.plot(ecm_cell.time, vt_cell, 'k--', label='cell')
config_ax(ax, xylabels=('Time [s]', 'Voltage [V]'), loc='best')

fig, ax = plt.subplots(tight_layout=True)
ax.plot(data_module.time, data_module.voltage, 'C3', label='module data')