Skip to content

Commit 558f226

Browse files
authored
Update Motor Drive Unit component, Vehicle1D component, and BEV project files. (#34)
* Update MotorDriveUnit, Vehicle1D, and BEV Project files. Make all tests pass.
1 parent bcd9dad commit 558f226

File tree

1,724 files changed

+48983
-29595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,724 files changed

+48983
-29595
lines changed
0 Bytes
Loading

BEVProjectDescription.html

Lines changed: 96 additions & 0 deletions
Large diffs are not rendered by default.

BEVProjectDescription.mlx

83.5 KB
Binary file not shown.

BEVProjectNavigator.m

Lines changed: 159 additions & 98 deletions
Large diffs are not rendered by default.

BEVProject_main_script.html

Lines changed: 0 additions & 94 deletions
This file was deleted.

BEVProject_main_script.mlx

-83.6 KB
Binary file not shown.

BEVProject_test.m

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
classdef BEVProject_test < matlab.unittest.TestCase
2+
%% Class implementation of unit test
3+
% This is class-based unit test implementation.
4+
% To navigate test results and see code coverage, use Test Browser (testBrowser).
5+
%
6+
% Documentation
7+
%
8+
% - Author Class-Based Unit Tests in MATLAB
9+
% https://www.mathworks.com/help/matlab/matlab_prog/author-class-based-unit-tests-in-matlab.html
10+
%
11+
% - matlab.unittest.TestCase Class
12+
% https://www.mathworks.com/help/matlab/ref/matlab.unittest.testcase-class.html
13+
%
14+
% - Test Browser
15+
% https://www.mathworks.com/help/matlab/ref/testbrowser-app.html
16+
17+
% Copyright 2021-2025 The MathWorks, Inc.
18+
19+
methods (Test)
20+
% Functions in this "Test" section are the tests.
21+
% Before a function in this section runs, the TestSetup function
22+
% defined in the "TestMethodSetup" section runs.
23+
24+
%% Minimum quality check (MQC)
25+
% Check that models, scripts, functions, and classes run right out of the box.
26+
27+
function MQC_Description_1(testcase)
28+
% The source of the description page is a MATLAB script.
29+
% Check that it runs cleanly.
30+
verifyWarningFree(testcase, @() test_target())
31+
function test_target()
32+
BEVProjectDescription % !test-target
33+
end % nested function
34+
end % function
35+
36+
%% Other tests
37+
38+
function test_Description_html_1(testcase)
39+
% Check that the project has the HTML version of the description page.
40+
all_project_files = [currentProject().Files.Path]';
41+
logical_index = endsWith(all_project_files, "BEVProjectDescription.html"); % !test-target
42+
verifyEqual(testcase, nnz(logical_index), 1)
43+
end % function
44+
45+
end % methods
46+
47+
end % classdef
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB 2024b"><title>High Voltage Battery - Main Script</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(192, 76, 11); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: left; }
3+
.S1 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; }
4+
.S2 { margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; }
5+
.S3 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px; }
6+
.S4 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; }</style></head><body><div class = rtcContent><h1 class = 'S0' id = 'T_1FFD3858' ><span>High Voltage Battery - Main Script</span></h1><div class = 'S1'><span>This is a component to simulate the abstract dynamics of a high voltage battery pack.</span></div><h2 class = 'S2'><span>Models</span></h2><div class = 'S1'><span>This component provides four models of a high voltage battery:</span></div><ul class = 'S3'><li class = 'S4'><span style=' font-weight: bold;'>Basic </span><span>model ... is the simplest model and computes the voltage and current of the battery with no temperature dependence.</span></li><li class = 'S4'><span style=' font-weight: bold;'>Simple system </span><span>model ... is the second simplest model, built with</span><span> </span><a href = "https://www.mathworks.com/help/sdl/ref/batterysystemlevel.html"><span>Battery (System-Level) block</span></a><span> </span><span>from Simscape Driveline. This model has a simple equation-based terminal voltage model computed from the state of charge (SOC). This model also computes the battery temperature from dissipated energy.</span></li><li class = 'S4'><span style=' font-weight: bold;'>System </span><span>model ... is a model built with</span><span> </span><a href = "https://www.mathworks.com/help/sps/ref/battery.html"><span>Battery block</span></a><span> </span><span>from Simscape Battery and Simscape Electrical. This model can simulate the terminal voltage more accurately than the simple system model above, but it requires more parameters. Optionally, this model can also simulate charging dynamics, fade, and aging.</span></li><li class = 'S4'><span style=' font-weight: bold;'>Table-based system </span><span>model ... is a model built with</span><span> </span><a href = "https://www.mathworks.com/help/sps/ref/batterytablebased.html"><span>Battery (Table-Based) block</span></a><span> </span><span>from Simscape Battery and Simscape Electrical. This model takes tabulated data for open-circuit voltage and terminal resistance as a function of temperature and SOC. This model also needs the number of cells and their series-parallel circuit configuration information. Similar to the system model above, this model can optionally simulate charging dynamics, fade, and aging.</span></li></ul><h2 class = 'S2'><span>Simulation cases</span></h2><div class = 'S1'><span>To validate the component, a harness model is used to run some simulation cases. Click the links below to see the simulation results.</span></div><ul class = 'S3'><li class = 'S4'><a href = "matlab:openFile('BatteryHV_simulationCase_Charge')"><span>Charging</span></a></li><li class = 'S4'><a href = "matlab:openFile('BatteryHV_simulationCase_Discharge')"><span>Discharging</span></a></li><li class = 'S4'><a href = "matlab:openFile('BatteryHV_simulationCase_Random')"><span>Random load current</span></a></li><li class = 'S4'><a href = "matlab:openFile('BatteryHV_simulationCase_Constant')"><span>Constant load current</span></a></li></ul><div class = 'S1'><span style=' font-style: italic;'>Copyright 2020-2025 The Mathworks, Inc.</span></div>
7+
<br>
8+
<!--
9+
##### SOURCE BEGIN #####
10+
%% High Voltage Battery - Main Script
11+
% This is a component to simulate the abstract dynamics of a high voltage battery
12+
% pack.
13+
%% Models
14+
% This component provides four models of a high voltage battery:
15+
%%
16+
% * *Basic* model ... is the simplest model and computes the voltage and current
17+
% of the battery with no temperature dependence.
18+
% * *Simple system* model ... is the second simplest model, built with <https://www.mathworks.com/help/sdl/ref/batterysystemlevel.html
19+
% Battery (System-Level) block> from Simscape Driveline. This model has a simple
20+
% equation-based terminal voltage model computed from the state of charge (SOC).
21+
% This model also computes the battery temperature from dissipated energy.
22+
% * *System* model ... is a model built with <https://www.mathworks.com/help/sps/ref/battery.html
23+
% Battery block> from Simscape Battery and Simscape Electrical. This model can
24+
% simulate the terminal voltage more accurately than the simple system model above,
25+
% but it requires more parameters. Optionally, this model can also simulate charging
26+
% dynamics, fade, and aging.
27+
% * *Table-based system* model ... is a model built with <https://www.mathworks.com/help/sps/ref/batterytablebased.html
28+
% Battery (Table-Based) block> from Simscape Battery and Simscape Electrical.
29+
% This model takes tabulated data for open-circuit voltage and terminal resistance
30+
% as a function of temperature and SOC. This model also needs the number of cells
31+
% and their series-parallel circuit configuration information. Similar to the
32+
% system model above, this model can optionally simulate charging dynamics, fade,
33+
% and aging.
34+
%% Simulation cases
35+
% To validate the component, a harness model is used to run some simulation
36+
% cases. Click the links below to see the simulation results.
37+
%%
38+
% * <matlab:openFile('BatteryHV_simulationCase_Charge') Charging>
39+
% * <matlab:openFile('BatteryHV_simulationCase_Discharge') Discharging>
40+
% * <matlab:openFile('BatteryHV_simulationCase_Random') Random load current>
41+
% * <matlab:openFile('BatteryHV_simulationCase_Constant') Constant load current>
42+
%%
43+
% _Copyright 2020-2025 The Mathworks, Inc._
44+
##### SOURCE END #####
45+
-->
46+
</div></body></html>
-138 Bytes
Binary file not shown.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
classdef BatteryHV_test < matlab.unittest.TestCase
2+
%% Class implementation of unit test
3+
% This is class-based unit test implementation.
4+
% To navigate test results and see code coverage, use Test Browser (testBrowser).
5+
%
6+
% Documentation
7+
%
8+
% - Author Class-Based Unit Tests in MATLAB
9+
% https://www.mathworks.com/help/matlab/matlab_prog/author-class-based-unit-tests-in-matlab.html
10+
%
11+
% - matlab.unittest.TestCase Class
12+
% https://www.mathworks.com/help/matlab/ref/matlab.unittest.testcase-class.html
13+
%
14+
% - Test Browser
15+
% https://www.mathworks.com/help/matlab/ref/testbrowser-app.html
16+
17+
% Copyright 2025 The MathWorks, Inc.
18+
19+
properties
20+
ModelName (1,1) string = "BatteryHV_harness_model"
21+
end % properties
22+
23+
methods (TestMethodSetup)
24+
% Functions in this "TestMethodSetup" section always run before
25+
% each test defined in the "Test" section runs.
26+
27+
function TestSetup(testcase)
28+
function close_all
29+
close all
30+
bdclose all
31+
end % nested function
32+
close_all
33+
% addTeardown adds a function which always runs after each test.
34+
% Even if the execution of a test ends with an error, the teardown function runs.
35+
addTeardown(testcase, @close_all)
36+
end % function
37+
38+
end % methods
39+
40+
methods (Test)
41+
% Functions in this "Test" section are the tests.
42+
% Before a function in this section runs, the TestSetup function
43+
% defined in the "TestMethodSetup" section runs.
44+
45+
%% Minimum quality check (MQC)
46+
% Check that models, scripts, functions, and classes run right out of the box.
47+
48+
function MQC_setup_1(~)
49+
BatteryHV_harness_setup % !test-target
50+
end % function
51+
52+
function MQC_load_1(testcase)
53+
load_system(testcase.ModelName) % !test-target
54+
end % function
55+
56+
function MQC_sim_1(testcase)
57+
load_system(testcase.ModelName)
58+
sim(testcase.ModelName) % !test-target
59+
end % function
60+
61+
function MQC_main_script_1(~)
62+
BatteryHV_main_script % !test-target
63+
end % function
64+
65+
%%
66+
67+
function main_html_1(testcase)
68+
% Check that thete is an HTML version of the main script.
69+
all_project_files = [currentProject().Files.Path]';
70+
logical_index = endsWith(all_project_files, "BatteryHV_main_script.html"); % !test-target
71+
verifyEqual(testcase, nnz(logical_index), 1)
72+
end % function
73+
74+
end % methods
75+
76+
end % classdef

0 commit comments

Comments
 (0)