Note

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

open runGenericStepControlSimple

Example using generic control input

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_simple_example.json'));

We print it to command window

[4]:
viewJsonStruct(jsonstruct_control)
[4]:
{
  "Control": {
    "controlPolicy": "Generic",
    "controlsteps": [
      {
        "controltype": "rest",
        "termination": {
          "quantity": "time",
          "value": 4000
        },
        "timeStepSize": 600
      },
      {
        "controltype": "current",
        "value": 1,
        "direction": "discharge",
        "termination": {
          "quantity": "voltage",
          "value": 3,
          "comparison": "below"
        },
        "timeStepSize": 600
      },
      {
        "controltype": "voltage",
        "value": 3,
        "termination": {
          "value": 0.0001,
          "quantity": "current",
          "comparison": "absolute value below"
        },
        "timeStepSize": 600
      },
      {
        "controltype": "current",
        "value": 1,
        "direction": "charge",
        "termination": {
          "quantity": "voltage",
          "value": 4,
          "comparison": "above"
        },
        "timeStepSize": 600
      },
      {
        "controltype": "rest",
        "termination": {
          "quantity": "time",
          "value": 4000
        },
        "timeStepSize": 600
      }
    ]
  }
}

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