Tutorial 2 - Change the Control Protocol
Introduction
In this tutorial, we will use a P2D model to simulate the discharge of an NMC-Graphite cell at different rates. After completing this tutorial, you should have a working knowledge of:
- Basics of the control protocol definitions in BattMo
- The link between battery discharge rate and simulation time
- How to setup and execute a parameter sweep
We'll use the same model from Tutorial 1.
jsonstruct = parseBattmoJson('Examples/jsondatafiles/sample_input.json');
Explore the Control Protocol
The control protocol is defined in the JSON parameter file and parsed into the MATLAB structure. Once the JSON parameter file has been read into MATLAB as a jsonstruct, its properties can be modified programmatically.
Let's begin by exploring the control protocol definition with the following command:
disp(jsonstruct.Control)
controlPolicy: 'CCDischarge'
CRate: 1
lowerCutoffVoltage: 2.4000
upperCutoffVoltage: 4.1000
dIdtLimit: 0.0100
dEdtLimit: 0.0100
rampupTime: 0.1000
Here, we can see that the control policy follows the schema for a constant current discharge (CCDischarge). The three main control parameters in this schema are the CRate, lowerCutoffVoltage, and upperCutoffVoltage. Let's first try changing the protocol to discharge at a rate of C/10 to a lower cutoff voltage of 3 V.
jsonstruct.Control.CRate = 0.1;
jsonstruct.Control.lowerCutoffVoltage = 3.0;
Remember that if we change the rate of the discharge then we also need to change the duration of the simulation. To do this we can explore the TimeStepping property of the structure.
disp(jsonstruct.TimeStepping)
totalTime: 5040
numberOfTimeSteps: 40
useRampup: 1
The total duration of the simulation is given by the totalTime property. We can adjust it to an appropriate duration using the following command.
jsonstruct.TimeStepping.totalTime = (1./jsonstruct.Control.CRate) .* 3600 .* 1.1;
This sets the total time of the simulation to be 10% longer than the expected duration based on the C-Rate. We can then run the simulation and plot the discharge curve.
output = runBatteryJson(jsonstruct);
Solving timestep 01/45: -> 30 Seconds, 937 Milliseconds
Solving timestep 02/45: 30 Seconds, 937 Milliseconds -> 61 Seconds, 875 Milliseconds
Solving timestep 03/45: 61 Seconds, 875 Milliseconds -> 123 Seconds, 750 Milliseconds
Solving timestep 04/45: 123 Seconds, 750 Milliseconds -> 247 Seconds, 500 Milliseconds
Solving timestep 05/45: 247 Seconds, 500 Milliseconds -> 495 Seconds
Solving timestep 06/45: 495 Seconds -> 990 Seconds
Solving timestep 07/45: 990 Seconds -> 1980 Seconds
Solving timestep 08/45: 1980 Seconds -> 2970 Seconds
Solving timestep 09/45: 2970 Seconds -> 1 Hour, 360 Seconds
Solving timestep 10/45: 1 Hour, 360 Seconds -> 1 Hour, 1350 Seconds
Solving timestep 11/45: 1 Hour, 1350 Seconds -> 1 Hour, 2340 Seconds
Solving timestep 12/45: 1 Hour, 2340 Seconds -> 1 Hour, 3330 Seconds
Solving timestep 13/45: 1 Hour, 3330 Seconds -> 2 Hours, 720 Seconds
Solving timestep 14/45: 2 Hours, 720 Seconds -> 2 Hours, 1710 Seconds
Solving timestep 15/45: 2 Hours, 1710 Seconds -> 2 Hours, 2700 Seconds
Solving timestep 16/45: 2 Hours, 2700 Seconds -> 3 Hours, 90 Seconds
Solving timestep 17/45: 3 Hours, 90 Seconds -> 3 Hours, 1080 Seconds
Solving timestep 18/45: 3 Hours, 1080 Seconds -> 3 Hours, 2070 Seconds
Solving timestep 19/45: 3 Hours, 2070 Seconds -> 3 Hours, 3060 Seconds
Solving timestep 20/45: 3 Hours, 3060 Seconds -> 4 Hours, 450 Seconds
Solving timestep 21/45: 4 Hours, 450 Seconds -> 4 Hours, 1440 Seconds
Solving timestep 22/45: 4 Hours, 1440 Seconds -> 4 Hours, 2430 Seconds
Solving timestep 23/45: 4 Hours, 2430 Seconds -> 4 Hours, 3420 Seconds
Solving timestep 24/45: 4 Hours, 3420 Seconds -> 5 Hours, 810 Seconds
Solving timestep 25/45: 5 Hours, 810 Seconds -> 5 Hours, 1800 Seconds
Solving timestep 26/45: 5 Hours, 1800 Seconds -> 5 Hours, 2790 Seconds
Solving timestep 27/45: 5 Hours, 2790 Seconds -> 6 Hours, 180 Seconds
Solving timestep 28/45: 6 Hours, 180 Seconds -> 6 Hours, 1170 Seconds
Solving timestep 29/45: 6 Hours, 1170 Seconds -> 6 Hours, 2160 Seconds
Solving timestep 30/45: 6 Hours, 2160 Seconds -> 6 Hours, 3150 Seconds
Solving timestep 31/45: 6 Hours, 3150 Seconds -> 7 Hours, 540 Seconds
Solving timestep 32/45: 7 Hours, 540 Seconds -> 7 Hours, 1530 Seconds
Solving timestep 33/45: 7 Hours, 1530 Seconds -> 7 Hours, 2520 Seconds
Solving timestep 34/45: 7 Hours, 2520 Seconds -> 7 Hours, 3510 Seconds
Solving timestep 35/45: 7 Hours, 3510 Seconds -> 8 Hours, 900 Seconds
Solving timestep 36/45: 8 Hours, 900 Seconds -> 8 Hours, 1890 Seconds
Solving timestep 37/45: 8 Hours, 1890 Seconds -> 8 Hours, 2880 Seconds
Solving timestep 38/45: 8 Hours, 2880 Seconds -> 9 Hours, 270 Seconds
Solving timestep 39/45: 9 Hours, 270 Seconds -> 9 Hours, 1260 Seconds
Solving timestep 40/45: 9 Hours, 1260 Seconds -> 9 Hours, 2250 Seconds
Solving timestep 41/45: 9 Hours, 2250 Seconds -> 9 Hours, 3240 Seconds
Solving timestep 42/45: 9 Hours, 3240 Seconds -> 10 Hours, 630 Seconds
*** Simulation complete. Solved 42 control steps in 5 Seconds, 966 Milliseconds (termination triggered by stopFunction) ***
retrieve the states from the simulation result
% extract the time and voltage quantities
time = cellfun(@(state) state.time, states);
voltage = cellfun(@(state) state.('Control').E, states);
% plot the discharge curve in a new figure
plot((time/hour), voltage, '-', 'linewidth', 3)
ylabel('Cell Voltage / V')
title('Cell Discharge at C/10')
Setup and Run a Parameter Sweep
Now, let's setup and run a paramter sweep that simulates the performance of the cell at many different rates. To do this, we can define the different rates that we want to simulate in a vector and then use a for-loop to simulate the cell discharge at each value from the vector. We can also store the outputs of the various simulations as elements in a MATLAB cell array so that they are accessible at the end of the sweep.
% create a vector of different c-rates for the parameter sweep
% instantiate and empty cell array to store the outputs of the simulations
output = cell(size(CRates));
% instantiate an empty figure
% use a for-loop to iterate through the vector of c-rates
for i = 1 : numel(CRates)
% modify the value for the c-rate in the control definition and update
% the total duration of the simulation accordingly
jsonstruct.Control.CRate = CRates(i);
jsonstruct.TimeStepping.totalTime = (1./jsonstruct.Control.CRate) .* 3600 .* 1.2;
% run the simulation and store the results in the output cell array
output{i} = runBatteryJson(jsonstruct);
% retrieve the states from the simulation result
states = output{i}.states;
% extract the time and voltage quantities
time = cellfun(@(state) state.time, states);
voltage = cellfun(@(state) state.('Control').E, states);
% plot the discharge curve in the figure
plot((time/hour), voltage, '-', 'linewidth', 3)
end
Solving timestep 01/45: -> 3 Seconds, 375 Milliseconds
Solving timestep 02/45: 3 Seconds, 375 Milliseconds -> 6 Seconds, 750 Milliseconds
Solving timestep 03/45: 6 Seconds, 750 Milliseconds -> 13 Seconds, 500 Milliseconds
Solving timestep 04/45: 13 Seconds, 500 Milliseconds -> 27 Seconds
Solving timestep 05/45: 27 Seconds -> 54 Seconds
Solving timestep 06/45: 54 Seconds -> 108 Seconds
Solving timestep 07/45: 108 Seconds -> 216 Seconds
Solving timestep 08/45: 216 Seconds -> 324 Seconds
Solving timestep 09/45: 324 Seconds -> 432 Seconds
Solving timestep 10/45: 432 Seconds -> 540 Seconds
Solving timestep 11/45: 540 Seconds -> 648 Seconds
Solving timestep 12/45: 648 Seconds -> 756 Seconds
Solving timestep 13/45: 756 Seconds -> 864 Seconds
Solving timestep 14/45: 864 Seconds -> 972 Seconds
Solving timestep 15/45: 972 Seconds -> 1080 Seconds
Solving timestep 16/45: 1080 Seconds -> 1188 Seconds
Solving timestep 17/45: 1188 Seconds -> 1296 Seconds
Solving timestep 18/45: 1296 Seconds -> 1404 Seconds
Solving timestep 19/45: 1404 Seconds -> 1512 Seconds
Solving timestep 20/45: 1512 Seconds -> 1620 Seconds
Solving timestep 21/45: 1620 Seconds -> 1728 Seconds
Solving timestep 22/45: 1728 Seconds -> 1836 Seconds
Solving timestep 23/45: 1836 Seconds -> 1944 Seconds
Solving timestep 24/45: 1944 Seconds -> 2052 Seconds
Solving timestep 25/45: 2052 Seconds -> 2160 Seconds
Solving timestep 26/45: 2160 Seconds -> 2268 Seconds
Solving timestep 27/45: 2268 Seconds -> 2376 Seconds
Solving timestep 28/45: 2376 Seconds -> 2484 Seconds
Solving timestep 29/45: 2484 Seconds -> 2592 Seconds
Solving timestep 30/45: 2592 Seconds -> 2700 Seconds
Solving timestep 31/45: 2700 Seconds -> 2808 Seconds
Solving timestep 32/45: 2808 Seconds -> 2916 Seconds
Solving timestep 33/45: 2916 Seconds -> 3024 Seconds
Solving timestep 34/45: 3024 Seconds -> 3132 Seconds
Solving timestep 35/45: 3132 Seconds -> 3240 Seconds
Solving timestep 36/45: 3240 Seconds -> 3348 Seconds
Solving timestep 37/45: 3348 Seconds -> 3456 Seconds
Solving timestep 38/45: 3456 Seconds -> 3564 Seconds
Solving timestep 39/45: 3564 Seconds -> 1 Hour, 72 Seconds
*** Simulation complete. Solved 39 control steps in 5 Seconds, 314 Milliseconds (termination triggered by stopFunction) ***
Solving timestep 01/45: -> 1 Second, 687 Milliseconds
Solving timestep 02/45: 1 Second, 687 Milliseconds -> 3 Seconds, 375 Milliseconds
Solving timestep 03/45: 3 Seconds, 375 Milliseconds -> 6 Seconds, 750 Milliseconds
Solving timestep 04/45: 6 Seconds, 750 Milliseconds -> 13 Seconds, 500 Milliseconds
Solving timestep 05/45: 13 Seconds, 500 Milliseconds -> 27 Seconds
Solving timestep 06/45: 27 Seconds -> 54 Seconds
Solving timestep 07/45: 54 Seconds -> 108 Seconds
Solving timestep 08/45: 108 Seconds -> 162 Seconds
Solving timestep 09/45: 162 Seconds -> 216 Seconds
Solving timestep 10/45: 216 Seconds -> 270 Seconds
Solving timestep 11/45: 270 Seconds -> 324 Seconds
Solving timestep 12/45: 324 Seconds -> 378 Seconds
Solving timestep 13/45: 378 Seconds -> 432 Seconds
Solving timestep 14/45: 432 Seconds -> 486 Seconds
Solving timestep 15/45: 486 Seconds -> 540 Seconds
Solving timestep 16/45: 540 Seconds -> 594 Seconds
Solving timestep 17/45: 594 Seconds -> 648 Seconds
Solving timestep 18/45: 648 Seconds -> 702 Seconds
Solving timestep 19/45: 702 Seconds -> 756 Seconds
Solving timestep 20/45: 756 Seconds -> 810 Seconds
Solving timestep 21/45: 810 Seconds -> 864 Seconds
Solving timestep 22/45: 864 Seconds -> 918 Seconds
Solving timestep 23/45: 918 Seconds -> 972 Seconds
Solving timestep 24/45: 972 Seconds -> 1026 Seconds
Solving timestep 25/45: 1026 Seconds -> 1080 Seconds
Solving timestep 26/45: 1080 Seconds -> 1134 Seconds
Solving timestep 27/45: 1134 Seconds -> 1188 Seconds
Solving timestep 28/45: 1188 Seconds -> 1242 Seconds
Solving timestep 29/45: 1242 Seconds -> 1296 Seconds
Solving timestep 30/45: 1296 Seconds -> 1350 Seconds
Solving timestep 31/45: 1350 Seconds -> 1404 Seconds
Solving timestep 32/45: 1404 Seconds -> 1458 Seconds
Solving timestep 33/45: 1458 Seconds -> 1512 Seconds
Solving timestep 34/45: 1512 Seconds -> 1566 Seconds
Solving timestep 35/45: 1566 Seconds -> 1620 Seconds
Solving timestep 36/45: 1620 Seconds -> 1674 Seconds
Solving timestep 37/45: 1674 Seconds -> 1728 Seconds
Solving timestep 38/45: 1728 Seconds -> 1782 Seconds
*** Simulation complete. Solved 38 control steps in 5 Seconds, 631 Milliseconds (termination triggered by stopFunction) ***
Solving timestep 01/45: -> 1 Second, 125 Milliseconds
Solving timestep 02/45: 1 Second, 125 Milliseconds -> 2 Seconds, 250 Milliseconds
Solving timestep 03/45: 2 Seconds, 250 Milliseconds -> 4 Seconds, 500 Milliseconds
Solving timestep 04/45: 4 Seconds, 500 Milliseconds -> 9 Seconds
Solving timestep 05/45: 9 Seconds -> 18 Seconds
Solving timestep 06/45: 18 Seconds -> 36 Seconds
Solving timestep 07/45: 36 Seconds -> 72 Seconds
Solving timestep 08/45: 72 Seconds -> 108 Seconds
Solving timestep 09/45: 108 Seconds -> 144 Seconds
Solving timestep 10/45: 144 Seconds -> 180 Seconds
Solving timestep 11/45: 180 Seconds -> 216 Seconds
Solving timestep 12/45: 216 Seconds -> 252 Seconds
Solving timestep 13/45: 252 Seconds -> 288 Seconds
Solving timestep 14/45: 288 Seconds -> 324 Seconds
Solving timestep 15/45: 324 Seconds -> 360 Seconds
Solving timestep 16/45: 360 Seconds -> 396 Seconds
Solving timestep 17/45: 396 Seconds -> 432 Seconds
Solving timestep 18/45: 432 Seconds -> 468 Seconds
Solving timestep 19/45: 468 Seconds -> 504 Seconds
Solving timestep 20/45: 504 Seconds -> 540 Seconds
Solving timestep 21/45: 540 Seconds -> 576 Seconds
Solving timestep 22/45: 576 Seconds -> 612 Seconds
Solving timestep 23/45: 612 Seconds -> 648 Seconds
Solving timestep 24/45: 648 Seconds -> 684 Seconds
Solving timestep 25/45: 684 Seconds -> 720 Seconds
Solving timestep 26/45: 720 Seconds -> 756 Seconds
Solving timestep 27/45: 756 Seconds -> 792 Seconds
Solving timestep 28/45: 792 Seconds -> 828 Seconds
Solving timestep 29/45: 828 Seconds -> 864 Seconds
Solving timestep 30/45: 864 Seconds -> 900 Seconds
Solving timestep 31/45: 900 Seconds -> 936 Seconds
Solving timestep 32/45: 936 Seconds -> 972 Seconds
Solving timestep 33/45: 972 Seconds -> 1008 Seconds
Solving timestep 34/45: 1008 Seconds -> 1044 Seconds
Solving timestep 35/45: 1044 Seconds -> 1080 Seconds
*** Simulation complete. Solved 35 control steps in 4 Seconds, 767 Milliseconds (termination triggered by stopFunction) ***
Often, it is a more direct comparison of the discharge curves to plot against an x-axis of capacity rather than time. We can use the following commands to make such a plot.
% instantiate an empty figure
% use a for-loop to iterate through the vector of c-rates
for i = 1 : numel(output)
% modify the value for the c-rate in the control definition and update
% the total duration of the simulation accordingly
jsonstruct.Control.CRate = CRates(i);
jsonstruct.TimeStepping.totalTime = (1./jsonstruct.Control.CRate) .* 3600 .* 1.2;
% run the simulation and store the results in the output cell array
output{i} = runBatteryJson(jsonstruct);
% retrieve the states from the simulation result
states = output{i}.states;
% extract the time, voltage, and current quantities
time = cellfun(@(state) state.time, states);
voltage = cellfun(@(state) state.('Control').E, states);
current = cellfun(@(state) state.('Control').I, states);
capacity = time .* current;
% plot the discharge curve in the figure
plot((capacity/(hour*milli)), voltage, '-', 'linewidth', 3)
end
Solving timestep 01/45: -> 3 Seconds, 375 Milliseconds
Solving timestep 02/45: 3 Seconds, 375 Milliseconds -> 6 Seconds, 750 Milliseconds
Solving timestep 03/45: 6 Seconds, 750 Milliseconds -> 13 Seconds, 500 Milliseconds
Solving timestep 04/45: 13 Seconds, 500 Milliseconds -> 27 Seconds
Solving timestep 05/45: 27 Seconds -> 54 Seconds
Solving timestep 06/45: 54 Seconds -> 108 Seconds
Solving timestep 07/45: 108 Seconds -> 216 Seconds
Solving timestep 08/45: 216 Seconds -> 324 Seconds
Solving timestep 09/45: 324 Seconds -> 432 Seconds
Solving timestep 10/45: 432 Seconds -> 540 Seconds
Solving timestep 11/45: 540 Seconds -> 648 Seconds
Solving timestep 12/45: 648 Seconds -> 756 Seconds
Solving timestep 13/45: 756 Seconds -> 864 Seconds
Solving timestep 14/45: 864 Seconds -> 972 Seconds
Solving timestep 15/45: 972 Seconds -> 1080 Seconds
Solving timestep 16/45: 1080 Seconds -> 1188 Seconds
Solving timestep 17/45: 1188 Seconds -> 1296 Seconds
Solving timestep 18/45: 1296 Seconds -> 1404 Seconds
Solving timestep 19/45: 1404 Seconds -> 1512 Seconds
Solving timestep 20/45: 1512 Seconds -> 1620 Seconds
Solving timestep 21/45: 1620 Seconds -> 1728 Seconds
Solving timestep 22/45: 1728 Seconds -> 1836 Seconds
Solving timestep 23/45: 1836 Seconds -> 1944 Seconds
Solving timestep 24/45: 1944 Seconds -> 2052 Seconds
Solving timestep 25/45: 2052 Seconds -> 2160 Seconds
Solving timestep 26/45: 2160 Seconds -> 2268 Seconds
Solving timestep 27/45: 2268 Seconds -> 2376 Seconds
Solving timestep 28/45: 2376 Seconds -> 2484 Seconds
Solving timestep 29/45: 2484 Seconds -> 2592 Seconds
Solving timestep 30/45: 2592 Seconds -> 2700 Seconds
Solving timestep 31/45: 2700 Seconds -> 2808 Seconds
Solving timestep 32/45: 2808 Seconds -> 2916 Seconds
Solving timestep 33/45: 2916 Seconds -> 3024 Seconds
Solving timestep 34/45: 3024 Seconds -> 3132 Seconds
Solving timestep 35/45: 3132 Seconds -> 3240 Seconds
Solving timestep 36/45: 3240 Seconds -> 3348 Seconds
Solving timestep 37/45: 3348 Seconds -> 3456 Seconds
Solving timestep 38/45: 3456 Seconds -> 3564 Seconds
Solving timestep 39/45: 3564 Seconds -> 1 Hour, 72 Seconds
*** Simulation complete. Solved 39 control steps in 4 Seconds, 694 Milliseconds (termination triggered by stopFunction) ***
Solving timestep 01/45: -> 1 Second, 687 Milliseconds
Solving timestep 02/45: 1 Second, 687 Milliseconds -> 3 Seconds, 375 Milliseconds
Solving timestep 03/45: 3 Seconds, 375 Milliseconds -> 6 Seconds, 750 Milliseconds
Solving timestep 04/45: 6 Seconds, 750 Milliseconds -> 13 Seconds, 500 Milliseconds
Solving timestep 05/45: 13 Seconds, 500 Milliseconds -> 27 Seconds
Solving timestep 06/45: 27 Seconds -> 54 Seconds
Solving timestep 07/45: 54 Seconds -> 108 Seconds
Solving timestep 08/45: 108 Seconds -> 162 Seconds
Solving timestep 09/45: 162 Seconds -> 216 Seconds
Solving timestep 10/45: 216 Seconds -> 270 Seconds
Solving timestep 11/45: 270 Seconds -> 324 Seconds
Solving timestep 12/45: 324 Seconds -> 378 Seconds
Solving timestep 13/45: 378 Seconds -> 432 Seconds
Solving timestep 14/45: 432 Seconds -> 486 Seconds
Solving timestep 15/45: 486 Seconds -> 540 Seconds
Solving timestep 16/45: 540 Seconds -> 594 Seconds
Solving timestep 17/45: 594 Seconds -> 648 Seconds
Solving timestep 18/45: 648 Seconds -> 702 Seconds
Solving timestep 19/45: 702 Seconds -> 756 Seconds
Solving timestep 20/45: 756 Seconds -> 810 Seconds
Solving timestep 21/45: 810 Seconds -> 864 Seconds
Solving timestep 22/45: 864 Seconds -> 918 Seconds
Solving timestep 23/45: 918 Seconds -> 972 Seconds
Solving timestep 24/45: 972 Seconds -> 1026 Seconds
Solving timestep 25/45: 1026 Seconds -> 1080 Seconds
Solving timestep 26/45: 1080 Seconds -> 1134 Seconds
Solving timestep 27/45: 1134 Seconds -> 1188 Seconds
Solving timestep 28/45: 1188 Seconds -> 1242 Seconds
Solving timestep 29/45: 1242 Seconds -> 1296 Seconds
Solving timestep 30/45: 1296 Seconds -> 1350 Seconds
Solving timestep 31/45: 1350 Seconds -> 1404 Seconds
Solving timestep 32/45: 1404 Seconds -> 1458 Seconds
Solving timestep 33/45: 1458 Seconds -> 1512 Seconds
Solving timestep 34/45: 1512 Seconds -> 1566 Seconds
Solving timestep 35/45: 1566 Seconds -> 1620 Seconds
Solving timestep 36/45: 1620 Seconds -> 1674 Seconds
Solving timestep 37/45: 1674 Seconds -> 1728 Seconds
Solving timestep 38/45: 1728 Seconds -> 1782 Seconds
*** Simulation complete. Solved 38 control steps in 5 Seconds, 519 Milliseconds (termination triggered by stopFunction) ***
Solving timestep 01/45: -> 1 Second, 125 Milliseconds
Solving timestep 02/45: 1 Second, 125 Milliseconds -> 2 Seconds, 250 Milliseconds
Solving timestep 03/45: 2 Seconds, 250 Milliseconds -> 4 Seconds, 500 Milliseconds
Solving timestep 04/45: 4 Seconds, 500 Milliseconds -> 9 Seconds
Solving timestep 05/45: 9 Seconds -> 18 Seconds
Solving timestep 06/45: 18 Seconds -> 36 Seconds
Solving timestep 07/45: 36 Seconds -> 72 Seconds
Solving timestep 08/45: 72 Seconds -> 108 Seconds
Solving timestep 09/45: 108 Seconds -> 144 Seconds
Solving timestep 10/45: 144 Seconds -> 180 Seconds
Solving timestep 11/45: 180 Seconds -> 216 Seconds
Solving timestep 12/45: 216 Seconds -> 252 Seconds
Solving timestep 13/45: 252 Seconds -> 288 Seconds
Solving timestep 14/45: 288 Seconds -> 324 Seconds
Solving timestep 15/45: 324 Seconds -> 360 Seconds
Solving timestep 16/45: 360 Seconds -> 396 Seconds
Solving timestep 17/45: 396 Seconds -> 432 Seconds
Solving timestep 18/45: 432 Seconds -> 468 Seconds
Solving timestep 19/45: 468 Seconds -> 504 Seconds
Solving timestep 20/45: 504 Seconds -> 540 Seconds
Solving timestep 21/45: 540 Seconds -> 576 Seconds
Solving timestep 22/45: 576 Seconds -> 612 Seconds
Solving timestep 23/45: 612 Seconds -> 648 Seconds
Solving timestep 24/45: 648 Seconds -> 684 Seconds
Solving timestep 25/45: 684 Seconds -> 720 Seconds
Solving timestep 26/45: 720 Seconds -> 756 Seconds
Solving timestep 27/45: 756 Seconds -> 792 Seconds
Solving timestep 28/45: 792 Seconds -> 828 Seconds
Solving timestep 29/45: 828 Seconds -> 864 Seconds
Solving timestep 30/45: 864 Seconds -> 900 Seconds
Solving timestep 31/45: 900 Seconds -> 936 Seconds
Solving timestep 32/45: 936 Seconds -> 972 Seconds
Solving timestep 33/45: 972 Seconds -> 1008 Seconds
Solving timestep 34/45: 1008 Seconds -> 1044 Seconds
Solving timestep 35/45: 1044 Seconds -> 1080 Seconds
*** Simulation complete. Solved 35 control steps in 5 Seconds, 390 Milliseconds (termination triggered by stopFunction) ***
xlabel('Capacity / mA \cdot h')
Summary
In this tutorial, we explored the basic structure of the control protocol definition and made changes to simulate cell discharge at a variety of rates. We showed that the control protocol is defined as part of the overall BattMo parameter structure. It can be modified by changing the properties of the Control structure. We learned that the total duration of the simulation is dependent on the rate of the battery discharge, and should be updated accordingly. Finally, we showed how to setup and execute a basic parameter sweep by defining a vector with different C-rates and using a for-loop to simulate the cell discharge at each rate.