-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
112 changed files
with
1,546 additions
and
607 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,22 @@ on: | |
branches: [ release ] | ||
workflow_dispatch: | ||
|
||
# Add permission to write GitHub pages | ||
permissions: | ||
contents: write | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
MATLABVersion: [R2021a,R2021b,R2022a,R2022b,R2023a,R2023b,R2024a] | ||
MATLABVersion: [R2024a,R2024b] | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks-out your repository | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
|
||
# Sets up a display server | ||
- name: Start display server | ||
|
@@ -32,14 +38,14 @@ jobs: | |
uses: matlab-actions/setup-matlab@v2 | ||
with: | ||
release: ${{ matrix.MATLABVersion }} | ||
products: | ||
products: > | ||
Symbolic_Math_Toolbox | ||
Image_Processing_Toolbox | ||
Computer_Vision_Toolbox | ||
Statistics_and_Machine_Learning_Toolbox | ||
Curve_Fitting_Toolbox | ||
Statistics_and_Machine_Learning_Toolbox | ||
Curve_Fitting_Toolbox | ||
Automated_Driving_Toolbox | ||
# Run all the tests | ||
- name: Run SmokeTests | ||
uses: matlab-actions/run-command@v2 | ||
|
@@ -48,10 +54,12 @@ jobs: | |
|
||
# Upload the test results as artifact | ||
- name: Upload TestResults | ||
uses: actions/[email protected] | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: TestResults | ||
path: ./SoftwareTests/TestResults_${{ matrix.MATLABVersion }}.txt | ||
name: TestResults_${{ matrix.MATLABVersion }} | ||
path: ./public/* | ||
overwrite: true | ||
|
||
badge: | ||
if: ${{ always() }} | ||
|
@@ -62,26 +70,38 @@ jobs: | |
steps: | ||
|
||
# Checks-out your repository | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
|
||
# Sets up R2023b | ||
- name: Setup MATLAB | ||
uses: matlab-actions/setup-matlab@v1 | ||
uses: matlab-actions/setup-matlab@v2 | ||
with: | ||
release: R2023b | ||
release: R2024b | ||
|
||
# Download the test results from artifact | ||
- name: Download TestResults | ||
uses: actions/download-artifact@v2.1.1 | ||
- name: Download All TestResults | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: TestResults | ||
path: ./SoftwareTests/ | ||
|
||
path: public | ||
pattern: TestResults_* | ||
merge-multiple: true | ||
|
||
# Create the test results badge | ||
- name: Run CreateBadge | ||
uses: matlab-actions/run-command@v1 | ||
- name: Run PostSmokeTest | ||
uses: matlab-actions/run-command@v2 | ||
with: | ||
command: openProject(pwd); PostSmokeTest; | ||
|
||
# Deploy reports to GitHub pages | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v5 | ||
- name: Upload pages artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
command: openProject(pwd); CreateBadge; | ||
path: public | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
|
||
# Commit the JSON for the MATLAB releases badge | ||
- name: Commit changed files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
roi = drawpolygon(ax); | ||
x = roi.Position(:,1); | ||
y = roi.Position(:,2); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
InstructorResources/Solutions/FunctionLibrarySolutions/cnPDESoln.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
function u = cnPDESoln(f,alpha,beta,tEnd,dx,gamma,L) | ||
% Solve the 1D heat equation u_t = gamma*u_{xx} on a rod of length L | ||
% using the Crank-Nicolson method | ||
% u(t,0) = alpha(t) | ||
% u(t,L) = beta(t) | ||
% u(0,x) = f(x) | ||
% The desired spatial resolution is dx | ||
% Output is u = u(tEnd,x_m), a vector of values on the mesh points | ||
|
||
% Define dt with reference to both error and stability concerns | ||
% Optimal dt for stability | ||
dtOpt = dx; | ||
% Forcing an integer numbers of dt steps that terminate at tEnd | ||
dt = tEnd/ceil(tEnd/dtOpt); | ||
|
||
% % testing %%%%%%%%%% | ||
% dt = 0.005; | ||
|
||
% Set up the helper values for defining the required matrices | ||
numRows = L/dx-1; | ||
mu = gamma*dt/(dx^2); | ||
baseDiag = ones(1,numRows); | ||
|
||
% Define modA for the explicit updating rule | ||
% modA-I = (A-I)/2, where I is the identity matrix | ||
modA = gallery('tridiag',0.5*mu*baseDiag(1:end-1),(1-mu)*baseDiag,0.5*mu*baseDiag(1:end-1)); | ||
|
||
% Define modB for the implicit updating rule | ||
% modB-I = (B-I)/2, where I is the identity matrix | ||
modB = gallery('tridiag',-0.5*mu*baseDiag(1:end-1),(1+mu)*baseDiag,-0.5*mu*baseDiag(1:end-1)); | ||
|
||
% Initialize bAvg = b^(j)+b^(j+1) as a vector of zeros | ||
bAvg = zeros(numRows,1); | ||
|
||
% Define a spatial mesh vector | ||
xVals = linspace(0,L,round(L/dx)+1); | ||
|
||
% Set up a column vector u0 of the initial values of u when t=0 | ||
u0 = f(xVals)'; | ||
|
||
% Initialize the output to the interior points of u0 | ||
u = u0(2:end-1); | ||
|
||
% To visualize the outputs | ||
p = plot(xVals,u0,"LineWidth",2,"SeriesIndex",1); | ||
ax = p.Parent; | ||
|
||
% Set the y limits to reasonable fixed values | ||
minAlpha = min(alpha(0:dt:tEnd)); | ||
maxAlpha = max(alpha(0:dt:tEnd)); | ||
minBeta = min(beta(0:dt:tEnd)); | ||
maxBeta = max(beta(0:dt:tEnd)); | ||
yLower = min([ax.YLim(1),minAlpha,minBeta]); | ||
yUpper = max([ax.YLim(2),maxAlpha,maxBeta]); | ||
scale = (yUpper-yLower)*0.05; | ||
ax.YLim = [yLower-scale yUpper+scale]; | ||
|
||
title("Solving $\frac{\partial u}{\partial t} = \gamma \frac{\partial^2 u}{\partial x^2}$ with Crank-Nicolson","Interpreter","latex") | ||
subtitle("$t=0$","Interpreter","latex") | ||
xlabel("$x$","Interpreter","latex") | ||
ylabel("$u$","Interpreter","latex") | ||
|
||
% Compute new values for halfB*u^(j+1)-b^(j+1) = halfA*u^(j)+b^(j) | ||
% Loop over timesteps to reach tEnd | ||
for j = 1:(tEnd/dt) | ||
bAvg(1) = mu*(alpha((j-1)*dt)+alpha(j*dt))/2; | ||
bAvg(end) = mu*(beta((j-1)*dt)+beta(j*dt))/2; | ||
u = modB\(modA*u+bAvg); | ||
% To visualize the outputs | ||
hold on | ||
delete(ax.Children(1:end-1)); | ||
plot(xVals,[alpha(j*dt);u;beta(j*dt)],"LineWidth",2,"SeriesIndex",2) | ||
subtitle("$t = $"+dt*j) | ||
drawnow | ||
pause(0.1) | ||
hold off | ||
% End visualization code | ||
end | ||
legend(["u(0,x)","u(t,x)"],"Location","north") | ||
end |
77 changes: 77 additions & 0 deletions
77
InstructorResources/Solutions/FunctionLibrarySolutions/cnPDEu0Soln.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
function u = cnPDE(u0,alpha,beta,tEnd,dx,gamma,L,t0) | ||
% Solve the 1D heat equation u_t = gamma*u_{xx} on a rod of length L | ||
% using the Crank-Nicolson method | ||
% u(t,0) = alpha(t) | ||
% u(t,L) = beta(t) | ||
% u(t0,x) = u0 | ||
% The desired spatial resolution is dx | ||
% Output is u = u(tEnd,x_m), a vector of values on the mesh points | ||
|
||
% Define dt with reference to both error and stability concerns | ||
% Optimal dt for stability | ||
dtOpt = dx; | ||
% Forcing an integer numbers of dt steps that terminate at tEnd | ||
dt = tEnd/ceil((tEnd-t0)/dtOpt); | ||
|
||
% % testing %%%%%%%%%% | ||
% dt = 0.005; | ||
|
||
% Set up the helper values for defining the required matrices | ||
numRows = L/dx-1; | ||
mu = gamma*dt/(dx^2); | ||
baseDiag = ones(1,numRows); | ||
|
||
% Define modA for the explicit updating rule | ||
% modA-I = (A-I)/2, where I is the identity matrix | ||
modA = gallery('tridiag',0.5*mu*baseDiag(1:end-1),(1-mu)*baseDiag,0.5*mu*baseDiag(1:end-1)); | ||
|
||
% Define modB for the implicit updating rule | ||
% modB-I = (B-I)/2, where I is the identity matrix | ||
modB = gallery('tridiag',-0.5*mu*baseDiag(1:end-1),(1+mu)*baseDiag,-0.5*mu*baseDiag(1:end-1)); | ||
|
||
% Initialize bAvg = b^(j)+b^(j+1) as a vector of zeros | ||
bAvg = zeros(numRows,1); | ||
|
||
% Define a spatial mesh vector | ||
xVals = linspace(0,L,round(L/dx)+1); | ||
|
||
% Initialize the output to the interior points of u0 | ||
u = u0(2:end-1); | ||
|
||
% To visualize the outputs | ||
p = plot(xVals,u0,"LineWidth",4); | ||
ax = p.Parent; | ||
|
||
% Set the y limits to reasonable fixed values | ||
minAlpha = min(alpha(0:dt:tEnd)); | ||
maxAlpha = max(alpha(0:dt:tEnd)); | ||
minBeta = min(beta(0:dt:tEnd)); | ||
maxBeta = max(beta(0:dt:tEnd)); | ||
yLower = min([ax.YLim(1),minAlpha,minBeta]); | ||
yUpper = max([ax.YLim(2),maxAlpha,maxBeta]); | ||
scale = (yUpper-yLower)*0.05; | ||
ax.YLim = [yLower-scale yUpper+scale]; | ||
|
||
title("Solving $\frac{\partial u}{\partial t} = \gamma \frac{\partial^2 u}{\partial x^2}$","Interpreter","latex") | ||
subtitle("$t=0$","Interpreter","latex") | ||
xlabel("$x$","Interpreter","latex") | ||
ylabel("$u$","Interpreter","latex") | ||
|
||
% Compute new values for halfB*u^(j+1)-b^(j+1) = halfA*u^(j)+b^(j) | ||
% Loop over timesteps to reach tEnd | ||
for j = 0:(tEnd/dt - 1) | ||
bAvg(1) = mu*(alpha(j*dt)+alpha((j+1)*dt))/2; | ||
bAvg(end) = mu*(beta(j*dt)+beta((j+1)*dt))/2; | ||
u = modB\(modA*u+bAvg); | ||
% To visualize the outputs | ||
hold on | ||
delete(ax.Children(1:end-1)); | ||
plot(xVals,[alpha((j+1)*dt);u;beta((j+1)*dt)],"LineWidth",4,SeriesIndex="none") | ||
subtitle("$t = $"+dt*(j+1)) | ||
drawnow | ||
pause(0.1) | ||
hold off | ||
% End visualization code | ||
end | ||
|
||
end |
Oops, something went wrong.