2D SWE: default LSPG#
ROM technique: basic LSPG
problem: 2D shallow water equations (SWE)
Prerequisites#
A valid build of the tutorials, see here,
The following env variables MUST be set:
export REPOSRC=<full-path-to-the-pressio-tutorials-source-repo>/end-to-end-roms export BUILDDIR=<full-path-to-where-you-built-the-tutorials>
To run the demo scripts below, you MUST be inside the correct directory:
cd $BUILDDIR/end-to-end-roms/2d_swe_lspg_default
Workflow File#
The workflow file for this demo is shown below for exposition purposes, but it is automatically copied to the build directory, so you don’t need to do anything:
1problem: 2d_swe
2
3parameterSpace:
4 names: ['coriolis', 'pulsemag', 'gravity']
5 trainPoints:
6 0: [-1.0, 0.125, 9.8]
7 1: [ 0.0, 0.125, 9.8]
8 testPoints:
9 0: [-0.5, 0.125, 9.8]
10
11fom:
12 meshSize: [65, 65]
13 inviscidFluxReconstruction: "Weno3"
14 odeScheme: "BDF1"
15 timeStepSize: 0.01
16 nonlinearSolverName: NewtonRaphson
17 nonlinearSolverTolerance: 1e-6
18 train:
19 finalTime: 5.0
20 stateSamplingFreq: 10
21 test:
22 finalTime: 5.0
23 stateSamplingFreq: 10
24
25offlineRom:
26 pod:
27 stateData:
28 useTrainingRuns: all
29
30onlineRom:
31 algorithm: defaultLspg
32 nonlinearSolverName: GaussNewton
33 nonlinearSolverTolerance: 1e-6
34 podTruncation:
35 energyBased: [99.999, 99.99999]
Step 1: execute FOMs#
# from within $BUILDDIR/end-to-end-roms/2d_swe_lspg_default
python3 $REPOSRC/wf_foms.py --wf wf.yaml
Warning
This might take a few mins to run, be patient!
At the end, doing tree -L 1 .
should produce:
.
├── CMakeFiles
├── Makefile
├── cmake_install.cmake
├── fom_mesh
├── fom_test_runid_0
├── fom_train_runid_0
├── fom_train_runid_1
├── plot.py
└── wf.yaml
Step 2: offline rom#
# from within $BUILDDIR/end-to-end-roms/2d_swe_lspg_default
python3 $REPOSRC/wf_offline_rom.py --wf wf.yaml
The offline rom takes care of using the FOM training data to compute the POD modes, and creates all data into an “offline_rom” subdirectory:
./offline_rom/
├── pod_input.yaml
├── state_left_singular_vectors.bin
├── state_singular_values.txt
└── state_snapshots.bin
Step 3: lspg rom#
# from within $BUILDDIR/end-to-end-roms/2d_swe_lspg_default
python3 $REPOSRC/wf_lspg.py --wf wf.yaml
At the end, you should have the following directory structure:
.
├── CMakeFiles
├── Makefile
├── cmake_install.cmake
├── default_lspg_truncation_energybased_99.99999_runid_0
├── default_lspg_truncation_energybased_99.999_runid_0
├── fom_mesh
├── fom_test_runid_0
├── fom_train_runid_0
├── fom_train_runid_1
├── offline_rom
├── plot.py
└── wf.yaml
Step 4: process results#
# from within $BUILDDIR/end-to-end-roms/2d_swe_lspg_default
python3 $REPOSRC/wf_reconstruct_on_full_mesh.py
python3 plot.py