Main Content

Reuse Compilation Artifacts of Textual Components

Scalable compilation also lets you reuse compilation artifacts of repeated textual components. The CompileReuse attribute lets you specify whether the components are reusable or not. If set to true, the compilation artifacts for these components are reusable. The default is false. This attribute is available for components only.

For example, consider a model similar to the Lithium-Ion Battery Pack with Fault Using Arrays example. (For a detailed description of this model, see Case Study — Battery Pack with Fault Using Arrays.) The battery_pack component models the battery pack as an array of battery_cell components connected to an array of thermal conduction components from the Foundation library. In the battery_pack component file, you can use the CompileReuse attribute to specify which component arrays are reusable:

component battery_pack
... 
for i =1:Ncells
    components(ExternalAccess=none,CompileReuse=true)
        battery_cell(i) = BatteryPack.battery_cell(cell_mass=cell_mass);
    end
    ...
end
...
for i=1:Ncells-1
    components(ExternalAccess=none)
        conduction(i) = foundation.thermal.elements.conduction(area={1e-3,'m^2'},...
            th_cond={200,'W/(m*K)'});
    end
    ...
end
...

If scalable compilation is enabled for a model containing this battery pack component, then the members of the first component array, battery_cell, are reusable. Members of the second array, conduction, are not designated as reusable because the conduction element in the Foundation library is not complex enough to benefit from scalable compilation.

Similar to reusable subsystems, members of reusable component arrays can also have different parameterizations. The Components field in the Advisory tool report indicates how many compiled instances are needed and calculates the reuse statistics accordingly.

Related Topics