Skip to content

Commit f7a601a

Browse files
committed
added functionality for Gaussian forcing and updated the test suites
1 parent e6b4b28 commit f7a601a

File tree

8 files changed

+226
-28
lines changed

8 files changed

+226
-28
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: IMR test suite - comparison
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "main" branch
8+
push:
9+
branches: [ "main" ]
10+
pull_request:
11+
branches: [ "main" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
testsuite:
20+
21+
name: Test suite
22+
23+
# The type of runner that the job will run on
24+
runs-on: ubuntu-22.04
25+
26+
continue-on-error: true # Does not stop other workflows
27+
28+
# Steps represent a sequence of tasks that will be executed as part of the job
29+
steps:
30+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
31+
- name: Checkout Repository
32+
uses: actions/checkout@v4
33+
34+
- name: Set up MATLAB
35+
uses: matlab-actions/setup-matlab@v1
36+
with:
37+
release: R2023a
38+
products: >
39+
MATLAB
40+
Symbolic_Math_Toolbox
41+
42+
- name: Compatibility test between FD and Spectral
43+
uses: matlab-actions/run-command@v1
44+
with:
45+
command: |
46+
cd toolchain;
47+
s_test_suite_compatibility;
48+
49+
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is a basic workflow to help you get started with Actions
22

3-
name: IMR test suite
3+
name: IMR test suite - base tests
44

55
# Controls when the workflow will run
66
on:
@@ -46,17 +46,10 @@ jobs:
4646
cd toolchain;
4747
s_test_suite_equilibrium;
4848
49-
- name: Compatibility test between FD and Spectral
49+
- name: Gaussian equilibrium test
5050
uses: matlab-actions/run-command@v1
5151
with:
5252
command: |
5353
cd toolchain;
54-
s_test_suite_compatibility;
55-
56-
- name: Finite difference mass transfer test
57-
uses: matlab-actions/run-command@v1
58-
with:
59-
command: |
60-
cd toolchain;
61-
s_test_suite_masstrans;
54+
s_test_suite_gaussian;
6255
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: IMR test suite - mass transfer
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "main" branch
8+
push:
9+
branches: [ "main" ]
10+
pull_request:
11+
branches: [ "main" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
testsuite:
20+
21+
name: Test suite
22+
23+
# The type of runner that the job will run on
24+
runs-on: ubuntu-22.04
25+
26+
continue-on-error: true # Does not stop other workflows
27+
28+
# Steps represent a sequence of tasks that will be executed as part of the job
29+
steps:
30+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
31+
- name: Checkout Repository
32+
uses: actions/checkout@v4
33+
34+
- name: Set up MATLAB
35+
uses: matlab-actions/setup-matlab@v1
36+
with:
37+
release: R2023a
38+
products: >
39+
MATLAB
40+
Symbolic_Math_Toolbox
41+
42+
- name: Finite difference mass transfer test
43+
uses: matlab-actions/run-command@v1
44+
with:
45+
command: |
46+
cd toolchain;
47+
s_test_suite_masstrans;
48+

s_run_full_model.m

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22
clear;
33
close;
44

5-
addpath('src');
5+
addpath('src/forward_solver/');
66

77
% equation options
88
R0 = 2.447495043190468e-04;
99
Req = 3.008409399929516e-05;
10-
% Req = 0.122917895573930*R0;
1110
ratio = Req/R0;
12-
% Req = R0;
13-
tfin = R0/3;
14-
% pzero = 0.001887748193919;
15-
% cstar = 1.520710024149080e+02;
11+
Req = R0;
12+
tfin = 2e-3;
1613
kappa = 1.4;
1714
Lheat = 2.378193575129533e+04;
1815
T8 = 298.15;
1916
rho8 = 1064;
2017
tvector = linspace(0,tfin,1000);
2118
radial = 2;
2219
vapor = 1;
23-
bubtherm = 1;
24-
medtherm = 1;
25-
masstrans = 1;
20+
bubtherm = 0;
21+
medtherm = 0;
22+
masstrans = 0;
2623
stress = 1;
24+
wave_type = 1;
25+
dt = 3e-4;
26+
tw = 1e-4;
27+
pA = 1e5;
2728
varin = {'progdisplay',0,...
2829
'radial',radial,...
2930
'bubtherm',bubtherm,...
@@ -32,22 +33,24 @@
3233
'medtherm',medtherm,...
3334
'method',23,...
3435
'stress',stress,...
35-
'mu',0.027606000000000,...
36+
'mu',0.5,...
3637
'g',3.125000000000000e+02,...
3738
'lambda1',0,...
3839
'r0',R0,...
3940
'req',Req,...
4041
'kappa',kappa,...
41-
're',92.055015921905493,...
4242
'masstrans',masstrans,...
4343
't8',T8,...
44-
'rho8',rho8};
44+
'rho8',rho8,...
45+
'wave_type',wave_type,...
46+
'dt',dt,...
47+
'tw',tw,...
48+
'pA',pA};
4549

46-
[t1,R1,~] = m_imr_full_model(varin{:},'Nt',50,'Mt',50);
47-
[t3,R3,~] = m_imr_fd(varin{:},'Nt',50,'Mt',50);
50+
[t3,R3,U3,P3] = f_imr_fd(varin{:},'Nt',50,'Mt',50);
4851

4952
figure(1)
5053
hold on;
51-
plot(t1,R1,'k^')
5254
plot(t3,R3,'bs')
53-
ylim([0 1.2])
55+
% plot(t3,P3,'rs')
56+
% ylim([0 1.2])

src/forward_solver/f_call_params.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
% non-dimensional frequency
259259
om = omega*t0;
260260
ee = pA/Pref;
261-
tw = TW*t0;
261+
tw = TW/t0;
262262
dt = DT/t0;
263263
% acoustic properties
264264

src/forward_solver/f_pinfinity.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,16 @@
5656
pdot = 0;
5757
end
5858

59+
% Gaussian waveform
60+
function [p,pdot] = gaussian(t)
61+
p = - ee * exp(-((t-dt)^2) / tw^2);
62+
pdot = ee * (2*(t-dt)/tw^2) * exp(-((t-dt)^2) / tw^2);
63+
end
64+
5965
% heaviside impulse
6066
function [p,pdot] = heaviside_impulse(t)
6167
p = -ee*(1-heaviside(t-tw));
6268
pdot = 0;
6369
end
64-
70+
6571
end

toolchain/s_test_suite_equilibrium.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
for vapor = 0:1
3535
for stress = 0:5
3636
if bubtherm == 0 && medtherm == 1
37+
count = count + 2;
3738
continue;
3839
end
3940
varin = {'radial',radial,...

toolchain/s_test_suite_gaussian.m

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
% file s_test_suite_equilibrium.m
2+
% brief contains script to test for equilibrium conditions
3+
4+
% brief This script runs both the finite difference and spectral codes to
5+
% test that initial equilibrium conditions are satisfied
6+
clc;
7+
clear;
8+
9+
addpath('../toolchain/');
10+
addpath('../src/forward_solver/');
11+
12+
num_tests = 4*2*2*2*5;
13+
errors_fd = zeros(num_tests,1);
14+
errors_sp = zeros(num_tests,1);
15+
failed_tests = zeros(size(errors_sp));
16+
% define threshold
17+
threshold = 1e-2;
18+
19+
fprintf('Checking L2 norm errors...\n');
20+
21+
% equilibrium test case
22+
masstrans = 0;
23+
collapse = 0;
24+
Req = 10e-6;
25+
R0 = Req;
26+
T8 = 298.15;
27+
tfin = 2e-3;
28+
tvector = linspace(0,tfin,1000);
29+
mu = 0.5;
30+
wave_type = 1;
31+
dt = 3e-4;
32+
tw = 1e-4;
33+
pA = 1e5;
34+
% equation options
35+
count = 1;
36+
for radial = 1:4
37+
for bubtherm = 0:1
38+
for medtherm = 0:1
39+
for vapor = 0:1
40+
for stress = 1:5
41+
if bubtherm == 0 && medtherm == 1
42+
count = count + 2;
43+
continue;
44+
end
45+
varin = {'radial',radial,...
46+
'bubtherm',bubtherm,...
47+
'masstrans',masstrans,...
48+
'tvector',tvector,...
49+
'vapor',vapor,...
50+
'medtherm',medtherm,...
51+
'stress',stress,...
52+
'collapse',collapse,...
53+
'method',23,...
54+
'Req',Req,...
55+
'mu',mu,...
56+
'R0',R0,...
57+
't8',T8,...
58+
'wave_type',wave_type,...
59+
'dt',dt,...
60+
'tw',tw,...
61+
'pA',pA};
62+
[ttest,Rf_test] = f_imr_fd(varin{:},'Nt',50,'Mt',50);
63+
plot(ttest,Rf_test)
64+
errors_fd(count) = abs(1-Rf_test(end));
65+
fprintf('Test %d: L2 norm error = %.6e\n', count, errors_fd(count));
66+
[~,Rs_test] = f_imr_spectral(varin{:},'Nt',12,'Mt',12);
67+
errors_sp(count) = abs(Rs_test(1)-Rs_test(end));
68+
fprintf('Test %d: L2 norm error = %.6e\n', count+1, errors_sp(count));
69+
if ( errors_fd(count) > threshold )
70+
failed_tests(count) = count;
71+
end
72+
if ( errors_sp(count) > threshold )
73+
failed_tests(count+1) = count+1;
74+
end
75+
count = count + 2;
76+
end
77+
end
78+
end
79+
end
80+
end
81+
82+
% Find the last non-empty cell index
83+
lastNonEmptyIdx = find(failed_tests ~= 0, 1, 'last');
84+
% Truncate the array, keeping empty cells within range
85+
failed_tests = failed_tests(1:lastNonEmptyIdx);
86+
87+
% Remove zeros from failed_tests
88+
failed_tests(failed_tests == 0) = [];
89+
90+
if isempty(failed_tests)
91+
fprintf('✅ All tests PASSED.\n');
92+
% Success
93+
exit(0);
94+
else
95+
fprintf('❌ Tests FAILED at indices: %s\n', sprintf('%d ', failed_tests));
96+
% Fail the workflow
97+
exit(1);
98+
end

0 commit comments

Comments
 (0)