Tutorial 7 - A Simple P4D Simulation

Introduction

In this tutorial, we will use a simple P4D simulation to explore the effects of battery cell architecture. After completing this tutorial, you should have a working knowledge of:

Construct the Model from Different Sources

Let's say that you parameterize some cell materials and put that data in a JSON file. Then you get some description of your cell geometry, and you put that data in another JSON file. Now you want to combine those descriptions into a single model and simulate it using some pre-defined contol protocol and simulation settings in other files. How can we combine those easily, without having to do any recoding?
To do that, we can simply make use of the mergeJsonStructs function in BattMo.
First, let’s define our cell materials. We have provided a JSON file that contains material properties for a NMC and Graphite active materials, which we can parse as a BattMo structure:
% parse material definitions as a BattMo structure
jsonfilename = 'ParameterData/BatteryCellParameters/LithiumIonBatteryCell/lithium_ion_battery_nmc_graphite.json';
jsonstruct_material = parseBattmoJson(jsonfilename);
Next, we have defined the cell geometry properties in a separate JSON file that we can also parse into BattMo:
% parse cell geometry specifications as a BattMo structure
jsonfilename = 'Examples/jsondatafiles/geometry3d.json';
jsonstruct_geometry = parseBattmoJson(jsonfilename);
Let's have a closer look at the cell geometry specification.
disp(jsonstruct_geometry.Geometry)
case: '3D-demo' width: 0.0100 height: 0.0200 Nw: 10 Nh: 10
Here we can see that the width and height dimensions of the cell are defined, along with the number of discretizations in each direction, and a case description. The case sets the type of simulation to be performed. Here it is set to '3D-demo', to BattMo knows to set up a P4D mesh.
We can take the same approach for the remaining parameters, as shown below, for the control protocol, simulation settings, and output settings:
% control protocol
jsonfilename = fullfile('Examples', 'jsondatafiles', 'cc_discharge_control.json');
jsonstruct_control = parseBattmoJson(jsonfilename);
 
% simulation settings
jsonfilename = fullfile('Examples', 'jsondatafiles', 'simulation_parameters.json');
jsonstruct_simparams = parseBattmoJson(jsonfilename);
 
% output settings
jsonfilename = fullfile('Examples', 'jsondatafiles', 'extra_output.json');
jsonstruct_output = parseBattmoJson(jsonfilename);
Now, we can merge these parameter definitions into a single parameter set and run the simulation:
% combine the parameter structures from the different sources into a single
% BattMo structure
jsonstruct = mergeJsonStructs({jsonstruct_geometry , ...
jsonstruct_material , ...
jsonstruct_control , ...
jsonstruct_simparams, ...
jsonstruct_output , ...
});
parameter include_current_collectors is assigned twice with different values. we use the value from first jsonstruct. parameter ThermalModel.externalHeatTransferCoefficient is assigned twice with different values. we use the value from first jsonstruct.
we store the output as a cell array so we can compare results across different simulation runs in this tutorial; here we instantiate an empty cell array
output = cell(2,1);
 
% run the simulation
output{1} = runBatteryJson(jsonstruct);
Solving timestep 01/45: -> 4 Seconds, 218 Milliseconds Solving timestep 02/45: 4 Seconds, 218 Milliseconds -> 8 Seconds, 437 Milliseconds Solving timestep 03/45: 8 Seconds, 437 Milliseconds -> 16 Seconds, 875 Milliseconds Solving timestep 04/45: 16 Seconds, 875 Milliseconds -> 33 Seconds, 750 Milliseconds Solving timestep 05/45: 33 Seconds, 750 Milliseconds -> 67 Seconds, 500 Milliseconds Solving timestep 06/45: 67 Seconds, 500 Milliseconds -> 135 Seconds Solving timestep 07/45: 135 Seconds -> 270 Seconds Solving timestep 08/45: 270 Seconds -> 405 Seconds Solving timestep 09/45: 405 Seconds -> 540 Seconds Solving timestep 10/45: 540 Seconds -> 675 Seconds Solving timestep 11/45: 675 Seconds -> 810 Seconds Solving timestep 12/45: 810 Seconds -> 945 Seconds Solving timestep 13/45: 945 Seconds -> 1080 Seconds Solving timestep 14/45: 1080 Seconds -> 1215 Seconds Solving timestep 15/45: 1215 Seconds -> 1350 Seconds Solving timestep 16/45: 1350 Seconds -> 1485 Seconds Solving timestep 17/45: 1485 Seconds -> 1620 Seconds Solving timestep 18/45: 1620 Seconds -> 1755 Seconds Solving timestep 19/45: 1755 Seconds -> 1890 Seconds Solving timestep 20/45: 1890 Seconds -> 2025 Seconds Solving timestep 21/45: 2025 Seconds -> 2160 Seconds Solving timestep 22/45: 2160 Seconds -> 2295 Seconds Solving timestep 23/45: 2295 Seconds -> 2430 Seconds Solving timestep 24/45: 2430 Seconds -> 2565 Seconds Solving timestep 25/45: 2565 Seconds -> 2700 Seconds Solving timestep 26/45: 2700 Seconds -> 2835 Seconds Solving timestep 27/45: 2835 Seconds -> 2970 Seconds Solving timestep 28/45: 2970 Seconds -> 3105 Seconds Solving timestep 29/45: 3105 Seconds -> 3240 Seconds Solving timestep 30/45: 3240 Seconds -> 3375 Seconds Solving timestep 31/45: 3375 Seconds -> 3510 Seconds Solving timestep 32/45: 3510 Seconds -> 1 Hour, 45 Seconds *** Simulation complete. Solved 32 control steps in 20 Seconds, 295 Milliseconds (termination triggered by stopFunction) ***

