Main Content

Build Model of Hybrid-Cell Battery Pack

This example shows how to build a Simscape™ system model of a hybrid-cell battery pack with two sets of cell run-time parameters. The generated battery pack model contains two types of battery modules, each with different battery cell components inside. Use this example to analyze the performance effects of combining different battery cells within a single battery system, such as power capability versus range.

To create the system model of a battery pack, you must first create the Cell, ParallelAssembly, Module, and ModuleAssembly objects that comprise the battery pack, and then use the buildBattery function. The buildBattery function creates a library in your working folder that contains a system model block of a battery pack that you can use as reference in your simulations. The run-time parameters for these models, such as the battery cell impedance or the battery open-circuit voltage, are defined after the model creation and are therefore not covered by the Battery Pack Builder classes. To define the run-time parameters, you can either specify them in the block mask of the generated Simscape models or use the MaskParameters argument of the buildBattery function. If you specify the MaskParameters argument, the function also generates a parameterization script that helps you managing the run-time parameters of the different modules and cells inside the pack.

To use the functions and objects in Simscape Battery, first import the required Simscape Battery package:

import simscape.battery.builder.*

Create Battery Pack Object in MATLAB

Battery-based energy storage is a good option for integrating intermittent renewable energy sources into the grid. To create a battery pack, you must first design and create the foundational elements of the battery pack.

This figure shows the overall process to create a battery pack object in a bottom-up approach:

A battery pack comprises multiple module assemblies. These module assemblies, in turn, comprise a number of battery modules connected electrically in series or in parallel. The battery modules are made of multiple parallel assemblies which, in turn, comprise a number of battery cells connected electrically in parallel under a specific topological configuration or geometrical arrangement.

Create Cell Objects

To create the battery Module object, first create a Cell object of prismatic format.

prismaticGeometry = PrismaticGeometry(Height = simscape.Value(0.2,"m"),...
    Length = simscape.Value(0.35,"m"), Thickness =  simscape.Value(0.07,"m"));

The PrismaticGeometry object allows you to define the pouch geometrical arrangement of the battery cell. You can specify the height, length, and thickness of the cell by setting the Height, Length, and Thickness properties of the PrismaticGeometry object. For more information on the possible geometrical arrangements of a battery cell, see the CylindricalGeometry and PouchGeometry documentation pages.

Now use this PrismaticGeometry object to create a prismatic battery cell and assign its name.

batteryCell1 = Cell(Geometry = prismaticGeometry)
batteryCell1 = 
  Cell with properties:

            Geometry: [1×1 simscape.battery.builder.PrismaticGeometry]
    CellModelOptions: [1×1 simscape.battery.builder.CellModelBlock]
                Mass: [1×1 simscape.Value]

Show all properties

batteryCell1.Name = "CellChemistryType1";

To create a Module object with a different set of cell parameters, create a Cell object of prismatic format and change its name.

batteryCell2 = Cell(Geometry = prismaticGeometry)
batteryCell2 = 
  Cell with properties:

            Geometry: [1×1 simscape.battery.builder.PrismaticGeometry]
    CellModelOptions: [1×1 simscape.battery.builder.CellModelBlock]
                Mass: [1×1 simscape.Value]

Show all properties

batteryCell2.Name = "CellChemistryType2";

For more information, see the Cell documentation page.

Create ParallelAssembly Objects

A battery parallel assembly comprise multiple battery cells connected electrically in parallel under a specific topological configuration or geometrical arrangement. In this example, you create two parallel assemblies of one prismatic cell each.

To create the ParallelAssembly objects, use the Cell object you created before and specify the NumParallelCells property according to your design.

batteryParallelAssembly1 = ParallelAssembly(Cell = batteryCell1,...
    NumParallelCells = 1)
batteryParallelAssembly1 = 
  ParallelAssembly with properties:

    NumParallelCells: 1
                Cell: [1×1 simscape.battery.builder.Cell]
            Topology: "SingleStack"
                Rows: 1
     ModelResolution: "Lumped"

Show all properties

batteryParallelAssembly2 = ParallelAssembly(Cell = batteryCell2,...
    NumParallelCells = 1)
batteryParallelAssembly2 = 
  ParallelAssembly with properties:

    NumParallelCells: 1
                Cell: [1×1 simscape.battery.builder.Cell]
            Topology: "SingleStack"
                Rows: 1
     ModelResolution: "Lumped"

Show all properties

For more information, see the ParallelAssembly documentation page.

Create Module Objects

A battery module comprises multiple parallel assemblies connected in series. In this example, you create two battery modules of 4 parallel assemblies each, with an intergap between each assembly of 0.005 meters.

To create the Module object2, use the ParallelAssembly objects you created in the previous step and specify the NumSeriesAssemblies and InterParallelAssemblyGap properties.

batteryModule1 = Module(ParallelAssembly = batteryParallelAssembly1,...
    NumSeriesAssemblies = 4, ...
    InterParallelAssemblyGap = simscape.Value(0.005,"m"), ...
    ModelResolution = "Lumped", ...
    StackingAxis="X")
batteryModule1 = 
  Module with properties:

    NumSeriesAssemblies: 4
       ParallelAssembly: [1×1 simscape.battery.builder.ParallelAssembly]
        ModelResolution: "Lumped"
         SeriesGrouping: 4
       ParallelGrouping: 1

