Skip to content

Commit feb1ee1

Browse files
committed
Maintenance for R2024b
1) Update GitHub workflow with reports published as Pages 2) Update .gitignore to support new workflow 3) Add CollectData to Function Library rather than as local function to aid in testing 4) Remove hard-coded colors in cnPDE and explicitPDE 5) Include solutions in InstructorResources 6) Update testing structures in SoftwareTests 7) Minor updates to scripts 8) Reorganize the project to start/stop the ProjectStartupApp
1 parent 554eb1b commit feb1ee1

File tree

112 files changed

+1546
-607
lines changed

Some content is hidden

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

112 files changed

+1546
-607
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@ on:
88
branches: [ release ]
99
workflow_dispatch:
1010

11+
# Add permission to write GitHub pages
12+
permissions:
13+
contents: write
14+
pages: write
15+
id-token: write
16+
1117
jobs:
1218
test:
1319
strategy:
1420
fail-fast: false
1521
matrix:
16-
MATLABVersion: [R2021a,R2021b,R2022a,R2022b,R2023a,R2023b,R2024a]
22+
MATLABVersion: [R2024a,R2024b]
1723
runs-on: ubuntu-latest
1824
steps:
1925
# Checks-out your repository
20-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2127

2228
# Sets up a display server
2329
- name: Start display server
@@ -32,14 +38,14 @@ jobs:
3238
uses: matlab-actions/setup-matlab@v2
3339
with:
3440
release: ${{ matrix.MATLABVersion }}
35-
products:
41+
products: >
3642
Symbolic_Math_Toolbox
3743
Image_Processing_Toolbox
38-
Computer_Vision_Toolbox
39-
Statistics_and_Machine_Learning_Toolbox
40-
Curve_Fitting_Toolbox
44+
Statistics_and_Machine_Learning_Toolbox
45+
Curve_Fitting_Toolbox
4146
Automated_Driving_Toolbox
4247
48+
4349
# Run all the tests
4450
- name: Run SmokeTests
4551
uses: matlab-actions/run-command@v2
@@ -48,10 +54,12 @@ jobs:
4854

