Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/test-matlab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'Test MATLAB-based tutorials'

on:
schedule:
- cron: "0 3 * * WED"
timezone: "Europe/Berlin"
workflow_dispatch:
push:
paths:
- '**/*matlab/**'

jobs:
test-matlab:
name: Test MATLAB-based tutorials
runs-on: ubuntu-latest
container:
image: precice/precice:nightly
strategy:
fail-fast: true
steps:
- name: Checkout the tutorials repository
uses: actions/checkout@v7
- name: Install Dependencies
run: |
apt-get -qq update
apt-get -qq install wget
rm -rf /var/lib/apt/lists/*
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v3
with:
release: R2024a
- name: Get the matlab-bindings repository
run: |
git clone --depth=1 https://github.com/precice/matlab-bindings.git
cd matlab-bindings && git status
- name: Run compilation script
uses: matlab-actions/run-command@v3
with:
command: "addpath('matlab-bindings'), compile_matlab_bindings_for_precice"
- name: Get run-matlab-command
run: |
wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command
chmod +x /usr/local/bin/run-matlab-command
- name: Run resonant-circuit
working-directory: resonant-circuit
env:
LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5
run: |
sed -i 's%</participant>%<export:vtu directory=\"../precice-exports\" /> </participant>%g' precice-config.xml &&
cd coil-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), coil" &
cd capacitor-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), capacitor"
- name: Archive logs
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: test-matlab-logs
path: |
resonant-circuit/*.log
resonant-circuit/*/*.log
resonant-circuit/capacitor-matlab/Curves.png
if-no-files-found: warn
- name: Archive exports
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: test-matlab-exports
path: |
resonant-circuit/precice-exports/*
if-no-files-found: warn
1 change: 1 addition & 0 deletions changelog-entries/942.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added a CI workflow to test MATLAB-based tutorials [#942](https://github.com/precice/tutorials/pull/942)
7 changes: 7 additions & 0 deletions resonant-circuit/capacitor-matlab/capacitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@

save('outputs.mat', 'I', 'U')
saveas(gcf, 'Curves.png')

% Error thresholds based on a reference run
if error_I > 0.47 || error_U > 0.12
error("Voltage or current differs more than expected from the analytical solution.");
quit(1)
end

6 changes: 6 additions & 0 deletions resonant-circuit/capacitor-matlab/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env bash
set -e -u

. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1

# Run MATLAB code without GUI
matlab -nodisplay -r "capacitor;exit;"

close_log
6 changes: 6 additions & 0 deletions resonant-circuit/coil-matlab/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env bash
set -e -u

. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1

# Run MATLAB code without GUI
matlab -nodisplay -r "coil;exit;"

close_log
Loading