Visualize the Results

We plot the model using plotBatteryGrid (note that the different axis are scaled differently)
% create a shorthand variable for the model
model = output{1}.model;
 
% use the plotBatteryGrid function to show the grid
plotBatteryGrid(model)
 
% make the axis tight and set the camera viewing angle
axis tight
view(45,45)
We find a extensive set of plotting functions in MRST. You may be interested to have a look at the Visualization Tutorial. Let us use the plotGrid and plotCellData to plot the surface particle concentrations in both electrode at a given time step.
% set the timestep we want to visualize
timestep = 20;
 
% get the state of the simulation at the given timestep
state = output{1}.states{timestep};
 
% create a new figure
figure()
 
% plot the surface concentration of lithium in the negative electrode active material
plotCellData(model.NegativeElectrode.Coating.grid, state.NegativeElectrode.Coating.ActiveMaterial.SolidDiffusion.cSurface/(mol/litre))
 
% plot the surface concentration of lithium in the positive electrode active material
plotCellData(model.PositiveElectrode.Coating.grid, state.PositiveElectrode.Coating.ActiveMaterial.SolidDiffusion.cSurface/(mol/litre))
 
% add a colorbar
colorbar()
 
% make the axis tight and set the camera viewing angle
axis tight
view(45,45)
 
% add plot annotations
title('Active Material Surface Lithium Concentration / mol \cdot L^{-1}');

Compare with a P2D Simulation

% change the setup of the model to consider a P2D case
jsonstruct.Geometry.case = '1D';
jsonstruct.Geometry.faceArea = jsonstruct.Geometry.width * jsonstruct.Geometry.height;
 
% update the total time of the simulation
jsonstruct.TimeStepping.totalTime = (1./jsonstruct.Control.CRate) .* 3600 .* 1.1;
 
