AMReX-Combustion / PeleLMeX

An adaptive mesh hydrodynamics simulation code for low Mach number reacting flows without level sub-cycling.
https://amrex-combustion.github.io/PeleLMeX/
BSD 3-Clause "New" or "Revised" License
33 stars 41 forks source link

"ODE" quantities and user defined external sources #427

Closed dmontgomeryNREL closed 1 month ago

dmontgomeryNREL commented 1 month ago

This PR introduces a quantity that varies in time, but is neither advected or diffused. I'll refer to it as an ode_qty for now. In PeleC these would be AUX quantities, but there already exists a placeholder for AUX in PeleLMeX that is not a state variable. I intend to rename the existing aux quantities to ADV and these ode quantities to AUX for consistency with PeleC, but that will be a large PR in itself.

The ode quantities are included in the state variable and satisfy $\frac{\partial Bk}{\partial t} = S{ext,B_k}$, for $k = 0, 1,...,$NUM_ODE. Currently this is only first order accurate in time, but is consistent with the treatment of external sources from soot, spray and radiation, which are calculated prior to the SDC iterations. In the future I would like to add the ability to update the source terms within the SDC iterations, but this may require solving additional nonlinear systems depending on the source terms. For now we assume that the source terms are constant from $t^{n} \rightarrow t^{n+1}$.

In addition to the ode quantities, this PR includes PeleLMeX_ProblemSpecificFunctions.cpp which allows users to define the name of the ode quantities as well as external source terms for any state variable. Note that external source terms for density, $S_{ext,\rho}$, affect the velocity constraint but this has not been addressed in this PR. For reference, the velocity constraint should be: $\nabla \cdot \vec{u} = \frac{1}{T}\frac{DT}{Dt} + W \displaystyle\sum_m \frac{1}{W_m} \frac{DYm}{Dt} + \frac{1}{\rho} S{\text{ext},\rho} = S.$ Note that the existing external force terms for soot, spray and radiation are now included in the function called getExternalSources in PeleLMeX_Forces.cpp.

I tested 3 ode quantities of increasing stiffness with $S_{ext} = -10^{k+2} \cdot B_k$, for $k = 0,1,2$. The results below demonstrate first order accuracy and the need for SDC iterations in the future.

ODEQty

solutions

convergence_SDC-0_stiff