Skip to content

Commit c1d1f5f

Browse files
committed
Add an error check in capacitor.m
1 parent a708d47 commit c1d1f5f

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎.github/workflows/test-matlab.yml‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,14 @@ jobs:
4141
run: |
4242
wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command
4343
chmod +x /usr/local/bin/run-matlab-command
44-
- name: Run solver dummies
45-
working-directory: matlab-bindings/examples/solverdummy
46-
env:
47-
LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5
48-
run: |
49-
run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverOne" & run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverTwo"
5044
- name: Run resonant-circuit
5145
working-directory: resonant-circuit
5246
env:
5347
LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5
5448
run: |
5549
sed -i 's%</participant>%<export:vtu directory=\"../precice-exports\" /> </participant>%g' precice-config.xml &&
56-
cd capacitor-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), capacitor;exit" &
57-
cd coil-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), coil;exit"
50+
cd coil-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), coil" &
51+
cd capacitor-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), capacitor"
5852
- name: Archive logs
5953
if: ${{ always() }}
6054
uses: actions/upload-artifact@v7

‎changelog-entries/942.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added a CI workflow to test MATLAB-based tutorials [#942](https://github.com/precice/tutorials/pull/942)

‎resonant-circuit/capacitor-matlab/capacitor.m‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,10 @@
104104

105105
save('outputs.mat', 'I', 'U')
106106
saveas(gcf, 'Curves.png')
107+
108+
% Error thresholds based on a reference run
109+
if error_I > 0.47 || error_U > 0.12
110+
error("Voltage or current differs more than expected from the analytical solution.");
111+
quit(1)
112+
end
113+
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/usr/bin/env bash
2+
set -e -u
3+
4+
. ../../tools/log.sh
5+
exec > >(tee --append "$LOGFILE") 2>&1
26

37
# Run MATLAB code without GUI
4-
matlab -nodisplay -r "capacitor;exit;"
8+
matlab -nodisplay -r "capacitor"
9+
10+
close_log
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/usr/bin/env bash
2+
set -e -u
3+
4+
. ../../tools/log.sh
5+
exec > >(tee --append "$LOGFILE") 2>&1
26

37
# Run MATLAB code without GUI
4-
matlab -nodisplay -r "coil;exit;"
8+
matlab -nodisplay -r "coil"
9+
10+
close_log

0 commit comments

Comments
 (0)