メインコンテンツ

Simulate Battery Using Doyle-Fuller-Newman Model

Since R2026a

This example shows how you can use a Doyle-Fuller-Newman (DFN) battery model to simulate the behavior of a lithium-ion battery cell under various load conditions. The DFN model, also called pseudo-two-dimensional (P2D) model, provides a detailed physical representation of the electrochemical processes that occur inside a battery, such as lithium diffusion, electrochemical reactions, charge conservation, and heat generation dynamics.

Open Model

Open the DFN model. In this model, the BatteryDFN custom block represents a single battery cell. To set the electro-thermal boundary conditions, the model uses the Controlled Current Source and Controlled Temperature Source blocks. You can modify these boundary conditions to suit your battery load case and application. In this example, you simulate the BatteryDFN block under discharge conditions.

modelName = "DFN";
open_system(modelName);

BatteryDFN block diagram.

Simulate DFN Model Under Constant Discharge Current

The DFNParameterSetDefault script stores the parameters and initial conditions of the BatteryDFN block. You must run this script each time you run this model.

run("DFNParameterSetDefault.m")

To simulate the DFN model under a constant discharge current, you must first define the initial conditions. There are four required initial conditions: the electrolyte concentration, the anode and cathode concentrations, and the temperature. To discharge the battery and avoid simulation errors, such as negative state-of-charge conditions:

  • The anode initial concentration must be greater than the maximum anode concentration multiplied by the minimum anode stoichiometry.

  • The cathode initial concentration must be lower than the maximum cathode concentration multiplied by the maximum cathode stoichiometry.

InitialElectrolyteConcentration = 1200; % mol/m^3
InitialConcentrationAnode = 30555*0.811; % mol/m^3
InitialConcentrationCathode = 22806*0.035; % mol/m^3
InitialTemperature = 298.15; % K

This example assumes that a discharge current is a negative current and a charge current is a positive current.

Current = -1; % Amps
SimulationTime = 3600; % Seconds

Run the discharge simulation.

dfnOut = sim("DFN"); 

To plot the simulation results, run the DFNOutputViewer script. This script plots:

  1. The key battery states as a function of time

  2. The battery electrochemical states across the length of the cell stack

DFNOutputViewer

Figure DFN Model Results contains 6 axes objects. Axes object 1 with title Time Series Plot:batteryCurrent, xlabel Time (seconds), ylabel batteryCurrent (A) contains an object of type line. Axes object 2 with title Time Series Plot:batteryStateOfCharge, xlabel Time (seconds), ylabel batteryStateOfCharge contains an object of type line. Axes object 3 with title Time Series Plot:batteryTemperature, xlabel Time (seconds), ylabel batteryTemperature (K) contains an object of type line. Axes object 4 with title Time Series Plot:batteryVoltage, xlabel Time (seconds), ylabel batteryVoltage (V) contains an object of type line. Axes object 5 with title Time Series Plot:surfacePotentialAnode, xlabel Time (seconds), ylabel surfacePotentialAnode (V) contains 20 objects of type line. Axes object 6 with title Time Series Plot:surfacePotentialCathode, xlabel Time (seconds), ylabel surfacePotentialCathode (V) contains 20 objects of type line.

Figure DFN Electrochemical States contains 8 axes objects. Axes object 1 with title Anode Potential, xlabel Anode thickness (m), ylabel Potential (V) contains 2 objects of type line. These objects represent Start, End. Axes object 2 with title Liquid Potential, xlabel Cell stack distance (m), ylabel Electrolyte potential (V) contains 2 objects of type line. These objects represent Start, End. Axes object 3 with title Cathode Potential, xlabel Cathode thickness (m), ylabel Potential (V) contains 2 objects of type line. These objects represent Start, End. Axes object 4 with title Anode Polarization, xlabel Anode thickness (m), ylabel Potential drop (V) contains 2 objects of type line. These objects represent Start, End. Axes object 5 with title Current Density Anode, xlabel Anode thickness (m), ylabel Current density (A/m^3) contains 2 objects of type line. These objects represent Start, End. Axes object 6 with title Electrolyte Concentration, xlabel Cell stack distance (m), ylabel Electrolyte concentration (mol/m^3) contains 2 objects of type line. These objects represent Start, End. Axes object 7 with title Current Density Cathode, xlabel Cathode thickness (m), ylabel Current density (A/m^3) contains 2 objects of type line. These objects represent Start, End. Axes object 8 with title Cathode Polarization, xlabel Cathode thickness (m), ylabel Potential drop (V) contains 2 objects of type line. These objects represent Start, End.

To view how the battery electrochemical states dynamically vary over the cell stack distance, run the createDFNAnimation script. In the MATLAB® Command Window, run:

createDFNAnimation(dfnOut)

Verify Model

To verify the DFN model equations, compare the output voltage and the state of charge of the BatteryDFN block against the output of an open-source DFN model implemented in the Python Battery Mathematical Modelling (PyBaMM) package. PyBaMM is a leading open-source battery electrochemical modeling tool, making it a reliable reference for comparison. These plots show a 1C discharge rate using a PyBaMM default parameter set.

There is good agreement between the terminal voltage and state-of-charge outputs from both implementations of the DFN model at 1C discharge rate and the selected initial temperature.

Model Description

The BatteryDFN block in this example implements these equations:

This figure shows how the equations are spatially discretized:

These tables contain additional information about the variables, parameters, and intermediate calculations of the BatteryDFN block.

References

[1] Sulzer, V., Marquis, S. G., Timms, R., Robinson, M., & Chapman, S. J. (2021). “Python Battery Mathematical Modelling (PyBaMM)”. Journal of Open Research Software, 9 (1), 14. https://doi.org/10.5334/jors.309.

[2] G. Richardson, I. Korotkin, "Heat generation and a conservation law for chemical energy in Li-ion batteries", Electrochimica Acta, Volume 392, 2021, 138909, ISSN 0013-4686, https://doi.org/10.1016/j.electacta.2021.138909.

[3] Doyle, Marc and Fuller, Thomas F. and Newman, John. "Modeling of Galvanostatic Charge and Discharge of the Lithium/Polymer/Insertion Cell". Journal of The Electrochemical Society, vol. 140, no. 6, 1993, pp. 1526. https://doi.org/10.1149/1.2221597.

[4] Zeng, Yi, et al. ‘Efficient Conservative Numerical Schemes for 1D Nonlinear Spherical Diffusion Equations with Applications in Battery Modeling’. Journal of The Electrochemical Society, vol. 160, no. 9, 2013, pp. A1565–71. DOI.org (Crossref), https://doi.org/10.1149/2.102309jes.

See Also

| |