Show all properties

batteryModule2 = Module(ParallelAssembly = batteryParallelAssembly2,...
    NumSeriesAssemblies = 4, ...
    InterParallelAssemblyGap = simscape.Value(0.005,"m"), ...
    ModelResolution = "Lumped", ...
    StackingAxis="X")
batteryModule2 = 
  Module with properties:

    NumSeriesAssemblies: 4
       ParallelAssembly: [1×1 simscape.battery.builder.ParallelAssembly]
        ModelResolution: "Lumped"
         SeriesGrouping: 4
       ParallelGrouping: 1

Show all properties

For more information, see the Module documentation page.

Create ModuleAssembly Object

A battery module assembly comprises multiple battery modules connected in series or in parallel. The battery module assembly in this example comprises the two modules you created before twice in an alternating sequence. By default, the ModuleAssembly object electrically connects the modules in series.

To create the ModuleAssembly object, use the Module objects you created in the previous step and specify the InterModuleGap and NumLevels properties.

batteryModuleAssembly = ModuleAssembly(Module = [batteryModule1,batteryModule2,batteryModule1,batteryModule2],...
    InterModuleGap = simscape.Value(0.02,"m"), ...
    NumLevels = 1)
batteryModuleAssembly = 
  ModuleAssembly with properties:

    Module: [1×4 simscape.battery.builder.Module]

Show all properties

For more information, see the ModuleAssembly documentation page.

Create Pack Object

You now have all the foundational elements to create your hybrid battery pack. A battery pack comprises multiple module assemblies connected in series or in parallel. In this example, you create a battery pack of two module assemblies.

To create the Pack object, use the ModuleAssembly object you created in the previous step.

batteryPack = Pack(ModuleAssembly = repmat(batteryModuleAssembly,1,2),...
    StackingAxis="Y");

For more information, see the Pack documentation page.

Visualize Battery Pack

To visualize the battery pack before you build the system model, use the BatteryChart object. To add default axis labels to the battery plot, use the setDefaultLabels method of the BatteryChart object.

batteryPackChart = BatteryChart(Battery = batteryPack);
batteryPackChart.setDefaultLabels

Figure contains an object of type simscape.battery.builder.batterychart.

For more information, see the BatteryChart documentation page.

Build Simscape Model for Battery Pack Object

After you have created your battery objects, you need to convert them into Simscape models to be able to use them in block diagrams. You can then use these models as reference for your system integration and requirement evaluation, cooling system design, control strategy development, hardware-in-the-loop, and many more applications.

To create a library that contains the Simscape Battery model of the Pack object you created in this example, use the buildBattery function and set the MaskInitialTargets and MaskParameters arguments. The MaskInitialTargets and MaskParameters arguments allow you to choose between default numeric values or variable names for the parameters in each Module and Parallel Assembly block in the generated library. If you set these arguments to "VariableNames", the function generates a script with all the run-time parameters and initial conditions required for simulation.

buildBattery(batteryPack,"LibraryName","hybridBatteryPack",...
    "MaskInitialTargets","VariableNames",...
    "MaskParameters","VariableNames")

The buildBattery function creates the hybridBatteryPack_lib and hybridBatteryPack SLX library files in your working directory. The hybridBatteryPack_lib library contains the Modules and ParallelAssemblies sublibraries.

To access the Simscape models of your Module and ParallelAssembly objects, open the hybridBatteryPack_lib. SLX file, double-click the sublibrary, and drag the Simscape blocks in your model.

The hybridBatteryPack library contains the Simscape models of your ModuleAssembly and Pack objects.

The Simscape models of your ModuleAssembly and Pack objects are subsystems. You can look inside these subsystems by opening the hybridBatteryPack_lib SLX file and double-click the subsystem.

MaskParameters and MaskInitialTargets

The MaskInitialTargets and MaskParameters arguments allow you to choose between default numeric values or variable names for the parameters and initial conditions in each Module and Parallel Assembly block in the generated library.

By setting the MaskParameters argument to VariableNames, the buildBattery function generates a hybridBatteryPack_param M file where you can individually assign all the module and cell parameters, like the resistance, the open circuit voltage, and other parameters, for all the types of battery modules inside your battery pack. If you also set the MaskInitialTargets argument to VariableNames, then the generated M file contains the mask parameter definition at the beginning.

By setting the MaskInitialTargets argument to VariableNames, the buildBattery function generates a hybridBatteryPack_param M file where you can individually assign the initial temperature, state-of-charge, and other conditions, for all your battery modules in your battery pack. If you also set the MaskParameters argument to VariableNames, then the generated M file contains the initial targets definition at the end.

Check the effect of setting the MaskParameters and the MaskInitialTargets arguments to VariableNames. Open the hybridBatteryPack_lib SLX file and navigate to the ModuleAssembly1 subsystem by double-clicking the Pack1 subsystem. Double-click on the Module1 block to open the Property Inspector.

A specific variable name is associated to the values of each parameter in the Main section of the Module1 block. You can then easily specify these values inside the hybridBatteryPack_param M file without having to change them inside the model by opening the Property Inspector of each block individually.

Copyright 2022 The MathWorks, Inc.