Note

This notebook is already available in your BattMo installation. In Matlab, run

open tutorial_5_simulate_CCCV_cycling_live

Tutorial 5 - Simulate CC-CV Cycling

Introduction

In this tutorial, we will use a P2D model to simulate CC-CV cycling. After completing this tutorial, you should have a working knowledge of:

  • How to define and modify cycling protocols in BattMo

We’ll use the same model from Tutorial 1.

[1]:
jsonstruct = parseBattmoJson('Examples/jsondatafiles/sample_input.json');

Parameters are defined in the JSON parameter file and parsed into the MATLAB structure. Once the JSON file has been read into MATLAB as a jsonstruct, its properties can be modified programmatically.

Explore the Control Definition

Let’s begin by reviewing the control protocol in BattMo, with the command:

[2]:
disp(jsonstruct.Control)
[2]:
         controlPolicy: 'CCDischarge'
                 DRate: 1
    lowerCutoffVoltage: 3
    upperCutoffVoltage: 4.1000
             dIdtLimit: 0.0100
             dEdtLimit: 0.0100
            rampupTime: 0.1000

We see that the default control protocol is set to a constant current (galvanostatic) discharge. To change to a CC-CV cycling protocol, we can use the command:

[3]:
cccv_control_protocol = parseBattmoJson('cccv_control.json');
jsonstruct_modified = mergeJsonStructs({cccv_control_protocol, jsonstruct});
[3]:
mergeJsonStructs: Parameter Control.controlPolicy is assigned twice with different values. Value from first jsonstruct is used.
mergeJsonStructs: Parameter Control.lowerCutoffVoltage is assigned twice with different values. Value from first jsonstruct is used.
mergeJsonStructs: Parameter Control.upperCutoffVoltage is assigned twice with different values. Value from first jsonstruct is used.
mergeJsonStructs: Parameter Control.dIdtLimit is assigned twice with different values. Value from first jsonstruct is used.
mergeJsonStructs: Parameter Control.dEdtLimit is assigned twice with different values. Value from first jsonstruct is used.

Now we can explore the modified control protocol definition with the command:

[4]:
disp(jsonstruct_modified.Control)
[4]:
         controlPolicy: 'CCCV'
        initialControl: 'discharging'
        numberOfCycles: 5
                 CRate: 0.5000
                 DRate: 1
    lowerCutoffVoltage: 2.8000
    upperCutoffVoltage: 4.2000
             dIdtLimit: 2.0000e-06
             dEdtLimit: 2.0000e-06
            rampupTime: 0.1000

Let’s run the simulation and plot the cell voltage curve.

[5]:
% run the simulation
output = runBatteryJson(jsonstruct_modified);

get the states

[6]:
states = output.states;

% extract the time and voltage quantities
time = cellfun(@(state) state.time, states);
voltage = cellfun(@(state) state.('Control').E, states);
current = cellfun(@(state) state.('Control').I, states);

% calculate the capacity
capacity = time .* current;

% plot the discharge curve in the figure
plot(time/hour, voltage, '-', 'linewidth', 3)

% add plot annotations
xlabel('Capacity  /  mA \cdot h')
ylabel('Cell Voltage  /  V')
[6]:
figure_0.png

Summary

In this tutorial, we explored how to modify material parameters in BattMo.