A model predictive control (MPC) integrated multiphase immersed boundary (IB) framework for simulating wave energy converters (WECs) as described in https://doi.org/10.1016/j.oceaneng.2022.111908
If you are using MATLAB or CFD codes from this repository in your work, please consider citing the following
@article{khedkar2022model,
title={{A model predictive control (MPC)-integrated multiphase immersed boundary (IB) framework for simulating wave energy converters (WECs)}},
author={Khedkar, Kaustubh and Bhalla, Amneet Pal Singh},
journal={Ocean Engineering},
volume={260},
pages={111908},
year={2022},
publisher={Elsevier},
doi = {10.1016/j.oceaneng.2022.111908},
URL = {https://www.sciencedirect.com/science/article/pii/S0029801822012471}
}
git clone https://github.com/IBAMR/cfd-mpc-wecs.git
This will clone the default branch main. The main branch does not use any libMesh constructs and hence it is not necesary to build IBAMR with libMesh. The branch with-libmesh-construct uses the libMesh library, which can potentially allow for constructing an arbitrary shaped WEC geometry (e.g., from a CAD geometry). To switch to the other branch do:
git clone https://github.com/IBAMR/cfd-mpc-wecs.git
git checkout with-libmesh-construct
Refer https://petsc.org/main/docs/manual/matlab/ (See also the Licensing the MATLAB Compute Engine on a cluster section). We used the following configure options when building PETSc
export PETSC_DIR=$PWD
export PETSC_ARCH=linux-opt
./configure \
--CC=/path/to/mpicc \
--CXX=/path/to/mpicxx \
--FC=/path/to/mpif90 \
--COPTFLAGS=-O3 --CXXOPTFLAGS=-O3 --FOPTFLAGS=-O3 --PETSC_ARCH=linux-opt --with-debugging=0 --download-hypre=1 --with-x=0 --download-fblaslapack=1 \
--with-matlab-dir=/path/to/Matlab_2020b/ --with-matlab-engine=1 --with-matlab-engine-dir=/path/to/Matlab_2020b/extern/engines/
Building IBAMR using autotools
cd $HOME/sfw
git clone https://github.com/IBAMR/IBAMR.git IBAMR
mkdir objs-opt
cd objs-opt
../IBAMR/configure \
CFLAGS="-g -O3 -Wall" \
CXXFLAGS="-g -O3 -Wall" \
FCFLAGS="-g -O3 -Wall" \
CC=mpicc \
CXX=mpicxx \
FC=mpif90 \
--with-samrai=$HOME/sfw/SAMRAI/linux-opt \
--with-hdf5=$HOME/sfw/HDF5 \
--with-silo=$HOME/sfw/SILO \
--with-boost=$HOME/sfw/boost/1.67.0 \
PETSC_DIR=$HOME/sfw/PETSc-MATLAB \
PETSC_ARCH=linux-opt
make -j56
It is also possible to build IBAMR using CMake (Refer https://ibamr.github.io/building)
-
Generate BEM_data.mat file: Go to the
BEM_datadirectory. Execute the MATLAB scriptprocess_bem_data.mto generate theBEM_data.matfile. The directory also contains the output from the ANSYS AQWA software for the 1:20 scaled cylinder:AQWA_ANALYSIS.AHandAQWA_ANALYSIS.LIS. Some files in theBEM_datadirectory are obtained from the WEC-Sim or rather BEMIO GitHub https://github.com/WEC-Sim/WEC-Sim. These files are distributed under the WEC-Sim Apache License (Version 2.0) that can be found in theBEM_datadirectory. Note that we are not using the most updated version of theBEMIOfiles. The most recent version of the files can be downloaded (as raw files) directly from https://github.com/WEC-Sim/WEC-Sim/tree/master/source/functions/BEMIO. The newer version of the BEMIO scripts may require some API changes to theprocess_bem_data.mscript. A user may need to use the updated BEMIO scripts to parse the outfile files generated by the newer versions of the AQWA software. The AQWA files in BEM_data directory correspond to the 19.2 version. -
Input files: The CFD solver requires an input file. Two sample input files are provided in the main directory with the names
input3d.cylfor first-order order regular waves andinput3d_irregwave.cylfor irregular waves. The input files are set to simulate the AR-enabled CFD cases given in Sec. 9.2 of the paper. -
C++ driver code (main.cpp): The BEM data and the MPC parameters are loaded by the
load_mpc_paramters.mMATLAB script called withinmain.cpp. Currently,load_mpc_paramters.mcorresponds to regular waves of Sec. 9.2. Similarly, the MATLAB MPC routines contained in theMPC_matlab_codedirectory are also called within the C++ driver code. -
Building and linking the executable: If IBAMR is built using autotools then: (1) Copy
Makefile.autotoolsto a new file namedMakefilein the same directory. Modify the IBAMR source and build directory paths at top of the file. (2) Use the commandmake -j8 main3dto compile the CFD code and link it with IBAMR.If IBAMR is built using CMake, then the CMakeLists.txt should be used instead. The CMake project can be configured using the command
cmake -DIBAMR_ROOT=/path/to/ibamr-install -S ./and then built usingmake -j8 main3d.The linking of IBAMR based applications using autotools and CMake are explained here https://ibamr.github.io/linking
-
Run the simulation: Use the command
mpirun -np 128 ./main3d input3d.cylto run the simulation with 128 processors (number of processors can be adjusted here). -
Output data: The following output files are generated by the code
rbd.curve : Contains the simulation time, WEC heave displacement, and velocity.
hydro_force_torque.curve : Contains the simulation time and the hydrodynamic forces acting on the device.
mpc_control_force.curve : Contains the simulation time and the control force.
-
Generate BEM_data.mat file: See step 1 of the above section.
-
Input file: The BEM code does not require an input file. Instead, the
load_mpc_parameters.mscript should be modified directly to adjust the MPC paramaters. -
Running the simulation: The MATLAB driver script for the BEM solver is
vcyl_driving_script.m. Set the solver and wave parameters in this file and run the script. -
Output data: Results are saved in
BEM_results.matfile. This includes the simulation time, WEC displacement and velocity, wave excitation and control force.