Skip to content

Commit

Permalink
Add DG discretizations for LRM, LRMP and GRM
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreue16 committed May 2, 2024
1 parent 59806c0 commit 967dbe6
Show file tree
Hide file tree
Showing 36 changed files with 17,507 additions and 62 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
path: |
${{ github.workspace }}/hdf5
${{ github.workspace }}/suitesparse/install
key: ${{ runner.os }}-deps-${{ steps.get-msvc.outputs.version }}
${{ github.workspace }}/eigen/install
key: ${{ runner.os }}-deps-${{ steps.get-msvc.outputs.version }}-1
- name: Download MKL and TBB
run: |
cd "${env:BASE_DIR}"
Expand All @@ -44,7 +45,7 @@ jobs:
nuget install intelmkl.static.win-x64 -Version 2023.0.0.25930
Invoke-WebRequest -Uri "https://gitlab.com/libeigen/eigen/-/archive/master/eigen-master.zip" -OutFile eigen.zip
7z x eigen.zip
- name: Build UMFPACK and HDF5
- name: Build UMFPACK and HDF5 and Eigen3
if: steps.cache.outputs.cache-hit != 'true'
run: |
$base_dir = $($env:BASE_DIR.Replace('\', '/'))
Expand All @@ -69,6 +70,14 @@ jobs:
$ENV:MKLROOT="${env:BASE_DIR}/intelmkl.static.win-x64.2023.0.0.25930/lib/native/win-x64".Replace('\', '/')
cmake -DCMAKE_INSTALL_PREFIX="${base_dir}\suitesparse\install" -DBLA_VENDOR=Intel10_64lp_seq -DBLA_STATIC=ON -G "Ninja" -DCMAKE_C_FLAGS="/GL" -DCMAKE_STATIC_LINKER_FLAGS="/LTCG" -DCMAKE_BUILD_TYPE=Release -DBUILD_METIS=OFF ..\suitesparse-metis-for-windows-e8d953dffb8a99aa8b65ff3ff03e12a3ed72f90c\
ninja install
cd "${env:BASE_DIR}"
Invoke-WebRequest -Uri "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip" -OutFile eigen.zip
7z x eigen.zip -oeigen\code -y
cd eigen
mkdir build
cd build
cmake ../code/eigen-3.4.0 -DCMAKE_INSTALL_PREFIX="../install"
cmake --build . --target install
- name: Build and Install
run: |
cd "${env:BASE_DIR}"
Expand All @@ -78,6 +87,7 @@ jobs:
$ENV:MKLROOT="${env:BASE_DIR}/intelmkl.static.win-x64.2023.0.0.25930/lib/native/win-x64".Replace('\', '/')
$ENV:TBB_ROOT="${env:BASE_DIR}/inteltbb.devel.win.2021.8.0.25874/lib/native".Replace('\', '/')
$ENV:UMFPACK_ROOT="${env:BASE_DIR}/suitesparse/install".Replace('\', '/')
$ENV:Eigen3_DIR="${env:BASE_DIR}/eigen/install".Replace('\', '/')
$install_prefix = $($env:INSTALL_PREFIX.Replace('\', '/'))
$src_dir = $($env:SRC_DIR.Replace('\', '/'))
$base_dir = $($env:BASE_DIR.Replace('\', '/'))
Expand Down
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ add_feature_info(ENABLE_DEBUG_THREADING ENABLE_DEBUG_THREADING "Use multi-thread
option(ENABLE_GRM_2D "Build 2D general rate model" ON)
add_feature_info(ENABLE_GRM_2D ENABLE_GRM_2D "Build 2D general rate model")

option(ENABLE_DG "Build DG variants of models" ON)
add_feature_info(ENABLE_DG ENABLE_DG "Build DG variants of models")

option(ENABLE_SUNDIALS_OPENMP "Prefer OpenMP vector implementation of SUNDIALS if available (for large problems)" OFF)
add_feature_info(ENABLE_SUNDIALS_OPENMP ENABLE_SUNDIALS_OPENMP "Prefer OpenMP vector implementation of SUNDIALS if available (for large problems)")

Expand Down Expand Up @@ -394,6 +397,21 @@ if (ENABLE_GRM_2D)
)
endif()

set(EIGEN_TARGET "")
if (ENABLE_DG)
find_package(Eigen3 3.4 NO_MODULE)

# Disable DG if Eigen is not present
if (NOT TARGET Eigen3::Eigen)
message(STATUS "Disabling DG support because Eigen3 could not be found")
set(ENABLE_DG OFF)
else()
set(EIGEN_TARGET "Eigen3::Eigen")
get_target_property(Eigen3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${Eigen3_INCLUDE_DIRS} "${Eigen3_INCLUDE_DIRS}/..")
endif()
endif()

set(IPO_AVAILABLE OFF)
if (ENABLE_IPO)
include(CheckIPOSupported)
Expand Down Expand Up @@ -592,6 +610,14 @@ if (ENABLE_GRM_2D)
endif()
endif()

if (ENABLE_DG)
message("Found Eigen3: ${Eigen3_FOUND}")
if (TARGET Eigen3::Eigen)
message(" Version ${Eigen3_VERSION}")
message(" Includes ${Eigen3_INCLUDE_DIRS}")
endif()
endif()

message("Found HDF5: ${HDF5_FOUND}")
if (HDF5_FOUND)
message(" Version ${HDF5_VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion doc/interface/sensitivities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Group /input/sensitivity/param_XXX

``SENS_NAME``

Name of the parameter
Name of the parameter (Note that ``PAR_RADIUS`` and ``PAR_CORE_RADIUS`` sensitivities are only available for Finite Volume discretization)

================ ===========================
**Type:** string **Length:** :math:`\geq 1`
Expand Down
99 changes: 87 additions & 12 deletions doc/interface/unit_operations/general_rate_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -454,21 +454,36 @@ For information on model equations, refer to :ref:`general_rate_model_model`.
================ ======================== =============================================================================


Discretization Methods
----------------------

CADET has two discretization frameworks available, Finite Volumes (FV) and Discontinuous Galerkin (DG), only one needs to be specified. Both methods approximate the same solution to the same underlying model but can differ regarding computational performance.

Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL
---------------------------------------------------------------------------
----------------------------------------------------------------------------------------

``USE_ANALYTIC_JACOBIAN``

Determines whether analytically computed Jacobian matrix (faster) is used (value is 1) instead of Jacobians generated by algorithmic differentiation (slower, value is 0)

============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============

Finite Volumes (Default)
------------------------

``NCOL``

Number of axial column discretization cells
Number of axial column discretization points

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``NPAR``

Number of particle (radial) discretization cells for each particle type
Number of particle (radial) discretization points for each particle type

============= ========================= =================================================
**Type:** int **Range:** :math:`\geq 1` **Length:** :math:`1` / :math:`\texttt{NPARTYPE}`
Expand Down Expand Up @@ -498,14 +513,6 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL
**Type:** int **Range:** :math:`\{ 1,2 \}` **Length:** 1
============= ============================ =============

``USE_ANALYTIC_JACOBIAN``

Determines whether analytically computed Jacobian matrix (faster) is used (value is :math:`1`) instead of Jacobians generated by algorithmic differentiation (slower, value is :math:`0`)

============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============

``RECONSTRUCTION``

Type of reconstruction method for fluxes
Expand Down Expand Up @@ -554,5 +561,73 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============

For further discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
For further Finite Volume discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.

Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL_DG
----------------------------------------------------------------------------------------
Discontinuous Galerkin
----------------------

``POLYDEG``

DG polynomial degree. Optional, defaults to 4. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``NCOL``

Number of axial column discretization DG cells\elements. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``EXACT_INTEGRATION``

Specifies the DG integration method. Optional, defaults to 0: Choose 1 for exact integration (more accurate but slower), 0 for LGL quadrature (less accurate but faster, typically more performant).

============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============

``NPARTYPE``

Number of particle types. Optional, inferred from the length of :math:`\texttt{NPAR}` or :math:`\texttt{NBOUND}` if left out.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``PARPOLYDEG``

DG particle (radial) polynomial degree. Optional, defaults to 3. The total number of particle (radial) discrete points is given by (``PARPOLYDEG`` + 1 ) * ``NPARCELL``.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``NPARCELL``

Number of particle (radial) discretization DG cells for each particle type. For the particle discretization, it is usually most performant to fix ``NPARCELL`` = 1 and to increase the polynomial degree for more accuracy.

============= ========================= =================================================
**Type:** int **Range:** :math:`\geq 1` **Length:** :math:`1` / :math:`\texttt{NPARTYPE}`
============= ========================= =================================================

``PAR_DISC_TYPE``

Specifies the DG element-spacing inside the particles for all or each particle type. Valid values are :math:`\texttt{EQUIDISTANT_PAR}`, :math:`\texttt{EQUIVOLUME_PAR}`, and :math:`\texttt{USER_DEFINED_PAR}`.

================ =================================================
**Type:** string **Length:** :math:`1` / :math:`\texttt{NPARTYPE}`
================ =================================================

``PAR_DISC_VECTOR``

Node coordinates for the element boundaries (ignored if :math:`\texttt{PAR_DISC_TYPE} \neq \texttt{USER_DEFINED_PAR}`). The coordinates are relative and have to include the endpoints :math:`0` and :math:`1`. They are later linearly mapped to the true radial range :math:`[r_{c,j}, r_{p,j}]`. The coordinates for each particle type are appended to one long vector in type-major ordering.

================ ======================== ================================================
**Type:** double **Range:** :math:`[0,1]` **Length:** :math:`\sum_i (\texttt{NPAR}_i + 1)`
================ ======================== ================================================
57 changes: 47 additions & 10 deletions doc/interface/unit_operations/lumped_rate_model_with_pores.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,26 +247,33 @@ For information on model equations, refer to :ref:`lumped_rate_model_with_pores_
================ ======================== =======================================================================


Discretization Methods
----------------------

CADET has two discretization frameworks available, Finite Volumes (FV) and Discontinuous Galerkin (DG), only one needs to be specified. Both methods approximate the same solution to the same underlying model but can differ regarding computational performance.

Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITH_PORES
-------------------------------------------------------------------------------------

``USE_ANALYTIC_JACOBIAN``

Determines whether analytically computed Jacobian matrix (faster) is used (value is 1) instead of Jacobians generated by algorithmic differentiation (slower, value is 0)

============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============

Finite Volumes (Default)
------------------------

``NCOL``

Number of axial column discretization cells
Number of axial column discretization points

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``USE_ANALYTIC_JACOBIAN``

Determines whether analytically computed Jacobian matrix (faster) is used (value is :math:`1`) instead of Jacobians generated by algorithmic differentiation (slower, value is :math:`0`)

============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============

``RECONSTRUCTION``

Type of reconstruction method for fluxes
Expand Down Expand Up @@ -307,4 +314,34 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITH_
**Type:** double **Range:** :math:`\geq 0` **Length:** 1
================ ========================= =============

For further discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
For further Finite Volume discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.


Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITH_PORES_DG
----------------------------------------------------------------------------------------
Discontinuous Galerkin
----------------------

``POLYDEG``

DG polynomial degree. Optional, defaults to 4. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``NCOL``

Number of axial column discretization DG cells\elements. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``EXACT_INTEGRATION``

Specifies the DG integration method. Optional, defaults to 0: Choose 1 for exact integration (more accurate but slower), 0 for LGL quadrature (less accurate but faster, typically more performant).

============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============
57 changes: 46 additions & 11 deletions doc/interface/unit_operations/lumped_rate_model_without_pores.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,13 @@ For information on model equations, refer to :ref:`lumped_rate_model_without_por
================ ===================== =============


Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHOUT_PORES
----------------------------------------------------------------------------------------
Discretization Methods
----------------------

CADET has two discretization frameworks available, Finite Volumes (FV) and Discontinuous Galerkin (DG), only one needs to be specified. Both methods approximate the same solution to the same underlying model but can differ regarding computational performance.

``NCOL``

Number of axial column discretization cells

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============
Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHOUT_PORES
----------------------------------------------------------------------------------------

``USE_ANALYTIC_JACOBIAN``

Expand All @@ -160,14 +156,53 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHO
============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============

Finite Volumes (Default)
------------------------

``NCOL``

Number of axial column discretization points

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``RECONSTRUCTION``

Type of reconstruction method for fluxes
Type of reconstruction method for fluxes only (only needs to be specified for FV)

================ ================================ =============
**Type:** string **Range:** :math:`\texttt{WENO}` **Length:** 1
================ ================================ =============

For further discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
For further Finite Volume discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.

Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHOUT_PORES_DG
-------------------------------------------------------------------------------------------
Discontinuous Galerkin
----------------------

``POLYDEG``

DG polynomial degree. Optional, defaults to 4. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``NCOL``

Number of axial column discretization DG cells\elements. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.

============= ========================= =============
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
============= ========================= =============

``EXACT_INTEGRATION``

Specifies the DG integration method. Optional, defaults to 0: Choose 1 for exact integration (more accurate but slower), 0 for LGL quadrature (less accurate but faster, typically more performant).

============= =========================== =============
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
============= =========================== =============
Loading

0 comments on commit 967dbe6

Please sign in to comment.