Skip to content

Cycling a battery 40 times with a constant current constant voltage (cccv) control

julia
using BattMo, GLMakie

We use the setup provided in the p2d_40.json file. In particular, see the data under the Control key.

julia
file_path_cell = parameter_file_path("cell_parameters", "chen_2020.json")
file_path_cycling = parameter_file_path("cycling_protocols", "cccv.json")


cell_parameters = load_cell_parameters(; from_file_path = file_path_cell)
cycling_protocol = load_cycling_protocol(; from_file_path = file_path_cycling)


model = LithiumIonBattery();

cycling_protocol["TotalNumberOfCycles"] = 10

sim = Simulation(model, cell_parameters, cycling_protocol);


output = solve(sim;)
✔️ Validation of ModelSettings passed: No issues found.
──────────────────────────────────────────────────
✔️ Validation of CellParameters passed: No issues found.
──────────────────────────────────────────────────
✔️ Validation of CyclingProtocol passed: No issues found.
──────────────────────────────────────────────────
✔️ Validation of SimulationSettings passed: No issues found.
──────────────────────────────────────────────────
✔️ Validation of SolverSettings passed: No issues found.
──────────────────────────────────────────────────
Jutul: Simulating 2 days, 2 hours as 3600 report steps
╭────────────────┬────────────┬────────────────┬─────────────╮
 Iteration type    Avg/step    Avg/ministep        Total 
 2599 steps  2717 ministeps     (wasted) 
├────────────────┼────────────┼────────────────┼─────────────┤
 Newton         │    2.73451 │        2.61575 │ 7107 (1620) │
 Linearization  │    3.77992 │        3.61575 │ 9824 (1701) │
 Linear solver  │    2.73451 │        2.61575 │ 7107 (1620) │
 Precond apply  │        0.0 │            0.0 │       0 (0) │
╰────────────────┴────────────┴────────────────┴─────────────╯
╭───────────────┬────────┬────────────┬─────────╮
 Timing type      Each    Relative    Total 
     ms  Percentage        s 
├───────────────┼────────┼────────────┼─────────┤
 Properties    │ 0.0783 │     2.68 % │  0.5563 │
 Equations     │ 1.1857 │    56.08 % │ 11.6486 │
 Assembly      │ 0.1251 │     5.92 % │  1.2289 │
 Linear solve  │ 0.4897 │    16.75 % │  3.4800 │
 Linear setup  │ 0.0000 │     0.00 % │  0.0000 │
 Precond apply │ 0.0000 │     0.00 % │  0.0000 │
 Update        │ 0.0735 │     2.52 % │  0.5226 │
 Convergence   │ 0.1541 │     7.29 % │  1.5139 │
 Input/Output  │ 0.0285 │     0.37 % │  0.0773 │
 Other         │ 0.2455 │     8.40 % │  1.7445 │
├───────────────┼────────┼────────────┼─────────┤
 Total         │ 2.9228 │   100.00 % │ 20.7721 │
╰───────────────┴────────┴────────────┴─────────╯

Plot the results

We can plot a simple voltage current dashboard

julia
plot_dashboard(output, plot_type = "simple")

Or plot specific variables

julia
plot_output(output, ["DischargeCapacity vs CycleIndex"])
plot_output(output, ["CumulativeCapacity vs Time"])

We can check in the overview which variables are available and can be plotted against each other

julia
print_info(output)

Case: TIME_SERIES
================================================================================================================================================================
Variable                                                         Unit                          Shape
----------------------------------------------------------------------------------------------------------------------------------------------------------------
CumulativeCapacity                                               Ah                            (nTime,)
Current                                                          A                             (nTime,)
CycleNumber                                                      1                             (nTime,)
NetCapacity                                                      Ah                            (nTime,)
Time                                                             s                             (nTime,)
Voltage                                                          V                             (nTime,)
================================================================================================================================================================

Case: METRICS
================================================================================================================================================================
Variable                                                         Unit                          Shape
----------------------------------------------------------------------------------------------------------------------------------------------------------------
ChargeCapacity                                                   Ah                            (nCycleIndex,)
ChargeEnergy                                                     J                             (nCycleIndex,)
CycleIndex                                                       1                             (nCycleIndex,)
DischargeCapacity                                                Ah                            (nCycleIndex,)
DischargeEnergy                                                  J                             (nCycleIndex,)
RoundTripEfficiency                                              %                             (nCycleIndex,)
================================================================================================================================================================

Case: STATES
================================================================================================================================================================
Variable                                                         Unit                          Shape
----------------------------------------------------------------------------------------------------------------------------------------------------------------
ElectrolyteCharge                                                C                             (nTime, nPosition)
ElectrolyteConcentration                                         mol·m⁻³                       (nTime, nPosition)
ElectrolyteConductivity                                          S·m⁻¹                         (nTime, nPosition)
ElectrolyteDiffusivity                                           m²·s                          (nTime, nPosition)
ElectrolyteMass                                                  g                             (nTime, nPosition)
ElectrolytePotential                                             V                             (nTime, nPosition)
NegativeElectrodeActiveMaterialCharge                            C                             (nTime, nPosition)
NegativeElectrodeActiveMaterialDiffusionCoefficient              m²·s⁻¹                        (nTime, nPosition)
NegativeElectrodeActiveMaterialOpenCircuitPotential              mol·m⁻²·s⁻¹                   (nTime, nPosition)
NegativeElectrodeActiveMaterialParticleConcentration             mol·L⁻¹                       (nTime, nPosition, nNegativeElectrodeActiveMaterialRadius)
NegativeElectrodeActiveMaterialPotential                         V                             (nTime, nPosition)
NegativeElectrodeActiveMaterialRadius                            m                             (nNegativeElectrodeActiveMaterialRadius,)
NegativeElectrodeActiveMaterialReactionRateConstant              V                             (nTime, nPosition)
NegativeElectrodeActiveMaterialSurfaceConcentration              mol·L⁻¹                       (nTime, nPosition)
NegativeElectrodeActiveMaterialTemperature                       T                             (nTime, nPosition)
Position                                                         m                             (nPosition,)
PositiveElectrodeActiveMaterialCharge                            C                             (nTime, nPosition)
PositiveElectrodeActiveMaterialDiffusionCoefficient              m²·s⁻¹                        (nTime, nPosition)
PositiveElectrodeActiveMaterialOpenCircuitPotential              V                             (nTime, nPosition)
PositiveElectrodeActiveMaterialParticleConcentration             mol·L⁻¹                       (nTime, nPosition, nPositiveElectrodeActiveMaterialRadius)
PositiveElectrodeActiveMaterialPotential                         V                             (nTime, nPosition)
PositiveElectrodeActiveMaterialRadius                            m                             (nPositiveElectrodeActiveMaterialRadius,)
PositiveElectrodeActiveMaterialReactionRateConstant              mol·m⁻²·s⁻¹                   (nTime, nPosition)
PositiveElectrodeActiveMaterialSurfaceConcentration              mol·L⁻¹                       (nTime, nPosition)
PositiveElectrodeActiveMaterialTemperature                       T                             (nTime, nPosition)
================================================================================================================================================================

Example on GitHub

If you would like to run this example yourself, it can be downloaded from the BattMo.jl GitHub repository as a script.


This page was generated using Literate.jl.