主要内容

Verify and Validate System

R2026b

This project includes test harnesses for a model component, the software architecture model, and the full system, enabling you to verify individual algorithms and then validate the full closed-loop system.

In this section, you:

  1. Run simulations using test harnesses.

  2. Define and run test cases in Simulink Test Manager (Simulink Test).

  3. Compare results across battery pack fidelity variants.

  4. Trace requirements to architecture, models, and tests.

Tip

Open Doc/BMSVerificationAndValidation.m in the project for an interactive walkthrough of this section.

Test Harnesses

The project includes three test harnesses at increasing levels of integration:

HarnessLevelLocationWhat It Tests
StateMachineHarness.slxComponentTests/StateMachine/StateMachine component in isolation. Uses Signal Editor inputs to test Standby, Charging, Driving, and Fault scenarios.
BMSAlgorithmArchitectureHarness.slxArchitectureTests/BMS/All three controller components connected through the reference architecture.
BMSHarness.slxSystemTests/BMS/Closed-loop simulation connecting the BMS controller to the BatteryModel plant through the Input and Output Adapters.

Start with the model component test harness (StateMachineHarness.slx) to verify and validate the algorithmic behavior of the StateMachine component. Then, to verify the BMS controller, simulate the software architecture model test harness (BMSAlgorithmArchitectureHarness.slx). After model components and intermediate systems are validated, you can simulate the full system, for closed-loop validation, using the system-level test harness (BMSHarness.slx).

BMSHarness model showing the BMS controller connected to the battery plant model in a closed-loop test configuration.

For more information about generating test harnesses, see Test Harnesses for Models and Model Components (Simulink Test) and Create a Test Harness (Simulink Test).

Run a Simulation

To run a quick closed-loop simulation:

  1. Set the battery pack to the Lumped fidelity level for fast execution. In BatteryData.sldd, set BattModelResolution to 0.

  2. Open the system-level test harness:

    open_system('BMSHarness')
  3. Run the simulation. View results in the Simulation Data Inspector.

For more information, see Decide How to Visualize Simulation Data.

Define and Run Test Cases

Use Simulink® Test™ Test Manager (Simulink Test) to organize test scenarios and automate test execution.

The project includes a predefined test file for the StateMachine component:

  • StateMachineTest.mldatx — Test Manager file with test cases for Charging, Driving, Standby, and Fault Injection scenarios.

  • StateMachineHarnessInputs.mat — Input signal data for the test scenarios.

  • StateMachineTestResults.mldatx — Baseline results stored for comparison.

To run the tests:

  1. Open the Simulink Test Manager.

    • If you have the StateMachine.slx model open, on the toolstrip, select the Tests tab, and click Simulink Test Manager.

    • If you have the StateMachineHarness.slx model open, on the toolstrip, select the Harness tab, and click Simulink Test Manager.

  2. Open the test file that defines the test cases, StateMachineTest.mldatx.

    1. On the toolstrip, select Open > Open (.mldatx).

    2. Browse for the test file in the project at this filepath: "\UseMBDtoBuildaBMS\SystemIntegrationAndTest\Tests\StateMachine\StateMachineTest.mldatx".

    3. Once Test Manager loads the test file, the Dashboard shows the StandBy test case.

  3. Run the test suite and review pass/fail results.

    Click Run.

For more information, see View Test Case Results (Simulink Test).

Compare Battery Pack Variants

To compare simulation results across battery pack fidelity levels:

  1. Change the fidelity level by using the BattModelResolution parameter in the battery data dictionary, BatteryData.sldd:

    • 0 = Lumped

    • 1 = Grouped

    • 2 = Detailed

    For more information about model resolution options, see Define Model Resolution (Simscape Battery).

  2. Run the system-level test harness, BMSHarness.slx, for each battery fidelity level.

  3. Use the Simulation Data Inspector to compare signals across runs:

    Simulink.sdi.view

    For more information, see Running Multiple Simulations in Simulink.

Requirements Traceability

Link requirements to architecture elements, model blocks, and test cases to establish a complete digital thread:

  • Requirements → Architecture — Link requirements from BMSSwRequirements.slreqx to their associated components in the software architecture, BMSAlgorithmArchitecture.slx.

  • Requirements → Implementation — Link requirements to behavior models of each component, such as StateMachine.slx.

  • Requirements → Verification — Link requirements to test cases defined in StateMachineTest.mldatx.

    For more information, see Link Test Cases to Requirements Documents (Requirements Toolbox).

Traceability files (.slmx) alongside each model store these links. For example, StateMachineTest~mldatx.slmx stores the links between test cases and their associated requirements.

Tip

To check whether there are any requirements that are not yet linked to an implementation or test, use the Requirements Perspective. For more information, see Export and Report Requirements and Traceability (Requirements Toolbox).

See Also

(Requirements Toolbox) | (Simulink Test)

Topics