Main Content

buildBattery

Build custom library blocks from battery objects

Description

example

buildBattery(battery,Name=Value) generates one or more custom Simscape™ library files from the battery object battery. You can build a custom Simscape library file from the ParallelAssembly, Module, ModuleAssembly, and Pack objects.

Note

When you generate a library file for the ParallelAssembly and Module objects, the buildBattery function first generates the corresponding Simscape SSC file and then calls the ssc_build function to generate the library file.

The blocks that are generated from ModuleAssembly and Pack objects are Simulink® subsystems that comprise parallel assemblies and module blocks.

Examples

collapse all

Create a Pack object by creating a Cell, ParallelAssembly, Module, and ModuleAssembly objects, in this order.

import simscape.battery.builder.*;
batteryCell = Cell(Geometry=CylindricalGeometry);
pSet = ParallelAssembly(Cell=batteryCell,NumParallelCells=48,Topology="Hexagonal",Rows=4);
module = Module(ParallelAssembly=pSet,NumSeriesAssemblies=4);
moduleAssembly = ModuleAssembly(Module=repmat(module,1,2));
pack = Pack(ModuleAssembly=repmat(moduleAssembly,1,4),BalancingStrategy="Passive");
pack = 

  Pack with properties:

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

Use the buildBattery function to build the library file from the Pack object. Provide the name-value arguments to the function to give the library a meaningful name and to specify the output folder.

buildBattery(pack,LibraryName="myBatteries",Directory="C:\Work\BatteryFolder")
Generating Simulink library 'myBatteries_lib' in the current directory 'C:\Work\BatteryFolder' ...

This figure shows the content of the folder after the function finishes generating the library files:

Open the generated library myBatteries_lib SLX file to access the ParallelAssembly and Module objects as Simscape blocks.

Open the generated library myBatteries SLX file to access the ModuleAssembly and Pack objects as Simscape subsystems.

Input Arguments

collapse all

Battery object from which to generate the custom Simscape library blocks, specified as a ParallelAssembly, Module, ModuleAssembly, or Pack object.

Note

When you build a battery object, the buildBattery function also builds all of its subcomponents. For example, if you build a Pack object, this function generates custom Simscape library blocks for the ModuleAssembly, Module, and ParallelAssembly objects that comprise the pack.

Example: buildBattery(batteryPack) builds a block library from a Pack battery object named batteryPack.

Name-Value Arguments

Example: buildBattery(batteryPack,LibraryName="myBatteries",Directory="C:\Work\batteryLibFolder")

Name of the block library file generated from the battery object, specified as a character vector or a string scalar. The name of the library file generated from a ParallelAssembly or Module object has the suffix _lib.

Example: buildBattery(batteryPack,LibraryName="myBatteries") builds two libraries named myBatteries and myBatteries_lib from a Pack battery object named batteryPack.

Name and location of the folder where you want to store the generated block library file, specified as a character vector or a string scalar.

Example: buildBattery(batteryPack,Directory="C:\Work\batteryLibFolder") builds a library from a Pack battery object named batteryPack in the folder C:\Work\batteryLibFolder.

Option to use default numeric values or variable names for the parameters in each type of module and parallel assembly defined in the Battery property. If you set this argument to "VariableNames", the function generates a script with all the run-time parameters required for simulation.

Option to use default numeric values or variable names for the initial targets in each type of module and parallel assembly defined in the Battery property. If you set this argument to "VariableNames", the function generates a script with all the initial conditions required for simulation.

Version History

Introduced in R2022b