Note

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

open runGenericStepControlCycle

Example using generic control input with cycles

We use a generic control input, as described in json schema documentation.

Input setup

We load material parameter input parameters

[1]:
jsonstruct_material = parseBattmoJson(fullfile('ParameterData'        , ...
                                               'BatteryCellParameters', ...
                                               'LithiumIonBatteryCell', ...
                                               'lithium_ion_battery_nmc_graphite.json'));

We load geometry parameter input parameters

[2]:
jsonstruct_geometry = parseBattmoJson(fullfile('Examples', 'JsonDataFiles', 'geometryChen.json'));

We load the generic control parameter we want to use

[3]:
jsonstruct_control  = parseBattmoJson(fullfile('Examples', 'JsonDataFiles', 'generic_step_control_cycle_example.json'));

We print it to command window

[4]:
viewJsonStruct(jsonstruct_control)
[4]:
{
  "Control": {
    "controlPolicy": "Generic",
    "controlsteps": [
      {
        "controltype": "cycle",
        "numberOfcycles": 3,
        "cycleControlSteps": [
          {
            "controltype": "current",
            "value": 5,
            "direction": "discharge",
            "termination": {
              "quantity": "voltage",
              "value": 3,
              "comparison": "below"
            },
            "timeStepSize": 100
          },
          {
            "controltype": "voltage",
            "value": 3,
            "termination": {
              "quantity": "current",
              "value": 0.0001,
              "comparison": "absolute value below"
            },
            "timeStepSize": 100
          },
          {
            "controltype": "current",
            "value": 5,
            "direction": "charge",
            "termination": {
              "quantity": "voltage",
              "value": 4,
              "comparison": "above"
            },
            "timeStepSize": 100
          }
        ]
      },
      {
        "controltype": "rest",
        "termination": {
          "value": 1000,
          "quantity": "time"
        },
        "timeStepSize": 100
      }
    ]
  }
}

We remove the fields that are not relevant for this example. This is done to simplify the input parameters and focus on the relevant aspects of the model.

[5]:
jsonstruct_material = removeJsonStructFields(jsonstruct_material              , ...
                                             {'Control', 'DRate'}             , ...
                                             {'Control', 'controlPolicy'}     , ...
                                             {'Control', 'upperCutoffVoltage'}, ...
                                             {'Control', 'rampupTime'}        , ...
                                             {'Control', 'lowerCutoffVoltage'});

We merge all the input structures

[6]:
jsonstruct = mergeJsonStructs({jsonstruct_material, ...
                               jsonstruct_geometry, ...
                               jsonstruct_control});

We do not include thermal effects and the current collectors in this example to simplify the model.

[7]:
jsonstruct.use_thermal                = false;
jsonstruct.include_current_collectors = false;

We run the simulation

[8]:
output = runBatteryJson(jsonstruct);

Plotting

[9]:
states = output.states;

E = cellfun(@(x) x.Control.E, states);
I = cellfun(@(x) x.Control.I, states);
time = cellfun(@(x) x.time, states);

figure
plot(time/hour, E, '*-', 'linewidth', 3);
grid on
xlabel 'time  / h';
ylabel 'potential  / V';
[9]:
figure_0.png
[10]:

figure plot(time/hour, I, '*-', 'linewidth', 3); grid on xlabel 'time / h'; ylabel 'Current / A';
[10]:
figure_1.png