4955
# Upload the test results as artifact
5056
- name: Upload TestResults
51-
uses: actions/[email protected]
57+
if: ${{ always() }}
58+
uses: actions/upload-artifact@v4
5259
with:
53-
name: TestResults
54-
path: ./SoftwareTests/TestResults_${{ matrix.MATLABVersion }}.txt
60+
name: TestResults_${{ matrix.MATLABVersion }}
61+
path: ./public/*
62+
overwrite: true
5563

5664
badge:
5765
if: ${{ always() }}
@@ -62,26 +70,38 @@ jobs:
6270
steps:
6371

6472
# Checks-out your repository
65-
- uses: actions/checkout@v3
73+
- uses: actions/checkout@v4
6674

6775
# Sets up R2023b
6876
- name: Setup MATLAB
69-
uses: matlab-actions/setup-matlab@v1
77+
uses: matlab-actions/setup-matlab@v2
7078
with:
71-
release: R2023b
79+
release: R2024b
7280

7381
# Download the test results from artifact
74-
- name: Download TestResults
75-
uses: actions/download-artifact@v2.1.1
82+
- name: Download All TestResults
83+
uses: actions/download-artifact@v4
7684
with:
77-
name: TestResults
78-
path: ./SoftwareTests/
79-
85+
path: public
86+
pattern: TestResults_*
87+
merge-multiple: true
88+
8089
# Create the test results badge
81-
- name: Run CreateBadge
82-
uses: matlab-actions/run-command@v1
90+
- name: Run PostSmokeTest
91+
uses: matlab-actions/run-command@v2
92+
with:
93+
command: openProject(pwd); PostSmokeTest;
94+
95+
# Deploy reports to GitHub pages
96+
- name: Setup Pages
97+
uses: actions/configure-pages@v5
98+
- name: Upload pages artifact
99+
uses: actions/upload-pages-artifact@v3
83100
with:
84-
command: openProject(pwd); CreateBadge;
101+
path: public
102+
- name: Deploy to GitHub Pages
103+
id: deployment
104+
uses: actions/deploy-pages@v4
85105

86106
# Commit the JSON for the MATLAB releases badge
87107
- name: Commit changed files

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,5 @@ Data/allStorms.csv
5252
Scripts/myLakeData.mat
5353
myLakeData.mat
5454

55-
# Test results
56-
SoftwareTests/TestResults_*
57-
5855
# GitLab page folder
5956
public/

.gitlab-ci.yml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,30 @@ smoke-test:
2424
# Make sure that the runner you plan to use matches the tags
2525
- matlab
2626
stage: test
27+
parallel:
28+
matrix:
29+
- VERSION: [R2024a,R2024b]
2730
script:
28-
- matlab -batch "openProject(pwd);RunAllTests(true)"
31+
- Set-Alias -Name matlab -Value "C:\Program Files\MATLAB\$VERSION\bin\matlab.exe"
32+
- matlab -batch "openProject(pwd);RunAllTests"
2933
when: always
3034
allow_failure: true
3135
artifacts:
36+
name: "$VERSION"
3237
paths:
3338
- public/*
34-
expire_in: 1 years
39+
when: always
40+
3541

3642
pages:
3743
tags:
3844
- matlab
3945
stage: deploy
4046
script:
41-
- echo 'Deploying pages'
47+
- matlab -batch "openProject(pwd);PostSmokeTest;"
4248
artifacts:
4349
paths:
4450
- public
45-
46-
smoke-test-solution:
47-
tags:
48-
- matlab
49-
stage: release
50-
script:
51-
- matlab -batch "proj = openProject(pwd);
52-
addpath(genpath(proj.RootFolder));
53-
results = runtests(fullfile('InternalFiles','Tests','CI','SolnSmokeTests.m'));
54-
disp(table(results)); assertSuccess(results);"
55-
rules:
56-
# This test should always run when merging to main
57-
# And be available for manual running on any push
58-
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
59-
when: always
60-
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
61-
when: manual
62-
allow_failure: true
6351

6452
file-test:
6553
tags:
@@ -87,6 +75,7 @@ release-testing:
8775
- matlab -batch "proj = openProject(pwd);
8876
cd ..;
8977
addpath(genpath(fullfile('utilities','TestingResources')));
78+
addpath(genpath(fullfile('utilities','Tools')));
9079
runCMTests"
9180
rules:
9281
# This test should always run when merging to main

FunctionLibrary/.gitkeep

Whitespace-only changes.

FunctionLibrary/CollectData.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
roi = drawpolygon(ax);
1313
x = roi.Position(:,1);
1414
y = roi.Position(:,2);
15-
end
15+
end

FunctionLibrary/cnPDE.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@
6969
% To visualize the outputs
7070
hold on
7171
delete(ax.Children(1:end-1));
72-
try
73-
plot(xVals,[alpha(j*dt);u;beta(j*dt)],LineWidth=1,SeriesIndex="none")
74-
catch % If using R2023a or earlier
75-
plot(xVals,[alpha(j*dt);u;beta(j*dt)],"k",LineWidth=1)
76-
end
72+
plot(xVals,[alpha(j*dt);u;beta(j*dt)],LineWidth=1,SeriesIndex="none")
7773
subtitle("$t = $"+dt*j)
7874
drawnow
7975
pause(0.1)

FunctionLibrary/explicitPDE.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@
6666
% To visualize the outputs
6767
hold on
6868
delete(ax.Children(1:end-1));
69-
try
70-
plot(xVals,[alpha((j+1)*dt);u;beta((j+1)*dt)],LineWidth=4,SeriesIndex="none")
71-
catch % If using R2023a or earlier
72-
plot(xVals,[alpha((j+1)*dt);u;beta((j+1)*dt)],"k",LineWidth=4)
73-
end
69+
plot(xVals,[alpha((j+1)*dt);u;beta((j+1)*dt)],"LineWidth",4,SeriesIndex="none")
7470
subtitle("$t = $"+dt*(j+1))
7571
drawnow
7672
pause(0.1)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
function u = cnPDESoln(f,alpha,beta,tEnd,dx,gamma,L)
2+
% Solve the 1D heat equation u_t = gamma*u_{xx} on a rod of length L
3+
% using the Crank-Nicolson method
4+
% u(t,0) = alpha(t)
5+
% u(t,L) = beta(t)
6+
% u(0,x) = f(x)
7+
% The desired spatial resolution is dx
8+
% Output is u = u(tEnd,x_m), a vector of values on the mesh points
9+
10+
% Define dt with reference to both error and stability concerns
11+
% Optimal dt for stability
12+
dtOpt = dx;
13+
% Forcing an integer numbers of dt steps that terminate at tEnd
14+
dt = tEnd/ceil(tEnd/dtOpt);
15+
16+
% % testing %%%%%%%%%%
17+
% dt = 0.005;
18+
19+
% Set up the helper values for defining the required matrices
20+
numRows = L/dx-1;
21+
mu = gamma*dt/(dx^2);
22+
baseDiag = ones(1,numRows);
23+
24+
% Define modA for the explicit updating rule
25+
% modA-I = (A-I)/2, where I is the identity matrix
26+
modA = gallery('tridiag',0.5*mu*baseDiag(1:end-1),(1-mu)*baseDiag,0.5*mu*baseDiag(1:end-1));
27+
28+
% Define modB for the implicit updating rule
29+
% modB-I = (B-I)/2, where I is the identity matrix
30+
modB = gallery('tridiag',-0.5*mu*baseDiag(1:end-1),(1+mu)*baseDiag,-0.5*mu*baseDiag(1:end-1));
31+
32+
% Initialize bAvg = b^(j)+b^(j+1) as a vector of zeros
33+
bAvg = zeros(numRows,1);
34+
35+
% Define a spatial mesh vector
36+
xVals = linspace(0,L,round(L/dx)+1);
37+
38+
% Set up a column vector u0 of the initial values of u when t=0
39+
u0 = f(xVals)';
40+
41+
% Initialize the output to the interior points of u0
42+
u = u0(2:end-1);
43+
44+
% To visualize the outputs
45+
p = plot(xVals,u0,"LineWidth",2,"SeriesIndex",1);
46+
ax = p.Parent;
47+
48+
% Set the y limits to reasonable fixed values
49+
minAlpha = min(alpha(0:dt:tEnd));
50+
maxAlpha = max(alpha(0:dt:tEnd));
51+
minBeta = min(beta(0:dt:tEnd));
52+
maxBeta = max(beta(0:dt:tEnd));
53+
yLower = min([ax.YLim(1),minAlpha,minBeta]);
54+
yUpper = max([ax.YLim(2),maxAlpha,maxBeta]);
55+
scale = (yUpper-yLower)*0.05;
56+
ax.YLim = [yLower-scale yUpper+scale];
57+
58+
title("Solving $\frac{\partial u}{\partial t} = \gamma \frac{\partial^2 u}{\partial x^2}$ with Crank-Nicolson","Interpreter","latex")
59+
subtitle("$t=0$","Interpreter","latex")
60+
xlabel("$x$","Interpreter","latex")
61+
ylabel("$u$","Interpreter","latex")
62+
63+
% Compute new values for halfB*u^(j+1)-b^(j+1) = halfA*u^(j)+b^(j)
64+
% Loop over timesteps to reach tEnd
65+
for j = 1:(tEnd/dt)
66+
bAvg(1) = mu*(alpha((j-1)*dt)+alpha(j*dt))/2;
67+
bAvg(end) = mu*(beta((j-1)*dt)+beta(j*dt))/2;
68+
u = modB\(modA*u+bAvg);
69+
% To visualize the outputs
70+
hold on
71+
delete(ax.Children(1:end-1));
72+
plot(xVals,[alpha(j*dt);u;beta(j*dt)],"LineWidth",2,"SeriesIndex",2)
73+
subtitle("$t = $"+dt*j)
74+
drawnow
75+
pause(0.1)
76+
hold off
77+
% End visualization code
78+
end
79+
legend(["u(0,x)","u(t,x)"],"Location","north")
80+
end
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
function u = cnPDE(u0,alpha,beta,tEnd,dx,gamma,L,t0)
2+
% Solve the 1D heat equation u_t = gamma*u_{xx} on a rod of length L
3+
% using the Crank-Nicolson method
4+
% u(t,0) = alpha(t)
5+
% u(t,L) = beta(t)
6+
% u(t0,x) = u0
7+
% The desired spatial resolution is dx
8+
% Output is u = u(tEnd,x_m), a vector of values on the mesh points
9+
10+
% Define dt with reference to both error and stability concerns
11+
% Optimal dt for stability
12+
dtOpt = dx;
13+
% Forcing an integer numbers of dt steps that terminate at tEnd
14+
dt = tEnd/ceil((tEnd-t0)/dtOpt);
15+
16+
% % testing %%%%%%%%%%
17+
% dt = 0.005;
18+
19+
% Set up the helper values for defining the required matrices
20+
numRows = L/dx-1;
21+
mu = gamma*dt/(dx^2);
22+
baseDiag = ones(1,numRows);
23+
24+
% Define modA for the explicit updating rule
25+
% modA-I = (A-I)/2, where I is the identity matrix
26+
modA = gallery('tridiag',0.5*mu*baseDiag(1:end-1),(1-mu)*baseDiag,0.5*mu*baseDiag(1:end-1));
27+
28+
% Define modB for the implicit updating rule
29+
% modB-I = (B-I)/2, where I is the identity matrix
30+
modB = gallery('tridiag',-0.5*mu*baseDiag(1:end-1),(1+mu)*baseDiag,-0.5*mu*baseDiag(1:end-1));
31+
32+
% Initialize bAvg = b^(j)+b^(j+1) as a vector of zeros
33+
bAvg = zeros(numRows,1);
34+
35+
% Define a spatial mesh vector
36+
xVals = linspace(0,L,round(L/dx)+1);
37+
38+
% Initialize the output to the interior points of u0
39+
u = u0(2:end-1);
40+
41+
% To visualize the outputs
42+
p = plot(xVals,u0,"LineWidth",4);
43+
ax = p.Parent;
44+
45+
% Set the y limits to reasonable fixed values
46+
minAlpha = min(alpha(0:dt:tEnd));
47+
maxAlpha = max(alpha(0:dt:tEnd));
48+
minBeta = min(beta(0:dt:tEnd));
49+
maxBeta = max(beta(0:dt:tEnd));
50+
yLower = min([ax.YLim(1),minAlpha,minBeta]);
51+
yUpper = max([ax.YLim(2),maxAlpha,maxBeta]);
52+
scale = (yUpper-yLower)*0.05;
53+
ax.YLim = [yLower-scale yUpper+scale];
54+
55+
title("Solving $\frac{\partial u}{\partial t} = \gamma \frac{\partial^2 u}{\partial x^2}$","Interpreter","latex")
56+
subtitle("$t=0$","Interpreter","latex")
57+
xlabel("$x$","Interpreter","latex")
58+
ylabel("$u$","Interpreter","latex")
59+
60+
% Compute new values for halfB*u^(j+1)-b^(j+1) = halfA*u^(j)+b^(j)
61+
% Loop over timesteps to reach tEnd
62+
for j = 0:(tEnd/dt - 1)
63+
bAvg(1) = mu*(alpha(j*dt)+alpha((j+1)*dt))/2;
64+
bAvg(end) = mu*(beta(j*dt)+beta((j+1)*dt))/2;
65+
u = modB\(modA*u+bAvg);
66+
% To visualize the outputs
67+
hold on
68+
delete(ax.Children(1:end-1));
69+
plot(xVals,[alpha((j+1)*dt);u;beta((j+1)*dt)],"LineWidth",4,SeriesIndex="none")
70+
subtitle("$t = $"+dt*(j+1))
71+
drawnow
72+
pause(0.1)
73+
hold off
74+
% End visualization code
75+
end
76+
77+
end

0 commit comments

Comments
 (0)