% run the simulation
output{2} = runBatteryJson(jsonstruct);
Solving timestep 01/45: -> 3 Seconds, 93 Milliseconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.006595e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.007076e-16.
Solving timestep 02/45: 3 Seconds, 93 Milliseconds -> 6 Seconds, 187 Milliseconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.034196e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.034801e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.105632e-16.
Solving timestep 03/45: 6 Seconds, 187 Milliseconds -> 12 Seconds, 375 Milliseconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.040513e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.041246e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.020084e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.020974e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.049308e-16.
Solving timestep 04/45: 12 Seconds, 375 Milliseconds -> 24 Seconds, 750 Milliseconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.923222e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.931575e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.805403e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.810571e-17.
Solving timestep 05/45: 24 Seconds, 750 Milliseconds -> 49 Seconds, 500 Milliseconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.806032e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.807671e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.697125e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.696966e-17.
Solving timestep 06/45: 49 Seconds, 500 Milliseconds -> 99 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.740215e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.739466e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.742620e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.741541e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.701713e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.699611e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.747791e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.746187e-17.
Solving timestep 07/45: 99 Seconds -> 198 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.655260e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.649862e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.631443e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.623418e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.638397e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.634393e-17.
Solving timestep 08/45: 198 Seconds -> 297 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.607668e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.607211e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.626054e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.629279e-17.
Solving timestep 09/45: 297 Seconds -> 396 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.601777e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.631298e-17.
Solving timestep 10/45: 396 Seconds -> 495 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.628287e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.669969e-17.
Solving timestep 11/45: 495 Seconds -> 594 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.667429e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.717001e-17.
Solving timestep 12/45: 594 Seconds -> 693 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.715418e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.770844e-17.
Solving timestep 13/45: 693 Seconds -> 792 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.769881e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.829922e-17.
Solving timestep 14/45: 792 Seconds -> 891 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.829317e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.893143e-17.
Solving timestep 15/45: 891 Seconds -> 990 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.892748e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.959788e-17.
Solving timestep 16/45: 990 Seconds -> 1089 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.959518e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.002937e-16.
Solving timestep 17/45: 1089 Seconds -> 1188 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.002914e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.010134e-16.
Solving timestep 18/45: 1188 Seconds -> 1287 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.010059e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.017268e-16.
Solving timestep 19/45: 1287 Seconds -> 1386 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.017258e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.024591e-16.
Solving timestep 20/45: 1386 Seconds -> 1485 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.024599e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.032066e-16.
Solving timestep 21/45: 1485 Seconds -> 1584 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.032042e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.039577e-16.
Solving timestep 22/45: 1584 Seconds -> 1683 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.039596e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.047296e-16.
Solving timestep 23/45: 1683 Seconds -> 1782 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.047337e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.055300e-16.
Solving timestep 24/45: 1782 Seconds -> 1881 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.055317e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.063540e-16.
Solving timestep 25/45: 1881 Seconds -> 1980 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.063539e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.071997e-16.
Solving timestep 26/45: 1980 Seconds -> 2079 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.071996e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.080680e-16.
Solving timestep 27/45: 2079 Seconds -> 2178 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.080688e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.089616e-16.
Solving timestep 28/45: 2178 Seconds -> 2277 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.089643e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.098875e-16.
Solving timestep 29/45: 2277 Seconds -> 2376 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.098926e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.108560e-16.
Solving timestep 30/45: 2376 Seconds -> 2475 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.108588e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.118510e-16.
Solving timestep 31/45: 2475 Seconds -> 2574 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.118440e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.128535e-16.
Solving timestep 32/45: 2574 Seconds -> 2673 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.128573e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.138996e-16.
Solving timestep 33/45: 2673 Seconds -> 2772 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.138931e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.149473e-16.
Solving timestep 34/45: 2772 Seconds -> 2871 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.149426e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.160084e-16.
Solving timestep 35/45: 2871 Seconds -> 2970 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.160110e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.171070e-16.
Solving timestep 36/45: 2970 Seconds -> 3069 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.171046e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.182232e-16.
Solving timestep 37/45: 3069 Seconds -> 3168 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.182135e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.193370e-16.
Solving timestep 38/45: 3168 Seconds -> 3267 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.193371e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.204772e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.204699e-16.
Solving timestep 39/45: 3267 Seconds -> 3366 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.204784e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.216266e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.216013e-16.
Solving timestep 40/45: 3366 Seconds -> 3465 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.216366e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.228040e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.225995e-16.
Solving timestep 41/45: 3465 Seconds -> 3564 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.230241e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.235722e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.235441e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.239357e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.242162e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.242144e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.247199e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.248869e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.248871e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.254259e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.255426e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.254052e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.255328e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.255328e-16.
Solving timestep 42/45: 3564 Seconds -> 1 Hour, 63 Seconds
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.266579e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.267338e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.274214e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.274825e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.281083e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.281602e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.287551e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.288007e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.293830e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.294238e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.300062e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.300431e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.306340e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.306677e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.312724e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.313033e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.319250e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.319536e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.325943e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.326209e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.332821e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.333069e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.339895e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.340127e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.347176e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.347394e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.354673e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.354878e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.362394e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.362587e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.370350e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.370532e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.378551e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.378725e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.387013e-16.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.387178e-16.
*** Simulation complete. Solved 42 control steps in 6 Seconds, 514 Milliseconds (termination triggered by stopFunction) ***
In this case, MATLAB sends many warnings about the ill-conditionness of the system. The ill-conditionness appears to come mainly from the very high ratio between the electronic conductivity of the current collectors and the other components. we now plot the discharge for the two systems,
% get the states from the P2D model
states_P2D = output{2}.states;
 
% extract the time and voltage quantities
time_P2D = cellfun(@(state) state.time, states_P2D);
voltage_P2D = cellfun(@(state) state.('Control').E, states_P2D);
 
% get the states from the P4D model
states_P4D = output{1}.states;
 
% extract the time and voltage quantities
time_P4D = cellfun(@(state) state.time, states_P4D);
voltage_P4D = cellfun(@(state) state.('Control').E, states_P4D);
 
% plot the discharge curves together in a new figure
figure();
plot((time_P2D/hour), voltage_P2D, '-', 'linewidth', 3)
hold on
plot((time_P4D/hour), voltage_P4D, '-', 'linewidth', 3)
xlabel('Time / h')
ylabel('Cell Voltage / V')
legend('P2D', 'P4D')

Summary

In this tutorial, we learned how to create a simple P4D simulation in BattMo. First, we explored how to combine parameter sets coming from a handful of different files into a single coherent BattMo model description. Then we had a closer look into the Geometry description to see how BattMo knows how to setup a P4D or P2D type model. After running the P4D simulation, we learned how to visualize simulation results on a 3D grid. For comparison, we ran the same model in a P2D configuration and plotted the discharge curves together. This showed that the results can diverge somewhat due to the effects of the tabs and non-ideal transport in the electrode plane. These results show that P4D models can yield important insight that may be lost in the averaged approach of P2D models.